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. // Will panic if called from outside a test environment.
func ensureTestOnly() { func ensureTestOnly() {
// Normal soong test environment if PrefixInList(os.Args, "-test.") {
if InList("-test.short", os.Args) {
return return
} }
// IntelliJ test environment panic(fmt.Errorf("Not in test. Command line:\n %s", strings.Join(os.Args, "\n ")))
if InList("-test.v", os.Args) {
return
}
panic(fmt.Errorf("Not in test\n%s", strings.Join(os.Args, "\n")))
} }
func (p InstallPath) RelativeToTop() Path { func (p InstallPath) RelativeToTop() Path {