Skip to content

Commit

Permalink
Merge pull request #7 from moul/dev/moul/continue-on-error
Browse files Browse the repository at this point in the history
feat: testman test -continue-on-error
  • Loading branch information
moul authored Sep 7, 2020
2 parents 1ba3c46 + 5262ec3 commit a04224b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ linters:
- govet
- ineffassign
- interfacer
- maligned
#- maligned
- misspell
- nakedret
- prealloc
Expand Down
7 changes: 6 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
TMPDIR ?= /tmp/testman-integration

integration:
# test with testman
@mkdir -p $(TMPDIR)
testman test -timeout=10s -run ^TestStable ./... # should always work
testman test -timeout=60s -run ^TestUnstable -retry=50 ./... # should work at least 1/50
@# FIXME: test broken tests
(testman test -timeout=10s -continue-on-error -retry=10 ./...; echo "EXIT CODE: $$?") | tee $(TMPDIR)/got.continue-on-error.log # should fail, but also run all tests
diff ./testdata/expected.continue-on-error.log $(TMPDIR)/got.continue-on-error.log

# test with default tools
go install moul.io/retry
Expand All @@ -12,3 +16,4 @@ integration:
go mod tidy

@echo "SUCCESS."
@rm -rf $(TMPDIR)
5 changes: 5 additions & 0 deletions examples/testdata/expected.continue-on-error.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ok moul.io/testman/examples/testpkg.TestStableAlwaysSucceed
ok moul.io/testman/examples/testpkg.TestUnstableMaySucceed
FAIL moul.io/testman/examples/testpkg.TestBrokenAlwaysFailing [test error: exit status 1]
ok moul.io/testman/examples/testpkg.ExampleAlwaysSucceed
EXIT CODE: 1
14 changes: 8 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func run(args []string) error {
testFlags.BoolVar(&opts.Verbose, "v", false, "verbose")
testFlags.StringVar(&opts.Run, "run", "^(Test|Example)", "regex to filter out tests and examples")
testFlags.IntVar(&opts.Retry, "retry", 0, "fail after N retries")
testFlags.DurationVar(&opts.Timeout, "timeout", opts.Timeout, "max duration allowed to run the whole suite")
testFlags.DurationVar(&opts.Timeout, "timeout", 0, "max duration allowed to run the whole suite")
testFlags.BoolVar(&opts.ContinueOnError, "continue-on-error", false, "continue on error (but still fails at the end)")
listFlags := flag.NewFlagSet("testman list", flag.ExitOnError)
listFlags.BoolVar(&opts.Verbose, "v", false, "verbose")
listFlags.StringVar(&opts.Run, "run", "^(Test|Example)", "regex to filter out tests and examples")
Expand Down Expand Up @@ -298,11 +299,12 @@ type Package struct {
}

type Opts struct {
Verbose bool
Run string
Timeout time.Duration
Retry int
TmpDir string
Verbose bool
Run string
Timeout time.Duration
Retry int
TmpDir string
ContinueOnError bool
// c
// debug
// continueOnFailure vs failFast
Expand Down

0 comments on commit a04224b

Please sign in to comment.