summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/gotoolchain_loop.txt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:25:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:25:22 +0000
commitf6ad4dcef54c5ce997a4bad5a6d86de229015700 (patch)
tree7cfa4e31ace5c2bd95c72b154d15af494b2bcbef /src/cmd/go/testdata/script/gotoolchain_loop.txt
parentInitial commit. (diff)
downloadgolang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.tar.xz
golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.zip
Adding upstream version 1.22.1.upstream/1.22.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/go/testdata/script/gotoolchain_loop.txt')
-rw-r--r--src/cmd/go/testdata/script/gotoolchain_loop.txt65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/gotoolchain_loop.txt b/src/cmd/go/testdata/script/gotoolchain_loop.txt
new file mode 100644
index 0000000..a803d2e
--- /dev/null
+++ b/src/cmd/go/testdata/script/gotoolchain_loop.txt
@@ -0,0 +1,65 @@
+env GOTOOLCHAIN=auto
+env TESTGO_VERSION=go1.21.1
+
+# Basic switch should work.
+env TESTGO_VERSION_SWITCH=switch
+go version
+stdout go1.21.99
+
+# Toolchain target mismatch should be detected.
+env TESTGO_VERSION_SWITCH=mismatch
+! go version
+stderr '^go: toolchain go1.21.1 invoked to provide go1.21.99$'
+
+# Toolchain loop should be detected.
+env TESTGO_VERSION_SWITCH=loop
+! go version
+stderr -count=10 '^go: switching from go1.21.1 to go1.21.99 \[depth 9[0-9]\]$'
+stderr -count=1 '^go: switching from go1.21.1 to go1.21.99 \[depth 100\]$'
+stderr '^go: too many toolchain switches$'
+
+[short] skip
+
+# Internal env vars should not leak to go test or go run.
+env TESTGO_VERSION_SWITCH=switch
+go version
+stdout go1.21.99
+go test
+stdout clean
+go run .
+stdout clean
+
+-- go.mod --
+module m
+go 1.21.99
+
+-- m_test.go --
+package main
+
+import "testing"
+
+func TestEnv(t *testing.T) {
+ // the check is in func init in m.go
+}
+
+-- m.go --
+package main
+
+import "os"
+
+func init() {
+ envs := []string{
+ "GOTOOLCHAIN_INTERNAL_SWITCH_COUNT",
+ "GOTOOLCHAIN_INTERNAL_SWITCH_VERSION",
+ }
+ for _, e := range envs {
+ if v := os.Getenv(e); v != "" {
+ panic("$"+e+"="+v)
+ }
+ }
+ os.Stdout.WriteString("clean\n")
+}
+
+func main() {
+}
+