MCPcopy Create free account
hub / github.com/apache/qpid-proton / exampleCommand

Function exampleCommand

go/examples/example_test.go:111–129  ·  view source on GitHub ↗

exampleCommand returns an exec.Cmd to run an example.

(t *testing.T, prog string, arg ...string)

Source from the content-addressed store, hash-verified

109
110// exampleCommand returns an exec.Cmd to run an example.
111func exampleCommand(t *testing.T, prog string, arg ...string) (cmd *exec.Cmd) {
112 args := []string{}
113 if *debug {
114 args = append(args, "-debug=true")
115 }
116 args = append(args, arg...)
117 prog, err := filepath.Abs(path.Join(*dir, prog))
118 fatalIf(t, err)
119 if _, err := os.Stat(prog); err == nil {
120 cmd = exec.Command(prog, args...)
121 } else if _, err := os.Stat(prog + ".go"); err == nil {
122 args = append([]string{"run", prog + ".go"}, args...)
123 cmd = exec.Command("go", args...)
124 } else {
125 t.Fatalf("Cannot find binary or source for %s", prog)
126 }
127 cmd.Stderr = os.Stderr
128 return cmd
129}
130
131// Run an example Go program, return the combined output as a string.
132func runExample(t *testing.T, prog string, arg ...string) (string, error) {

Callers 4

startMethod · 0.85
runExampleFunction · 0.85
goReceiveWantFunction · 0.85
TestExampleReceiveSendFunction · 0.85

Calls 1

fatalIfFunction · 0.70

Tested by

no test coverage detected