summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-05-30 13:42:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-05-30 13:42:32 (GMT)
commit0283b2d2bd90de3096bd348ba9e0ffb9e54cea74 (patch)
tree8e501b764afccaba71f058562cc5e4ba11625155 /Tests
parent150f0f19bc4832c27cf70bdbc56a87867ef60b84 (diff)
parentec80090ce347f639fc893d0f56385da3c2ad28ec (diff)
downloadCMake-0283b2d2bd90de3096bd348ba9e0ffb9e54cea74.zip
CMake-0283b2d2bd90de3096bd348ba9e0ffb9e54cea74.tar.gz
CMake-0283b2d2bd90de3096bd348ba9e0ffb9e54cea74.tar.bz2
Merge topic 'cmuvprocesschain-merged-output'
ec80090ce3 cmUVProcessChain: Add option for merged output and error Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8513
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLib/testUVProcessChain.cxx60
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;