mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
@@ -127,7 +127,8 @@ bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
|
||||
uv_pipe_open(pipe_writer, fds[1]);
|
||||
|
||||
uv_stdio_container_t stdio[3];
|
||||
stdio[0].flags = UV_IGNORE;
|
||||
stdio[0].flags = UV_INHERIT_FD;
|
||||
stdio[0].data.fd = 0;
|
||||
stdio[1].flags = UV_INHERIT_STREAM;
|
||||
stdio[1].data.stream = pipe_writer;
|
||||
stdio[2] = stdio[1];
|
||||
|
||||
@@ -368,7 +368,8 @@ add_RunCMake_test(FetchContent)
|
||||
if(NOT CMake_TEST_EXTERNAL_CMAKE)
|
||||
set(CTestCommandLine_ARGS -DTEST_AFFINITY=$<TARGET_FILE:testAffinity>)
|
||||
endif()
|
||||
add_RunCMake_test(CTestCommandLine)
|
||||
add_executable(print_stdin print_stdin.c)
|
||||
add_RunCMake_test(CTestCommandLine -DTEST_PRINT_STDIN=$<TARGET_FILE:print_stdin>)
|
||||
add_RunCMake_test(CacheNewline)
|
||||
# Only run this test on unix platforms that support
|
||||
# symbolic links
|
||||
|
||||
@@ -161,3 +161,15 @@ endfunction()
|
||||
if(TEST_AFFINITY)
|
||||
run_TestAffinity()
|
||||
endif()
|
||||
|
||||
function(run_TestStdin)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestStdin)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
|
||||
add_test(TestStdin \"${TEST_PRINT_STDIN}\")
|
||||
")
|
||||
run_cmake_command(TestStdin ${CMAKE_CTEST_COMMAND} -V)
|
||||
endfunction()
|
||||
run_TestStdin()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Content for TestStdin
|
||||
@@ -0,0 +1 @@
|
||||
Content for TestStdin
|
||||
@@ -65,6 +65,13 @@ function(run_cmake test)
|
||||
else()
|
||||
set(maybe_timeout "")
|
||||
endif()
|
||||
if(RunCMake-stdin-file AND EXISTS ${top_src}/${RunCMake-stdin-file})
|
||||
set(maybe_input_file INPUT_FILE ${top_src}/${RunCMake-stdin-file})
|
||||
elseif(EXISTS ${top_src}/${test}-stdin.txt)
|
||||
set(maybe_input_file INPUT_FILE ${top_src}/${test}-stdin.txt)
|
||||
else()
|
||||
set(maybe_input_file "")
|
||||
endif()
|
||||
if(RunCMake_TEST_COMMAND)
|
||||
execute_process(
|
||||
COMMAND ${RunCMake_TEST_COMMAND}
|
||||
@@ -74,6 +81,7 @@ function(run_cmake test)
|
||||
RESULT_VARIABLE actual_result
|
||||
ENCODING UTF8
|
||||
${maybe_timeout}
|
||||
${maybe_input_file}
|
||||
)
|
||||
else()
|
||||
if(RunCMake_GENERATOR_INSTANCE)
|
||||
@@ -96,6 +104,7 @@ function(run_cmake test)
|
||||
RESULT_VARIABLE actual_result
|
||||
ENCODING UTF8
|
||||
${maybe_timeout}
|
||||
${maybe_input_file}
|
||||
)
|
||||
endif()
|
||||
set(msg "")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[1024];
|
||||
size_t nIn = sizeof(buf);
|
||||
while (nIn == sizeof(buf)) {
|
||||
nIn = fread(buf, 1, sizeof(buf), stdin);
|
||||
if (nIn > 0) {
|
||||
size_t nOut;
|
||||
nOut = fwrite(buf, 1, nIn, stdout);
|
||||
if (nOut != nIn) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user