diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-05-26 19:52:01 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-05-26 19:52:01 (GMT) |
commit | ec80090ce347f639fc893d0f56385da3c2ad28ec (patch) | |
tree | 3efdf6d74ca8f7737724d0bfe80b673ccc33eb83 /Tests/CMakeLib | |
parent | 67bb1ee50cde981dd36f2b9964013c330f7e92fe (diff) | |
download | CMake-ec80090ce347f639fc893d0f56385da3c2ad28ec.zip CMake-ec80090ce347f639fc893d0f56385da3c2ad28ec.tar.gz CMake-ec80090ce347f639fc893d0f56385da3c2ad28ec.tar.bz2 |
cmUVProcessChain: Add option for merged output and error
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r-- | Tests/CMakeLib/testUVProcessChain.cxx | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index 05262bc..cbb4384 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -229,6 +229,61 @@ bool testUVProcessChainBuiltin(const char* helperCommand) return true; } +bool testUVProcessChainBuiltinMerged(const char* helperCommand) +{ + cmUVProcessChainBuilder builder; + std::unique_ptr<cmUVProcessChain> chain; + builder.AddCommand({ helperCommand, "echo" }) + .AddCommand({ helperCommand, "capitalize" }) + .AddCommand({ helperCommand, "dedup" }) + .SetMergedBuiltinStreams(); + + if (!checkExecution(builder, chain)) { + return false; + } + + if (!chain->OutputStream()) { + std::cout << "OutputStream() was null, expecting not null" << std::endl; + return false; + } + if (!chain->ErrorStream()) { + std::cout << "ErrorStream() was null, expecting not null" << std::endl; + return false; + } + if (chain->OutputStream() != chain->ErrorStream()) { + std::cout << "OutputStream() and ErrorStream() expected to be the same" + << std::endl; + return false; + } + + std::string merged = getInput(*chain->OutputStream()); + auto qemuErrorPos = merged.find("qemu:"); + if (qemuErrorPos != std::string::npos) { + merged.resize(qemuErrorPos); + } + if (merged.length() != cmStrLen("HELO WRD!123") || + merged.find('1') == std::string::npos || + merged.find('2') == std::string::npos || + merged.find('3') == std::string::npos) { + std::cout << "Expected output to contain '1', '2', and '3', was \"" + << merged << "\"" << std::endl; + return false; + } + std::string output; + for (auto const& c : merged) { + if (c != '1' && c != '2' && c != '3') { + output += c; + } + } + if (output != "HELO WRD!") { + std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\"" + << std::endl; + return false; + } + + return true; +} + bool testUVProcessChainExternal(const char* helperCommand) { cmUVProcessChainBuilder builder; @@ -378,6 +433,11 @@ int testUVProcessChain(int argc, char** const argv) return -1; } + if (!testUVProcessChainBuiltinMerged(argv[1])) { + std::cout << "While executing testUVProcessChainBuiltinMerged().\n"; + return -1; + } + if (!testUVProcessChainExternal(argv[1])) { std::cout << "While executing testUVProcessChainExternal().\n"; return -1; |