vitess-gh/tools/check_make_parser.sh

41 строка
947 B
Bash
Исходник Обычный вид История

#!/bin/sh
#
# Validate that the current version of the generated parser matches the output
# generated by the version of goyacc installed on the local system.
#
# This is used in Travis to verify that the currently committed version was
# generated with the proper version of goyacc.
CUR="sql.go"
TMP="/tmp/sql.$$.go"
if ! cd go/vt/sqlparser/ ; then
echo "ERROR: $0 must be run in the root project directory"
exit 1
fi
mv $CUR $TMP
output=`goyacc -o $CUR sql.y`
if [ -n "$output" ]; then
echo "Expected empty output from goyacc, got:"
echo $output
mv $TMP $CUR
exit 1
fi
gofmt -w $CUR
if ! diff -q $CUR $TMP > /dev/null ; then
echo "ERROR: Regenerated parser $TMP does not match current version $(pwd)/sql.go:"
diff -u $CUR $TMP
mv $TMP $CUR
echo
echo "Please ensure go and goyacc are up to date and re-run 'make parser' to generate."
exit 1
fi
mv $TMP $CUR