add a test to validate sql.go matches goyacc output

Add a test script that regenerates the contents of sql.go into a temp
file and then compares to the current contents in order to make sure
that the version checked in matches the output of the expected
toolchain.
This commit is contained in:
Michael Demmer 2017-10-10 20:53:49 -07:00
Родитель e92ab80470
Коммит 05c1de8006
2 изменённых файлов: 36 добавлений и 0 удалений

Просмотреть файл

@ -210,6 +210,17 @@
"site_test"
]
},
"parser_generator": {
"File": "",
"Args": [],
"Command": [
"tools/test_parser_generator.sh"
],
"Manual": false,
"Shard": 0,
"RetryMax": 0,
"Tags": []
},
"php": {
"File": "",
"Args": [],

25
tools/test_parser_generator.sh Executable file
Просмотреть файл

@ -0,0 +1,25 @@
#!/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"
cd go/vt/sqlparser/
goyacc -o $TMP sql.y
gofmt -w $TMP
diff -q $CUR $TMP > /dev/null 2>&1
if [ $? != 0 ] ; then
echo "ERROR: Regenerated parser $TMP does not match current version `pwd`/sql.go:"
diff -u $CUR $TMP
exit 1
fi
rm $TMP