MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / processChainPipeSingle

Method processChainPipeSingle

Tests/Libraries/Process/ProcessTest.cpp:230–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230void SC::ProcessTest::processChainPipeSingle()
231{
232 //! [processChainPipeSingleSnippet]
233 // Executes two processes piping output of process p1 to input of process p2.
234 // Reads p2 stdout and stderr into a pair of Strings.
235 ProcessChain chain;
236 Process p1;
237 StringView expectedOutput;
238 switch (HostPlatform)
239 {
240 case Platform::Windows: {
241 expectedOutput = "C:\\Windows\\System32\\where.exe\r\n";
242 SC_TEST_EXPECT(chain.pipe(p1, {"where", "where.exe"}));
243 }
244 break;
245 default: { // Posix
246 expectedOutput = "DOCTORI\n";
247 SC_TEST_EXPECT(chain.pipe(p1, {"echo", "DOCTORI"}));
248 }
249 break;
250 }
251
252 String stdOut(StringEncoding::Ascii);
253 String stdErr(StringEncoding::Ascii);
254 SC_TEST_EXPECT(chain.exec(stdOut, Process::StdIn::Inherit(), stdErr));
255 SC_TEST_EXPECT(stdOut == expectedOutput);
256 SC_TEST_EXPECT(stdErr.isEmpty());
257 //! [processChainPipeSingleSnippet]
258}
259
260void SC::ProcessTest::processChainPipeDual()
261{

Callers

nothing calls this directly

Calls 3

InheritClass · 0.50
pipeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected