| 378 | } |
| 379 | |
| 380 | bool testUVProcessChainExternal(char const* helperCommand) |
| 381 | { |
| 382 | cmUVProcessChainBuilder builder; |
| 383 | std::unique_ptr<cmUVProcessChain> chain; |
| 384 | int outputPipe[2], errorPipe[2]; |
| 385 | cm::uv_pipe_ptr outputInPipe, outputOutPipe, errorInPipe, errorOutPipe; |
| 386 | |
| 387 | if (cmGetPipes(outputPipe) < 0) { |
| 388 | std::cout << "Error creating pipes" << std::endl; |
| 389 | return false; |
| 390 | } |
| 391 | if (cmGetPipes(errorPipe) < 0) { |
| 392 | std::cout << "Error creating pipes" << std::endl; |
| 393 | return false; |
| 394 | } |
| 395 | |
| 396 | builder.AddCommand({ helperCommand, "echo" }) |
| 397 | .AddCommand({ helperCommand, "capitalize" }) |
| 398 | .AddCommand({ helperCommand, "dedup" }) |
| 399 | .SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, outputPipe[1]) |
| 400 | .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, errorPipe[1]); |
| 401 | if (builder.GetLoop()) { |
| 402 | std::cout << "GetLoop() should return null" << std::endl; |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | if (!checkExecution(builder, chain)) { |
| 407 | return false; |
| 408 | } |
| 409 | |
| 410 | if (chain->OutputStream()) { |
| 411 | std::cout << "OutputStream() was valid, expecting invalid" << std::endl; |
| 412 | return false; |
| 413 | } |
| 414 | if (chain->ErrorStream()) { |
| 415 | std::cout << "ErrorStream() was valid, expecting invalid" << std::endl; |
| 416 | return false; |
| 417 | } |
| 418 | |
| 419 | outputOutPipe.init(chain->GetLoop(), 0); |
| 420 | uv_pipe_open(outputOutPipe, outputPipe[1]); |
| 421 | outputOutPipe.reset(); |
| 422 | |
| 423 | errorOutPipe.init(chain->GetLoop(), 0); |
| 424 | uv_pipe_open(errorOutPipe, errorPipe[1]); |
| 425 | errorOutPipe.reset(); |
| 426 | |
| 427 | outputInPipe.init(chain->GetLoop(), 0); |
| 428 | uv_pipe_open(outputInPipe, outputPipe[0]); |
| 429 | cmUVStreambuf outputBuf; |
| 430 | outputBuf.open(outputInPipe); |
| 431 | std::istream outputStream(&outputBuf); |
| 432 | |
| 433 | errorInPipe.init(chain->GetLoop(), 0); |
| 434 | uv_pipe_open(errorInPipe, errorPipe[0]); |
| 435 | cmUVStreambuf errorBuf; |
| 436 | errorBuf.open(errorInPipe); |
| 437 | std::istream errorStream(&errorBuf); |
no test coverage detected
searching dependent graphs…