Don't panic on "go test" invocations from the command line.

Test: cd build/soong; go test ./android
Bug: 183650682
Change-Id: I2d1bbda21cb262eafc7f7d329206720809399985
This commit is contained in:
Martin Stjernholm 2021-03-27 18:54:49 +00:00
parent 045ed0f684
commit 32312eb75a
1 changed files with 2 additions and 8 deletions

View File

@ -1642,16 +1642,10 @@ type InstallPath struct {
// Will panic if called from outside a test environment.
func ensureTestOnly() {
// Normal soong test environment
if InList("-test.short", os.Args) {
if PrefixInList(os.Args, "-test.") {
return
}
// IntelliJ test environment
if InList("-test.v", os.Args) {
return
}
panic(fmt.Errorf("Not in test\n%s", strings.Join(os.Args, "\n")))
panic(fmt.Errorf("Not in test. Command line:\n %s", strings.Join(os.Args, "\n ")))
}
func (p InstallPath) RelativeToTop() Path {