Skip to content

Commit

Permalink
Merge pull request mitchellh#96 from dave-tucker/update
Browse files Browse the repository at this point in the history
Update Platforms to Go 1.10
  • Loading branch information
mitchellh authored Feb 23, 2018
2 parents 5b2a53e + 8dbb5ca commit e05df8d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 32 deletions.
12 changes: 7 additions & 5 deletions go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ func TestGoVersion(t *testing.T) {
}

acceptable := []string{
"devel", "go1.0", "go1.1", "go1.2", "go1.3", "go1.4.2", "go1.5",
"go1.5.1", "go1.5.2", "go1.5.3", "go1.5.4", "go1.6", "go1.6.1",
"go1.6.2", "go1.6.3", "go1.6.4", "go1.7", "go1.7.1", "go1.7.2",
"go1.7.3", "go1.7.4", "go1.7.5", "go1.8", "go1.8.1", "go1.8.2",
"go1.8.3", "go1.8.4", "go1.8.5", "go1.9", "go1.9.1", "go1.9.2",
"devel", "go1.0", "go1.1", "go1.2", "go1.3",
"go1.4", "go1.4.1", "go1.4.2", "go1.4.3",
"go1.5", "go1.5.1", "go1.5.2", "go1.5.3", "go1.5.4",
"go1.6", "go1.6.1", "go1.6.2", "go1.6.3", "go1.6.4",
"go1.7", "go1.7.1", "go1.7.2", "go1.7.3", "go1.7.4", "go1.7.5", "go1.7.6",
"go1.8", "go1.8.1", "go1.8.2", "go1.8.3", "go1.8.4",
"go1.9", "go1.9.1", "go1.9.2",
}
found := false
for _, expected := range acceptable {
Expand Down
65 changes: 39 additions & 26 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,6 @@ func (p *Platform) String() string {
}

var (
OsList = []string{
"darwin",
"dragonfly",
"freebsd",
"linux",
"netbsd",
"openbsd",
"plan9",
"solaris",
"windows",
}

ArchList = []string{
"386",
"amd64",
"arm",
"arm64",
"ppc64",
"ppc64le",
}

Platforms_1_0 = []Platform{
{"darwin", "386", true},
{"darwin", "amd64", true},
Expand Down Expand Up @@ -90,14 +69,43 @@ var (
{"linux", "ppc64", false},
{"linux", "ppc64le", false},
}...)

Platforms_1_6 = append(Platforms_1_5, []Platform{
{"android", "386", false},
{"linux", "mips64", false},
{"linux", "mips64le", false},
}...)

Platforms_1_7 = append(Platforms_1_5, []Platform{
// While not fully supported s390x is generally useful
{"linux", "s390x", true},
{"plan9", "arm", false},
// Add the 1.6 Platforms, but reflect full support for mips64 and mips64le
{"android", "386", false},
{"linux", "mips64", true},
{"linux", "mips64le", true},
}...)

Platforms_1_8 = append(Platforms_1_7, []Platform{
{"linux", "mips", true},
{"linux", "mipsle", true},
}...)

// no new platforms in 1.9
Platforms_1_9 = Platforms_1_8

// no new platforms in 1.10
Platforms_1_10 = Platforms_1_9

PlatformsLatest = Platforms_1_10
)

// SupportedPlatforms returns the full list of supported platforms for
// the version of Go that is
func SupportedPlatforms(v string) []Platform {
// Use latest if we get an unexpected version string
if !strings.HasPrefix(v, "go") {
return Platforms_1_5
return PlatformsLatest
}
// go-version only cares about version numbers
v = v[2:]
Expand All @@ -106,8 +114,8 @@ func SupportedPlatforms(v string) []Platform {
if err != nil {
log.Printf("Unable to parse current go version: %s\n%s", v, err.Error())

// Default to 1.5
return Platforms_1_5
// Default to latest
return PlatformsLatest
}

var platforms = []struct {
Expand All @@ -118,7 +126,12 @@ func SupportedPlatforms(v string) []Platform {
{">= 1.1, < 1.3", Platforms_1_1},
{">= 1.3, < 1.4", Platforms_1_3},
{">= 1.4, < 1.5", Platforms_1_4},
{">= 1.5", Platforms_1_5},
{">= 1.5, < 1.6", Platforms_1_5},
{">= 1.6, < 1.7", Platforms_1_6},
{">= 1.7, < 1.8", Platforms_1_7},
{">= 1.8, < 1.9", Platforms_1_8},
{">= 1.9, < 1.10", Platforms_1_9},
{">=1.10, < 1.11", Platforms_1_10},
}

for _, p := range platforms {
Expand All @@ -132,5 +145,5 @@ func SupportedPlatforms(v string) []Platform {
}

// Assume latest
return Platforms_1_5
return Platforms_1_9
}
49 changes: 48 additions & 1 deletion platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,56 @@ func TestSupportedPlatforms(t *testing.T) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.5")
if !reflect.DeepEqual(ps, Platforms_1_5) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.6")
if !reflect.DeepEqual(ps, Platforms_1_6) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.7")
if !reflect.DeepEqual(ps, Platforms_1_7) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.8")
if !reflect.DeepEqual(ps, Platforms_1_8) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.9")
if !reflect.DeepEqual(ps, Platforms_1_9) {
t.Fatalf("bad: %#v", ps)
}

ps = SupportedPlatforms("go1.10")
if !reflect.DeepEqual(ps, Platforms_1_10) {
t.Fatalf("bad: %#v", ps)
}

// Unknown
ps = SupportedPlatforms("foo")
if !reflect.DeepEqual(ps, Platforms_1_5) {
if !reflect.DeepEqual(ps, PlatformsLatest) {
t.Fatalf("bad: %#v", ps)
}
}

func TestMIPS(t *testing.T) {
g16 := SupportedPlatforms("go1.6")
for _, p := range g16 {
if p.Arch == "mips64" && p.Default {
t.Fatal("mips64 should not be default for 1.6")
}
}

g17 := SupportedPlatforms("go1.7")
for _, p := range g17 {
if p.Arch == "mips64" && !p.Default {
t.Fatal("mips64 should be default for 1.7")
}
}

}

0 comments on commit e05df8d

Please sign in to comment.