From 32312eb75afe65dbe95c9668e5792d36ff529131 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Sat, 27 Mar 2021 18:54:49 +0000 Subject: [PATCH] Don't panic on "go test" invocations from the command line. Test: cd build/soong; go test ./android Bug: 183650682 Change-Id: I2d1bbda21cb262eafc7f7d329206720809399985 --- android/paths.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/android/paths.go b/android/paths.go index 127896104..b4573728a 100644 --- a/android/paths.go +++ b/android/paths.go @@ -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 {