MCPcopy
hub / github.com/perkeep/perkeep / Run

Method Run

cmd/pk-put/camput_test.go:50–77  ·  view source on GitHub ↗
(args ...string)

Source from the content-addressed store, hash-verified

48
49}
50func (e *env) Run(args ...string) (out, err []byte, exitCode int) {
51 outbuf := new(bytes.Buffer)
52 errbuf := new(bytes.Buffer)
53 os.Args = append(os.Args[:1], args...)
54 cmdmain.Stdout, cmdmain.Stderr = outbuf, errbuf
55 if e.stdin == nil {
56 cmdmain.Stdin = strings.NewReader("")
57 } else {
58 cmdmain.Stdin = e.stdin
59 }
60 exitc := make(chan int, 1)
61 cmdmain.Exit = func(code int) {
62 exitc <- code
63 runtime.Goexit()
64 }
65 go func() {
66 cmdmain.Main()
67 cmdmain.Exit(0)
68 }()
69 select {
70 case exitCode = <-exitc:
71 case <-time.After(e.timeout()):
72 panic("timeout running command")
73 }
74 out = outbuf.Bytes()
75 err = errbuf.Bytes()
76 return
77}
78
79// TestUsageOnNoargs tests that we output a usage message when given no args, and return
80// with a non-zero exit status.

Callers 4

TestUsageOnNoargsFunction · 0.95
TestCommandUsageFunction · 0.95
TestUploadDirectoriesFunction · 0.95
TestCamputBlobFunction · 0.95

Calls 2

timeoutMethod · 0.95
MainFunction · 0.92

Tested by

no test coverage detected