forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_make_parser.sh
executable file
·43 lines (33 loc) · 1.01 KB
/
check_make_parser.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#
# 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.
source build.env
CUR="sql.go"
TMP="/tmp/sql.$$.go"
set -e
if ! cd go/vt/sqlparser/ ; then
echo "ERROR: $0 must be run in the root project directory"
exit 1
fi
mv $CUR $TMP
output=$(go run ./goyacc -fast-append -o $CUR sql.y)
expectedOutput=""
if [[ "$output" != "$expectedOutput" ]]; then
echo -e "Expected output from goyacc:$expectedOutput\ngot:$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