Skip to content

Commit 78889ab

Browse files
adonovangopherbot
authored andcommitted
x/tools: make tests agnostic as to whether gotypesalias="" => 0 or 1
This is required temporarily as we flip the default. Updates golang/go#65294 Change-Id: I552e40475cc48b949e2307af347ca98a428c55ea Reviewed-on: https://go-review.googlesource.com/c/tools/+/578041 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent e81c307 commit 78889ab

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/testenv/exec.go

+20
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"reflect"
1313
"runtime"
1414
"strconv"
15+
"strings"
1516
"sync"
1617
"testing"
1718
"time"
@@ -190,3 +191,22 @@ func Command(t testing.TB, name string, args ...string) *exec.Cmd {
190191
t.Helper()
191192
return CommandContext(t, context.Background(), name, args...)
192193
}
194+
195+
// SkipMaterializedAliases skips the test if go/types would create
196+
// instances of types.Alias, which some tests do not yet handle
197+
// correctly.
198+
func SkipMaterializedAliases(t *testing.T, message string) {
199+
if hasMaterializedAliases(Go1Point()) {
200+
t.Skipf("%s", message)
201+
}
202+
}
203+
204+
func hasMaterializedAliases(minor int) bool {
205+
if minor >= 23 && !strings.Contains(os.Getenv("GODEBUG"), "gotypesalias=0") {
206+
return true // gotypesalias=1 became the default in go1.23
207+
}
208+
if minor == 22 && strings.Contains(os.Getenv("GODEBUG"), "gotypesalias=1") {
209+
return true // gotypesalias=0 was the default in go1.22
210+
}
211+
return false // types.Alias didn't exist in go1.21
212+
}

0 commit comments

Comments
 (0)