-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into billyzkid-patch-3
- Loading branch information
Showing
43 changed files
with
1,578 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: monthly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env bats | ||
|
||
load ../test_helper | ||
export GETOPTS_LONG_TEST_BIN='getopts_long-no_shortspec' | ||
|
||
@test "${FEATURE}: long option, silent" { | ||
compare '-o user_val' \ | ||
'--option user_val' | ||
} | ||
@test "${FEATURE}: long option, verbose" { | ||
compare '-o user_val' \ | ||
'--option user_val' | ||
} | ||
|
||
@test "${FEATURE}: long variable, silent" { | ||
compare '-v user_val' \ | ||
'--variable=user_val' \ | ||
'/^OPTIND: /d' | ||
expect "${bash_getopts[5]}" == 'OPTIND: 3' | ||
expect "${getopts_long[5]}" == 'OPTIND: 2' | ||
} | ||
@test "${FEATURE}: long variable, verbose" { | ||
compare '-v user_val' \ | ||
'--variable=user_val' \ | ||
'/^OPTIND: /d' | ||
expect "${bash_getopts[5]}" == 'OPTIND: 3' | ||
expect "${getopts_long[5]}" == 'OPTIND: 2' | ||
} | ||
|
||
@test "${FEATURE}: toggle followed by long variable, silent" { | ||
compare '-t -v user_val' \ | ||
'--toggle --variable=user_val' \ | ||
'/^OPTIND: /d' | ||
expect "${bash_getopts[6]}" == 'OPTIND: 4' | ||
expect "${getopts_long[6]}" == 'OPTIND: 3' | ||
} | ||
@test "${FEATURE}: toggle followed by long variable, verbose" { | ||
compare '-t -v user_val' \ | ||
'--toggle --variable=user_val' \ | ||
'/^OPTIND: /d' | ||
expect "${bash_getopts[6]}" == 'OPTIND: 4' | ||
expect "${getopts_long[6]}" == 'OPTIND: 3' | ||
} | ||
|
||
@test "${FEATURE}: long variable followed by toggle, silent" { | ||
compare '-v user_val -t' \ | ||
'--variable=user_val --toggle' \ | ||
'/^OPTIND: /d' | ||
expect "${bash_getopts[6]}" == 'OPTIND: 4' | ||
expect "${getopts_long[6]}" == 'OPTIND: 3' | ||
} | ||
@test "${FEATURE}: long variable followed by toggle, verbose" { | ||
compare '-v user_val -t' \ | ||
'--variable=user_val --toggle' \ | ||
'/^OPTIND: /d' | ||
expect "${bash_getopts[6]}" == 'OPTIND: 4' | ||
expect "${getopts_long[6]}" == 'OPTIND: 3' | ||
} | ||
|
||
@test "${FEATURE}: terminator followed by long variable, silent" { | ||
compare '-t -- -v user_val' \ | ||
'--toggle -- --variable=user_val' \ | ||
'/^\$@: /d' | ||
expect "${bash_getopts[6]}" == '$@: ([0]="-v" [1]="user_val")' | ||
expect "${getopts_long[6]}" == '$@: ([0]="--variable=user_val")' | ||
} | ||
@test "${FEATURE}: terminator followed by long variable, verbose" { | ||
compare '-t -- -v user_val' \ | ||
'--toggle -- --variable=user_val' \ | ||
'/^\$@: /d' | ||
expect "${bash_getopts[6]}" == '$@: ([0]="-v" [1]="user_val")' | ||
expect "${getopts_long[6]}" == '$@: ([0]="--variable=user_val")' | ||
} | ||
|
||
@test "${FEATURE}: long variable followed by terminator, silent" { | ||
compare '-v user_val -- -t' \ | ||
'--variable=user_val -- --toggle' \ | ||
'/^(OPTIND|\$@): /d' | ||
expect "${bash_getopts[5]}" == 'OPTIND: 4' | ||
expect "${getopts_long[5]}" == 'OPTIND: 3' | ||
expect "${bash_getopts[6]}" == '$@: ([0]="-t")' | ||
expect "${getopts_long[6]}" == '$@: ([0]="--toggle")' | ||
} | ||
@test "${FEATURE}: long variable followed by terminator, verbose" { | ||
compare '-v user_val -- -t' \ | ||
'--variable=user_val -- --toggle' \ | ||
'/^(OPTIND|\$@): /d' | ||
expect "${bash_getopts[5]}" == 'OPTIND: 4' | ||
expect "${getopts_long[5]}" == 'OPTIND: 3' | ||
expect "${bash_getopts[6]}" == '$@: ([0]="-t")' | ||
expect "${getopts_long[6]}" == '$@: ([0]="--toggle")' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env bats | ||
|
||
load ../test_helper | ||
|
||
# Neither bash getopts nor getopts_long OPTSPEC includes [-] | ||
|
||
@test "${FEATURE}: short toggle, single, silent" { | ||
compare '-t- -t user_arg' \ | ||
'-t- -t user_arg' | ||
} | ||
@test "${FEATURE}: short toggle, single, verbose" { | ||
compare '-t- -t user_arg' \ | ||
'-t- -t user_arg' \ | ||
's/getopts[[:alpha:]_-]*/GETOPTS-NORMALISED/' | ||
} | ||
|
||
@test "${FEATURE}: short toggle, silent" { | ||
compare '-t-- -t user_arg' \ | ||
'-t-- -t user_arg' | ||
} | ||
@test "${FEATURE}: short toggle, verbose" { | ||
compare '-t-- -t user_arg' \ | ||
'-t-- -t user_arg' \ | ||
's/getopts[[:alpha:]_-]*/GETOPTS-NORMALISED/' | ||
} | ||
|
||
# Standard getopts should see: | ||
# -t - a toggle | ||
# -- - an invalid option | ||
# -- - an invalid option | ||
# -t - a toggle | ||
# Getopts_long should see: | ||
# --toggle-- - an invalid option | ||
# --toggle - a toggle | ||
@test "${FEATURE}: long toggle, silent" { | ||
compare '-t-- -t user_arg' \ | ||
'--toggle-- --toggle user_arg' \ | ||
'1{/^toggle triggered/d}' \ | ||
'/^INVALID OPTION/d' | ||
expect "${bash_getopts[2]}" == 'INVALID OPTION -- OPTARG="-"' | ||
expect "${bash_getopts[3]}" == 'INVALID OPTION -- OPTARG="-"' | ||
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="toggle--"' | ||
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG' | ||
expect "${bash_getopts[4]}" == 'toggle triggered -- OPTARG' | ||
expect "${getopts_long[2]}" == 'toggle triggered -- OPTARG' | ||
} | ||
@test "${FEATURE}: long toggle, verbose" { | ||
compare '-t-- -t user_arg' \ | ||
'--toggle-- --toggle user_arg' \ | ||
'1{/^toggle triggered/d}' \ | ||
'4{/getopts-verbose: illegal option -- -$/d}' \ | ||
'5{/^INVALID OPTION or MISSING ARGUMENT/d}' \ | ||
's/getopts[[:alpha:]_-]*/GETOPTS-NORMALISED/' \ | ||
's/(illegal option --) (-|toggle--)/\1 TOGGLE-NORMALISED/' | ||
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG' | ||
expect "${bash_getopts[2]}" =~ 'getopts-verbose: illegal option -- -$' | ||
expect "${bash_getopts[4]}" =~ 'getopts-verbose: illegal option -- -$' | ||
expect "${bash_getopts[6]}" == 'toggle triggered -- OPTARG' | ||
expect "${getopts_long[1]}" =~ 'getopts_long-verbose: illegal option -- toggle--$' | ||
expect "${getopts_long[3]}" == 'toggle triggered -- OPTARG' | ||
} | ||
|
||
# Both implementations should see: | ||
# -o -- - an option with a value | ||
# -t - a toggle | ||
@test "${FEATURE}: short option, silent" { | ||
compare '-o-- -t user_arg' \ | ||
'-o-- -t user_arg' | ||
} | ||
@test "${FEATURE}: short option, verbose" { | ||
compare '-o-- -t user_arg' \ | ||
'-o-- -t user_arg' | ||
} | ||
|
||
# Standard getopts should see: | ||
# -o -- - an option with a value | ||
# -t - a toggle | ||
# Getopts_long should see: | ||
# --option-- - an invalid option | ||
# --toggle - a toggle | ||
@test "${FEATURE}: long option, silent" { | ||
compare '-o-- -t user_arg' \ | ||
'--option-- --toggle user_arg' \ | ||
'1{/(option supplied|INVALID OPTION)/d}' | ||
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="--"' | ||
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="option--"' | ||
} | ||
@test "${FEATURE}: long option, verbose" { | ||
compare '-o-- -t user_arg' \ | ||
'--option-- --toggle user_arg' \ | ||
'1{/(option supplied|illegal option)/d}' \ | ||
'2{/^INVALID OPTION or MISSING ARGUMENT/d}' | ||
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="--"' | ||
expect "${getopts_long[1]}" =~ "getopts_long-verbose: illegal option -- option--$" | ||
} |
Oops, something went wrong.