1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00
cde/bin/shtests
Martijn Dekker f811482350 bin/shtests wrapper: export INSTALLROOT when using other ksh
When specifying another ksh to test using e.g. KSH=/bin/ksh to test
the system's stock ksh, the pty command was not found because it
resides in the arch/*/bin directory. The main shtests script bases
its $PATH on $INSTALLROOT, but does not set INSTALLROOT itself if
the shell to test is outside the installation hierarchy. Setting it
would allow the pty.sh regresssion tests to run on a shell
specified on the command line.

bin/shtests:
- Set and export INSTALLROOT to our default installation hierarchy
  if it wasn't already set on entry.
2020-06-26 12:22:25 +02:00

54 lines
1.6 KiB
Bash
Executable file

#! /bin/sh
# Wrapper script to run the ksh93 regression tests without requiring nmake.
# By Martijn Dekker <martijn@inlv.org> 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.
#
# Note: The test suite actually uses $SHELL to indicate the shell to test. But
# we cannot use the $SHELL environment value on entry to this wrapper script,
# as that is already used for the user's default login shell on most systems.
# Process and remove any assignment-argument indicating the shell to test
for arg do
case $arg in
( SHELL=* | KSH=* )
KSH=${arg#*=} ;;
( * ) set -- "$@" "$1" ;;
esac
shift
done
# Find root dir of ksh source
mydir=$(dirname "$0") \
&& mydir=$(CDPATH='' cd -P -- "$mydir/.." && printf '%sX' "$PWD") \
&& mydir=${mydir%X} \
|| exit
myarch=$("$mydir/bin/package" host type) || exit
# Check if there is a ksh to test.
case ${KSH+set} in
( '' ) 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
INSTALLROOT=${INSTALLROOT:-$mydir/arch/$myarch}
export SHELL INSTALLROOT
unset -v KSH
printf '#### Regression-testing %s ####\n' "$SHELL"
exec "$SHELL" shtests "$@"