github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/dist/supported_test.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package dist 6 7 import ( 8 "testing" 9 10 "github.com/go-asm/go/platform" 11 ) 12 13 // TestSupportedBuildModes tests that dist and the main tools agree on 14 // which build modes are supported for a given target. We do things 15 // this way because the dist tool needs to be buildable directly by 16 // the bootstrap compiler, and as such can't import internal packages. 17 func TestSupported(t *testing.T) { 18 defer func(a, o string) { 19 goarch = a 20 goos = o 21 }(goarch, goos) 22 23 var modes = []string{ 24 // we assume that "exe" and "archive" always work 25 "pie", 26 "c-archive", 27 "c-shared", 28 "shared", 29 "plugin", 30 } 31 32 for _, a := range okgoarch { 33 goarch = a 34 for _, o := range okgoos { 35 if _, ok := cgoEnabled[o+"/"+a]; !ok { 36 continue 37 } 38 goos = o 39 for _, mode := range modes { 40 var dt tester 41 dist := dt.supportedBuildmode(mode) 42 std := platform.BuildModeSupported("gc", mode, o, a) 43 if dist != std { 44 t.Errorf("discrepancy for %s-%s %s: dist says %t, standard library says %t", o, a, mode, dist, std) 45 } 46 } 47 } 48 } 49 }