diff options
author | Brad King <brad.king@kitware.com> | 2023-06-13 15:12:59 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-06-13 15:13:08 (GMT) |
commit | 09028bed4c8fe0fde6172bb2ca7783eea27ea89f (patch) | |
tree | f3ff78f048a638569ef6cf40efe352bd786c2c58 /Tests | |
parent | aa66b7fa738cdef4dcbeedb1da6b04c5bcef0413 (diff) | |
parent | e3297045467e7bb6389237e9ace2815abef61159 (diff) | |
download | CMake-09028bed4c8fe0fde6172bb2ca7783eea27ea89f.zip CMake-09028bed4c8fe0fde6172bb2ca7783eea27ea89f.tar.gz CMake-09028bed4c8fe0fde6172bb2ca7783eea27ea89f.tar.bz2 |
Merge topic 'cmuvprocesschain-input-file'
e329704546 cmUVProcessChain: Add support for SetExternalStream(Stream_INPUT)
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8552
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeLib/testUVProcessChain.cxx | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 5c14de2..b22d76d 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -63,6 +63,7 @@ if(WIN32) endif() configure_file(testXMLParser.h.in testXMLParser.h @ONLY) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testUVProcessChainInput.txt" "HELLO WORLD!") create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index e0a67e9..f3024dc 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -1,5 +1,6 @@ #include <algorithm> #include <csignal> +#include <cstdio> #include <functional> #include <iostream> #include <sstream> @@ -615,6 +616,33 @@ bool testUVProcessChainSpawnFail(const char* helperCommand) return true; } +bool testUVProcessChainInputFile(const char* helperCommand) +{ + std::unique_ptr<FILE, int (*)(FILE*)> f( + fopen("testUVProcessChainInput.txt", "rb"), fclose); + + cmUVProcessChainBuilder builder; + builder.AddCommand({ helperCommand, "dedup" }) + .SetExternalStream(cmUVProcessChainBuilder::Stream_INPUT, fileno(f.get())) + .SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT); + + auto chain = builder.Start(); + + if (!chain.Wait()) { + std::cout << "Wait() timed out" << std::endl; + return false; + } + + std::string output = getInput(*chain.OutputStream()); + if (output != "HELO WRD!") { + std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\"" + << std::endl; + return false; + } + + return true; +} + int testUVProcessChain(int argc, char** const argv) { if (argc < 2) { @@ -657,5 +685,10 @@ int testUVProcessChain(int argc, char** const argv) return -1; } + if (!testUVProcessChainInputFile(argv[1])) { + std::cout << "While executing testUVProcessChainInputFile().\n"; + return -1; + } + return 0; } |