Skip to content

Commit

Permalink
Improve this test.
Browse files Browse the repository at this point in the history
danfuzz committed Oct 4, 2023
1 parent df294df commit 2a52345
Showing 2 changed files with 15 additions and 21 deletions.
24 changes: 8 additions & 16 deletions tests/02-core/02-define-usage/01-usage-call/expect.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
## short

### stdout
```
(no exit expected)
```

### stderr
```
This is an error!
This is not actually an error! (But we can pretend.)
the-cmd -- This is the short
help for the command.
the-cmd [--help | -h]
the-cmd another-option-variant
(no exit expected; should see this)
```

### exit: 0
@@ -20,21 +16,17 @@ the-cmd [--help | -h]

## long

### stdout
```
(no exit expected)
```

### stderr
```
the-cmd -- This is the short
help for the command.
This is the longer help.
the-cmd [--help | -h]
the-cmd another-option-variant
Displays this message.
And more help about that.
(no exit expected; should see this)
```

### exit: 0
@@ -49,7 +41,7 @@ This is an error!
the-cmd -- This is the short
help for the command.
the-cmd [--help | -h]
the-cmd another-option-variant
```

### exit: 1
@@ -64,7 +56,7 @@ This is an error!
the-cmd -- This is the short
help for the command.
the-cmd [--help | -h]
the-cmd another-option-variant
```

### exit: 99
12 changes: 7 additions & 5 deletions tests/02-core/02-define-usage/01-usage-call/the-cmd
Original file line number Diff line number Diff line change
@@ -15,24 +15,26 @@ define-usage $'
This is the longer help.
${help}
${name} another-option-variant
And more help about that.
'

what="$1"

case "${what}" in
long)
usage
echo '(no exit expected)'
echo 1>&2 '(no exit expected; should see this)'
;;
short)
echo 1>&2 'This is an error!'
echo 1>&2 'This is not actually an error! (But we can pretend.)'
usage --short
echo '(no exit expected)'
echo 1>&2 '(no exit expected; should see this)'
;;
*)
echo 1>&2 'This is an error!'
(exit "${what}") || usage --short
echo '(exit expected; should not see this)'
echo 1>&2 '(exit expected; should not see this)'
;;
esac

0 comments on commit 2a52345

Please sign in to comment.