diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-08-09 00:55:13 +0700 |
|---|---|---|
| committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-08-09 12:16:31 +0000 |
| commit | a292b3905c0976ed2ab7aae24fa96d506cb7b0a7 (patch) | |
| tree | f25f1cc3f1fd7e72505326e477de67618272c809 /src/internal/testenv | |
| parent | 98277f30e4365f3b35d856fa9cdee2fe01ab862b (diff) | |
| download | go-a292b3905c0976ed2ab7aae24fa96d506cb7b0a7.tar.xz | |
internal/testenv: add and use OptimizationOff/SkipIfOptimizationOff
So we don't have to duplicate the logic to detect noopt builder in
multiple places.
Based on khr@'s suggestion in CL 422037.
Change-Id: Idb338e8bc08cdf00460574bfc0d2f7018c79bbd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/422038
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/internal/testenv')
| -rw-r--r-- | src/internal/testenv/testenv.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 1feb630cf5..4f8c097573 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -408,6 +408,19 @@ func SkipIfShortAndSlow(t testing.TB) { } } +// SkipIfOptimizationOff skips t if optimization is disabled. +func SkipIfOptimizationOff(t testing.TB) { + if OptimizationOff() { + t.Helper() + t.Skip("skipping test with optimization disabled on builder") + } +} + +// OptimizationOff reports whether optimization is disabled. +func OptimizationOff() bool { + return strings.HasSuffix(Builder(), "-noopt") +} + // RunWithTimeout runs cmd and returns its combined output. If the // subprocess exits with a non-zero status, it will log that status // and return a non-nil error, but this is not considered fatal. |
