Skip to content

Commit 18c1f57

Browse files
committed
Keep empty packages by default in testdox format
And only hide Fuzz test cases, always report the top level test function.
1 parent 61b66b7 commit 18c1f57

7 files changed

Lines changed: 19 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Commonly used formats (see `--help` for a full list):
4848
* `dots` - print a character for each test.
4949
* `pkgname` (default) - print a line for each package.
5050
* `testname` - print a line for each test and package.
51+
* `testdox` - print a sentence for each test using [gotestdox](https://github.com/bitfield/gotestdox).
5152
* `standard-quiet` - the standard `go test` format.
5253
* `standard-verbose` - the standard `go test -v` format.
5354

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ Formats:
139139
dots-v2 experimental dots format, one package per line
140140
pkgname print a line for each package
141141
pkgname-and-test-fails print a line for each package and failed test output
142-
testdox TestDox format (print a sentence for each test)
143142
testname print a line for each test and package
143+
testdox print a sentence for each test using gotestdox
144144
github-actions testname format with github actions log grouping
145145
standard-quiet standard go test format
146146
standard-verbose standard go test -v format

cmd/testdata/gotestsum-help-text

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Formats:
3535
dots-v2 experimental dots format, one package per line
3636
pkgname print a line for each package
3737
pkgname-and-test-fails print a line for each package and failed test output
38-
testdox TestDox format (print a sentence for each test)
3938
testname print a line for each test and package
39+
testdox print a sentence for each test using gotestdox
4040
github-actions testname format with github actions log grouping
4141
standard-quiet standard go test format
4242
standard-verbose standard go test -v format

testjson/format.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ func testDoxFormat(out io.Writer, opts FormatOptions) EventFormatter {
103103
if !event.Action.IsTerminal() {
104104
return nil
105105
}
106-
if len(results[event.Package]) == 0 {
107-
// No testdox for you
106+
if opts.HideEmptyPackages && len(results[event.Package]) == 0 {
108107
return nil
109108
}
110109
fmt.Fprintf(buf, "%s:\n", event.Package)
@@ -123,7 +122,7 @@ func testDoxFormat(out io.Writer, opts FormatOptions) EventFormatter {
123122
case event.Action.IsTerminal():
124123
// Fuzz test cases tend not to have interesting names,
125124
// so only report these if they're failures
126-
if strings.HasPrefix(event.Test, "Fuzz") && event.Action == ActionPass {
125+
if isFuzzCase(event) {
127126
return nil
128127
}
129128
results[event.Package] = append(results[event.Package], Result{
@@ -135,6 +134,12 @@ func testDoxFormat(out io.Writer, opts FormatOptions) EventFormatter {
135134
})
136135
}
137136

137+
func isFuzzCase(event TestEvent) bool {
138+
return strings.HasPrefix(event.Test, "Fuzz") &&
139+
event.Action == ActionPass &&
140+
TestName(event.Test).IsSubTest()
141+
}
142+
138143
func testNameFormat(out io.Writer) EventFormatter {
139144
buf := bufio.NewWriter(out)
140145
// nolint:errcheck

testjson/testdata/format/testdox-coverage.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
gotest.tools/gotestsum/testjson/internal/badmain:
2+
13
gotest.tools/gotestsum/testjson/internal/good:
24
✓ Nested success (0.00s)
35
✓ Nested success a (0.00s)

testjson/testdata/format/testdox-shuffle.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
gotest.tools/gotestsum/testjson/internal/badmain:
2+
13
gotest.tools/gotestsum/testjson/internal/good:
24
✓ Nested success (0.00s)
35
✓ Nested success a (0.00s)

testjson/testdata/format/testdox.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
gotest.tools/gotestsum/testjson/internal/badmain:
2+
3+
gotest.tools/gotestsum/testjson/internal/empty:
4+
15
gotest.tools/gotestsum/testjson/internal/good:
26
✓ Nested success (0.00s)
37
✓ Nested success a (0.00s)

0 commit comments

Comments
 (0)