summaryrefslogtreecommitdiffstats
path: root/Tests/BuildDepends
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-06-13 20:26:50 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-06-13 20:26:50 (GMT)
commit92270d5bf8ea8cdf4db7cb5db12e32c7af1fe2fb (patch)
tree934c8f319a04adb80fa1083b5184cd4c9169a22b /Tests/BuildDepends
parent698ca6e9566aeb6bd324982f93dc8b2fae308a1e (diff)
downloadCMake-92270d5bf8ea8cdf4db7cb5db12e32c7af1fe2fb.zip
CMake-92270d5bf8ea8cdf4db7cb5db12e32c7af1fe2fb.tar.gz
CMake-92270d5bf8ea8cdf4db7cb5db12e32c7af1fe2fb.tar.bz2
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
Diffstat (limited to 'Tests/BuildDepends')
-rw-r--r--Tests/BuildDepends/CMakeLists.txt36
-rw-r--r--Tests/BuildDepends/Project/bar.cxx9
2 files changed, 32 insertions, 13 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 6acb844..dc3a475 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -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!")
diff --git a/Tests/BuildDepends/Project/bar.cxx b/Tests/BuildDepends/Project/bar.cxx
index 76e934f..25d8bd2 100644
--- a/Tests/BuildDepends/Project/bar.cxx
+++ b/Tests/BuildDepends/Project/bar.cxx
@@ -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;
}