Merge pull request 'mesh-build-go: count skipped tests per package, so the checker keeps no pass that skipped (issue 890)' (#492) from fix/checker-skips-not-kept into main
This commit was merged in pull request #492.
This commit is contained in:
@@ -41,6 +41,8 @@ type PackageResult struct {
|
|||||||
Tests int `json:"tests"`
|
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 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"`
|
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.
|
// TestTime is one test and the time it took.
|
||||||
@@ -227,6 +229,7 @@ func (r *reader) event(ev event) {
|
|||||||
r.res.Tests++
|
r.res.Tests++
|
||||||
if ev.Action == "skip" {
|
if ev.Action == "skip" {
|
||||||
r.res.Skipped++
|
r.res.Skipped++
|
||||||
|
p.Skipped++
|
||||||
}
|
}
|
||||||
r.times = append(r.times, TestTime{Package: ev.Package, Test: ev.Test, Elapsed: ev.Elapsed})
|
r.times = append(r.times, TestTime{Package: ev.Package, Test: ev.Test, Elapsed: ev.Elapsed})
|
||||||
if ev.Action == "fail" {
|
if ev.Action == "fail" {
|
||||||
|
|||||||
@@ -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)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user