github.phpd.cn/goreleaser/goreleaser@v0.92.0/internal/builders/golang/targets_test.go (about) 1 package golang 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/goreleaser/goreleaser/pkg/config" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestAllBuildTargets(t *testing.T) { 12 var build = config.Build{ 13 Goos: []string{ 14 "linux", 15 "darwin", 16 "freebsd", 17 "openbsd", 18 }, 19 Goarch: []string{ 20 "386", 21 "amd64", 22 "arm", 23 "arm64", 24 }, 25 Goarm: []string{ 26 "6", 27 "7", 28 }, 29 Ignore: []config.IgnoredBuild{ 30 { 31 Goos: "darwin", 32 Goarch: "386", 33 }, { 34 Goos: "linux", 35 Goarch: "arm", 36 Goarm: "7", 37 }, { 38 Goos: "openbsd", 39 Goarch: "arm", 40 }, 41 }, 42 } 43 assert.Equal(t, []string{ 44 "linux_386", 45 "linux_amd64", 46 "linux_arm_6", 47 "linux_arm64", 48 "darwin_amd64", 49 "freebsd_386", 50 "freebsd_amd64", 51 "freebsd_arm_6", 52 "freebsd_arm_7", 53 "openbsd_386", 54 "openbsd_amd64", 55 }, matrix(build)) 56 } 57 58 func TestGoosGoarchCombos(t *testing.T) { 59 var platforms = []struct { 60 os string 61 arch string 62 valid bool 63 }{ 64 // valid targets: 65 {"android", "arm", true}, 66 {"darwin", "386", true}, 67 {"darwin", "amd64", true}, 68 {"dragonfly", "amd64", true}, 69 {"freebsd", "386", true}, 70 {"freebsd", "amd64", true}, 71 {"freebsd", "arm", true}, 72 {"linux", "386", true}, 73 {"linux", "amd64", true}, 74 {"linux", "arm", true}, 75 {"linux", "arm64", true}, 76 {"linux", "mips", true}, 77 {"linux", "mipsle", true}, 78 {"linux", "mips64", true}, 79 {"linux", "mips64le", true}, 80 {"linux", "ppc64", true}, 81 {"linux", "ppc64le", true}, 82 {"linux", "s390x", true}, 83 {"netbsd", "386", true}, 84 {"netbsd", "amd64", true}, 85 {"netbsd", "arm", true}, 86 {"openbsd", "386", true}, 87 {"openbsd", "amd64", true}, 88 {"openbsd", "arm", true}, 89 {"plan9", "386", true}, 90 {"plan9", "amd64", true}, 91 {"solaris", "amd64", true}, 92 {"windows", "386", true}, 93 {"windows", "amd64", true}, 94 // invalid targets 95 {"darwin", "arm", false}, 96 {"darwin", "arm64", false}, 97 {"windows", "arm", false}, 98 {"windows", "arm64", false}, 99 } 100 for _, p := range platforms { 101 t.Run(fmt.Sprintf("%v %v valid=%v", p.os, p.arch, p.valid), func(t *testing.T) { 102 assert.Equal(t, p.valid, valid(target{p.os, p.arch, ""})) 103 }) 104 } 105 }