Skip to content

Commit d0c7631

Browse files
committed
Remove non-local architecture-specific tests when testing
1 parent 346baa9 commit d0c7631

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

betteralign_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package betteralign_test
33
import (
44
"os"
55
"path/filepath"
6+
"runtime"
67
"strings"
78
"testing"
89

@@ -12,6 +13,41 @@ import (
1213
"gotest.tools/v3/golden"
1314
)
1415

16+
func removeotherArches(paths []string) []string {
17+
var filtered []string
18+
arches := map[string]struct{}{
19+
"386": {},
20+
"amd64": {},
21+
"arm": {},
22+
"arm64": {},
23+
"ppc64": {},
24+
"ppc64le": {},
25+
"riscv64": {},
26+
"s390x": {},
27+
"wasm": {},
28+
}
29+
30+
delete(arches, runtime.GOARCH)
31+
32+
var blacklist bool
33+
for _, path := range paths {
34+
blacklist = false
35+
36+
for arch := range arches {
37+
if strings.Contains(path, strings.Join([]string{"_", arch, ".go"}, "")) {
38+
blacklist = true
39+
break
40+
}
41+
}
42+
43+
if !blacklist {
44+
filtered = append(filtered, path)
45+
}
46+
}
47+
48+
return filtered
49+
}
50+
1551
func NewTestAnalyzer() *analysis.Analyzer {
1652
analyzer := &analysis.Analyzer{
1753
Name: betteralign.Analyzer.Name,
@@ -50,6 +86,8 @@ func TestApply(t *testing.T) {
5086
t.Fatal(err)
5187
}
5288

89+
paths = removeotherArches(paths)
90+
5391
for _, path := range paths {
5492
testBasename := filepath.Base(path)
5593
testTmpname := filepath.Join(tmpWorkDir, testBasename)

0 commit comments

Comments
 (0)