| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
# hack/verify-examples.sh |
| 4 |
# Pre-submit script to verify: |
| 5 |
# 1.) committed generated code matches source |
| 6 |
# 2.) code generation tests pass |
| 7 |
|
| 8 |
# Exit immediately if any command fails |
| 9 |
set -e |
| 10 |
|
| 11 |
# Make sure we run from the v2 root. |
| 12 |
V2_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. |
| 13 |
cd "${V2_ROOT}" |
| 14 |
|
| 15 |
# Ensure all files are committed |
| 16 |
if ! git diff --quiet HEAD; then |
| 17 |
echo "FAIL: git client is not clean" |
| 18 |
exit 1 |
| 19 |
fi |
| 20 |
|
| 21 |
echo "Running ./examples/tracer" |
| 22 |
rm ./examples/tracer/testdata/simple/out.txt |
| 23 |
go run ./examples/tracer ./examples/tracer/testdata/simple > ./examples/tracer/testdata/simple/out.txt |
| 24 |
if ! git diff --quiet HEAD; then |
| 25 |
echo "FAIL: output files changed" |
| 26 |
git diff |
| 27 |
exit 1 |
| 28 |
fi |
| 29 |
|
| 30 |
echo "Running ./examples/kilroy" |
| 31 |
rm ./examples/kilroy/testdata/simple/generated.kilroy.go |
| 32 |
go run ./examples/kilroy/ ./examples/kilroy/testdata/simple |
| 33 |
if ! git diff --quiet HEAD; then |
| 34 |
echo "FAIL: output files changed" |
| 35 |
git diff |
| 36 |
exit 1 |
| 37 |
fi |
| 38 |
|
| 39 |
echo "Running ./examples/pointuh" |
| 40 |
rm -rf ./examples/pointuh/testdata/results |
| 41 |
go run ./examples/pointuh/ \ |
| 42 |
--output-dir ./examples/pointuh/testdata/results \ |
| 43 |
--output-pkg k8s.io/gengo/examples/pointuh/testdata/results \ |
| 44 |
./examples/pointuh/testdata/simple |
| 45 |
if ! git diff --quiet HEAD; then |
| 46 |
echo "FAIL: output files changed" |
| 47 |
git diff |
| 48 |
exit 1 |
| 49 |
fi |