summaryrefslogtreecommitdiffstats
path: root/tpl/internal/go_templates/testenv/exec.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/internal/go_templates/testenv/exec.go')
-rw-r--r--tpl/internal/go_templates/testenv/exec.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/tpl/internal/go_templates/testenv/exec.go b/tpl/internal/go_templates/testenv/exec.go
index 144602248..7f6ad5cac 100644
--- a/tpl/internal/go_templates/testenv/exec.go
+++ b/tpl/internal/go_templates/testenv/exec.go
@@ -6,6 +6,7 @@ package testenv
import (
"context"
+ "errors"
"fmt"
"os"
"os/exec"
@@ -60,6 +61,13 @@ func tryExec() error {
// may as well use the same path so that this branch can be tested without
// an ios environment.
+ if !testing.Testing() {
+ // This isn't a standard 'go test' binary, so we don't know how to
+ // self-exec in a way that should succeed without side effects.
+ // Just forget it.
+ return errors.New("can't probe for exec support with a non-test executable")
+ }
+
// We know that this is a test executable. We should be able to run it with a
// no-op flag to check for overall exec support.
exe, err := os.Executable()