1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00

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.
This commit is contained in:
Martijn Dekker 2020-06-17 15:43:16 +02:00
parent fae8862c53
commit 9ff692c2bb

View file

@ -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)