github.com/amane3/goreleaser@v0.182.0/internal/builders/golang/targets_test.go (about) 1 package golang 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/amane3/goreleaser/pkg/config" 8 "github.com/stretchr/testify/require" 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 "js", 19 }, 20 Goarch: []string{ 21 "386", 22 "amd64", 23 "arm", 24 "arm64", 25 "wasm", 26 "mips", 27 "mips64", 28 "mipsle", 29 "mips64le", 30 }, 31 Goarm: []string{ 32 "6", 33 "7", 34 }, 35 Gomips: []string{ 36 "hardfloat", 37 "softfloat", 38 }, 39 Ignore: []config.IgnoredBuild{ 40 { 41 Goos: "linux", 42 Goarch: "arm", 43 Goarm: "7", 44 }, { 45 Goos: "openbsd", 46 Goarch: "arm", 47 }, { 48 Goarch: "mips64", 49 Gomips: "hardfloat", 50 }, { 51 Goarch: "mips64le", 52 Gomips: "softfloat", 53 }, 54 }, 55 } 56 result, err := matrix(build) 57 require.NoError(t, err) 58 require.Equal(t, []string{ 59 "linux_386", 60 "linux_amd64", 61 "linux_arm_6", 62 "linux_arm64", 63 "linux_mips_hardfloat", 64 "linux_mips_softfloat", 65 "linux_mips64_softfloat", 66 "linux_mipsle_hardfloat", 67 "linux_mipsle_softfloat", 68 "linux_mips64le_hardfloat", 69 "darwin_amd64", 70 "freebsd_386", 71 "freebsd_amd64", 72 "freebsd_arm_6", 73 "freebsd_arm_7", 74 "freebsd_arm64", 75 "openbsd_386", 76 "openbsd_amd64", 77 "openbsd_arm64", 78 "js_wasm", 79 }, result) 80 } 81 82 func TestGoosGoarchCombos(t *testing.T) { 83 var platforms = []struct { 84 os string 85 arch string 86 valid bool 87 }{ 88 // valid targets: 89 {"aix", "ppc64", true}, 90 {"android", "386", true}, 91 {"android", "amd64", true}, 92 {"android", "arm", true}, 93 {"android", "arm64", true}, 94 {"darwin", "amd64", true}, 95 {"dragonfly", "amd64", true}, 96 {"freebsd", "386", true}, 97 {"freebsd", "amd64", true}, 98 {"freebsd", "arm", true}, 99 {"illumos", "amd64", true}, 100 {"linux", "386", true}, 101 {"linux", "amd64", true}, 102 {"linux", "arm", true}, 103 {"linux", "arm64", true}, 104 {"linux", "mips", true}, 105 {"linux", "mipsle", true}, 106 {"linux", "mips64", true}, 107 {"linux", "mips64le", true}, 108 {"linux", "ppc64", true}, 109 {"linux", "ppc64le", true}, 110 {"linux", "s390x", true}, 111 {"netbsd", "386", true}, 112 {"netbsd", "amd64", true}, 113 {"netbsd", "arm", true}, 114 {"openbsd", "386", true}, 115 {"openbsd", "amd64", true}, 116 {"openbsd", "arm", true}, 117 {"plan9", "386", true}, 118 {"plan9", "amd64", true}, 119 {"plan9", "arm", true}, 120 {"solaris", "amd64", true}, 121 {"windows", "386", true}, 122 {"windows", "amd64", true}, 123 {"js", "wasm", true}, 124 // invalid targets 125 {"darwin", "386", false}, 126 {"darwin", "arm", false}, 127 {"darwin", "arm64", false}, 128 {"windows", "arm", false}, 129 {"windows", "arm64", false}, 130 } 131 for _, p := range platforms { 132 t.Run(fmt.Sprintf("%v %v valid=%v", p.os, p.arch, p.valid), func(t *testing.T) { 133 require.Equal(t, p.valid, valid(target{p.os, p.arch, "", ""})) 134 }) 135 } 136 }