Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
danfuzz committed Oct 4, 2023
1 parent 28599e7 commit 95133ea
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/02-core/03-arg-processor/90-init-required/expect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## test

### stderr
```
the-cmd:
the-cmd:18: Cannot use both --required and --init.
the-cmd:19: Cannot use both --required and --init.
the-cmd:20: Cannot use both --required and --init.
Cannot process arguments, due to declaration errors.
the-cmd -- test command
```

### exit: 1
1 change: 1 addition & 0 deletions tests/02-core/03-arg-processor/90-init-required/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test for error detection on `--init=... --required`.
10 changes: 10 additions & 0 deletions tests/02-core/03-arg-processor/90-init-required/run
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}"
24 changes: 24 additions & 0 deletions tests/02-core/03-arg-processor/90-init-required/the-cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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 --required --var=var1 --init=florp some-value
opt-choice --init=maybe --required --var=var3 yes no
positional-arg --init=x --var=var4 --required some-position

process-args "$@" || usage --short

echo 'Nopers.'

0 comments on commit 95133ea

Please sign in to comment.