(testName string, invokeScriptFunc func(script *ShellScript), inputFunc func(inputWriter io.Writer), outputFunc func(outputReader io.Reader))
| 40 | } |
| 41 | |
| 42 | func 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 | } |
no test coverage detected