-
Notifications
You must be signed in to change notification settings - Fork 832
Expand file tree
/
Copy pathdogfood_test_contract_test.go
More file actions
85 lines (77 loc) · 2.68 KB
/
Copy pathdogfood_test_contract_test.go
File metadata and controls
85 lines (77 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/kunchenguid/no-mistakes/internal/config"
)
// Local Test is targeted validation of the requested intent. This repository
// must not dogfood a complete-suite commands.test override (historically
// go test -race ./...), which burned multi-hour local walks while remote CI
// already owns the race-enabled full suite.
func TestDogfoodConfig_NoBroadLocalTestCommand(t *testing.T) {
t.Parallel()
root, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
cfg, err := config.LoadRepo(root)
if err != nil {
t.Fatalf("LoadRepo: %v", err)
}
if got := strings.TrimSpace(cfg.Commands.Test); got != "" {
t.Fatalf("dogfood commands.test = %q, want empty so local Test stays agent-targeted; put broad regression in remote CI", got)
}
raw, err := os.ReadFile(filepath.Join(root, ".no-mistakes.yaml"))
if err != nil {
t.Fatalf("read .no-mistakes.yaml: %v", err)
}
content := string(raw)
for _, forbid := range []string{
`test: "go test -race ./..."`,
`test: 'go test -race ./...'`,
`test: go test -race ./...`,
} {
if strings.Contains(content, forbid) {
t.Fatalf(".no-mistakes.yaml still configures broad local Test %q", forbid)
}
}
}
// commands.test contract ownership lives in repo-config.md: targeted local
// validation, not CI-parity complete-suite configuration, and no brittle
// shell-heuristics claiming to detect "broad" commands.
func TestRepoConfigDocs_CommandsTestIsTargetedContract(t *testing.T) {
t.Parallel()
data, err := os.ReadFile(filepath.Join("docs", "src", "content", "docs", "reference", "repo-config.md"))
if err != nil {
t.Fatalf("read repo-config.md: %v", err)
}
content := string(data)
for _, want := range []string{
"### commands.test",
"targeted validation",
"not a CI-parity repository-wide regression command",
"Broad regression belongs in remote CI",
"does not guess whether an arbitrary shell string is \"too broad\"",
} {
if !strings.Contains(content, want) {
t.Errorf("repo-config.md commands.test contract missing %q", want)
}
}
}
// Remote CI must keep the complete race-enabled Go suite as the broad
// regression owner after local Test stops duplicating it.
func TestCIWorkflow_RetainsFullRaceSuiteAsBroadRegressionOwner(t *testing.T) {
data, err := os.ReadFile(filepath.Join(".github", "workflows", "ci.yml"))
if err != nil {
t.Fatalf("read ci.yml: %v", err)
}
content := string(data)
if !strings.Contains(content, "run: go test -race ./...") {
t.Fatal("CI workflow must still run go test -race ./... as the broad regression owner")
}
if !strings.Contains(content, "if: runner.os != 'Windows'") {
t.Fatal("CI workflow must keep the Unix race-test branch")
}
}