Skip to content

Commit

Permalink
shtests: make aliases work again for shcomp tests (re: aed5c6d)
Browse files Browse the repository at this point in the history
Moving the 'err_exit' and 'warning' alias definitions in the
regression tests to one _common file introduced a bug: they are no
longer expanded at compile time when the tests are run with shcomp,
resulting in a 'command not found' (at best) on trying to execute
one. shcomp requires that the alias definitions need to be present
in the file itself. But that means maintaining 50-odd copies again.
I'd rather add a hack to shtests to avoid this.

src/cmd/ksh93/tests/shtests:
- Before running a test with shcomp, physically concatenate _common
  and the test script together into a temporary file, minus the '.'
  command that includes _common, and compile that with shcomp.
  • Loading branch information
McDutchie committed Mar 23, 2021
1 parent 88d7a62 commit bd38c80
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cmd/ksh93/tests/shtests
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ valgrindflags='--xml=yes --log-file=/dev/null --track-origins=yes --read-var-inf

USAGE=$'
[-s8?
@(#)$Id: shtests (ksh 93u+m) 2021-03-06 $
@(#)$Id: shtests (ksh 93u+m) 2021-03-23 $
]
[-author?David Korn <[email protected]>]
[-author?Glenn Fowler <[email protected]>]
Expand Down Expand Up @@ -405,8 +405,13 @@ do [[ $i == *.sh ]] || i+='.sh'
echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"}
tmp_s=$tmp/$u.shcomp
mkdir -m700 "$tmp_s" || exit
# must incorporate _common in script itself so the aliases are expanded at compile time
sed '/^\. .*\/_common/ {
r _common
d
}' < $i > $c.orig
cd "$tmp_s" || exit
if $SHCOMP "$OLDPWD/$i" > $c
if "$SHCOMP" "$c.orig" > $c
then if tmp=$tmp_s $valgrind $SHELL $trace $c
then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 errors ]"
else e=$?
Expand Down

0 comments on commit bd38c80

Please sign in to comment.