From 2e7602da2a78f0f25eee305fa6a0159621ec4fd1 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 14 May 2020 17:41:26 +0100 Subject: [PATCH] Add bin/shtests, convenient wrapper for regression tests This new wrapper script sets up the correct environment for running the ksh93 regression test suite. It allows running the tests without AST nmake, which is not maintained in this repository. An alternative ksh to test may be passed in the $KSH env var. bin/shtests: - Added. Sets up environment before passing control to 'src/cmd/ksh93/tests/shtest'. Passes on any options given. NEWS: - Updated. (cherry picked from commit 14ced94ed83991687c645a09bd2e45a5c2ffe8dc) --- NEWS | 3 +++ bin/shtests | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 bin/shtests diff --git a/NEWS b/NEWS index 59d1aea9a..b78d45831 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ Any uppercase BUG_* names are modernish shell bug IDs. status on the 'print', 'printf' and 'echo' builtins and prevent possible infinite loops if SIGPIPE is ignored. +- Add a convenient bin/run_ksh_tests script to the source tree that + sets up the necessary environment and runs the ksh regression tests. + 2020-05-13: - Fix BUG_CASELIT: an undocumented 'case' pattern matching misbehaviour that diff --git a/bin/shtests b/bin/shtests new file mode 100755 index 000000000..713102998 --- /dev/null +++ b/bin/shtests @@ -0,0 +1,40 @@ +#! /bin/sh +# Wrapper script to run the ksh93 regression tests without requiring nmake. +# By Martijn Dekker 2020-05-14 +# Public domain. http://creativecommons.org/publicdomain/zero/1.0/ +# +# The manual: bin/shtests --man +# Brief help: bin/shtests --help +# +# By default, this runs your compiled arch/*/bin/ksh. +# To use another ksh, run: KSH=path/to/ksh bin/shtests + +# Find root dir of ksh source +mydir=$(dirname "$0") \ +&& mydir=$(CDPATH='' cd -P -- "$mydir/.." && printf '%sX' "$PWD") \ +&& mydir=${mydir%X} \ +|| exit + +# Check if there is a ksh to test. +case ${KSH+set} in +( '' ) myarch=$("$mydir/bin/package" host) || exit + KSH=$mydir/arch/$myarch/bin/ksh ;; +esac +if ! test -x "$KSH" || ! test -f "$KSH"; then + printf '%s: shell not found: %s\n' "${0##*/}" "$KSH" >&2 + printf 'Specify a shell like: KSH=path/to/ksh bin/shtests\n' >&2 + exit 1 +fi + +# Ensure absolute path to ksh +KSH=$(CDPATH='' cd -P -- "$(dirname "$KSH")" \ + && printf '%s/%sX' "$PWD" "${KSH##*/}") \ +&& KSH=${KSH%X} + +# Run the test suite +CDPATH='' cd -P -- "$mydir/src/cmd/ksh93/tests" || exit +SHELL=$KSH +export SHELL +unset -v KSH +printf '#### Regression-testing %s ####\n' "$SHELL" +exec "$SHELL" shtests "$@"