summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn J. Camilleri <john@digitalgrammars.com>2021-07-01 14:05:30 +0200
committerJohn J. Camilleri <john@digitalgrammars.com>2021-07-01 14:05:30 +0200
commita27b07542d731ee0287383feb7a97d5d4708b85e (patch)
tree810c2c9bd50c91e9fbf349f09a1440607f1fa806
parent78b73fba20d45ed8c3f1c87455795fbf7d670950 (diff)
Add run-on-grammar canonical test script
-rwxr-xr-xtestsuite/canonical/run-on-grammar.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/testsuite/canonical/run-on-grammar.sh b/testsuite/canonical/run-on-grammar.sh
new file mode 100755
index 000000000..f621035e3
--- /dev/null
+++ b/testsuite/canonical/run-on-grammar.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env sh
+
+# For a given grammar, compile into canonical format,
+# then ensure that the canonical format itself is compilable.
+
+if [ $# -lt 1 ]; then
+ echo "Please specify concrete modules to test with, e.g.:"
+ echo "./run-on-grammar.sh ../../../gf-contrib/foods/FoodsEng.gf ../../../gf-contrib/foods/FoodsFin.gf"
+ exit 2
+fi
+
+FAILURES=0
+
+for CNC_PATH in "$@"; do
+ CNC_FILE=$(basename "$CNC_PATH")
+ stack run -- --batch --output-format=canonical_gf "$CNC_PATH"
+ if [ $? -ne 0 ]; then
+ echo "Failed to compile into canonical"
+ FAILURES=$((FAILURES+1))
+ continue
+ fi
+
+ stack run -- --batch "canonical/$CNC_FILE"
+ if [ $? -ne 0 ]; then
+ echo "Failed to compile canonical"
+ FAILURES=$((FAILURES+1))
+ fi
+done
+
+# Summary
+if [ $FAILURES -ne 0 ]; then
+ echo "Failures: $FAILURES"
+ exit 1
+else
+ echo "All tests passed"
+fi