1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:01:19 -07:00

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>
This commit is contained in:
Cuong Manh Le 2023-10-18 00:26:42 +07:00 committed by Gopher Robot
parent 408b31dcc5
commit 860c2557ab

View File

@ -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.