summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-06-09 14:02:47 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2023-06-14 15:53:55 (GMT)
commitb8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421 (patch)
treee2874af8d0a86cd73221f8ccb5bc33f05782e122 /Tests/CMakeLib
parentec81d40be437a0ca2362f3b8c84dbfbf7fe6a2b3 (diff)
downloadCMake-b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421.zip
CMake-b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421.tar.gz
CMake-b8fd273ed7b14ff71cd55d39ffb7c41c2f5ee421.tar.bz2
cmUVProcessChain: Return output and error streams as file descriptors
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r--Tests/CMakeLib/testUVProcessChain.cxx51
1 files changed, 30 insertions, 21 deletions
diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx
index f3024dc..7630aa0 100644
--- a/Tests/CMakeLib/testUVProcessChain.cxx
+++ b/Tests/CMakeLib/testUVProcessChain.cxx
@@ -17,6 +17,7 @@
#include "cmStringAlgorithms.h"
#include "cmUVHandlePtr.h"
#include "cmUVProcessChain.h"
+#include "cmUVStream.h"
#include "cmUVStreambuf.h"
struct ExpectedStatus
@@ -301,16 +302,19 @@ bool testUVProcessChainBuiltin(const char* helperCommand)
return false;
}
- if (!chain->OutputStream()) {
- std::cout << "OutputStream() was null, expecting not null" << std::endl;
+ if (chain->OutputStream() < 0) {
+ std::cout << "OutputStream() was invalid, expecting valid" << std::endl;
return false;
}
- if (!chain->ErrorStream()) {
- std::cout << "ErrorStream() was null, expecting not null" << std::endl;
+ if (chain->ErrorStream() < 0) {
+ std::cout << "ErrorStream() was invalid, expecting valid" << std::endl;
return false;
}
- if (!checkOutput(*chain->OutputStream(), *chain->ErrorStream())) {
+ cmUVPipeIStream output(chain->GetLoop(), chain->OutputStream());
+ cmUVPipeIStream error(chain->GetLoop(), chain->ErrorStream());
+
+ if (!checkOutput(output, error)) {
return false;
}
@@ -330,12 +334,12 @@ bool testUVProcessChainBuiltinMerged(const char* helperCommand)
return false;
}
- if (!chain->OutputStream()) {
- std::cout << "OutputStream() was null, expecting not null" << std::endl;
+ if (chain->OutputStream() < 0) {
+ std::cout << "OutputStream() was invalid, expecting valid" << std::endl;
return false;
}
- if (!chain->ErrorStream()) {
- std::cout << "ErrorStream() was null, expecting not null" << std::endl;
+ if (chain->ErrorStream() < 0) {
+ std::cout << "ErrorStream() was invalid, expecting valid" << std::endl;
return false;
}
if (chain->OutputStream() != chain->ErrorStream()) {
@@ -344,7 +348,9 @@ bool testUVProcessChainBuiltinMerged(const char* helperCommand)
return false;
}
- std::string merged = getInput(*chain->OutputStream());
+ cmUVPipeIStream mergedStream(chain->GetLoop(), chain->OutputStream());
+
+ std::string merged = getInput(mergedStream);
auto qemuErrorPos = merged.find("qemu:");
if (qemuErrorPos != std::string::npos) {
merged.resize(qemuErrorPos);
@@ -398,12 +404,12 @@ bool testUVProcessChainExternal(const char* helperCommand)
return false;
}
- if (chain->OutputStream()) {
- std::cout << "OutputStream() was not null, expecting null" << std::endl;
+ if (chain->OutputStream() >= 0) {
+ std::cout << "OutputStream() was valid, expecting invalid" << std::endl;
return false;
}
- if (chain->ErrorStream()) {
- std::cout << "ErrorStream() was not null, expecting null" << std::endl;
+ if (chain->ErrorStream() >= 0) {
+ std::cout << "ErrorStream() was valid, expecting invalid" << std::endl;
return false;
}
@@ -446,12 +452,12 @@ bool testUVProcessChainNone(const char* helperCommand)
return false;
}
- if (chain->OutputStream()) {
- std::cout << "OutputStream() was not null, expecting null" << std::endl;
+ if (chain->OutputStream() >= 0) {
+ std::cout << "OutputStream() was valid, expecting invalid" << std::endl;
return false;
}
- if (chain->ErrorStream()) {
- std::cout << "ErrorStream() was not null, expecting null" << std::endl;
+ if (chain->ErrorStream() >= 0) {
+ std::cout << "ErrorStream() was valid, expecting invalid" << std::endl;
return false;
}
@@ -473,7 +479,8 @@ bool testUVProcessChainCwdUnchanged(const char* helperCommand)
return false;
}
- auto cwd = getInput(*chain.OutputStream());
+ cmUVPipeIStream output(chain.GetLoop(), chain.OutputStream());
+ auto cwd = getInput(output);
if (!cmHasLiteralSuffix(cwd, "/Tests/CMakeLib")) {
std::cout << "Working directory was \"" << cwd
<< "\", expected to end in \"/Tests/CMakeLib\"" << std::endl;
@@ -499,7 +506,8 @@ bool testUVProcessChainCwdChanged(const char* helperCommand)
return false;
}
- auto cwd = getInput(*chain.OutputStream());
+ cmUVPipeIStream output(chain.GetLoop(), chain.OutputStream());
+ auto cwd = getInput(output);
if (!cmHasLiteralSuffix(cwd, "/Tests")) {
std::cout << "Working directory was \"" << cwd
<< "\", expected to end in \"/Tests\"" << std::endl;
@@ -633,7 +641,8 @@ bool testUVProcessChainInputFile(const char* helperCommand)
return false;
}
- std::string output = getInput(*chain.OutputStream());
+ cmUVPipeIStream stream(chain.GetLoop(), chain.OutputStream());
+ std::string output = getInput(stream);
if (output != "HELO WRD!") {
std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\""
<< std::endl;