-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
tests/02-core/03-arg-processor/91-unknown-declaration-opts/expect.md
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,19 @@ | ||
## test | ||
|
||
### stderr | ||
``` | ||
the-cmd: | ||
the-cmd:18: Unknown option: --florp | ||
the-cmd:19: Unknown option: --fleep | ||
the-cmd:20: Unknown option: --flomp | ||
the-cmd:21: Unknown option: --beep | ||
the-cmd:22: Unknown option: --what-the-muffin | ||
the-cmd:25: Invalid option syntax: -zonk | ||
the-cmd:26: Invalid option syntax: ---zonk | ||
the-cmd:27: Invalid option syntax: --Zomg | ||
Cannot process arguments, due to declaration errors. | ||
the-cmd -- test command | ||
``` | ||
|
||
### exit: 1 |
1 change: 1 addition & 0 deletions
1
tests/02-core/03-arg-processor/91-unknown-declaration-opts/info.txt
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 @@ | ||
Test for error detection of totally unknown argument declaration options. |
10 changes: 10 additions & 0 deletions
10
tests/02-core/03-arg-processor/91-unknown-declaration-opts/run
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,10 @@ | ||
#!/bin/bash | ||
# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[[ "$(readlink -f "$0")" =~ ^(.*/tests/) ]] && . "${BASH_REMATCH[1]}_test-init.sh" || exit 1 | ||
|
||
cmd="$(this-cmd-dir)/the-cmd" | ||
|
||
call-and-log-as-test 'test' \ | ||
"${cmd}" |
31 changes: 31 additions & 0 deletions
31
tests/02-core/03-arg-processor/91-unknown-declaration-opts/the-cmd
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,31 @@ | ||
#!/bin/bash | ||
# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[[ "$(readlink -f "$0")" =~ ^(.*/tests/) ]] && . "${BASH_REMATCH[1]}_init.sh" || exit 1 | ||
|
||
|
||
# | ||
# Argument parsing | ||
# | ||
|
||
define-usage $' | ||
${name} -- test command | ||
This is a test command. | ||
' | ||
|
||
opt-value --florp --var=var1 some-value | ||
opt-choice --fleep=zonk --call=func1 yes no | ||
opt-toggle --init=23 --flomp --var=var2 boop | ||
positional-arg --beep=boop --required --var=var3 some-position | ||
rest-arg --filter='/./' --call=func2 --what-the-muffin the-rest | ||
|
||
# Examples of "option-like" but not syntactically correct as options. | ||
opt-value -zonk --var=v x | ||
opt-value ---zonk --var=v x | ||
opt-value --Zomg --var=v x | ||
|
||
process-args "$@" || usage --short | ||
|
||
echo 'Nopers.' |
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,15 @@ | ||
## test | ||
|
||
### stderr | ||
``` | ||
the-cmd: | ||
the-cmd:18: Unknown option: --florp | ||
the-cmd:19: Unknown option: --fleep | ||
the-cmd:20: Unknown option: --flomp | ||
the-cmd:21: Unknown option: --beep | ||
Cannot process arguments, due to declaration errors. | ||
the-cmd -- test command | ||
``` | ||
|
||
### exit: 1 |
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,2 @@ | ||
Test for error detection of the requirement to declare at least | ||
one of `--call` or `--var`. |
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,10 @@ | ||
#!/bin/bash | ||
# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[[ "$(readlink -f "$0")" =~ ^(.*/tests/) ]] && . "${BASH_REMATCH[1]}_test-init.sh" || exit 1 | ||
|
||
cmd="$(this-cmd-dir)/the-cmd" | ||
|
||
call-and-log-as-test 'test' \ | ||
"${cmd}" |
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,26 @@ | ||
#!/bin/bash | ||
# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[[ "$(readlink -f "$0")" =~ ^(.*/tests/) ]] && . "${BASH_REMATCH[1]}_init.sh" || exit 1 | ||
|
||
|
||
# | ||
# Argument parsing | ||
# | ||
|
||
define-usage $' | ||
${name} -- test command | ||
This is a test command. | ||
' | ||
|
||
opt-value some-value | ||
opt-choice yes no | ||
opt-toggle boop | ||
positional-arg --filter='/boop/' some-position | ||
rest-arg --required the-rest | ||
|
||
process-args "$@" || usage --short | ||
|
||
echo 'Nopers.' |