| 228 | } |
| 229 | |
| 230 | void 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 | |
| 260 | void SC::ProcessTest::processChainPipeDual() |
| 261 | { |