From 0d05cb5eb07d19275370e3daa5da22dfc08786b1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 15 Mar 2022 00:30:06 +0100 Subject: tests: run_tests.sh: use greadlink if available This ensures that GNU readlink is preferred over OS X own readlink when executing test cases. This is required due to lacking `-f` flag support on OS X. Signed-off-by: Jo-Philipp Wich --- tests/custom/run_tests.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/custom') diff --git a/tests/custom/run_tests.sh b/tests/custom/run_tests.sh index c2839df..8063747 100755 --- a/tests/custom/run_tests.sh +++ b/tests/custom/run_tests.sh @@ -1,7 +1,13 @@ #!/usr/bin/env bash +if greadlink -f . &>/dev/null; then + readlink=greadlink +else + readlink=readlink +fi + testdir=$(dirname "$0") -topdir=$(readlink -f "$testdir/../..") +topdir=$($readlink -f "$testdir/../..") line='........................................' ucode_bin=${UCODE_BIN:-"$topdir/ucode"} @@ -44,7 +50,7 @@ extract_sections() { tag="file" outfile="${line#-- File }" outfile="$(echo "${outfile% --}" | xargs)" - outfile="$dir/files$(readlink -m "/${outfile:-file}")" + outfile="$dir/files$($readlink -m "/${outfile:-file}")" mkdir -p "$(dirname "$outfile")" printf "" > "$outfile" ;; @@ -200,14 +206,14 @@ n_fails=0 select_tests="$@" use_test() { - local input="$(readlink -f "$1")" + local input="$($readlink -f "$1")" local test [ -f "$input" ] || return 1 [ -n "$select_tests" ] || return 0 for test in "$select_tests"; do - test="$(readlink -f "$test")" + test="$($readlink -f "$test")" [ "$test" != "$input" ] || return 0 done -- cgit v1.2.3 From 2c71bf25950eef39fdc07794acf7d121b1c9230e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 15 Mar 2022 21:25:29 +0100 Subject: tests: run_tests.sh: pass dummy value to `-T` flag Since OS X `getopt()` does not handle optional arguments, we need to always pass a value to `-T`. Signed-off-by: Jo-Philipp Wich --- tests/custom/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/custom') diff --git a/tests/custom/run_tests.sh b/tests/custom/run_tests.sh index 8063747..fb92379 100755 --- a/tests/custom/run_tests.sh +++ b/tests/custom/run_tests.sh @@ -99,7 +99,7 @@ run_testcase() { IFS=$' \t\n' - $ucode_bin -T -L "$ucode_lib/*.so" -D TESTFILES_PATH="$dir/files" $args - <"$in" >"$dir/res.out" 2>"$dir/res.err" + $ucode_bin -T"," -L "$ucode_lib/*.so" -D TESTFILES_PATH="$($readlink -f "$dir/files")" $args - <"$in" >"$dir/res.out" 2>"$dir/res.err" ) printf "%d\n" $? > "$dir/res.code" -- cgit v1.2.3 From fd2e5e7e9d216c14d78258cd3420b6225fe91b37 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 15 Mar 2022 21:55:36 +0100 Subject: tests: 16_sort: fix logic flaw exposed on OS X A typo in the custom order function of the test case caused the test case to yield differently sorted results on OS X, triggered by differences in the libc's `qsort()` implementation. Signed-off-by: Jo-Philipp Wich --- tests/custom/03_stdlib/16_sort | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/custom') diff --git a/tests/custom/03_stdlib/16_sort b/tests/custom/03_stdlib/16_sort index ccc235f..ac4a0e1 100644 --- a/tests/custom/03_stdlib/16_sort +++ b/tests/custom/03_stdlib/16_sort @@ -31,7 +31,7 @@ Returns `null` if the given input array value is not an array. let t1 = type(a), t2 = type(b); if (t1 < t2) return -1; - else if (t2 > t2) + else if (t1 > t2) return 1; if (a < b) -- cgit v1.2.3 From b8f49b1b00c624df1208cd854aa65516b47c4c11 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 15 Mar 2022 23:09:56 +0100 Subject: tests: 21_regex_literals: generalize syntax error test case Different libc implementations produce different syntax error messages on invalid regular expression patterns, so rework the test case to produce stable output across all environments. Signed-off-by: Jo-Philipp Wich --- tests/custom/00_syntax/21_regex_literals | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/custom') diff --git a/tests/custom/00_syntax/21_regex_literals b/tests/custom/00_syntax/21_regex_literals index 6d85e97..d7ba7c4 100644 --- a/tests/custom/00_syntax/21_regex_literals +++ b/tests/custom/00_syntax/21_regex_literals @@ -73,17 +73,23 @@ In line 2, byte 2: Testing regex compilation errors. -- Expect stderr -- -Syntax error: Unmatched \{ -In line 2, byte 3: +Catched syntax error +In line 7, byte 30: - ` /foo {/` - ^-- Near here + ` die("Catched syntax error");` + Near here ----------------------------^ -- End -- -- Testcase -- {% - /foo {/ + try { + /foo (/ + } + catch (e) { + if (e.type == "Syntax error") + die("Catched syntax error"); + } %} -- End -- -- cgit v1.2.3