lang: Add indentation test to parser
This adds a test case to catch some common typos.
This commit is contained in:
1
test.sh
1
test.sh
@@ -43,6 +43,7 @@ function skip-testsuite()
|
||||
# used at the end to tell if everything went fine
|
||||
failures=''
|
||||
|
||||
run-testsuite ./test/test-vet.sh
|
||||
run-testsuite ./test/test-misc.sh
|
||||
run-testsuite ./test/test-gofmt.sh
|
||||
run-testsuite ./test/test-yamlfmt.sh
|
||||
|
||||
44
test/test-vet.sh
Executable file
44
test/test-vet.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# vet a few random things
|
||||
|
||||
echo running "$0"
|
||||
|
||||
#ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir!
|
||||
ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
cd "${ROOT}"
|
||||
. test/util.sh
|
||||
|
||||
failures=''
|
||||
function run-test()
|
||||
{
|
||||
$@ || failures=$( [ -n "$failures" ] && echo "$failures\\n$@" || echo "$@" )
|
||||
}
|
||||
|
||||
function parser-indentation() {
|
||||
# the $ before the \t magically makes grep match the tab somehow...
|
||||
if grep $'\t|' "$1"; then # indent the pipe too
|
||||
return 1
|
||||
fi
|
||||
if grep ' |' "$1"; then # indent the pipe too (no spaces!)
|
||||
return 1
|
||||
fi
|
||||
if grep '^ ' "$1"; then # format with tabs, no leading spaces
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# loop through individual *.y files
|
||||
for file in `find . -maxdepth 3 -type f -name '*.y' -not -path './old/*' -not -path './tmp/*'`; do
|
||||
run-test parser-indentation "$file"
|
||||
done
|
||||
|
||||
if [[ -n "$failures" ]]; then
|
||||
echo 'FAIL'
|
||||
echo 'The following tests have failed:'
|
||||
echo -e "$failures"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
echo 'PASS'
|
||||
Reference in New Issue
Block a user