Skip to content

Commit d2ae515

Browse files
committed
Whatever the reported TEST_TIMEOUT is, timeout 3 seconds before (#17)
1 parent 11451de commit d2ae515

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

go/tools/bzltestutil/wrap.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ func Wrap(pkg string) error {
131131
// and will be killed by Bazel after the grace period instead.
132132
signal.Ignore(syscall.SIGTERM)
133133

134+
secsString, ok := os.LookupEnv("TEST_TIMEOUT")
135+
if ok {
136+
timeoutSecs, err := strconv.Atoi(secsString)
137+
if err != nil {
138+
return fmt.Errorf("could not parse TEST_TIMEOUT string %s: got error %w", secsString, err)
139+
}
140+
mungedTimeoutSecs := timeoutSecs - 3
141+
if mungedTimeoutSecs <= 0 {
142+
mungedTimeoutSecs = timeoutSecs
143+
}
144+
args = append([]string{"-test.timeout", fmt.Sprintf("%ds", mungedTimeoutSecs)}, args...)
145+
}
134146
cmd := exec.Command(exePath, args...)
135147
cmd.Env = append(os.Environ(), "GO_TEST_WRAP=0")
136148
cmd.Stderr = io.MultiWriter(os.Stderr, streamMerger.ErrW)

0 commit comments

Comments
 (0)