MCPcopy Create free account
hub / github.com/go-python/gopy / TestGofmt

Function TestGofmt

main_test.go:73–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestGofmt(t *testing.T) {
74 exe, err := exec.LookPath("goimports")
75 if err != nil {
76 switch e := err.(type) {
77 case *exec.Error:
78 if e.Err == exec.ErrNotFound {
79 exe, err = exec.LookPath("gofmt")
80 }
81 }
82 }
83 if err != nil {
84 t.Fatal(err)
85 }
86
87 cmd := exec.Command(exe, "-d", ".")
88 buf := new(bytes.Buffer)
89 cmd.Stdout = buf
90 cmd.Stderr = buf
91
92 err = cmd.Run()
93 if err != nil {
94 t.Fatalf("error running %s:\n%s\n%v", exe, buf.String(), err)
95 }
96
97 if len(buf.Bytes()) != 0 {
98 t.Errorf("some files were not gofmt'ed:\n%s\n", buf.String())
99 }
100}
101
102func TestGoPyErrors(t *testing.T) {
103 pyvm := testBackends["py3"]

Callers

nothing calls this directly

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected