github.com/tomsquest/goreleaser@v0.34.3-0.20171008022654-7d6ef4d338b3/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 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, []Target{
    44  		New("linux", "386", ""),
    45  		New("linux", "amd64", ""),
    46  		New("linux", "arm", "6"),
    47  		New("linux", "arm64", ""),
    48  		New("darwin", "amd64", ""),
    49  		New("freebsd", "386", ""),
    50  		New("freebsd", "amd64", ""),
    51  		New("freebsd", "arm", "6"),
    52  		New("freebsd", "arm", "7"),
    53  		New("openbsd", "386", ""),
    54  		New("openbsd", "amd64", ""),
    55  	}, All(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(New(p.os, p.arch, "")))
   103  		})
   104  	}
   105  }