MCPcopy Create free account
hub / github.com/golang/mobile / testMain

Function testMain

bind/java/seq_test.go:28–56  ·  view source on GitHub ↗
(m *testing.M)

Source from the content-addressed store, hash-verified

26}
27
28func testMain(m *testing.M) int {
29 // Build gomobile and gobind and put them into PATH.
30 binDir, err := os.MkdirTemp("", "bind-java-test-")
31 if err != nil {
32 log.Fatal(err)
33 }
34 defer os.RemoveAll(binDir)
35 exe := ""
36 if runtime.GOOS == "windows" {
37 exe = ".exe"
38 }
39 if runtime.GOOS != "android" {
40 gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
41 gomobileBin = filepath.Join(binDir, "gomobile"+exe)
42 gobindBin := filepath.Join(binDir, "gobind"+exe)
43 if out, err := exec.Command(gocmd, "build", "-o", gomobileBin, "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
44 log.Fatalf("gomobile build failed: %v: %s", err, out)
45 }
46 if out, err := exec.Command(gocmd, "build", "-o", gobindBin, "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
47 log.Fatalf("gobind build failed: %v: %s", err, out)
48 }
49 path := binDir
50 if oldPath := os.Getenv("PATH"); oldPath != "" {
51 path += string(filepath.ListSeparator) + oldPath
52 }
53 os.Setenv("PATH", path)
54 }
55 return m.Run()
56}
57
58func TestClasses(t *testing.T) {
59 if !java.IsAvailable() {

Callers 1

TestMainFunction · 0.70

Calls 1

RunMethod · 0.65

Tested by

no test coverage detected