COMP: fix test, in some cases stdout from bar was not captured correctly,
probably because the process was killed before the fflush() worked because the busy loop blocked the processor (failing midworld test) Alex
This commit is contained in:
parent
698ca6e956
commit
92270d5bf8
|
@ -5,15 +5,20 @@
|
|||
# value. The subdir Project contains the CMakelists.txt
|
||||
# and source files for the test project.
|
||||
project(BuildDepends)
|
||||
make_directory(${BuildDepends_BINARY_DIR}/Project)
|
||||
|
||||
file(REMOVE_RECURSE ${BuildDepends_BINARY_DIR}/Project)
|
||||
file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project)
|
||||
message("Creating Project/foo.cxx")
|
||||
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
|
||||
"const char* foo() { return \"foo\";}" )
|
||||
|
||||
message("Building project first time")
|
||||
try_compile(RESULT
|
||||
${BuildDepends_BINARY_DIR}/Project
|
||||
${BuildDepends_SOURCE_DIR}/Project
|
||||
testRebuild
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
IF("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
try_compile(RESULT
|
||||
${BuildDepends_BINARY_DIR}/Project
|
||||
${BuildDepends_SOURCE_DIR}/Project
|
||||
|
@ -24,14 +29,13 @@ IF("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
|||
${BuildDepends_SOURCE_DIR}/Project
|
||||
testRebuild
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
ENDIF("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
|
||||
if(NOT RESULT)
|
||||
message(SEND_ERROR "Could not build test project: ${OUTPUT}")
|
||||
endif(NOT RESULT)
|
||||
|
||||
set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX})
|
||||
message("${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
if(EXISTS
|
||||
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" )
|
||||
message("found debug")
|
||||
|
@ -39,18 +43,27 @@ if(EXISTS
|
|||
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
endif(EXISTS
|
||||
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
message("running ${bar} ")
|
||||
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out TIMEOUT 3)
|
||||
|
||||
message("Running ${bar} ")
|
||||
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
|
||||
string(REGEX REPLACE "[\r\n]" " " out "${out}")
|
||||
message("${out}")
|
||||
message("Run result: ${runResult} Output: \"${out}\"")
|
||||
|
||||
if("${out}" STREQUAL "foo ")
|
||||
message("Worked!")
|
||||
else("${out}" STREQUAL "foo ")
|
||||
message(SEND_ERROR "Project did not initially build properly: ${out}")
|
||||
endif("${out}" STREQUAL "foo ")
|
||||
|
||||
message("Waiting 3 seconds...")
|
||||
# any additional argument will cause ${bar} to wait forever
|
||||
execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
|
||||
|
||||
message("Modifying Project/foo.cxx")
|
||||
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
|
||||
"const char* foo() { return \"foo changed\";}" )
|
||||
|
||||
message("Building project second time")
|
||||
try_compile(RESULT
|
||||
${BuildDepends_BINARY_DIR}/Project
|
||||
${BuildDepends_SOURCE_DIR}/Project
|
||||
|
@ -58,7 +71,7 @@ try_compile(RESULT
|
|||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
# Xcode is in serious need of help here
|
||||
IF("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
try_compile(RESULT
|
||||
${BuildDepends_BINARY_DIR}/Project
|
||||
${BuildDepends_SOURCE_DIR}/Project
|
||||
|
@ -69,7 +82,7 @@ IF("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
|||
${BuildDepends_SOURCE_DIR}/Project
|
||||
testRebuild
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
ENDIF("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
|
||||
if(NOT RESULT)
|
||||
message(SEND_ERROR "Could not build test project: ${OUTPUT}")
|
||||
|
@ -80,9 +93,10 @@ if(EXISTS
|
|||
endif(EXISTS
|
||||
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
|
||||
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out TIMEOUT 3)
|
||||
message("Running ${bar} ")
|
||||
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
|
||||
string(REGEX REPLACE "[\r\n]" " " out "${out}")
|
||||
message("${out}")
|
||||
message("Run result: ${runResult} Output: \"${out}\"")
|
||||
|
||||
if("${out}" STREQUAL "foo changed ")
|
||||
message("Worked!")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <regen.h>
|
||||
#include <noregen.h>
|
||||
|
||||
int main()
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
/* Make sure the noregen header was not regenerated. */
|
||||
if(strcmp("foo", noregen_string) != 0)
|
||||
|
@ -15,6 +15,11 @@ int main()
|
|||
/* Print out the string that should have been regenerated. */
|
||||
printf("%s\n", regen_string);
|
||||
fflush(stdout);
|
||||
for(;;);
|
||||
// if any argument is used, wait forever
|
||||
if (argc>1)
|
||||
{
|
||||
// wait that we get killed...
|
||||
for(;;);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue