MCPcopy Index your code
hub / github.com/go-python/gopy / init

Function init

main_unix_test.go:17–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func init() {
18
19 testEnvironment = os.Environ()
20
21 var (
22 py3 = "python3"
23 // pypy3 = "pypy3"
24 )
25
26 if os.Getenv("GOPY_TRAVIS_CI") == "1" {
27 log.Printf("Running in travis CI")
28 }
29
30 var (
31 disabled []string
32 missing int
33 )
34 for _, be := range []struct {
35 name string
36 vm string
37 module string
38 mandatory bool
39 }{
40 {"py3", py3, "", true},
41 } {
42 args := []string{"-c", ""}
43 if be.module != "" {
44 args[1] = "import " + be.module
45 }
46 log.Printf("checking testbackend: %q...", be.name)
47 cmd := exec.Command(be.vm, args...)
48 cmd.Stdin = os.Stdin
49 cmd.Stdout = os.Stdout
50 cmd.Stderr = os.Stderr
51 err := cmd.Run()
52 if err != nil {
53 log.Printf("disabling testbackend: %q, error: '%s'", be.name, err.Error())
54 testBackends[be.name] = ""
55 disabled = append(disabled, be.name)
56 if be.mandatory {
57 missing++
58 }
59 } else {
60 log.Printf("enabling testbackend: %q", be.name)
61 testBackends[be.name] = be.vm
62 }
63 }
64
65 if len(disabled) > 0 {
66 log.Printf("The following test backends are not available: %s",
67 strings.Join(disabled, ", "))
68 if os.Getenv("GOPY_TRAVIS_CI") == "1" && missing > 0 {
69 log.Fatalf("Not all backends available in travis CI")
70 }
71 }
72}

Callers

nothing calls this directly

Calls 2

PrintfMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected