aboutsummaryrefslogtreecommitdiff
path: root/misc/android
diff options
context:
space:
mode:
authorElias Naur <mail@eliasnaur.com>2019-03-15 18:13:38 +0100
committerElias Naur <mail@eliasnaur.com>2019-03-15 17:20:47 +0000
commit6e63b15567cb67059153bbcd787ed0d2f64dbcf3 (patch)
tree1911b470f5894db140716084d1eb36362e7150e6 /misc/android
parent653579138555ff2728ba16f841b640e06deab8df (diff)
downloadgo-6e63b15567cb67059153bbcd787ed0d2f64dbcf3.tar.gz
go-6e63b15567cb67059153bbcd787ed0d2f64dbcf3.zip
misc/android: copy go.mod and go.sum files
Fixes TestFindStdlib in x/tools on android. Change-Id: I2da7c702164e23488c7f9574f636ac36f63ab421 Reviewed-on: https://go-review.googlesource.com/c/go/+/167799 Run-TryBot: Elias Naur <mail@eliasnaur.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'misc/android')
-rw-r--r--misc/android/go_android_exec.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/misc/android/go_android_exec.go b/misc/android/go_android_exec.go
index ee3f16ae3d..2be0b07502 100644
--- a/misc/android/go_android_exec.go
+++ b/misc/android/go_android_exec.go
@@ -116,7 +116,7 @@ func runMain() (int, error) {
if _, err := run("exec-out", "mkdir", "-p", deviceCwd); err != nil {
return 0, err
}
- if err := adbCopyTestdata(deviceCwd, subdir); err != nil {
+ if err := adbCopyTree(deviceCwd, subdir); err != nil {
return 0, err
}
@@ -217,21 +217,24 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
cwd, runtime.GOROOT(), build.Default.GOPATH)
}
-// adbCopyTestdata copies testdata directories from subdir to deviceCwd
-// on the device.
-// It is common for tests to reach out into testdata from parent
-// packages, so copy testdata directories all the way up to the root
-// of subdir.
-func adbCopyTestdata(deviceCwd, subdir string) error {
+// adbCopyTree copies testdata, go.mod, go.sum files from subdir
+// and from parent directories all the way up to the root of subdir.
+// go.mod and go.sum files are needed for the go tool modules queries,
+// and the testdata directories for tests. It is common for tests to
+// reach out into testdata from parent packages.
+func adbCopyTree(deviceCwd, subdir string) error {
dir := ""
for {
- testdata := filepath.Join(dir, "testdata")
- if _, err := os.Stat(testdata); err == nil {
+ for _, path := range []string{"testdata", "go.mod", "go.sum"} {
+ path := filepath.Join(dir, path)
+ if _, err := os.Stat(path); err != nil {
+ continue
+ }
devicePath := filepath.Join(deviceCwd, dir)
if _, err := run("exec-out", "mkdir", "-p", devicePath); err != nil {
return err
}
- if _, err := run("push", testdata, devicePath); err != nil {
+ if _, err := run("push", path, devicePath); err != nil {
return err
}
}