Skip to content

Commit 3b9d20c

Browse files
author
Bryan C. Mills
committed
internal/gcimporter: in TestStdlib, only check x/tools packages if we expect to have their source
The go_android_exec and go_ios_exec wrappers (found in GOROOT/misc/android and GOROOT/misc/ios, respectively) only copy over the source code for the package under test, its parent directories, and the 'testdata' subdirectories of those parents. That does not necessarily include the transitive closure of packages imported by those packages. This may fix the failing tests on the android-amd64-emu builder on release-branch.go1.19. (I do not understand why the test is not already being skipped due to the call to testenv.NeedsGoPackages, but I do not intend to investigate further.) Change-Id: I6bd32fd7e7e9f56e85b2e03baae59da5d9ba0ed9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/451995 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Alan Donovan <[email protected]> gopls-CI: kokoro <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
1 parent 2ad3c33 commit 3b9d20c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

internal/gcimporter/stdlib_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"go/token"
1111
"go/types"
12+
"runtime"
1213
"testing"
1314
"unsafe"
1415

@@ -30,9 +31,18 @@ func TestStdlib(t *testing.T) {
3031
t.Skip("skipping test on 32-bit machine")
3132
}
3233

33-
// Load, parse and type-check the standard library and x/tools.
34+
// Load, parse and type-check the standard library.
35+
// If we have the full source code for x/tools, also load and type-check that.
3436
cfg := &packages.Config{Mode: packages.LoadAllSyntax}
35-
pkgs, err := packages.Load(cfg, "std", "golang.org/x/tools/...")
37+
patterns := []string{"std"}
38+
switch runtime.GOOS {
39+
case "android", "ios":
40+
// The go_.*_exec script for mobile builders only copies over the source tree
41+
// for the package under test.
42+
default:
43+
patterns = append(patterns, "golang.org/x/tools/...")
44+
}
45+
pkgs, err := packages.Load(cfg, patterns...)
3646
if err != nil {
3747
t.Fatalf("failed to load/parse/type-check: %v", err)
3848
}

0 commit comments

Comments
 (0)