Austin Clements would like Robert Griesemer, David Chase and Junyang Shao to review this change.
go/types: exclude all packages under simd/archsimd/_gen
Right now we manually exclude every package under simd/archsimd/_gen
from TestStdlib. We're about to add another package and it took me far
too long to realize it needed to be excluded as well. To future-proof
this, add support for excluding x/... patterns and use this for
simd/archsimd/_gen.
diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go
index 94d31ba..9f0a5ff 100644
--- a/src/cmd/compile/internal/types2/stdlib_test.go
+++ b/src/cmd/compile/internal/types2/stdlib_test.go
@@ -352,19 +352,28 @@
}
// Package paths of excluded packages.
-var excluded = map[string]bool{
- "builtin": true,
- "cmd/compile/internal/ssa/_gen": true,
- "crypto/internal/cryptotest/wycheproof/_schema": true,
- "crypto/internal/cryptotest/x509limbo/_schema": true,
- "runtime/_mkmalloc": true,
- "simd/archsimd/_gen/midway": true,
- "simd/archsimd/_gen/sgutil": true,
- "simd/archsimd/_gen/simdgen": true,
- "simd/archsimd/_gen/simdgen/arm64": true,
- "simd/archsimd/_gen/tmplgen": true,
- "simd/archsimd/_gen/unify": true,
- "simd/archsimd/_gen/wasmgen": true,
+var excluded = slices.SortedFunc(slices.Values([]string{
+ "builtin",
+ "cmd/compile/internal/ssa/_gen/...",
+ "crypto/internal/cryptotest/wycheproof/_schema",
+ "crypto/internal/cryptotest/x509limbo/_schema",
+ "runtime/_mkmalloc",
+ "simd/archsimd/_gen/...",
+}), func(a, b string) int {
+ pA, _ := strings.CutSuffix(a, "/...")
+ pB, _ := strings.CutSuffix(b, "/...")
+ return strings.Compare(pA, pB)
+})
+
+func isExcluded(path string) bool {
+ _, found := slices.BinarySearchFunc(excluded, path, func(pattern, target string) int {
+ prefix, isWild := strings.CutSuffix(pattern, "/...")
+ if isWild && (target == prefix || strings.HasPrefix(target, prefix+"/")) {
+ return 0
+ }
+ return strings.Compare(prefix, target)
+ })
+ return found
}
// printPackageMu synchronizes the printing of type-checked package files in
@@ -443,7 +452,7 @@
}
return nil, err
}
- if excluded[pkg.ImportPath] {
+ if isExcluded(pkg.ImportPath) {
return nil, nil
}
if slices.Contains(strings.Split(pkg.ImportPath, "/"), "_asm") {
diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go
index d4ff0af..27b1e7a 100644
--- a/src/go/types/stdlib_test.go
+++ b/src/go/types/stdlib_test.go
@@ -354,19 +354,28 @@
}
// Package paths of excluded packages.
-var excluded = map[string]bool{
- "builtin": true,
- "cmd/compile/internal/ssa/_gen": true,
- "crypto/internal/cryptotest/wycheproof/_schema": true,
- "crypto/internal/cryptotest/x509limbo/_schema": true,
- "runtime/_mkmalloc": true,
- "simd/archsimd/_gen/midway": true,
- "simd/archsimd/_gen/sgutil": true,
- "simd/archsimd/_gen/simdgen": true,
- "simd/archsimd/_gen/simdgen/arm64": true,
- "simd/archsimd/_gen/tmplgen": true,
- "simd/archsimd/_gen/unify": true,
- "simd/archsimd/_gen/wasmgen": true,
+var excluded = slices.SortedFunc(slices.Values([]string{
+ "builtin",
+ "cmd/compile/internal/ssa/_gen/...",
+ "crypto/internal/cryptotest/wycheproof/_schema",
+ "crypto/internal/cryptotest/x509limbo/_schema",
+ "runtime/_mkmalloc",
+ "simd/archsimd/_gen/...",
+}), func(a, b string) int {
+ pA, _ := strings.CutSuffix(a, "/...")
+ pB, _ := strings.CutSuffix(b, "/...")
+ return strings.Compare(pA, pB)
+})
+
+func isExcluded(path string) bool {
+ _, found := slices.BinarySearchFunc(excluded, path, func(pattern, target string) int {
+ prefix, isWild := strings.CutSuffix(pattern, "/...")
+ if isWild && (target == prefix || strings.HasPrefix(target, prefix+"/")) {
+ return 0
+ }
+ return strings.Compare(prefix, target)
+ })
+ return found
}
// printPackageMu synchronizes the printing of type-checked package files in
@@ -445,7 +454,7 @@
}
return nil, err
}
- if excluded[pkg.ImportPath] {
+ if isExcluded(pkg.ImportPath) {
return nil, nil
}
if slices.Contains(strings.Split(pkg.ImportPath, "/"), "_asm") {
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |