diff options
| author | Shulhan <m.shulhan@gmail.com> | 2023-12-03 01:06:29 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2024-01-25 04:01:14 +0700 |
| commit | 65f7032d4ed53d7e8d605d72b294527a0eef6740 (patch) | |
| tree | a6f56d62d6c1ec05a27d5c04f8e8792b61910ad2 | |
| parent | 8096b47dd09fcda8712f7a3c07dced5244123a4d (diff) | |
| download | go-65f7032d4ed53d7e8d605d72b294527a0eef6740.tar.xz | |
testing: change the FAIL and SKIP prefix to "!!!" and "???"
Previously, there are three output of message printed by test or
benchmark: PASS, SKIP, or FAIL. All of them use the same prefix "---".
In case we have a module that run many many tests, it's become hard to
differentiate between PASS, SKIP, and FAIL.
This changes differentiate the SKIP and FAIL using different prefix.
For SKIP we prefix it with "???", for FAIL we prefix it with "!!!".
| -rw-r--r-- | src/runtime/race/output_test.go | 2 | ||||
| -rw-r--r-- | src/testing/benchmark.go | 6 | ||||
| -rw-r--r-- | src/testing/example.go | 2 | ||||
| -rw-r--r-- | src/testing/fuzz.go | 8 | ||||
| -rw-r--r-- | src/testing/helper_test.go | 6 | ||||
| -rw-r--r-- | src/testing/panic_test.go | 34 | ||||
| -rw-r--r-- | src/testing/sub_test.go | 48 | ||||
| -rw-r--r-- | src/testing/testing.go | 16 |
8 files changed, 61 insertions, 61 deletions
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go index 0ee0f41334..e6397eac7a 100644 --- a/src/runtime/race/output_test.go +++ b/src/runtime/race/output_test.go @@ -363,7 +363,7 @@ func TestPass(t *testing.T) { } `, []string{` ================== ---- FAIL: TestFail \([0-9.]+s\) +!!! FAIL: TestFail \([0-9.]+s\) .*testing.go:.*: race detected during execution of test FAIL`}}, {"mutex", "run", "", "atexit_sleep_ms=0", ` diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index 9491213ef1..e3d9cee5c6 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -216,7 +216,7 @@ func (b *B) run1() bool { }() <-b.signal if b.failed { - fmt.Fprintf(b.w, "%s--- FAIL: %s\n%s", b.chatty.prefix(), b.name, b.output) + fmt.Fprintf(b.w, "%s!!! FAIL: %s\n%s", b.chatty.prefix(), b.name, b.output) return false } // Only print the output if we know we are not going to proceed. @@ -227,7 +227,7 @@ func (b *B) run1() bool { if b.hasSub.Load() || finished { tag := "BENCH" if b.skipped { - tag = "SKIP" + tag = "??? SKIP" } if b.chatty != nil && (len(b.output) > 0 || finished) { b.trimOutput() @@ -584,7 +584,7 @@ func (ctx *benchContext) processBench(b *B) { // The output could be very long here, but probably isn't. // We print it all, regardless, because we don't want to trim the reason // the benchmark failed. - fmt.Fprintf(b.w, "%s--- FAIL: %s\n%s", b.chatty.prefix(), benchName, b.output) + fmt.Fprintf(b.w, "%s!!! FAIL: %s\n%s", b.chatty.prefix(), benchName, b.output) continue } results := r.String() diff --git a/src/testing/example.go b/src/testing/example.go index 07aa5cb66c..0b1776b289 100644 --- a/src/testing/example.go +++ b/src/testing/example.go @@ -76,7 +76,7 @@ func (eg *InternalExample) processRunResult(stdout string, timeSpent time.Durati } } if fail != "" || !finished || recovered != nil { - fmt.Printf("%s--- FAIL: %s (%s)\n%s", chatty.prefix(), eg.Name, dstr, fail) + fmt.Printf("%s!!! FAIL: %s (%s)\n%s", chatty.prefix(), eg.Name, dstr, fail) passed = false } else if chatty.on { fmt.Printf("%s--- PASS: %s (%s)\n", chatty.prefix(), eg.Name, dstr) diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index d50ea793e0..b10d5dc216 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -410,14 +410,14 @@ func (f *F) report() { return } dstr := fmtDuration(f.duration) - format := "--- %s: %s (%s)\n" + format := "%s: %s (%s)\n" if f.Failed() { - f.flushToParent(f.name, format, "FAIL", f.name, dstr) + f.flushToParent(f.name, format, "!!! FAIL", f.name, dstr) } else if f.chatty != nil { if f.Skipped() { - f.flushToParent(f.name, format, "SKIP", f.name, dstr) + f.flushToParent(f.name, format, "??? SKIP", f.name, dstr) } else { - f.flushToParent(f.name, format, "PASS", f.name, dstr) + f.flushToParent(f.name, format, "--- PASS", f.name, dstr) } } } diff --git a/src/testing/helper_test.go b/src/testing/helper_test.go index da5622f85f..2deb9c9f3c 100644 --- a/src/testing/helper_test.go +++ b/src/testing/helper_test.go @@ -36,17 +36,17 @@ func TestTBHelper(t *testing.T) { cmd.Env = append(cmd.Env, "GO_WANT_HELPER_PROCESS=1") out, _ := cmd.CombinedOutput() - want := `--- FAIL: TestTBHelper \([^)]+\) + want := `!!! FAIL: TestTBHelper \([^)]+\) helperfuncs_test.go:15: 0 helperfuncs_test.go:47: 1 helperfuncs_test.go:24: 2 helperfuncs_test.go:49: 3 helperfuncs_test.go:56: 4 - --- FAIL: TestTBHelper/sub \([^)]+\) + !!! FAIL: TestTBHelper/sub \([^)]+\) helperfuncs_test.go:59: 5 helperfuncs_test.go:24: 6 helperfuncs_test.go:58: 7 - --- FAIL: TestTBHelper/sub2 \([^)]+\) + !!! FAIL: TestTBHelper/sub2 \([^)]+\) helperfuncs_test.go:80: 11 helperfuncs_test.go:84: recover 12 helperfuncs_test.go:86: GenericFloat64 diff --git a/src/testing/panic_test.go b/src/testing/panic_test.go index 6307b84a7a..0a8399ddd1 100644 --- a/src/testing/panic_test.go +++ b/src/testing/panic_test.go @@ -32,16 +32,16 @@ func TestPanic(t *testing.T) { desc: "root test panics", flags: []string{"-test_panic_test=TestPanicHelper"}, want: ` ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper `, }, { desc: "subtest panics", flags: []string{"-test_panic_test=TestPanicHelper/1"}, want: ` ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }, { @@ -51,9 +51,9 @@ func TestPanic(t *testing.T) { ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }, { @@ -63,7 +63,7 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper `, }, { @@ -73,9 +73,9 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }, { @@ -85,9 +85,9 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }, { @@ -97,9 +97,9 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }, { @@ -109,7 +109,7 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper `, }, { @@ -119,9 +119,9 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }, { @@ -131,9 +131,9 @@ ran outer cleanup ran inner cleanup 1 ran middle cleanup 1 ran outer cleanup ---- FAIL: TestPanicHelper (N.NNs) +!!! FAIL: TestPanicHelper (N.NNs) panic_test.go:NNN: TestPanicHelper - --- FAIL: TestPanicHelper/1 (N.NNs) + !!! FAIL: TestPanicHelper/1 (N.NNs) panic_test.go:NNN: TestPanicHelper/1 `, }} diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go index 1c23d054a0..6b04cdf4c4 100644 --- a/src/testing/sub_test.go +++ b/src/testing/sub_test.go @@ -132,8 +132,8 @@ func TestTRun(t *T) { ok: false, maxPar: 1, output: ` ---- FAIL: failnow skips future sequential and parallel tests at same level (N.NNs) - --- FAIL: failnow skips future sequential and parallel tests at same level/#00 (N.NNs) +!!! FAIL: failnow skips future sequential and parallel tests at same level (N.NNs) + !!! FAIL: failnow skips future sequential and parallel tests at same level/#00 (N.NNs) `, f: func(t *T) { ranSeq := false @@ -167,9 +167,9 @@ func TestTRun(t *T) { ok: false, maxPar: 1, output: ` ---- FAIL: failure in parallel test propagates upwards (N.NNs) - --- FAIL: failure in parallel test propagates upwards/#00 (N.NNs) - --- FAIL: failure in parallel test propagates upwards/#00/par (N.NNs) +!!! FAIL: failure in parallel test propagates upwards (N.NNs) + !!! FAIL: failure in parallel test propagates upwards/#00 (N.NNs) + !!! FAIL: failure in parallel test propagates upwards/#00/par (N.NNs) `, f: func(t *T) { t.Run("", func(t *T) { @@ -186,7 +186,7 @@ func TestTRun(t *T) { chatty: true, output: ` === RUN skipping without message, chatty ---- SKIP: skipping without message, chatty (N.NNs)`, +??? SKIP: skipping without message, chatty (N.NNs)`, f: func(t *T) { t.SkipNow() }, }, { desc: "chatty with recursion", @@ -217,15 +217,15 @@ func TestTRun(t *T) { ^V=== NAME chatty with recursion and json/#00 ^V=== RUN chatty with recursion and json/#00/#01 sub_test.go:NNN: skip -^V--- SKIP: chatty with recursion and json/#00/#01 (N.NNs) +^V??? SKIP: chatty with recursion and json/#00/#01 (N.NNs) ^V=== NAME chatty with recursion and json/#00 ^V=== RUN chatty with recursion and json/#00/#02 sub_test.go:NNN: fail -^V--- FAIL: chatty with recursion and json/#00/#02 (N.NNs) +^V!!! FAIL: chatty with recursion and json/#00/#02 (N.NNs) ^V=== NAME chatty with recursion and json/#00 -^V--- FAIL: chatty with recursion and json/#00 (N.NNs) +^V!!! FAIL: chatty with recursion and json/#00 (N.NNs) ^V=== NAME chatty with recursion and json -^V--- FAIL: chatty with recursion and json (N.NNs) +^V!!! FAIL: chatty with recursion and json (N.NNs) ^V=== NAME `, f: func(t *T) { t.Run("", func(t *T) { @@ -241,7 +241,7 @@ func TestTRun(t *T) { }, { desc: "skipping after error", output: ` ---- FAIL: skipping after error (N.NNs) +!!! FAIL: skipping after error (N.NNs) sub_test.go:NNN: an error sub_test.go:NNN: skipped`, f: func(t *T) { @@ -351,7 +351,7 @@ func TestTRun(t *T) { desc: "subtest calls error on parent", ok: false, output: ` ---- FAIL: subtest calls error on parent (N.NNs) +!!! FAIL: subtest calls error on parent (N.NNs) sub_test.go:NNN: first this sub_test.go:NNN: and now this! sub_test.go:NNN: oh, and this too`, @@ -368,10 +368,10 @@ func TestTRun(t *T) { desc: "subtest calls fatal on parent", ok: false, output: ` ---- FAIL: subtest calls fatal on parent (N.NNs) +!!! FAIL: subtest calls fatal on parent (N.NNs) sub_test.go:NNN: first this sub_test.go:NNN: and now this! - --- FAIL: subtest calls fatal on parent/#00 (N.NNs) + !!! FAIL: subtest calls fatal on parent/#00 (N.NNs) testing.go:NNN: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test`, maxPar: 1, f: func(t *T) { @@ -386,9 +386,9 @@ func TestTRun(t *T) { desc: "subtest calls error on ancestor", ok: false, output: ` ---- FAIL: subtest calls error on ancestor (N.NNs) +!!! FAIL: subtest calls error on ancestor (N.NNs) sub_test.go:NNN: Report to ancestor - --- FAIL: subtest calls error on ancestor/#00 (N.NNs) + !!! FAIL: subtest calls error on ancestor/#00 (N.NNs) sub_test.go:NNN: Still do this sub_test.go:NNN: Also do this`, maxPar: 1, @@ -406,7 +406,7 @@ func TestTRun(t *T) { desc: "subtest calls fatal on ancestor", ok: false, output: ` ---- FAIL: subtest calls fatal on ancestor (N.NNs) +!!! FAIL: subtest calls fatal on ancestor (N.NNs) sub_test.go:NNN: Nope`, maxPar: 1, f: func(t *T) { @@ -447,7 +447,7 @@ func TestTRun(t *T) { desc: "log in finished sub test logs to parent", ok: false, output: ` - --- FAIL: log in finished sub test logs to parent (N.NNs) + !!! FAIL: log in finished sub test logs to parent (N.NNs) sub_test.go:NNN: message2 sub_test.go:NNN: message1 sub_test.go:NNN: error`, @@ -473,7 +473,7 @@ func TestTRun(t *T) { ok: false, chatty: true, output: ` - --- FAIL: log in finished sub test with chatty (N.NNs)`, + !!! FAIL: log in finished sub test with chatty (N.NNs)`, maxPar: 1, f: func(t *T) { ch := make(chan bool) @@ -495,8 +495,8 @@ func TestTRun(t *T) { ok: false, chatty: false, output: ` ---- FAIL: cleanup when subtest panics (N.NNs) - --- FAIL: cleanup when subtest panics/sub (N.NNs) +!!! FAIL: cleanup when subtest panics (N.NNs) + !!! FAIL: cleanup when subtest panics/sub (N.NNs) sub_test.go:NNN: running cleanup`, f: func(t *T) { t.Cleanup(func() { t.Log("running cleanup") }) @@ -590,12 +590,12 @@ func TestBRun(t *T) { }, { desc: "failure carried over to root", failed: true, - output: "--- FAIL: root", + output: "!!! FAIL: root", f: func(b *B) { b.Fail() }, }, { desc: "skipping without message, chatty", chatty: true, - output: "--- SKIP: root", + output: "??? SKIP: root", f: func(b *B) { b.SkipNow() }, }, { desc: "chatty with recursion", @@ -612,7 +612,7 @@ func TestBRun(t *T) { desc: "skipping after error", failed: true, output: ` ---- FAIL: root +!!! FAIL: root sub_test.go:NNN: an error sub_test.go:NNN: skipped`, f: func(b *B) { diff --git a/src/testing/testing.go b/src/testing/testing.go index 5c06aea5f8..3db0ed282a 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1622,7 +1622,7 @@ func tRunner(t *T, fn func(t *T)) { root.duration += time.Since(root.start) d := root.duration root.mu.Unlock() - root.flushToParent(root.name, "--- FAIL: %s (%s)\n", root.name, fmtDuration(d)) + root.flushToParent(root.name, "!!! FAIL: %s (%s)\n", root.name, fmtDuration(d)) if r := root.parent.runCleanup(recoverAndReturnPanic); r != nil { fmt.Fprintf(root.parent.w, "cleanup panicked with %v", r) } @@ -2036,7 +2036,7 @@ func (m *M) Run() (code int) { // in which case every test will run nothing and succeed, // with no obvious way to detect this problem (since no tests are running). // So make 'no tests to run' a hard failure when testing package testing itself. - fmt.Print(chatty.prefix(), "FAIL: package testing must run tests\n") + fmt.Print(chatty.prefix(), "!!! FAIL: package testing must run tests\n") testOk = false } } @@ -2046,7 +2046,7 @@ func (m *M) Run() (code int) { anyFailed = true } if anyFailed { - fmt.Print(chatty.prefix(), "FAIL\n") + fmt.Print(chatty.prefix(), "!!! FAIL\n") m.exitCode = 1 return } @@ -2054,7 +2054,7 @@ func (m *M) Run() (code int) { fuzzingOk := runFuzzing(m.deps, m.fuzzTargets) if !fuzzingOk { - fmt.Print(chatty.prefix(), "FAIL\n") + fmt.Print(chatty.prefix(), "!!! FAIL\n") if *isFuzzWorker { m.exitCode = fuzzWorkerExitCode } else { @@ -2075,14 +2075,14 @@ func (t *T) report() { return } dstr := fmtDuration(t.duration) - format := "--- %s: %s (%s)\n" + format := "%s: %s (%s)\n" if t.Failed() { - t.flushToParent(t.name, format, "FAIL", t.name, dstr) + t.flushToParent(t.name, format, "!!! FAIL", t.name, dstr) } else if t.chatty != nil { if t.Skipped() { - t.flushToParent(t.name, format, "SKIP", t.name, dstr) + t.flushToParent(t.name, format, "??? SKIP", t.name, dstr) } else { - t.flushToParent(t.name, format, "PASS", t.name, dstr) + t.flushToParent(t.name, format, "--- PASS", t.name, dstr) } } } |
