diff --git a/interp/build.go b/interp/build.go index 1e641b776..85c1ac908 100644 --- a/interp/build.go +++ b/interp/build.go @@ -147,10 +147,22 @@ func skipFile(ctx *build.Context, p string, skipTest bool) bool { } a := strings.Split(p[i+1:], "_") last := len(a) - 1 - if last1 := last - 1; last1 >= 0 && a[last1] == ctx.GOOS && a[last] == ctx.GOARCH { - return false + if last-1 >= 0 { + switch x, y := a[last-1], a[last]; { + case x == ctx.GOOS: + if knownArch[y] { + return y != ctx.GOARCH + } + return false + case knownOs[x] && knownArch[y]: + return true + case knownArch[y] && y != ctx.GOARCH: + return true + default: + return false + } } - if s := a[last]; s != ctx.GOOS && s != ctx.GOARCH && knownOs[s] || knownArch[s] { + if x := a[last]; knownOs[x] && x != ctx.GOOS || knownArch[x] && x != ctx.GOARCH { return true } return false diff --git a/interp/build_test.go b/interp/build_test.go index 8c89d9ac9..5706cc996 100644 --- a/interp/build_test.go +++ b/interp/build_test.go @@ -51,7 +51,7 @@ func TestBuildTag(t *testing.T) { } } -func TestBuildFile(t *testing.T) { +func TestSkipFile(t *testing.T) { // Assume a specific OS, arch and go pattern no matter the real underlying system ctx := build.Context{ GOARCH: "amd64", @@ -65,10 +65,18 @@ func TestBuildFile(t *testing.T) { {"bar_linux.go", false}, {"bar_maix.go", false}, {"bar_mlinux.go", false}, + {"bar_aix_foo.go", false}, + {"bar_linux_foo.go", false}, + {"bar_foo_amd64.go", false}, + {"bar_foo_arm.go", true}, + {"bar_aix_s390x.go", true}, {"bar_aix_amd64.go", true}, {"bar_linux_arm.go", true}, + + {"bar_amd64.go", false}, + {"bar_arm.go", true}, } for _, test := range tests {