summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-10-07 19:14:04 +0000
committerpeter <peter@pmikkelsen.com>2026-10-07 19:14:04 +0000
commit66993321af1e67570469a2b9a9731492d0aaff5b (patch)
tree963db5f8777efaf73283ed9ca7d8e3a24d61ea6e
parent09a882746304791e9462bec3df746f9203594d34 (diff)
[de3a009ef3] Write a very basic "hello world" test which verifies that the program outputs the correct message.
This fails for now, as the interpreter isn't implemented yet, but it's a good way to start doing test-driven development. FossilOrigin-Name: f34934025a9f22b574c1076b05673b94a4f40d8a55c723fced7c055155042c57
-rw-r--r--Makefile.am3
-rw-r--r--tests/Makefile.am6
-rwxr-xr-xtests/run_script_test.sh18
-rw-r--r--tests/scripts/good/4.aplwc6
-rw-r--r--tests/scripts/good/4.aplwc.output1
-rwxr-xr-xtests/scripts/simfail.sh5
6 files changed, 34 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index 6f4ed8e..56fb787 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,6 +13,7 @@ TEST_EXTENSIONS =
TEST_INPUTS =
TEST_SCRIPTS_APLWC =
TEST_SCRIPTS_SH =
+TEST_SCRIPTS_OUTPUT =
TEST_FUZZ_CRASHES =
XFAIL_TESTS =
AM_TESTS_ENVIRONMENT = PATH="$(top_bindir):$$PATH"; export PATH;
@@ -22,5 +23,5 @@ include src/Makefile.am
include tests/Makefile.am
TESTS += $(TEST_INPUTS) $(TEST_SCRIPTS_SH) $(TEST_SCRIPTS_APLWC) $(TEST_FUZZ_CRASHES)
-EXTRA_DIST += $(TEST_INPUTS) $(TEST_SCRIPTS_SH) $(TEST_SCRIPTS_APLWC)
+EXTRA_DIST += $(TEST_INPUTS) $(TEST_SCRIPTS_SH) $(TEST_SCRIPTS_APLWC) $(TEST_SCRIPTS_OUTPUT)
CLEANFILES += $(BUILT_SOURCES)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 27fd83f..461f2c2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -68,7 +68,8 @@ TEST_SCRIPTS_SH += \
TEST_SCRIPTS_APLWC += \
tests/scripts/good/1.aplwc \
tests/scripts/good/2.aplwc \
- tests/scripts/good/3.aplwc
+ tests/scripts/good/3.aplwc \
+ tests/scripts/good/4.aplwc
TEST_SCRIPTS_APLWC += \
tests/scripts/bad/4.aplwc \
@@ -81,6 +82,9 @@ TEST_SCRIPTS_APLWC += \
tests/scripts/bad/12.aplwc \
tests/scripts/bad/13.aplwc
+TEST_SCRIPTS_OUTPUT += \
+ tests/scripts/good/4.aplwc.output
+
TEST_EXTENSIONS += .fuzz
FUZZ_LOG_COMPILER = $(top_srcdir)/tests/run_fuzz_test.sh
EXTRA_DIST += $(FUZZ_LOG_COMPILER)
diff --git a/tests/run_script_test.sh b/tests/run_script_test.sh
index a6ccfa8..21c4e04 100755
--- a/tests/run_script_test.sh
+++ b/tests/run_script_test.sh
@@ -39,13 +39,25 @@ case $expected in
;;
esac
-"$1"
-check $?
+if [ -x "$1" ]
+then
+ "$1"
+ check $?
+fi
case "$ext" in
aplwc)
- aplwc "$1"
+ aplwc -x "$1"
check $?
+
+ if [ -f "$1.output" ]
+ then
+ aplwc -x "$1" 2>&1 | cmp - "$1.output"
+ if [ "$?" -ne 0 ]
+ then
+ exit 1
+ fi
+ fi
;;
esac
diff --git a/tests/scripts/good/4.aplwc b/tests/scripts/good/4.aplwc
new file mode 100644
index 0000000..a260efc
--- /dev/null
+++ b/tests/scripts/good/4.aplwc
@@ -0,0 +1,6 @@
+:module Main
+:run Main
+
+∇ Main
+ ⎕←'Hello from aplwc'
+∇
diff --git a/tests/scripts/good/4.aplwc.output b/tests/scripts/good/4.aplwc.output
new file mode 100644
index 0000000..180ee04
--- /dev/null
+++ b/tests/scripts/good/4.aplwc.output
@@ -0,0 +1 @@
+Hello from aplwc
diff --git a/tests/scripts/simfail.sh b/tests/scripts/simfail.sh
index 75b97ab..394f223 100755
--- a/tests/scripts/simfail.sh
+++ b/tests/scripts/simfail.sh
@@ -1,5 +1,10 @@
#!/bin/sh
+if [ ! -x "$1" ]
+then
+ exit 0
+fi
+
START=0
COUNT=1