test: support GOOS/GOARCH pairs in the -target flag

This means it's possible to test just a particular OS/arch with a
command like this:

    go test -run=Build -target=linux/arm

I found it useful while working on MIPS support.
This commit is contained in:
Ayke van Laethem
2024-06-27 19:31:35 +02:00
committed by Ron Evans
parent 2d5a8d407b
commit f18c6e342f
+4
View File
@@ -297,6 +297,10 @@ func emuCheck(t *testing.T, options compileopts.Options) {
}
func optionsFromTarget(target string, sema chan struct{}) compileopts.Options {
separators := strings.Count(target, "/")
if (separators == 1 || separators == 2) && !strings.HasSuffix(target, ".json") {
return optionsFromOSARCH(target, sema)
}
return compileopts.Options{
// GOOS/GOARCH are only used if target == ""
GOOS: goenv.Get("GOOS"),