MCPcopy
hub / github.com/protocolbuffers/protobuf-go / mustRun

Method mustRun

integration_test.go:544–564  ·  view source on GitHub ↗
(t *testing.T, args ...string)

Source from the content-addressed store, hash-verified

542}
543
544func (c command) mustRun(t *testing.T, args ...string) string {
545 t.Helper()
546 stdout := new(bytes.Buffer)
547 stderr := new(bytes.Buffer)
548 cmd := exec.Command(args[0], args[1:]...)
549 cmd.Dir = "."
550 if c.Dir != "" {
551 cmd.Dir = c.Dir
552 }
553 cmd.Env = os.Environ()
554 if c.Env != nil {
555 cmd.Env = c.Env
556 }
557 cmd.Env = append(cmd.Env, "PWD="+cmd.Dir)
558 cmd.Stdout = stdout
559 cmd.Stderr = stderr
560 if err := cmd.Run(); err != nil {
561 t.Fatalf("executing (%v): %v\n%s%s", strings.Join(args, " "), err, stdout.String(), stderr.String())
562 }
563 return stdout.String()
564}
565
566func mustRunCommand(t *testing.T, args ...string) string {
567 t.Helper()

Callers 4

mustHandleFlagsFunction · 0.95
TestIntegrationFunction · 0.80
mustInitDepsFunction · 0.80
mustRunCommandFunction · 0.80

Calls 3

RunMethod · 0.80
JoinMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected