-
Notifications
You must be signed in to change notification settings - Fork 23
/
math32_test.go
57 lines (50 loc) · 1.29 KB
/
math32_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//go:build !tinygo
// +build !tinygo
package math32
import (
"fmt"
"os"
"os/exec"
"testing"
)
func TestVetMath32(t *testing.T) {
linuxArches := []string{"amd64", "arm", "arm64", "s390x", "ppc64le", "riscv64", "386", "mips", "mips64", "mipsle", "mips64le"}
// Linux architectures
for _, GOARCH := range linuxArches {
GOOS := "linux"
t.Run(fmt.Sprintf("GOOS=%s GOARCH=%s", GOOS, GOARCH), func(t *testing.T) {
goVet(t, GOOS, GOARCH)
goBuildVet(t, GOOS, GOARCH)
})
}
// WASM
t.Run("GOOS=js GOARCH=wasm", func(t *testing.T) {
goVet(t, "js", "wasm")
goBuildVet(t, "js", "wasm")
})
// AIX
t.Run("GOOS=aix GOARCH=ppc64", func(t *testing.T) {
goVet(t, "aix", "ppc64")
goBuildVet(t, "aix", "ppc64")
})
}
func goVet(t *testing.T, GOOS, GOARCH string) {
env := append(os.Environ(), "GOOS="+GOOS, "GOARCH="+GOARCH)
cmd := exec.Command("go", "vet", ".")
cmd.Env = env
output, err := cmd.CombinedOutput()
if err != nil {
t.Error(string(output), err)
}
}
func goBuildVet(t *testing.T, GOOS, GOARCH string) {
env := append(os.Environ(), "GOOS="+GOOS, "GOARCH="+GOARCH)
const buildname = "math32.test"
defer os.Remove(buildname)
cmd := exec.Command("go", "test", "-c", "-o="+buildname)
cmd.Env = env
output, err := cmd.CombinedOutput()
if err != nil {
t.Error(string(output), err)
}
}