2020-03-17 21:47:03 +03:00
|
|
|
#!/bin/bash
|
2017-10-11 06:53:49 +03:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2019-12-07 22:11:06 +03:00
|
|
|
source build.env
|
|
|
|
|
2017-10-11 06:53:49 +03:00
|
|
|
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
|
2022-08-26 13:30:45 +03:00
|
|
|
output=$(go run ./goyacc -fo $CUR sql.y)
|
2022-06-29 09:59:57 +03:00
|
|
|
expectedOutput=$'\nconflicts: 3 shift/reduce'
|
2019-01-15 20:57:12 +03:00
|
|
|
|
2021-02-09 08:45:43 +03:00
|
|
|
if [[ "$output" != "$expectedOutput" ]]; then
|
|
|
|
echo -e "Expected output from goyacc:$expectedOutput\ngot:$output"
|
2019-01-15 20:57:12 +03:00
|
|
|
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
|