Skip to content

Commit

Permalink
Fixed remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UrsaDK committed Dec 18, 2024
1 parent 6033364 commit e12f575
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
24 changes: 10 additions & 14 deletions test/bats/github_13.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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")'
}
3 changes: 2 additions & 1 deletion test/bin/getopts_long-explicit_args-silent
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion test/bin/getopts_long-explicit_args-verbose
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e12f575

Please sign in to comment.