diff options
| author | peter <peter@pmikkelsen.com> | 2026-09-20 20:58:10 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-09-20 20:58:10 +0000 |
| commit | aa51adcfc9a79c606aa4435dc64dd5f160efbde1 (patch) | |
| tree | b0e50185da9e93e38cf7e651eb92592bd57ea23a /tests | |
| parent | 83bdc0e59232434fc30f94e2fc3a22e81989e4dd (diff) | |
Start working on migrating to autoconf/automake instead of cmake
FossilOrigin-Name: d870487495106763d2a4e416f1ddbf4c795081a6b77100d34063591e385692e0
Diffstat (limited to 'tests')
30 files changed, 186 insertions, 31 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..479b7ac --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,91 @@ +LOG_COMPILER = $(top_srcdir)/tests/run_script_test.sh +EXTRA_DIST += $(LOG_COMPILER) +EXTRA_DIST += tests/scripts/simfail.sh + +check_PROGRAMS += testbin-aplwc_errstr +testbin_aplwc_errstr_SOURCES = tests/aplwc_errstr.c +testbin_aplwc_errstr_LDADD = libaplwc.a +TESTS += testbin-aplwc_errstr + +check_PROGRAMS += testbin-aplwc_utf8 +testbin_aplwc_utf8_SOURCES= tests/aplwc_utf8.c +testbin_aplwc_utf8_LDADD = libaplwc.a +TESTS += testbin-aplwc_utf8 + +TEST_EXTENSIONS += .txt +TXT_LOG_COMPILER = $(top_srcdir)/tests/run_simple_test.sh +EXTRA_DIST += $(TXT_LOG_COMPILER) + +check_PROGRAMS += testbin-aplwc_eval +testbin_aplwc_eval_SOURCES= tests/aplwc_eval.c +testbin_aplwc_eval_LDADD = libaplwc.a +TEST_INPUTS += \ + tests/aplwc_eval/good/1.txt \ + tests/aplwc_eval/good/2.txt \ + tests/aplwc_eval/good/3.txt + +check_PROGRAMS += testbin-aplwc_read +testbin_aplwc_read_SOURCES= tests/aplwc_read.c +testbin_aplwc_read_LDADD = libaplwc.a +TEST_INPUTS += \ + tests/aplwc_read/good/1.txt \ + tests/aplwc_read/good/2.txt \ + tests/aplwc_read/good/3.txt \ + tests/aplwc_read/good/4.txt \ + tests/aplwc_read/good/5.txt \ + tests/aplwc_read/good/6.txt \ + tests/aplwc_read/good/7.txt \ + tests/aplwc_read/good/8.txt \ + tests/aplwc_read/good/9.txt \ + tests/aplwc_read/good/10.txt \ + tests/aplwc_read/good/11.txt \ + tests/aplwc_read/good/12.txt \ + tests/aplwc_read/good/13.txt +TEST_INPUTS += \ + tests/aplwc_read/bad/1.txt \ + tests/aplwc_read/bad/2.txt \ + tests/aplwc_read/bad/3.txt \ + tests/aplwc_read/bad/4.txt \ + tests/aplwc_read/bad/5.txt \ + tests/aplwc_read/bad/6.txt + +TEST_SCRIPTS_SH += \ + tests/scripts/good/1.sh \ + tests/scripts/good/2.sh \ + tests/scripts/good/3.sh \ + tests/scripts/good/4.sh \ + tests/scripts/good/5.sh \ + tests/scripts/good/6.sh \ + tests/scripts/good/7.sh +TEST_SCRIPTS_SH += \ + tests/scripts/bad/1.sh \ + tests/scripts/bad/2.sh \ + tests/scripts/bad/3.sh \ + tests/scripts/bad/4.sh \ + tests/scripts/bad/5.sh \ + tests/scripts/bad/6.sh \ + tests/scripts/bad/7.sh + +TEST_SCRIPTS_APLWC += \ + tests/scripts/good/1.aplwc \ + tests/scripts/good/2.aplwc \ + tests/scripts/good/3.aplwc + +TEST_SCRIPTS_APLWC += \ + tests/scripts/bad/1.aplwc \ + tests/scripts/bad/2.aplwc \ + tests/scripts/bad/3.aplwc \ + tests/scripts/bad/4.aplwc \ + tests/scripts/bad/5.aplwc \ + tests/scripts/bad/6.aplwc \ + tests/scripts/bad/7.aplwc \ + tests/scripts/bad/8.aplwc \ + tests/scripts/bad/9.aplwc \ + tests/scripts/bad/10.aplwc \ + tests/scripts/bad/11.aplwc \ + tests/scripts/bad/12.aplwc \ + tests/scripts/bad/13.aplwc + +XFAIL_TESTS += \ + tests/scripts/bad/1.aplwc \ + tests/scripts/bad/3.aplwc diff --git a/tests/run_script_test.sh b/tests/run_script_test.sh new file mode 100755 index 0000000..cef7add --- /dev/null +++ b/tests/run_script_test.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +input=$1 + +input=${input#*/tests/scripts/} +expected=${input%%/*} +ext=${input##*.} + +check() +{ + status=$1 + case $expected in + bad) + [ "$status" -ne 0 ] + ;; + *) + [ "$status" -eq 0 ] + ;; + esac + if [ "$?" -ne 0 ]; then + exit 1 + fi +} + +"$1" +check $? + +case "$ext" in + aplwc) + aplwc "$1" + check $? + ;; +esac + +case $expected in + *) + "$srcdir/tests/scripts/simfail.sh" "$1" + check $? +esac diff --git a/tests/run_simple_test.sh b/tests/run_simple_test.sh new file mode 100755 index 0000000..6c1d56c --- /dev/null +++ b/tests/run_simple_test.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +input=$1 + +input=${input#*/tests/} +program=${input%%/*} + +input=${input#*/} +expected=${input%%/*} + +"./testbin-$program" "$1" +status=$? + +case $expected in + good) + [ "$status" -eq 0 ] + ;; + bad) + [ "$status" -ne 0 ] + ;; +esac diff --git a/tests/scripts/bad/10.aplwc b/tests/scripts/bad/10.aplwc index ae7d5f7..a82aa53 100755 --- a/tests/scripts/bad/10.aplwc +++ b/tests/scripts/bad/10.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc -:module
\ No newline at end of file +:module diff --git a/tests/scripts/bad/11.aplwc b/tests/scripts/bad/11.aplwc index 3de20cd..837ac9b 100755 --- a/tests/scripts/bad/11.aplwc +++ b/tests/scripts/bad/11.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc :module 123 diff --git a/tests/scripts/bad/12.aplwc b/tests/scripts/bad/12.aplwc index 471643b..99e3f91 100755 --- a/tests/scripts/bad/12.aplwc +++ b/tests/scripts/bad/12.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc -:symbol plus
\ No newline at end of file +:symbol plus diff --git a/tests/scripts/bad/13.aplwc b/tests/scripts/bad/13.aplwc index 50bdb9f..cdd33ef 100755 --- a/tests/scripts/bad/13.aplwc +++ b/tests/scripts/bad/13.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc :symbol plus + + diff --git a/tests/scripts/bad/14.aplwc b/tests/scripts/bad/14.aplwc index 6b609ee..1e6f29f 100755 --- a/tests/scripts/bad/14.aplwc +++ b/tests/scripts/bad/14.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc :peter diff --git a/tests/scripts/bad/15.aplwc b/tests/scripts/bad/15.aplwc index 0662ccd..fe16903 100755 --- a/tests/scripts/bad/15.aplwc +++ b/tests/scripts/bad/15.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc -'
\ No newline at end of file +' diff --git a/tests/scripts/bad/2.sh b/tests/scripts/bad/2.sh index 73321be..4c7516e 100755 --- a/tests/scripts/bad/2.sh +++ b/tests/scripts/bad/2.sh @@ -1,3 +1,3 @@ #!/bin/sh -aplwc-repl -x -? +aplwc -x -? diff --git a/tests/scripts/bad/3.sh b/tests/scripts/bad/3.sh index ff0e033..bebca76 100755 --- a/tests/scripts/bad/3.sh +++ b/tests/scripts/bad/3.sh @@ -1,3 +1,3 @@ #!/bin/sh -aplwc-repl -x some-file-which-does-not-exist +aplwc -x some-file-which-does-not-exist diff --git a/tests/scripts/bad/4.aplwc b/tests/scripts/bad/4.aplwc index 8934275..1dc7666 100755 --- a/tests/scripts/bad/4.aplwc +++ b/tests/scripts/bad/4.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc ∇ foo diff --git a/tests/scripts/bad/4.sh b/tests/scripts/bad/4.sh index 0c48eaf..ae70b35 100755 --- a/tests/scripts/bad/4.sh +++ b/tests/scripts/bad/4.sh @@ -1,3 +1,3 @@ #!/bin/sh -aplwc-repl -x f1 f2 +aplwc -x f1 f2 diff --git a/tests/scripts/bad/5.aplwc b/tests/scripts/bad/5.aplwc index 26b3140..b727d2c 100755 --- a/tests/scripts/bad/5.aplwc +++ b/tests/scripts/bad/5.aplwc @@ -1,4 +1,4 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc ∇ foo ' diff --git a/tests/scripts/bad/5.sh b/tests/scripts/bad/5.sh index 8411e21..a2635a5 100755 --- a/tests/scripts/bad/5.sh +++ b/tests/scripts/bad/5.sh @@ -1,3 +1,3 @@ #!/bin/sh -aplwc-repl -x /dev/stdin +aplwc -x /dev/stdin diff --git a/tests/scripts/bad/6.sh b/tests/scripts/bad/6.sh index 2d9a94c..21fcc38 100755 --- a/tests/scripts/bad/6.sh +++ b/tests/scripts/bad/6.sh @@ -1,4 +1,4 @@ #!/bin/sh export APLWC_SIMULATE_FAILURE_PRINT_COUNT=1 -aplwc-repl -x 3>&- +aplwc -x 3>&- diff --git a/tests/scripts/bad/7.aplwc b/tests/scripts/bad/7.aplwc index ae9dcf3..cd50d41 100755 --- a/tests/scripts/bad/7.aplwc +++ b/tests/scripts/bad/7.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc -:symbol
\ No newline at end of file +:symbol diff --git a/tests/scripts/bad/7.sh b/tests/scripts/bad/7.sh index 189a5f0..8bf9d13 100755 --- a/tests/scripts/bad/7.sh +++ b/tests/scripts/bad/7.sh @@ -1,4 +1,4 @@ #!/bin/sh export APLWC_SIMULATE_FAILURE_AT=100 -aplwc-repl -x /dev/stdin +aplwc -x /dev/stdin diff --git a/tests/scripts/bad/8.aplwc b/tests/scripts/bad/8.aplwc index c2610e0..573edec 100755 --- a/tests/scripts/bad/8.aplwc +++ b/tests/scripts/bad/8.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc :symbol 123 diff --git a/tests/scripts/bad/9.aplwc b/tests/scripts/bad/9.aplwc index 469cc0b..e4ca077 100755 --- a/tests/scripts/bad/9.aplwc +++ b/tests/scripts/bad/9.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc :symbol plus 123 diff --git a/tests/scripts/good/1.aplwc b/tests/scripts/good/1.aplwc index e101d02..7a86f8f 100755 --- a/tests/scripts/good/1.aplwc +++ b/tests/scripts/good/1.aplwc @@ -1,4 +1,4 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc ∇ run ⎕←40 + 2 diff --git a/tests/scripts/good/2.aplwc b/tests/scripts/good/2.aplwc index e60e717..b6b5e63 100755 --- a/tests/scripts/good/2.aplwc +++ b/tests/scripts/good/2.aplwc @@ -1,4 +1,4 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc ∇ run foo 123 diff --git a/tests/scripts/good/2.sh b/tests/scripts/good/2.sh index 9bb0268..e0d41f3 100755 --- a/tests/scripts/good/2.sh +++ b/tests/scripts/good/2.sh @@ -2,4 +2,4 @@ set -e -echo "1+2" | aplwc-repl +echo "1+2" | aplwc diff --git a/tests/scripts/good/3.aplwc b/tests/scripts/good/3.aplwc index 7a6c0c5..50f8ca5 100755 --- a/tests/scripts/good/3.aplwc +++ b/tests/scripts/good/3.aplwc @@ -1,3 +1,3 @@ -#!/usr/bin/env aplwc-repl +#!/usr/bin/env aplwc -:export plus minus foo
\ No newline at end of file +:export plus minus foo diff --git a/tests/scripts/good/3.sh b/tests/scripts/good/3.sh index 4a86c11..93f52d6 100755 --- a/tests/scripts/good/3.sh +++ b/tests/scripts/good/3.sh @@ -2,7 +2,7 @@ set -e -cat <<EOF | aplwc-repl +cat <<EOF | aplwc 1+2 3+4 EOF diff --git a/tests/scripts/good/4.sh b/tests/scripts/good/4.sh index b075ac7..c3c6160 100755 --- a/tests/scripts/good/4.sh +++ b/tests/scripts/good/4.sh @@ -2,7 +2,7 @@ set -e -cat <<EOF | aplwc-repl +cat <<EOF | aplwc 'abc' 123 EOF diff --git a/tests/scripts/good/5.sh b/tests/scripts/good/5.sh index 28a4734..60c6860 100755 --- a/tests/scripts/good/5.sh +++ b/tests/scripts/good/5.sh @@ -1,4 +1,4 @@ #!/bin/sh export APLWC_SIMULATE_FAILURE_AT=one -aplwc-repl -x +aplwc -x diff --git a/tests/scripts/good/6.sh b/tests/scripts/good/6.sh index 822ff68..a5d8bfc 100755 --- a/tests/scripts/good/6.sh +++ b/tests/scripts/good/6.sh @@ -1,4 +1,4 @@ #!/bin/sh export APLWC_SIMULATE_FAILURE_AT= -aplwc-repl -x +aplwc -x diff --git a/tests/scripts/good/7.sh b/tests/scripts/good/7.sh index d59b189..7f2794d 100755 --- a/tests/scripts/good/7.sh +++ b/tests/scripts/good/7.sh @@ -2,4 +2,4 @@ set -e -echo "'abc'" | aplwc-repl +echo "'abc'" | aplwc diff --git a/tests/scripts/simfail.sh b/tests/scripts/simfail.sh index fe64a25..c10a7cb 100755 --- a/tests/scripts/simfail.sh +++ b/tests/scripts/simfail.sh @@ -5,6 +5,10 @@ set -e export APLWC_SIMULATE_FAILURE_PRINT_COUNT=1 N=$($1 3>&1 1>/dev/null 2>/dev/null) n=1 +if [ -z "$N" ]; then + N=0 +fi + export APLWC_SIMULATE_FAILURE_PRINT_COUNT=0 while [ "$n" -le "$N" ] |