-
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CHANGELOG + improvements to #980
Closes #978
- Loading branch information
1 parent
aa6c7e4
commit 2efb353
Showing
7 changed files
with
171 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package goext | ||
|
||
// NOTE(@andreynering): The lists in this file were copied from: | ||
// | ||
// https://github.com/golang/go/blob/master/src/go/build/syslist.go | ||
|
||
func IsKnownOS(str string) bool { | ||
_, known := knownOS[str] | ||
return known | ||
} | ||
|
||
func IsKnownArch(str string) bool { | ||
_, known := knownArch[str] | ||
return known | ||
} | ||
|
||
var knownOS = map[string]struct{}{ | ||
"aix": {}, | ||
"android": {}, | ||
"darwin": {}, | ||
"dragonfly": {}, | ||
"freebsd": {}, | ||
"hurd": {}, | ||
"illumos": {}, | ||
"ios": {}, | ||
"js": {}, | ||
"linux": {}, | ||
"nacl": {}, | ||
"netbsd": {}, | ||
"openbsd": {}, | ||
"plan9": {}, | ||
"solaris": {}, | ||
"windows": {}, | ||
"zos": {}, | ||
} | ||
|
||
var knownArch = map[string]struct{}{ | ||
"386": {}, | ||
"amd64": {}, | ||
"amd64p32": {}, | ||
"arm": {}, | ||
"armbe": {}, | ||
"arm64": {}, | ||
"arm64be": {}, | ||
"loong64": {}, | ||
"mips": {}, | ||
"mipsle": {}, | ||
"mips64": {}, | ||
"mips64le": {}, | ||
"mips64p32": {}, | ||
"mips64p32le": {}, | ||
"ppc": {}, | ||
"ppc64": {}, | ||
"ppc64le": {}, | ||
"riscv": {}, | ||
"riscv64": {}, | ||
"s390": {}, | ||
"s390x": {}, | ||
"sparc": {}, | ||
"sparc64": {}, | ||
"wasm": {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package taskfile | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPlatformParsing(t *testing.T) { | ||
tests := []struct { | ||
Input string | ||
ExpectedOS string | ||
ExpectedArch string | ||
Error string | ||
}{ | ||
{Input: "windows", ExpectedOS: "windows", ExpectedArch: ""}, | ||
{Input: "linux", ExpectedOS: "linux", ExpectedArch: ""}, | ||
{Input: "darwin", ExpectedOS: "darwin", ExpectedArch: ""}, | ||
|
||
{Input: "386", ExpectedOS: "", ExpectedArch: "386"}, | ||
{Input: "amd64", ExpectedOS: "", ExpectedArch: "amd64"}, | ||
{Input: "arm64", ExpectedOS: "", ExpectedArch: "arm64"}, | ||
|
||
{Input: "windows/386", ExpectedOS: "windows", ExpectedArch: "386"}, | ||
{Input: "windows/amd64", ExpectedOS: "windows", ExpectedArch: "amd64"}, | ||
{Input: "windows/arm64", ExpectedOS: "windows", ExpectedArch: "arm64"}, | ||
|
||
{Input: "invalid", Error: `task: Invalid platform "invalid"`}, | ||
{Input: "invalid/invalid", Error: `task: Invalid platform "invalid/invalid"`}, | ||
{Input: "windows/invalid", Error: `task: Invalid platform "windows/invalid"`}, | ||
{Input: "invalid/amd64", Error: `task: Invalid platform "invalid/amd64"`}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.Input, func(t *testing.T) { | ||
var p Platform | ||
err := p.parsePlatform(test.Input) | ||
|
||
if test.Error != "" { | ||
assert.Error(t, err) | ||
assert.Equal(t, test.Error, err.Error()) | ||
} else { | ||
assert.NoError(t, err) | ||
assert.Equal(t, test.ExpectedOS, p.OS) | ||
assert.Equal(t, test.ExpectedArch, p.Arch) | ||
} | ||
}) | ||
} | ||
} |