MCPcopy Index your code
hub / github.com/kopia/kopia / Start

Method Start

tests/testenv/cli_inproc_runner.go:30–55  ·  view source on GitHub ↗

Start implements CLIRunner.

(tb testing.TB, ctx context.Context, args []string, env map[string]string)

Source from the content-addressed store, hash-verified

28
29// Start implements CLIRunner.
30func (e *CLIInProcRunner) Start(tb testing.TB, ctx context.Context, args []string, env map[string]string) (stdout, stderr io.Reader, wait func() error, interrupt func(os.Signal)) {
31 tb.Helper()
32
33 a := cli.NewApp()
34 a.DangerousCommands = "enabled"
35
36 envPrefix := fmt.Sprintf("T%v_", atomic.AddInt32(envPrefixCounter, 1))
37 a.SetEnvNamePrefixForTesting(envPrefix)
38
39 kpapp := kingpin.New("test", "test")
40
41 if e.CustomizeApp != nil {
42 e.CustomizeApp(a, kpapp)
43 }
44
45 e.mu.Lock()
46 stdin := e.nextCommandStdin
47 e.nextCommandStdin = nil
48 e.mu.Unlock()
49
50 for k, v := range env {
51 os.Setenv(envPrefix+k, v)
52 }
53
54 return a.RunSubcommand(ctx, kpapp, stdin, args)
55}
56
57// SetNextStdin sets the stdin to be used on next command execution.
58func (e *CLIInProcRunner) SetNextStdin(stdin io.Reader) {

Callers

nothing calls this directly

Calls 6

RunSubcommandMethod · 0.95
NewAppFunction · 0.92
HelperMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected