mirror of
https://github.com/golang/go
synced 2024-11-17 01:44:52 -07:00
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 <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
2ad3c3337f
commit
3b9d20c521
@ -9,6 +9,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
"go/types"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -30,9 +31,18 @@ func TestStdlib(t *testing.T) {
|
|||||||
t.Skip("skipping test on 32-bit machine")
|
t.Skip("skipping test on 32-bit machine")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load, parse and type-check the standard library and x/tools.
|
// Load, parse and type-check the standard library.
|
||||||
|
// If we have the full source code for x/tools, also load and type-check that.
|
||||||
cfg := &packages.Config{Mode: packages.LoadAllSyntax}
|
cfg := &packages.Config{Mode: packages.LoadAllSyntax}
|
||||||
pkgs, err := packages.Load(cfg, "std", "golang.org/x/tools/...")
|
patterns := []string{"std"}
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "android", "ios":
|
||||||
|
// The go_.*_exec script for mobile builders only copies over the source tree
|
||||||
|
// for the package under test.
|
||||||
|
default:
|
||||||
|
patterns = append(patterns, "golang.org/x/tools/...")
|
||||||
|
}
|
||||||
|
pkgs, err := packages.Load(cfg, patterns...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to load/parse/type-check: %v", err)
|
t.Fatalf("failed to load/parse/type-check: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user