sway/scripts/formatter/forc-fmt-check-panic.sh
Sophie Dankel c6b0afd30f
Add CI check to ensure forc-fmt doesn't panic (#5051)
## Description

Closes https://github.com/FuelLabs/sway/issues/5006

## Checklist

- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2023-08-29 19:48:21 +10:00

32 lines
725 B
Bash
Executable file

#!/bin/bash
# This script will format all sway projects in the current directory and all subdirectories.
# This is useful for testing the formatter itself to make sure it's not panicking on any valid
# sway projects and for checking that it's formatted output is correct.
forc_manifests=`find . -name Forc.toml | sort`
let count=0
let panicked=0
for f in $forc_manifests
do
dir="${f%/*}"
stderr="$(forc-fmt -p $dir 2>&1 > /dev/null)"
echo $dir
if [[ $stderr == *"panicked at"* ]]
then
let panicked=panicked+1
echo $stderr
echo ""
fi
let count=count+1
done
echo ""
echo "Panicked count: $panicked"
echo "Total count: $count"
if [[ $panicked -gt 0 ]]
then
exit 1
fi