mesh-build-go: the real-go integration tests expect the tests to run after a failed gofmt or vet (ADR 0591)
The group's check named TestUnitLevelRunsTheRealGoOnTheFixtureRepositories and TestAnUnformattedFileFailsTheRealUnitLevel: both asserted the old stop after the lint. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -63,13 +63,15 @@ func TestUnitLevelRunsTheRealGoOnTheFixtureRepositories(t *testing.T) {
|
||||
needTools(t, "the unit level on fixtures", "go", "git", "bwrap")
|
||||
want := map[string]struct {
|
||||
passed, noTests bool
|
||||
failed string
|
||||
failed []string // the packages of the failures, in order
|
||||
}{
|
||||
"failing": {failed: "fixture/failing/bad"},
|
||||
"failing": {failed: []string{"fixture/failing/bad"}},
|
||||
"tagged": {passed: true, noTests: true},
|
||||
"empty": {passed: true, noTests: true},
|
||||
"slow": {passed: true},
|
||||
"broken": {failed: "."}, // go vet, before the tests since R4g (ADR 0529 §1), names the directory and the compiler's line
|
||||
// go vet, before the tests since R4g (ADR 0529 §1), names the directory and the compiler's line; the tests still
|
||||
// run after it (ADR 0591), and the package that does not build is their failure.
|
||||
"broken": {failed: []string{".", "fixture/broken"}},
|
||||
}
|
||||
for name, w := range want {
|
||||
home := t.TempDir()
|
||||
@@ -87,14 +89,18 @@ func TestUnitLevelRunsTheRealGoOnTheFixtureRepositories(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
if res.Passed != w.passed || res.NoTests != w.noTests || (w.failed != "" && (len(res.Failed) != 1 || res.Failed[0].Package != w.failed)) {
|
||||
t.Errorf("%s: result = %+v", name, res)
|
||||
var failed []string
|
||||
for _, f := range res.Failed {
|
||||
failed = append(failed, f.Package)
|
||||
}
|
||||
if res.Passed != w.passed || res.NoTests != w.noTests || strings.Join(failed, " ") != strings.Join(w.failed, " ") {
|
||||
t.Errorf("%s: result = %+v, want the failures of %v", name, res, w.failed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1887/D7-go against the real go: a tree holding an unformatted file fails the unit level naming the file, before any
|
||||
// test runs, and the level's result carries the lint's time.
|
||||
// 1887/D7-go against the real go: a tree holding an unformatted file fails the unit level naming the file first, its
|
||||
// tests still run after it (ADR 0591: one check names every failure), and the level's result carries the lint's time.
|
||||
func TestAnUnformattedFileFailsTheRealUnitLevel(t *testing.T) {
|
||||
needTools(t, "the unit level's gofmt and vet", "go", "git", "bwrap")
|
||||
home := t.TempDir()
|
||||
@@ -114,8 +120,8 @@ func TestAnUnformattedFileFailsTheRealUnitLevel(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Passed || len(res.Failed) == 0 || res.Failed[0].Test != "gofmt" || !strings.Contains(res.Failed[0].Output, "ugly.go") || res.Tests != 0 {
|
||||
t.Fatalf("result = %+v, want the level failed by gofmt naming ugly.go and no test run", res)
|
||||
if res.Passed || len(res.Failed) == 0 || res.Failed[0].Test != "gofmt" || !strings.Contains(res.Failed[0].Output, "ugly.go") || res.Tests != 2 || res.Lint <= 0 {
|
||||
t.Fatalf("result = %+v, want the level failed by gofmt naming ugly.go, then the fixture's two tests run", res)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user