This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository terminology.
View the commit online.
commit 7be88bb3001b5145c60cf816fda787ef1d7e18dc
Author: Boris Faure <[email protected]>
AuthorDate: Mon Aug 24 16:51:41 2026 +0200
tests: run the test scripts through a shell whose printf takes \xNN
The scripts spell their escape sequences out as \xNN, which POSIX does not
require printf to understand. dash -- /bin/sh on Debian and Ubuntu -- does not:
it prints the six characters verbatim. So c2.sh, shift_in_out.sh and
zero-width-spaces.sh fed tytest literal backslashes there and failed on any
distribution where the shebang resolves to dash, while passing everywhere
/bin/sh is bash.
Pick the shell rather than leaving it to the shebang. meson probes sh, bash,
ksh and zsh at configure time for one whose printf turns \x41 into A and passes
it to run_tests.sh
---
tests/meson.build | 27 +++++++++++++++++++++++++--
tests/run_tests.sh | 36 ++++++++++++++++++++++++++++++++++--
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/tests/meson.build b/tests/meson.build
index 257e1ba4..7c86e661 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,26 @@
if tests
run_tests = find_program('run_tests.sh')
+ # The test scripts spell out their escape sequences as \xNN, which POSIX does
+ # not require printf to understand : dash, /bin/sh on Debian and Ubuntu,
+ # prints them verbatim. Find a shell that does understand them rather than
+ # letting the scripts' shebang pick one.
+ test_shell = ''
+ foreach candidate : ['sh', 'bash', 'ksh', 'zsh']
+ prog = find_program(candidate, required: false)
+ if prog.found()
+ res = run_command(prog, '-c', 'printf "\\x41"', check: false)
+ if res.returncode() == 0 and res.stdout() == 'A'
+ test_shell = prog.full_path()
+ break
+ endif
+ endif
+ endforeach
+ if test_shell == ''
+ error('no shell found whose printf understands \\xNN escapes')
+ endif
+ message('Shell used to run the test scripts: ' + test_shell)
+
# Each script's output is piped through tytest and the resulting state
# checksum compared against tests.results.
test('escape-codes',
@@ -8,7 +28,8 @@ if tests
args: ['-v',
'-t', tytest.full_path(),
'-r', meson.current_source_dir() / 'tests.results',
- '-d', meson.current_source_dir()],
+ '-d', meson.current_source_dir(),
+ '-s', test_shell],
depends: tytest,
workdir: meson.current_source_dir(),
timeout: 300)
@@ -22,6 +43,7 @@ if tests
'-t', tytest.full_path(),
'-r', meson.current_source_dir() / 'tests.results',
'-d', meson.current_source_dir(),
+ '-s', test_shell,
'--chunk=' + chunk],
depends: tytest,
workdir: meson.current_source_dir(),
@@ -35,7 +57,8 @@ if tests
args: ['-v',
'-t', tytest.full_path(),
'-r', meson.current_source_dir() / 'tests.results',
- '-d', meson.current_source_dir()],
+ '-d', meson.current_source_dir(),
+ '-s', test_shell],
env: {'TERMINOLOGY_SIMD_DISABLE': '1'},
depends: tytest,
workdir: meson.current_source_dir(),
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 1ff55d09..5497b181 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -10,6 +10,7 @@ DEBUG=0
GENRESULTS=0
EXIT_ON_FAILURE=0
CHUNK=""
+TEST_SHELL=""
NB_TESTS=0
OK_TESTS=0
FAILED_TESTS=0
@@ -19,6 +20,22 @@ die()
echo "$*" 1>&2
exit 1
}
+
+# The test scripts write their escape sequences as \xNN, which POSIX does not
+# require printf to understand: dash, /bin/sh on Debian and Ubuntu, emits them
+# verbatim instead. So the scripts cannot simply be run through /bin/sh; pick a
+# shell whose printf does the right thing. meson passes one it found at
+# configure time, this is for standalone runs.
+detect_shell()
+{
+ for CANDIDATE in "$@"; do
+ if [ "$("$CANDIDATE" -c 'printf "\x41"' 2>/dev/null)" = "A" ]; then
+ printf '%s' "$CANDIDATE"
+ return 0
+ fi
+ done
+ return 1
+}
ESC="\033"
GREEN="${ESC}[32m"
BOLD_RED="${ESC}[31;1m"
@@ -72,6 +89,9 @@ where options are:
-t, --tytest=PATH Path to the tytest binary
-r, --results=PATH Path to the result file
-d, --testdir=PATH Path to the test files
+ -s, --shell=PATH Shell used to run the test scripts. Defaults to the
+ first of sh, bash, ksh, zsh whose printf understands
+ \xNN escapes.
-e, --exitonfailure Exit as soon as a test fails
-c, --chunk=N Feed tytest N bytes per read, to exercise sequences
split across read boundaries. Results must match the
@@ -129,6 +149,13 @@ while [ $# -gt 0 ]; do
fi
TESTDIR=$value
;;
+ -s|-shell|--shell)
+ if [ -z "$value" ]; then
+ value=$1
+ shift
+ fi
+ TEST_SHELL=$value
+ ;;
-e|-exitonfailure|--exitonfailure)
EXIT_ON_FAILURE=1
;;
@@ -154,6 +181,10 @@ fi
if [ ! -d "$TESTDIR" ]; then
die "Invalid test directory: $TESTDIR"
fi
+if [ -z "$TEST_SHELL" ]; then
+ TEST_SHELL=$(detect_shell sh bash ksh zsh) ||
+ die "No shell found whose printf understands \\xNN escapes"
+fi
if [ $GENRESULTS -ne 0 ]; then
DEBUG=0
VERBOSE=0
@@ -167,6 +198,7 @@ Using:
TYTEST=$TYTEST
RESULTS=$RESULTS
TESTDIR=$TESTDIR
+ TEST_SHELL=$TEST_SHELL
EXIT_ON_FAILURE=$EXIT_ON_FAILURE
EOF
@@ -179,9 +211,9 @@ while read -r TEST EXPECTED_CHECKSUMS; do
printf "%s... " "$TEST"
fi
if [ -n "$CHUNK" ]; then
- TEST_CHECKSUM=$("$TESTDIR"/"$TEST" | "$TYTEST" "$CHUNK")
+ TEST_CHECKSUM=$("$TEST_SHELL" "$TESTDIR"/"$TEST" | "$TYTEST" "$CHUNK")
else
- TEST_CHECKSUM=$("$TESTDIR"/"$TEST" | "$TYTEST")
+ TEST_CHECKSUM=$("$TEST_SHELL" "$TESTDIR"/"$TEST" | "$TYTEST")
fi
if [ $DEBUG -ne 0 ]; then
printf "(got %s, expected %s) " "$TEST_CHECKSUM" "$EXPECTED_CHECKSUMS"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.