aboutsummaryrefslogtreecommitdiffhomepage
path: root/main_test.go
diff options
context:
space:
mode:
authorElliott Sales de Andrade <[email protected]>2022-02-06 23:26:25 -0500
committerAyke <[email protected]>2022-02-07 11:05:47 +0100
commit010cc13e9e5861bd9292a66f22be867f6629f943 (patch)
tree296b81f77e6ebf7fcf933e765495fc70c2f1f36f /main_test.go
parentac7e370c729bec110ddaa676de8c3cbf3def5ca1 (diff)
downloadtinygo-010cc13e9e5861bd9292a66f22be867f6629f943.tar.gz
tinygo-010cc13e9e5861bd9292a66f22be867f6629f943.zip
Fix cross-Linux setup on non-amd64 arches
In that case, an emulator is needed for amd64, and tests should be run for amd64 as a _cross_ test.
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go39
1 files changed, 21 insertions, 18 deletions
diff --git a/main_test.go b/main_test.go
index cf3fc9894..82c0b6110 100644
--- a/main_test.go
+++ b/main_test.go
@@ -31,6 +31,13 @@ const TESTDATA = "testdata"
var testTarget = flag.String("target", "", "override test target")
+var supportedLinuxArches = map[string]string{
+ "AMD64Linux": "linux/amd64",
+ "X86Linux": "linux/386",
+ "ARMLinux": "linux/arm/6",
+ "ARM64Linux": "linux/arm64",
+}
+
var sema = make(chan struct{}, runtime.NumCPU())
func TestBuild(t *testing.T) {
@@ -180,18 +187,14 @@ func TestBuild(t *testing.T) {
})
if runtime.GOOS == "linux" {
- t.Run("X86Linux", func(t *testing.T) {
- t.Parallel()
- runPlatTests(optionsFromOSARCH("linux/386", sema), tests, t)
- })
- t.Run("ARMLinux", func(t *testing.T) {
- t.Parallel()
- runPlatTests(optionsFromOSARCH("linux/arm/6", sema), tests, t)
- })
- t.Run("ARM64Linux", func(t *testing.T) {
- t.Parallel()
- runPlatTests(optionsFromOSARCH("linux/arm64", sema), tests, t)
- })
+ for name, osArch := range supportedLinuxArches {
+ options := optionsFromOSARCH(osArch, sema)
+ if options.GOARCH != runtime.GOARCH { // Native architecture already run above.
+ t.Run(name, func(t *testing.T) {
+ runPlatTests(options, tests, t)
+ })
+ }
+ }
t.Run("WebAssembly", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromTarget("wasm", sema), tests, t)
@@ -475,12 +478,12 @@ func TestTest(t *testing.T) {
}
if !testing.Short() {
if runtime.GOOS == "linux" {
- targs = append(targs,
- // Linux
- targ{"X86Linux", optionsFromOSARCH("linux/386", sema)},
- targ{"ARMLinux", optionsFromOSARCH("linux/arm/6", sema)},
- targ{"ARM64Linux", optionsFromOSARCH("linux/arm64", sema)},
- )
+ for name, osArch := range supportedLinuxArches {
+ options := optionsFromOSARCH(osArch, sema)
+ if options.GOARCH != runtime.GOARCH { // Native architecture already run above.
+ targs = append(targs, targ{name, options})
+ }
+ }
}
targs = append(targs,