]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/testdir: accept build go1.x build tag
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 17 Oct 2023 17:26:42 +0000 (00:26 +0700)
committerGopher Robot <gobot@golang.org>
Tue, 17 Oct 2023 18:43:14 +0000 (18:43 +0000)
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>

src/cmd/internal/testdir/testdir_test.go

index 92c8f4c093cf11fa69fc68ea6422b8349986a28e..1b91dbe3ce222d3ce105b82d8bb8bbceb22a25a9 100644 (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.