From 9ff692c2bbecf1c1e8d9e43eb608295c73a5f323 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 17 Jun 2020 15:43:16 +0200 Subject: [PATCH] regress: count tests and report line numbers (re: 7b994b6a) Four added tests did not correctly report their line numbers upon failure and were counted as one, because the err_exit alias/function pair was called from a shell function. Note that shtests simply does a 'grep -c err_exit' to count the number of regression tests in a test script. src/cmd/ksh93/tests/subshell.sh: - check_hash_table(): - Take line number as 1st argument. - Quote a character in err_exit to bypass the alias when calling it, so we can pass on the argument for the line number. This also stops this helper function from being counted as a test. - When calling check_hash_table(), pass $LINENO. - Add dummy err_exit comments to have the tests counted. --- src/cmd/ksh93/tests/subshell.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh index e7969f052..24e9d5cdb 100755 --- a/src/cmd/ksh93/tests/subshell.sh +++ b/src/cmd/ksh93/tests/subshell.sh @@ -723,15 +723,15 @@ v=${ eval 'al'; alias al='echo subshare'; } && [[ $v == 'mainalias' && $(eval 'a # Resetting a subshell's hash table should not affect the parent shell check_hash_table() { - [[ $(hash) ]] || err_exit $'resetting the hash table in a subshell affects the parent shell\'s hash table' + [[ $(hash) ]] || err_\exit $1 $'resetting the hash table in a subshell affects the parent shell\'s hash table' # Ensure the hash table isn't empty before the next test is run hash -r chmod } -(hash -r); check_hash_table -(PATH="$PATH"); check_hash_table -(unset PATH); check_hash_table -(nameref PATH_TWO=PATH; unset PATH_TWO); check_hash_table +(hash -r); check_hash_table $LINENO # err_exit (count me) +(PATH="$PATH"); check_hash_table $LINENO # err_exit (count me) +(unset PATH); check_hash_table $LINENO # err_exit (count me) +(nameref PATH_TWO=PATH; unset PATH_TWO); check_hash_table $LINENO # err_exit (count me) # Adding a utility to a subshell's hash table should not affect the parent shell (hash cat)