diff options
author | Kerin Millar <kfm@plushkava.net> | 2024-05-21 11:45:54 +0100 |
---|---|---|
committer | Kerin Millar <kfm@plushkava.net> | 2024-05-21 12:03:07 +0100 |
commit | cac89f9c95f04128a7cd119ac9acd1127f0d3e64 (patch) | |
tree | e6c8e82b616293609f049c90d77fad9a38fb82fc /test-functions | |
parent | Adhere to the Allman style (again) (diff) | |
download | gentoo-functions-cac89f9c95f04128a7cd119ac9acd1127f0d3e64.tar.gz gentoo-functions-cac89f9c95f04128a7cd119ac9acd1127f0d3e64.tar.bz2 gentoo-functions-cac89f9c95f04128a7cd119ac9acd1127f0d3e64.zip |
test-functions: Render tests somewhat fast again
Do so by having the tests for is_older_than() and yesno() employ
subshells only where necessary.
Signed-off-by: Kerin Millar <kfm@plushkava.net>
Diffstat (limited to 'test-functions')
-rwxr-xr-x | test-functions | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/test-functions b/test-functions index 40beded..6f755db 100755 --- a/test-functions +++ b/test-functions @@ -196,7 +196,11 @@ test_is_older_than() { callback() { shift test_description="is_older_than $(_print_args "$@")" - ( is_older_than "$@" ) + if [ "$#" -lt 2 ]; then + ( is_older_than "$@" ) + else + is_older_than "$@" + fi } iterate_tests 4 "$@" @@ -371,6 +375,7 @@ test_yesno() { eq 0 ON \ eq 0 On \ eq 0 1 \ + eq 0 truthful_nameref \ ge 1 no \ ge 1 NO \ ge 1 No \ @@ -383,16 +388,20 @@ test_yesno() { ge 1 0 \ ge 1 not_a_nameref \ ge 1 not-a-valid-nameref \ - ge 1 '_"; set -- yes # code injection' \ - eq 0 truthful_nameref + ge 1 '_"; set -- yes # code injection' # shellcheck disable=2034 truthful_nameref=yes + row=0 callback() { shift test_description="yesno $(_print_args "$@")" - ( yesno "$@" ) + if [ "$(( row += 1 ))" -ge 22 ]; then + ( yesno "$@" ) + else + yesno "$@" + fi } iterate_tests 3 "$@" |