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