MCPcopy Create free account
hub / github.com/chrislusf/gleam / testShellScript

Function testShellScript

script/shell_test.go:42–71  ·  view source on GitHub ↗
(testName string, invokeScriptFunc func(script *ShellScript),
	inputFunc func(inputWriter io.Writer),
	outputFunc func(outputReader io.Reader))

Source from the content-addressed store, hash-verified

40}
41
42func testShellScript(testName string, invokeScriptFunc func(script *ShellScript),
43 inputFunc func(inputWriter io.Writer),
44 outputFunc func(outputReader io.Reader)) {
45
46 shellScript := NewShellScript()
47 shellScript.Init("")
48
49 input, output := util.NewPiper(), util.NewPiper()
50
51 invokeScriptFunc(shellScript)
52
53 var wg sync.WaitGroup
54 wg.Add(1)
55 go util.Execute(context.Background(), &wg, &pb.InstructionStat{}, testName, shellScript.GetCommand().ToOsExecCommand(), input.Reader, output.Writer, false, false, true, os.Stderr)
56
57 wg.Add(1)
58 go func() {
59 defer wg.Done()
60 inputFunc(input.Writer)
61 input.Writer.Close()
62 }()
63
64 wg.Add(1)
65 go func() {
66 defer wg.Done()
67 outputFunc(output.Reader)
68 }()
69
70 wg.Wait()
71}

Callers 1

TestShellCatFunction · 0.85

Calls 7

InitMethod · 0.95
GetCommandMethod · 0.95
NewPiperFunction · 0.92
ExecuteFunction · 0.92
NewShellScriptFunction · 0.85
ToOsExecCommandMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected