MCPcopy Create free account
hub / github.com/Kitware/CMake / testUVProcessChainExternal

Function testUVProcessChainExternal

Tests/CMakeLib/testUVProcessChain.cxx:380–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380bool 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);

Callers 1

testUVProcessChainFunction · 0.85

Calls 11

cmGetPipesFunction · 0.85
checkExecutionFunction · 0.85
checkOutputFunction · 0.85
GetLoopMethod · 0.80
OutputStreamMethod · 0.80
ErrorStreamMethod · 0.80
uv_pipe_openFunction · 0.50
AddCommandMethod · 0.45
initMethod · 0.45
resetMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…