aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/api/api_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/api/api_test.go')
-rw-r--r--src/cmd/api/api_test.go59
1 files changed, 38 insertions, 21 deletions
diff --git a/src/cmd/api/api_test.go b/src/cmd/api/api_test.go
index 5f9aa6d297..142cbb4339 100644
--- a/src/cmd/api/api_test.go
+++ b/src/cmd/api/api_test.go
@@ -115,16 +115,23 @@ func TestGolden(t *testing.T) {
func TestCompareAPI(t *testing.T) {
tests := []struct {
- name string
- features, required, optional, exception []string
- ok bool // want
- out string // want
+ name string
+ features, required, exception []string
+ ok bool // want
+ out string // want
}{
{
+ name: "equal",
+ features: []string{"A", "B", "C"},
+ required: []string{"A", "B", "C"},
+ ok: true,
+ out: "",
+ },
+ {
name: "feature added",
features: []string{"A", "B", "C", "D", "E", "F"},
required: []string{"B", "D"},
- ok: true,
+ ok: false,
out: "+A\n+C\n+E\n+F\n",
},
{
@@ -135,41 +142,51 @@ func TestCompareAPI(t *testing.T) {
out: "-B\n",
},
{
- name: "feature added then removed",
- features: []string{"A", "C"},
- optional: []string{"B"},
- required: []string{"A", "C"},
- ok: true,
- out: "±B\n",
- },
- {
name: "exception removal",
- required: []string{"A", "B", "C"},
features: []string{"A", "C"},
+ required: []string{"A", "B", "C"},
exception: []string{"B"},
ok: true,
out: "",
},
+
+ // Test that a feature required on a subset of ports is implicitly satisfied
+ // by the same feature being implemented on all ports. That is, it shouldn't
+ // say "pkg syscall (darwin-amd64), type RawSockaddrInet6 struct" is missing.
+ // See https://go.dev/issue/4303.
{
- // https://golang.org/issue/4303
- name: "contexts reconverging",
+ name: "contexts reconverging after api/next/* update",
+ features: []string{
+ "A",
+ "pkg syscall, type RawSockaddrInet6 struct",
+ },
required: []string{
"A",
- "pkg syscall (darwin-amd64), type RawSockaddrInet6 struct",
+ "pkg syscall (darwin-amd64), type RawSockaddrInet6 struct", // api/go1.n.txt
+ "pkg syscall, type RawSockaddrInet6 struct", // api/next/n.txt
},
+ ok: true,
+ out: "",
+ },
+ {
+ name: "contexts reconverging before api/next/* update",
features: []string{
"A",
"pkg syscall, type RawSockaddrInet6 struct",
},
- ok: true,
+ required: []string{
+ "A",
+ "pkg syscall (darwin-amd64), type RawSockaddrInet6 struct",
+ },
+ ok: false,
out: "+pkg syscall, type RawSockaddrInet6 struct\n",
},
}
for _, tt := range tests {
buf := new(strings.Builder)
- gotok := compareAPI(buf, tt.features, tt.required, tt.optional, tt.exception, true)
- if gotok != tt.ok {
- t.Errorf("%s: ok = %v; want %v", tt.name, gotok, tt.ok)
+ gotOK := compareAPI(buf, tt.features, tt.required, tt.exception)
+ if gotOK != tt.ok {
+ t.Errorf("%s: ok = %v; want %v", tt.name, gotOK, tt.ok)
}
if got := buf.String(); got != tt.out {
t.Errorf("%s: output differs\nGOT:\n%s\nWANT:\n%s", tt.name, got, tt.out)