Skip to content

Commit

Permalink
ci: add go 1.17.x and 1.18.x, fix failing test
Browse files Browse the repository at this point in the history
One test is failing with Go 1.17+ since it now panics instead of
returning an error. Catch the panic and consider the test passed.

With that out of the door, add Go 1.17.x and 1.18.x to the testing
matrix.

While at it, do not use && in run since it is executed by a shell with
set -e, thus making && redundant.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Apr 27, 2022
1 parent 1b4a05e commit f971df9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/cli.yml
Expand Up @@ -16,12 +16,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
go:
- 1.16.x
# NOTE: tests fail with panic at
# TestApp_RunAsSubCommandIncorrectUsage on these
# versions:
# - 1.17.x
# - 1.18.x
- [1.16.x, 1.17.x, 1.18.x]
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -38,6 +33,6 @@ jobs:

- name: Run Tests
run:
go run build.go vet &&
go run build.go test &&
go run build.go vet
go run build.go test
go run build.go toc docs/v1/manual.md
8 changes: 8 additions & 0 deletions app_test.go
Expand Up @@ -508,6 +508,14 @@ func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
}

func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) {
// Go 1.17+ panics when invalid flag is given.
// Catch it here and consider the test passed.
defer func() {
if err := recover(); err == nil {
t.Fatal("expected error, got nothing")
}
}()

a := App{
Flags: []Flag{
StringFlag{Name: "--foo"},
Expand Down

0 comments on commit f971df9

Please sign in to comment.