File: math32_test.go

package info (click to toggle)
golang-github-chewxy-math32 1.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: asm: 388; makefile: 4
file content (57 lines) | stat: -rw-r--r-- 1,326 bytes parent folder | download
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)
	}
}