Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: testman test -continue-on-error #7

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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