Skip to content

Commit 7d7fa50

Browse files
committed
apidiff: pull test go version into a const
The version of Go used to load the code under test was buried in a string, so it was hard to find. Make it a const at the top of the file. Change-Id: I7ad221759d7c84ccf3ded5ca1403898e5f343fad Reviewed-on: https://go-review.googlesource.com/c/exp/+/639737 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent dd03c70 commit 7d7fa50

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apidiff/apidiff_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import (
1717
"golang.org/x/tools/go/packages/packagestest"
1818
)
1919

20+
// The version to write into the go.mod file used to load the packages being tested.
21+
const testGoVersion = "1.22"
22+
2023
func TestModuleChanges(t *testing.T) {
2124
packagestest.TestAll(t, testModuleChanges)
2225
}
@@ -129,7 +132,8 @@ func splitIntoPackages(t *testing.T, file, dir string) (incompatibles, compatibl
129132
if err := os.MkdirAll(filepath.Join(dir, "src", "apidiff"), 0700); err != nil {
130133
t.Fatal(err)
131134
}
132-
if err := os.WriteFile(filepath.Join(dir, "src", "apidiff", "go.mod"), []byte("module apidiff\ngo 1.22\n"), 0600); err != nil {
135+
goMod := fmt.Sprintf("module apidiff\ngo %s\n", testGoVersion)
136+
if err := os.WriteFile(filepath.Join(dir, "src", "apidiff", "go.mod"), []byte(goMod), 0600); err != nil {
133137
t.Fatal(err)
134138
}
135139

0 commit comments

Comments
 (0)