golang/go

misc/android: go_android_exec fails to copy other package sources in the main module when executing tests

Open

#37,088 opened on Feb 6, 2020

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsFixhelp wantedmobile

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

In order to ensure that a test binary can find any associated test data, go test runs the resulting test binary in its own source directory.

That implies that, if a go binary is present, the test can go build both files in its own directory and any associated packages in the same module.

Unfortunately, adbCopyTree function in go_android_exec.go does not ensure that the source code for the complete module is present. Instead, it copies only the go.mod and go.sum files and testdata directories going up the tree.

That implies that go_android_exec cannot successfully execute an external test that runs an associated main package as a subprocess if that main package imports any other package outside of the standard library, such as in CL 218277.

CC @hajimehoshi @hyangah @steeve @eliasnaur

Contributor guide