diff --git a/internal/junitxml/testdata/junitxml-report.golden b/internal/junitxml/testdata/junitxml-report.golden
index f51b75c6..de9a4f17 100644
--- a/internal/junitxml/testdata/junitxml-report.golden
+++ b/internal/junitxml/testdata/junitxml-report.golden
@@ -80,4 +80,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/testjson/dotformat_test.go b/testjson/dotformat_test.go
index a6b6964e..ac56f331 100644
--- a/testjson/dotformat_test.go
+++ b/testjson/dotformat_test.go
@@ -18,6 +18,8 @@ import (
)
func TestScanTestOutput_WithDotsFormatter(t *testing.T) {
+ skip.If(t, runtime.GOOS == "windows")
+
defer patchPkgPathPrefix("github.com/gotestyourself/gotestyourself")()
out := new(bytes.Buffer)
diff --git a/testjson/execution.go b/testjson/execution.go
index 24790246..ded622c7 100644
--- a/testjson/execution.go
+++ b/testjson/execution.go
@@ -32,6 +32,16 @@ const (
ActionSkip Action = "skip"
)
+// IsTerminal returns true if the Action is one of: pass, fail, skip.
+func (a Action) IsTerminal() bool {
+ switch a {
+ case ActionPass, ActionFail, ActionSkip:
+ return true
+ default:
+ return false
+ }
+}
+
// TestEvent is a structure output by go tool test2json and go test -json.
type TestEvent struct {
// Time encoded as an RFC3339-format string
@@ -392,6 +402,10 @@ func isCachedOutput(output string) bool {
return strings.Contains(output, "\t(cached)")
}
+func isWarningNoTestsToRunOutput(output string) bool {
+ return output == "testing: warning: no tests to run\n"
+}
+
// OutputLines returns the full test output for a test as an slice of lines.
// This function is a convenient wrapper around Package.OutputLines() to
// support the hiding of output in the summary.
diff --git a/testjson/format.go b/testjson/format.go
index c6006c75..29f6d421 100644
--- a/testjson/format.go
+++ b/testjson/format.go
@@ -31,10 +31,14 @@ func standardQuietFormat(event TestEvent, _ *Execution) (string, error) {
if !event.PackageEvent() {
return "", nil
}
- if event.Output != "PASS\n" && !isCoverageOutput(event.Output) {
- return event.Output, nil
+ if event.Output == "PASS\n" || isCoverageOutput(event.Output) {
+ return "", nil
}
- return "", nil
+ if isWarningNoTestsToRunOutput(event.Output) {
+ return "", nil
+ }
+
+ return event.Output, nil
}
func testNameFormat(event TestEvent, exec *Execution) (string, error) {
@@ -54,21 +58,23 @@ func testNameFormat(event TestEvent, exec *Execution) (string, error) {
return event.Output, nil
case event.PackageEvent():
- switch event.Action {
- case ActionSkip:
+ if !event.Action.IsTerminal() {
+ return "", nil
+ }
+ pkg := exec.Package(event.Package)
+ if event.Action == ActionSkip || (event.Action == ActionPass && pkg.Total == 0) {
result = colorEvent(event)("EMPTY")
- fallthrough
- case ActionPass, ActionFail:
- var cached string
- if exec.Package(event.Package).cached {
- cached = cachedMessage
- }
- return fmt.Sprintf("%s %s%s\n",
- result,
- RelativePackagePath(event.Package),
- cached), nil
}
+ var cached string
+ if pkg.cached {
+ cached = cachedMessage
+ }
+ return fmt.Sprintf("%s %s%s\n",
+ result,
+ RelativePackagePath(event.Package),
+ cached), nil
+
case event.Action == ActionFail:
pkg := exec.Package(event.Package)
tc := pkg.LastFailedByName(event.Test)
@@ -111,6 +117,7 @@ func isPkgFailureOutput(event TestEvent) bool {
event.Action == ActionOutput,
out != "PASS\n",
out != "FAIL\n",
+ !isWarningNoTestsToRunOutput(out),
!strings.HasPrefix(out, "FAIL\t"+event.Package),
!strings.HasPrefix(out, "ok \t"+event.Package),
!strings.HasPrefix(out, "? \t"+event.Package),
@@ -167,6 +174,9 @@ func shortFormatPackageEvent(event TestEvent, exec *Execution) (string, error) {
case ActionSkip:
return fmtEvent(withColor("∅"))
case ActionPass:
+ if pkg.Total == 0 {
+ return fmtEvent(withColor("∅"))
+ }
return fmtEvent(withColor("✓"))
case ActionFail:
return fmtEvent(withColor("✖"))
diff --git a/testjson/format_test.go b/testjson/format_test.go
index c0fcab1a..fb6bb435 100644
--- a/testjson/format_test.go
+++ b/testjson/format_test.go
@@ -112,6 +112,9 @@ var expectedExecution = &Execution{
action: ActionFail,
running: map[string]TestCase{},
},
+ "gotest.tools/gotestsum/internal/empty": {
+ action: ActionPass,
+ },
},
}
diff --git a/testjson/testdata/dots-format.out b/testjson/testdata/dots-format.out
index dbddb671..900260fc 100644
--- a/testjson/testdata/dots-format.out
+++ b/testjson/testdata/dots-format.out
@@ -702,3 +702,11 @@
20ms testjson/internal/stub ···↷↷✖·✖····✖··✖············
46 tests, 4 skipped, 5 failures, 1 error
+[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K
+
+ testjson/internal/badmain
+ 🖴 testjson/internal/good ···↷↷·············
+ 20ms testjson/internal/stub ···↷↷✖·✖····✖··✖············
+ gotest.tools/gotestsum/internal/empty
+
+ 46 tests, 4 skipped, 5 failures, 1 error
diff --git a/testjson/testdata/go-test-json.out b/testjson/testdata/go-test-json.out
index d4cd9c48..070f8490 100644
--- a/testjson/testdata/go-test-json.out
+++ b/testjson/testdata/go-test-json.out
@@ -229,3 +229,7 @@
{"Time":"2018-03-22T22:33:35.288005158Z","Action":"output","Package":"github.com/gotestyourself/gotestyourself/testjson/internal/stub","Output":"FAIL\n"}
{"Time":"2018-03-22T22:33:35.288154141Z","Action":"output","Package":"github.com/gotestyourself/gotestyourself/testjson/internal/stub","Output":"FAIL\tgithub.com/gotestyourself/gotestyourself/testjson/internal/stub\t0.011s\n"}
{"Time":"2018-03-22T22:33:35.288167612Z","Action":"fail","Package":"github.com/gotestyourself/gotestyourself/testjson/internal/stub","Elapsed":0.011}
+{"Time":"2021-03-28T13:58:17.979131051-04:00","Action":"output","Package":"gotest.tools/gotestsum/internal/empty","Output":"testing: warning: no tests to run\n"}
+{"Time":"2021-03-28T13:58:17.979525677-04:00","Action":"output","Package":"gotest.tools/gotestsum/internal/empty","Output":"PASS\n"}
+{"Time":"2021-03-28T13:58:17.979689639-04:00","Action":"output","Package":"gotest.tools/gotestsum/internal/empty","Output":"ok \tgotest.tools/gotestsum/internal/empty\t0.004s [no tests to run]\n"}
+{"Time":"2021-03-28T13:58:17.979759254-04:00","Action":"pass","Package":"gotest.tools/gotestsum/internal/empty","Elapsed":0.004}
diff --git a/testjson/testdata/go-test-verbose.out b/testjson/testdata/go-test-verbose.out
index be35afcf..fb334f88 100644
--- a/testjson/testdata/go-test-verbose.out
+++ b/testjson/testdata/go-test-verbose.out
@@ -122,3 +122,6 @@ this is stderr
--- PASS: TestParallelTheFirst (0.01s)
FAIL
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/stub 0.011s
+testing: warning: no tests to run
+PASS
+ok gotest.tools/gotestsum/internal/empty 0.004s [no tests to run]
diff --git a/testjson/testdata/short-format.out b/testjson/testdata/short-format.out
index 595951aa..dadb89f3 100644
--- a/testjson/testdata/short-format.out
+++ b/testjson/testdata/short-format.out
@@ -1,3 +1,4 @@
✖ testjson/internal/badmain (10ms)
✓ testjson/internal/good (cached)
✖ testjson/internal/stub (11ms)
+∅ gotest.tools/gotestsum/internal/empty (4ms)
diff --git a/testjson/testdata/short-verbose-format.out b/testjson/testdata/short-verbose-format.out
index 7f09a523..cb26114d 100644
--- a/testjson/testdata/short-verbose-format.out
+++ b/testjson/testdata/short-verbose-format.out
@@ -56,3 +56,4 @@ PASS testjson/internal/stub.TestParallelTheThird (0.00s)
PASS testjson/internal/stub.TestParallelTheSecond (0.01s)
PASS testjson/internal/stub.TestParallelTheFirst (0.01s)
FAIL testjson/internal/stub
+EMPTY gotest.tools/gotestsum/internal/empty
diff --git a/testjson/testdata/standard-quiet-format.out b/testjson/testdata/standard-quiet-format.out
index 88f5df40..a338b3f8 100644
--- a/testjson/testdata/standard-quiet-format.out
+++ b/testjson/testdata/standard-quiet-format.out
@@ -3,3 +3,4 @@ FAIL github.com/gotestyourself/gotestyourself/testjson/internal/badmain 0.010s
ok github.com/gotestyourself/gotestyourself/testjson/internal/good (cached)
FAIL
FAIL github.com/gotestyourself/gotestyourself/testjson/internal/stub 0.011s
+ok gotest.tools/gotestsum/internal/empty 0.004s [no tests to run]