Skip to content

Commit b412da5

Browse files
mknyszekbradfitz
authored andcommitted
[release-branch.go1.22] internal/testenv: support the LUCI mobile builders in tests
This change updates the testenv tests to correctly match on future LUCI builder names for mobile builders. This isn't a problem today because those haven't been set up yet, but the builder names are structured and it's clear where the modifiers will appear. Might as well set them up now. For golang#65473. Fixes golang#65474. Change-Id: I244b88a62a90312c0f3ff2360527d58531070362 Reviewed-on: https://go-review.googlesource.com/c/go/+/558597 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit 5c7c24c) Reviewed-on: https://go-review.googlesource.com/c/go/+/560536
1 parent e906022 commit b412da5

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/internal/testenv/testenv_test.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestHasGoBuild(t *testing.T) {
7878
// we will presumably find out about it when those tests fail.)
7979
switch runtime.GOOS {
8080
case "ios":
81-
if strings.HasSuffix(b, "-corellium") {
81+
if isCorelliumBuilder(b) {
8282
// The corellium environment is self-hosting, so it should be able
8383
// to build even though real "ios" devices can't exec.
8484
} else {
@@ -89,7 +89,7 @@ func TestHasGoBuild(t *testing.T) {
8989
return
9090
}
9191
case "android":
92-
if strings.HasSuffix(b, "-emu") && platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, false) {
92+
if isEmulatedBuilder(b) && platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, false) {
9393
// As of 2023-05-02, the test environment on the emulated builders is
9494
// missing a C linker.
9595
t.Logf("HasGoBuild is false on %s", b)
@@ -153,7 +153,7 @@ func TestMustHaveExec(t *testing.T) {
153153
t.Errorf("expected MustHaveExec to skip on %v", runtime.GOOS)
154154
}
155155
case "ios":
156-
if b := testenv.Builder(); strings.HasSuffix(b, "-corellium") && !hasExec {
156+
if b := testenv.Builder(); isCorelliumBuilder(b) && !hasExec {
157157
// Most ios environments can't exec, but the corellium builder can.
158158
t.Errorf("expected MustHaveExec not to skip on %v", b)
159159
}
@@ -186,3 +186,23 @@ func TestCleanCmdEnvPWD(t *testing.T) {
186186
}
187187
t.Error("PWD not set in cmd.Env")
188188
}
189+
190+
func isCorelliumBuilder(builderName string) bool {
191+
// Support both the old infra's builder names and the LUCI builder names.
192+
// The former's names are ad-hoc so we could maintain this invariant on
193+
// the builder side. The latter's names are structured, and "corellium" will
194+
// appear as a "host" suffix after the GOOS and GOARCH, which always begin
195+
// with an underscore.
196+
return strings.HasSuffix(builderName, "-corellium") || strings.Contains(builderName, "_corellium")
197+
}
198+
199+
func isEmulatedBuilder(builderName string) bool {
200+
// Support both the old infra's builder names and the LUCI builder names.
201+
// The former's names are ad-hoc so we could maintain this invariant on
202+
// the builder side. The latter's names are structured, and the signifier
203+
// of emulation "emu" will appear as a "host" suffix after the GOOS and
204+
// GOARCH because it modifies the run environment in such a way that it
205+
// the target GOOS and GOARCH may not match the host. This suffix always
206+
// begins with an underscore.
207+
return strings.HasSuffix(builderName, "-emu") || strings.Contains(builderName, "_emu")
208+
}

0 commit comments

Comments
 (0)