Skip to content

Commit

Permalink
test: add tests for go output
Browse files Browse the repository at this point in the history
Signed-off-by: James Elliott <[email protected]>
  • Loading branch information
james-d-elliott committed Aug 13, 2023
1 parent 522aa6b commit 5d11e26
Show file tree
Hide file tree
Showing 5 changed files with 925 additions and 131 deletions.
32 changes: 17 additions & 15 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
goosWindows = "windows"
goosLinux = "linux"
goosDarwin = "darwin"
goosIOS = "ios"
goosFreeBSD = "freebsd"
goosNetBSD = "netbsd"
goosOpenBSD = "openbsd"
Expand All @@ -45,23 +46,24 @@ const (
goosJavaScript = "js"
goosAIX = "aix"
goosIllumos = "illumos"
goosWASIP1 = "wasip1"
)

// Go Architecture values for GOARCH.
const (
goarch386 = "386"
goarchAMD64 = "amd64"
goarchAMD64P32 = "amd64p32"
goarchARM = "arm"
goarchARM64 = "arm64"
gooarchMIPS = "mips"
gooarchMIPSLE = "mipsle"
goarchMIPS64 = "mips64"
goarchMIPS64LE = "mips64le"
goarchS390X = "s390x"
gooarchPowerPC64 = "ppc64"
gooarchPowerPC64LE = "ppc64le"
gooarchRISCV64 = "riscv64"
gooarchLoong64 = "loong64"
gooarchWebAssembly = "wasm"
goarch386 = "386"
goarchAMD64 = "amd64"
goarchAMD64P32 = "amd64p32"
goarchARM = "arm"
goarchARM64 = "arm64"
goarchMIPS = "mips"
goarchMIPSLE = "mipsle"
goarchMIPS64 = "mips64"
goarchMIPS64LE = "mips64le"
goarchS390X = "s390x"
goarchPowerPC64 = "ppc64"
goarchPowerPC64LE = "ppc64le"
goarchRISCV64 = "riscv64"
goarchLoong64 = "loong64"
goarchWebAssembly = "wasm"
)
4 changes: 3 additions & 1 deletion constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func init() {
platforms []Platform
}{
{"<= 1.0", Platforms_1_0},
{">= 1.1, < 1.3", Platforms_1_1},
{">= 1.1, < 1.2", Platforms_1_1},
{">= 1.2, < 1.3", Platforms_1_2},
{">= 1.3, < 1.4", Platforms_1_3},
{">= 1.4, < 1.5", Platforms_1_4},
{">= 1.5, < 1.6", Platforms_1_5},
Expand All @@ -76,6 +77,7 @@ func init() {
{">= 1.18, < 1.19", Platforms_1_18},
{">= 1.19, < 1.20", Platforms_1_19},
{">= 1.20, < 1.21", Platforms_1_20},
{">= 1.21, < 1.22", Platforms_1_21},
}

platformConstraints = make([]PlatformConstraint, len(platformConstraintsInputs))
Expand Down
305 changes: 190 additions & 115 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ func addDrop(base []Platform, add []Platform, drop []Platform) []Platform {
if found < 0 {
panic(fmt.Sprintf("Expected to remove %+v but not found in list %+v", platform, newPlatforms))
}
if found == len(newPlatforms)-1 {

switch found {
case 0:
newPlatforms = newPlatforms[1:]
case len(newPlatforms) - 1:
newPlatforms = newPlatforms[:found]
} else if found == 0 {
newPlatforms = newPlatforms[found:]
} else {
default:
newPlatforms = append(newPlatforms[:found], newPlatforms[found+1:]...)
}
}
Expand All @@ -68,121 +70,194 @@ var (
{goosWindows, goarchAMD64, true},
}

Platforms_1_1 = addDrop(Platforms_1_0, []Platform{
{goosFreeBSD, goarchARM, true},
{goosNetBSD, goarch386, true},
{goosNetBSD, goarchAMD64, true},
{goosNetBSD, goarchARM, true},
{goosPlan9, goarch386, false},
}, nil)

Platforms_1_3 = addDrop(Platforms_1_1, []Platform{
{goosDragonfly, goarch386, false},
{goosDragonfly, goarchAMD64, false},
{goosNACL, goarchAMD64, false},
{goosNACL, goarchAMD64P32, false},
{goosNACL, goarchARM, false},
{goosSolaris, goarchAMD64, false},
}, nil)

Platforms_1_4 = addDrop(Platforms_1_3, []Platform{
{goosAndroid, goarchARM, false},
{goosPlan9, goarchAMD64, false},
}, nil)

Platforms_1_5 = addDrop(Platforms_1_4, []Platform{
{goosDarwin, goarchARM, false},
{goosDarwin, goarchARM64, false},
{goosLinux, goarchARM64, false},
{goosLinux, gooarchPowerPC64, false},
{goosLinux, gooarchPowerPC64LE, false},
}, nil)

Platforms_1_6 = addDrop(Platforms_1_5, []Platform{
{goosAndroid, goarch386, false},
{goosAndroid, goarchAMD64, false},
{goosLinux, goarchMIPS64, false},
{goosLinux, goarchMIPS64LE, false},
{goosNACL, goarch386, false},
{goosOpenBSD, goarchARM, true},
}, nil)

Platforms_1_7 = addDrop(Platforms_1_5, []Platform{
// While not fully supported s390x is generally useful
{goosLinux, goarchS390X, true},
{goosPlan9, goarchARM, false},
// Add the 1.6 Platforms, but reflect full support for mips64 and mips64le
{goosAndroid, goarch386, false},
{goosAndroid, goarchAMD64, false},
{goosLinux, goarchMIPS64, true},
{goosLinux, goarchMIPS64LE, true},
{goosNACL, goarch386, false},
{goosOpenBSD, goarchARM, true},
}, nil)

Platforms_1_8 = addDrop(Platforms_1_7, []Platform{
{goosLinux, gooarchMIPS, true},
{goosLinux, gooarchMIPSLE, true},
}, nil)
Platforms_1_1 = addDrop(Platforms_1_0,
[]Platform{
{goosFreeBSD, goarchARM, true},
{goosNetBSD, goarch386, true},
{goosNetBSD, goarchAMD64, true},
{goosNetBSD, goarchARM, true},
{goosPlan9, goarch386, false},
},
nil,
)

// no new platforms in 1.2
Platforms_1_2 = Platforms_1_1

Platforms_1_3 = addDrop(Platforms_1_2,
[]Platform{
{goosDragonfly, goarch386, false},
{goosDragonfly, goarchAMD64, false},
{goosNACL, goarchAMD64, false},
{goosNACL, goarchAMD64P32, false},
{goosNACL, goarchARM, false},
{goosSolaris, goarchAMD64, false},
},
nil,
)

Platforms_1_4 = addDrop(Platforms_1_3,
[]Platform{
{goosAndroid, goarchARM, false},
{goosPlan9, goarchAMD64, false},
},
nil,
)

Platforms_1_5 = addDrop(Platforms_1_4,
[]Platform{
{goosDarwin, goarchARM, false},
{goosDarwin, goarchARM64, false},
{goosLinux, goarchARM64, false},
{goosLinux, goarchPowerPC64, false},
{goosLinux, goarchPowerPC64LE, false},
},
nil,
)

Platforms_1_6 = addDrop(Platforms_1_5,
[]Platform{
{goosAndroid, goarch386, false},
{goosAndroid, goarchAMD64, false},
{goosLinux, goarchMIPS64, false},
{goosLinux, goarchMIPS64LE, false},
{goosNACL, goarch386, false},
{goosOpenBSD, goarchARM, true},
},
nil,
)

Platforms_1_7 = addDrop(Platforms_1_5,
[]Platform{
// Add the 1.6 Platforms, but reflect full support for mips64 and mips64le
{goosAndroid, goarch386, false},
{goosAndroid, goarchAMD64, false},
{goosLinux, goarchMIPS64, true},
{goosLinux, goarchMIPS64LE, true},
{goosNACL, goarch386, false},
{goosOpenBSD, goarchARM, true},

{goosAndroid, goarchARM64, false},
{goosLinux, goarchS390X, true},
{goosPlan9, goarchARM, false},
},
[]Platform{
{goosNACL, goarchAMD64, false},
{goosDragonfly, goarch386, false},
},
)

Platforms_1_8 = addDrop(Platforms_1_7,
[]Platform{
{goosLinux, goarchMIPS, true},
{goosLinux, goarchMIPSLE, true},
},
nil,
)

// no new platforms in 1.9
Platforms_1_9 = Platforms_1_8

// unannounced, but dropped support for android/amd64
Platforms_1_10 = addDrop(Platforms_1_9, nil, []Platform{{goosAndroid, goarchAMD64, false}})

Platforms_1_11 = addDrop(Platforms_1_10, []Platform{
{goosJavaScript, gooarchWebAssembly, true},
}, nil)

Platforms_1_12 = addDrop(Platforms_1_11, []Platform{
{goosAIX, gooarchPowerPC64, false},
{goosWindows, goarchARM, true},
}, nil)

Platforms_1_13 = addDrop(Platforms_1_12, []Platform{
{goosIllumos, goarchAMD64, false},
{goosNetBSD, goarchARM64, true},
{goosOpenBSD, goarchARM64, true},
}, nil)

Platforms_1_14 = addDrop(Platforms_1_13, []Platform{
{goosFreeBSD, goarchARM64, true},
{goosLinux, gooarchRISCV64, true},
}, []Platform{
// drop nacl
{goosNACL, goarch386, false},
{goosNACL, goarchAMD64, false},
{goosNACL, goarchARM, false},
})

Platforms_1_15 = addDrop(Platforms_1_14, []Platform{
{goosAndroid, goarchARM64, false},
}, []Platform{
// drop i386 macos
{goosDarwin, goarch386, false},
})

Platforms_1_16 = addDrop(Platforms_1_15, []Platform{
{goosAndroid, goarchAMD64, false},
{goosDarwin, goarchARM64, true},
{goosOpenBSD, goarchMIPS64, false},
}, nil)

Platforms_1_17 = addDrop(Platforms_1_16, []Platform{
{goosWindows, goarchARM64, true},
}, nil)

// no new platforms in 1.18
Platforms_1_18 = Platforms_1_17

Platforms_1_19 = addDrop(Platforms_1_18, []Platform{
{goosLinux, gooarchLoong64, true},
}, nil)

Platforms_1_20 = Platforms_1_19

PlatformsLatest = Platforms_1_20
// no new platforms in 1.10
Platforms_1_10 = Platforms_1_9

Platforms_1_11 = addDrop(Platforms_1_10,
[]Platform{
{goosJavaScript, goarchWebAssembly, true},
{goosLinux, goarchRISCV64, false},
},
nil,
)

Platforms_1_12 = addDrop(Platforms_1_11,
[]Platform{
{goosAIX, goarchPowerPC64, false},
{goosWindows, goarchARM, true},
},
[]Platform{
{goosLinux, goarchRISCV64, false},
},
)

Platforms_1_13 = addDrop(Platforms_1_12,
[]Platform{
{goosIllumos, goarchAMD64, false},
{goosNetBSD, goarchARM64, true},
{goosOpenBSD, goarchARM64, true},
},
nil,
)

Platforms_1_14 = addDrop(Platforms_1_13,
[]Platform{
{goosFreeBSD, goarchARM64, true},
{goosLinux, goarchRISCV64, true},
},
[]Platform{
// drop nacl
{goosNACL, goarch386, false},
{goosNACL, goarchARM, false},
{goosNACL, goarchAMD64P32, false},
},
)

Platforms_1_15 = addDrop(Platforms_1_14,
nil,
[]Platform{
{goosDarwin, goarch386, false},
{goosDarwin, goarchARM, false},
},
)

Platforms_1_16 = addDrop(Platforms_1_15,
[]Platform{
{goosAndroid, goarchAMD64, false},
{goosDarwin, goarchARM64, true},
{goosIOS, goarchARM64, false},
{goosIOS, goarchAMD64, false},
{goosOpenBSD, goarchMIPS64, false},
},
nil,
)

Platforms_1_17 = addDrop(Platforms_1_16,
[]Platform{
{goosWindows, goarchARM64, true},
},
nil,
)

Platforms_1_18 = addDrop(Platforms_1_17,
[]Platform{
{goosIllumos, goarchAMD64, false},
},
nil,
)

Platforms_1_19 = addDrop(Platforms_1_18,
[]Platform{
{goosLinux, goarchLoong64, true},
},
nil,
)

Platforms_1_20 = addDrop(Platforms_1_19,
[]Platform{
{goosFreeBSD, goarchRISCV64, false},
},
nil,
)

Platforms_1_21 = addDrop(Platforms_1_20,
[]Platform{
{goosWASIP1, goarchWebAssembly, false},
},
[]Platform{
{goosOpenBSD, goarchMIPS64, false},
},
)

PlatformsLatest = Platforms_1_21
)

// SupportedPlatforms returns the full list of supported platforms for
Expand Down
Loading

0 comments on commit 5d11e26

Please sign in to comment.