From e12f5755ee25fa0c45e1e6278a7ac594140e39e8 Mon Sep 17 00:00:00 2001 From: Dmytro Konstantinov Date: Wed, 18 Dec 2024 10:05:39 +0000 Subject: [PATCH] Fixed remaining tests --- test/bats/github_13.bats | 24 +++++++++------------ test/bin/getopts_long-explicit_args-silent | 3 ++- test/bin/getopts_long-explicit_args-verbose | 3 ++- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/test/bats/github_13.bats b/test/bats/github_13.bats index 5ddd271..d218a7d 100644 --- a/test/bats/github_13.bats +++ b/test/bats/github_13.bats @@ -58,35 +58,31 @@ export GETOPTS_LONG_TEST_BIN='getopts_long-no_shortspec' } @test "${FEATURE}: terminator followed by long variable, silent" { - compare '-t -- -v user_val' \ + compare '-t -- -vuser_val' \ '--toggle -- --variable=user_val' \ - '/^\$@: /d' - expect "${bash_getopts[6]}" == 'declare -a $@=([0]="-v" [1]="user_val")' + '6{s/\[0]="(-v|--variable=)/[0]="-NORMALIZED=/}' + expect "${bash_getopts[6]}" == 'declare -a $@=([0]="-vuser_val")' expect "${getopts_long[6]}" == 'declare -a $@=([0]="--variable=user_val")' } @test "${FEATURE}: terminator followed by long variable, verbose" { - compare '-t -- -v user_val' \ + compare '-t -- -vuser_val' \ '--toggle -- --variable=user_val' \ - '/^\$@: /d' - expect "${bash_getopts[6]}" == 'declare -a $@=([0]="-v" [1]="user_val")' + '6{s/\[0]="(-v|--variable=)/[0]="-NORMALIZED=/}' + expect "${bash_getopts[6]}" == 'declare -a $@=([0]="-vuser_val")' expect "${getopts_long[6]}" == 'declare -a $@=([0]="--variable=user_val")' } @test "${FEATURE}: long variable followed by terminator, silent" { - compare '-v user_val -- -t' \ + compare '-vuser_val -- -t' \ '--variable=user_val -- --toggle' \ - '/^(OPTIND|\$@): /d' - expect "${bash_getopts[5]}" == 'declare -i OPTIND="4"' - expect "${getopts_long[5]}" == 'declare -i OPTIND="3"' + '6{s/\[0]="(-t|--toggle)"/[0]="NORMALIZED"/}' expect "${bash_getopts[6]}" == 'declare -a $@=([0]="-t")' expect "${getopts_long[6]}" == 'declare -a $@=([0]="--toggle")' } @test "${FEATURE}: long variable followed by terminator, verbose" { - compare '-v user_val -- -t' \ + compare '-vuser_val -- -t' \ '--variable=user_val -- --toggle' \ - '/^(OPTIND|\$@): /d' - expect "${bash_getopts[5]}" == 'declare -i OPTIND="4"' - expect "${getopts_long[5]}" == 'declare -i OPTIND="3"' + '6{s/\[0]="(-t|--toggle)"/[0]="NORMALIZED"/}' expect "${bash_getopts[6]}" == 'declare -a $@=([0]="-t")' expect "${getopts_long[6]}" == 'declare -a $@=([0]="--toggle")' } diff --git a/test/bin/getopts_long-explicit_args-silent b/test/bin/getopts_long-explicit_args-silent index 6fe2eca..9f11d7b 100755 --- a/test/bin/getopts_long-explicit_args-silent +++ b/test/bin/getopts_long-explicit_args-silent @@ -39,7 +39,8 @@ getopts_function() { local function_args=("$@") declare -p function_args \ - | sed -e 's/script_args/$@/' | grep -oe 'declare.*' + | sed -e 's/function_args/$@/' \ + | grep -oe 'declare.*' } proxy() { diff --git a/test/bin/getopts_long-explicit_args-verbose b/test/bin/getopts_long-explicit_args-verbose index 9687279..3edda6d 100755 --- a/test/bin/getopts_long-explicit_args-verbose +++ b/test/bin/getopts_long-explicit_args-verbose @@ -39,7 +39,8 @@ getopts_function() { local function_args=("$@") declare -p function_args \ - | sed -e 's/script_args/$@/' | grep -oe 'declare.*' + | sed -e 's/function_args/$@/' \ + | grep -oe 'declare.*' } proxy() {