github.com/marianogappa/goreleaser@v0.26.2-0.20170715090149-96acd0a9fc46/internal/buildtarget/targets_test.go (about) 1 package buildtarget 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/goreleaser/goreleaser/config" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestAllBuildTargets(t *testing.T) { 12 var assert = assert.New(t) 13 var build = config.Build{ 14 Goos: []string{ 15 "linux", 16 "darwin", 17 "freebsd", 18 "openbsd", 19 }, 20 Goarch: []string{ 21 "386", 22 "amd64", 23 "arm", 24 "arm64", 25 }, 26 Goarm: []string{ 27 "6", 28 "7", 29 }, 30 Ignore: []config.IgnoredBuild{ 31 { 32 Goos: "darwin", 33 Goarch: "386", 34 }, { 35 Goos: "linux", 36 Goarch: "arm", 37 Goarm: "7", 38 }, { 39 Goos: "openbsd", 40 Goarch: "arm", 41 }, 42 }, 43 } 44 assert.Equal([]Target{ 45 New("linux", "386", ""), 46 New("linux", "amd64", ""), 47 New("linux", "arm", "6"), 48 New("linux", "arm64", ""), 49 New("darwin", "amd64", ""), 50 New("freebsd", "386", ""), 51 New("freebsd", "amd64", ""), 52 New("freebsd", "arm", "6"), 53 New("freebsd", "arm", "7"), 54 New("openbsd", "386", ""), 55 New("openbsd", "amd64", ""), 56 }, All(build)) 57 } 58 59 func TestGoosGoarchCombos(t *testing.T) { 60 var platforms = []struct { 61 os string 62 arch string 63 valid bool 64 }{ 65 // valid targets: 66 {"android", "arm", true}, 67 {"darwin", "386", true}, 68 {"darwin", "amd64", true}, 69 {"dragonfly", "amd64", true}, 70 {"freebsd", "386", true}, 71 {"freebsd", "amd64", true}, 72 {"freebsd", "arm", true}, 73 {"linux", "386", true}, 74 {"linux", "amd64", true}, 75 {"linux", "arm", true}, 76 {"linux", "arm64", true}, 77 {"linux", "mips", true}, 78 {"linux", "mipsle", true}, 79 {"linux", "mips64", true}, 80 {"linux", "mips64le", true}, 81 {"linux", "ppc64", true}, 82 {"linux", "ppc64le", 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(New(p.os, p.arch, ""))) 103 }) 104 } 105 }