diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2023-10-18 00:26:42 +0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-10-17 18:43:14 +0000 |
| commit | 860c2557ab7995e64e5cc0f045ff676f1fcec0a0 (patch) | |
| tree | b94a9b4090661d433d9177db2588d604ff16c6ee /src/cmd/internal | |
| parent | 408b31dcc5d888fe7599e703bb05f50d4a378d4f (diff) | |
| download | go-860c2557ab7995e64e5cc0f045ff676f1fcec0a0.tar.xz | |
cmd/internal/testdir: accept build go1.x build tag
While at it, also using "slices" package to simplify code.
For #63489
Change-Id: I72b325f6ad379b996c108145885fa71706f6659f
Reviewed-on: https://go-review.googlesource.com/c/go/+/536055
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/internal')
| -rw-r--r-- | src/cmd/internal/testdir/testdir_test.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/cmd/internal/testdir/testdir_test.go b/src/cmd/internal/testdir/testdir_test.go index 92c8f4c093..1b91dbe3ce 100644 --- a/src/cmd/internal/testdir/testdir_test.go +++ b/src/cmd/internal/testdir/testdir_test.go @@ -24,6 +24,7 @@ import ( "path/filepath" "regexp" "runtime" + "slices" "sort" "strconv" "strings" @@ -417,13 +418,12 @@ func (ctxt *context) match(name string) bool { } } + if slices.Contains(build.Default.ReleaseTags, name) { + return true + } + if strings.HasPrefix(name, "goexperiment.") { - for _, tag := range build.Default.ToolTags { - if tag == name { - return true - } - } - return false + return slices.Contains(build.Default.ToolTags, name) } if name == "cgo" && ctxt.cgoEnabled { @@ -1751,6 +1751,9 @@ func TestShouldTest(t *testing.T) { // Test that (!a OR !b) matches anything. assert(shouldTest("// +build !windows !plan9", "windows", "amd64")) + + // Test that //go:build tag match. + assert(shouldTest("//go:build go1.4", "linux", "amd64")) } // overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added. |
