2017-10-11 06:53:49 +03:00
|
|
|
#!/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.
|
|
|
|
#
|
2017-10-13 04:02:37 +03:00
|
|
|
# This is used in Travis to verify that the currently committed version was
|
2017-10-11 06:53:49 +03:00
|
|
|
# generated with the proper version of goyacc.
|
|
|
|
|
|
|
|
CUR="sql.go"
|
|
|
|
TMP="/tmp/sql.$$.go"
|
|
|
|
|
2019-09-13 00:09:38 +03:00
|
|
|
set -e
|
2017-10-11 16:20:56 +03:00
|
|
|
|
2017-10-12 16:57:37 +03:00
|
|
|
if ! cd go/vt/sqlparser/ ; then
|
2017-10-11 16:20:56 +03:00
|
|
|
echo "ERROR: $0 must be run in the root project directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-11 06:53:49 +03:00
|
|
|
|
2018-07-26 02:10:20 +03:00
|
|
|
mv $CUR $TMP
|
2019-09-13 00:09:38 +03:00
|
|
|
output=$(go run golang.org/x/tools/cmd/goyacc -o $CUR sql.y)
|
2019-01-15 20:57:12 +03:00
|
|
|
|
|
|
|
if [ -n "$output" ]; then
|
|
|
|
echo "Expected empty output from goyacc, got:"
|
|
|
|
echo $output
|
|
|
|
mv $TMP $CUR
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-07-26 02:10:20 +03:00
|
|
|
gofmt -w $CUR
|
2017-10-11 06:53:49 +03:00
|
|
|
|
2017-10-12 16:57:37 +03:00
|
|
|
if ! diff -q $CUR $TMP > /dev/null ; then
|
2017-10-11 16:20:56 +03:00
|
|
|
echo "ERROR: Regenerated parser $TMP does not match current version $(pwd)/sql.go:"
|
2017-10-11 06:53:49 +03:00
|
|
|
diff -u $CUR $TMP
|
2018-07-26 02:10:20 +03:00
|
|
|
mv $TMP $CUR
|
2017-10-13 04:02:37 +03:00
|
|
|
|
|
|
|
echo
|
2017-10-12 16:57:37 +03:00
|
|
|
echo "Please ensure go and goyacc are up to date and re-run 'make parser' to generate."
|
2017-10-11 06:53:49 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-07-26 02:10:20 +03:00
|
|
|
mv $TMP $CUR
|