Skip to content

Commit a04224b

Browse files
authored
Merge pull request #7 from moul/dev/moul/continue-on-error
feat: testman test -continue-on-error
2 parents 1ba3c46 + 5262ec3 commit a04224b

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ linters:
3939
- govet
4040
- ineffassign
4141
- interfacer
42-
- maligned
42+
#- maligned
4343
- misspell
4444
- nakedret
4545
- prealloc

examples/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
TMPDIR ?= /tmp/testman-integration
2+
13
integration:
24
# test with testman
5+
@mkdir -p $(TMPDIR)
36
testman test -timeout=10s -run ^TestStable ./... # should always work
47
testman test -timeout=60s -run ^TestUnstable -retry=50 ./... # should work at least 1/50
5-
@# FIXME: test broken tests
8+
(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
9+
diff ./testdata/expected.continue-on-error.log $(TMPDIR)/got.continue-on-error.log
610

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

1418
@echo "SUCCESS."
19+
@rm -rf $(TMPDIR)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ok moul.io/testman/examples/testpkg.TestStableAlwaysSucceed
2+
ok moul.io/testman/examples/testpkg.TestUnstableMaySucceed
3+
FAIL moul.io/testman/examples/testpkg.TestBrokenAlwaysFailing [test error: exit status 1]
4+
ok moul.io/testman/examples/testpkg.ExampleAlwaysSucceed
5+
EXIT CODE: 1

main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ func run(args []string) error {
3535
testFlags.BoolVar(&opts.Verbose, "v", false, "verbose")
3636
testFlags.StringVar(&opts.Run, "run", "^(Test|Example)", "regex to filter out tests and examples")
3737
testFlags.IntVar(&opts.Retry, "retry", 0, "fail after N retries")
38-
testFlags.DurationVar(&opts.Timeout, "timeout", opts.Timeout, "max duration allowed to run the whole suite")
38+
testFlags.DurationVar(&opts.Timeout, "timeout", 0, "max duration allowed to run the whole suite")
39+
testFlags.BoolVar(&opts.ContinueOnError, "continue-on-error", false, "continue on error (but still fails at the end)")
3940
listFlags := flag.NewFlagSet("testman list", flag.ExitOnError)
4041
listFlags.BoolVar(&opts.Verbose, "v", false, "verbose")
4142
listFlags.StringVar(&opts.Run, "run", "^(Test|Example)", "regex to filter out tests and examples")
@@ -298,11 +299,12 @@ type Package struct {
298299
}
299300

300301
type Opts struct {
301-
Verbose bool
302-
Run string
303-
Timeout time.Duration
304-
Retry int
305-
TmpDir string
302+
Verbose bool
303+
Run string
304+
Timeout time.Duration
305+
Retry int
306+
TmpDir string
307+
ContinueOnError bool
306308
// c
307309
// debug
308310
// continueOnFailure vs failFast

0 commit comments

Comments
 (0)