diff --git a/modules/mesh-build-go/cmd/mesh-build-go/levels.go b/modules/mesh-build-go/cmd/mesh-build-go/levels.go index ea5bc596..eeab6dd0 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/levels.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/levels.go @@ -41,6 +41,8 @@ type PackageResult struct { Tests int `json:"tests"` // NoTests is a package with no test files (at this level: a file with the other level's build tag is none). NoTests bool `json:"no_tests,omitempty"` + // Skipped is how many of the package's tests skipped: a pass that skipped proved less than it says, so the checker keeps no verdict for it. + Skipped int `json:"skipped,omitempty"` } // TestTime is one test and the time it took. @@ -227,6 +229,7 @@ func (r *reader) event(ev event) { r.res.Tests++ if ev.Action == "skip" { r.res.Skipped++ + p.Skipped++ } r.times = append(r.times, TestTime{Package: ev.Package, Test: ev.Test, Elapsed: ev.Elapsed}) if ev.Action == "fail" { diff --git a/modules/mesh-build-go/cmd/mesh-build-go/package_cause_test.go b/modules/mesh-build-go/cmd/mesh-build-go/package_cause_test.go index cf002bbe..1770e335 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/package_cause_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/package_cause_test.go @@ -101,3 +101,25 @@ func TestALoggedPanicIsNotTheCause(t *testing.T) { // 1901/AC4 t.Errorf("1901/AC4: failures = %+v, want the timeout's panic as the cause", res.Failed) } } + +// A package counts its own skipped tests, so the checker withholds a kept verdict from that package alone (issue 890). +func TestEachPackageCountsItsOwnSkippedTests(t *testing.T) { + log := `{"Action":"run","Package":"m/a","Test":"TestA"} +{"Action":"skip","Package":"m/a","Test":"TestA","Elapsed":0} +{"Action":"run","Package":"m/b","Test":"TestB"} +{"Action":"pass","Package":"m/b","Test":"TestB","Elapsed":0} +{"Action":"pass","Package":"m/a","Elapsed":0} +{"Action":"pass","Package":"m/b","Elapsed":0} +` + res := &TestResult{} + rd := newReader(res, ".") + rd.read(log) + rd.finish() + got := map[string]int{} + for _, p := range res.Packages { + got[p.Package] = p.Skipped + } + if res.Skipped != 1 || got["m/a"] != 1 || got["m/b"] != 0 { + t.Errorf("skipped = %d, per package %v, want 1 with m/a 1 and m/b 0", res.Skipped, got) + } +}