vitess-gh/tools/check_make_parser.sh

32 строки
788 B
Bash
Executable File

#!/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
goyacc -o $TMP sql.y
gofmt -w $TMP
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
rm $TMP
echo
echo "Please ensure go and goyacc are up to date and re-run 'make parser' to generate."
exit 1
fi
rm $TMP