internal/codegen: fixes tests for new config Adding --- counter: tools/command:goimports title: goimports command invocations description: count the number of times goimports is invoked type: partition issue: https://github.com/golang/go/issues/75321 program: golang.org/x/tools/cmd/goimports module: golang.org/x/tools to config.txt caused the checking tests to fail on a local machine. This CL adds paddings for the new program, and avoids running the test in the local copy of the repo. (The test is protected by t.Short(). The change to config.txt is in a different CL.) Change-Id: I8c94009c04aa72db334027498ae265c2c056961c Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/701717 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/configgen/main.go b/internal/configgen/main.go index afc9258..31c868a 100644 --- a/internal/configgen/main.go +++ b/internal/configgen/main.go
@@ -70,6 +70,13 @@ patch: 1, pre: 0, }, + "golang.org/x/tools/cmd/goimports": { + releases: 2, + maj: 0, + majmin: 1, + patch: 2, + pre: 0, + }, } // regularPaddings maps from program name to padding used to reserve enough @@ -112,6 +119,14 @@ patch: 2, pre: 0, }, + "golang.org/x/tools/cmd/goimports": { + // same as gopls + releases: 6, + maj: 1, + majmin: 6, + patch: 3, + pre: 4, + }, } func main() { @@ -455,10 +470,18 @@ // any escaping of upper-cased letters, as is required by the proxy prototol // (https://go.dev/ref/mod#goproxy-protocol). func listProxyVersions(modulePath string) ([]string, error) { + // Avoid problematic interactions with the local workspace by running in a + // temp directory. + listDir, err := os.MkdirTemp("", "") + if err != nil { + return nil, err + } + defer os.RemoveAll(listDir) if vers, ok := versionsForTesting[modulePath]; ok { return vers, nil } cmd := exec.Command("go", "list", "-m", "--versions", modulePath) + cmd.Dir = listDir var stderr bytes.Buffer cmd.Stderr = &stderr out, err := cmd.Output()