summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-04-25 18:11:05 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-30 13:18:13 (GMT)
commit42e1cd137c0eff0297adaea5b34abca0da254eba (patch)
treecb0911144205f1bd269c157ed99c4bc2b630f0f2 /Tests
parent3c8226e590f252977e0ab79d7fe85b2fb9e7ef78 (diff)
downloadCMake-42e1cd137c0eff0297adaea5b34abca0da254eba.zip
CMake-42e1cd137c0eff0297adaea5b34abca0da254eba.tar.gz
CMake-42e1cd137c0eff0297adaea5b34abca0da254eba.tar.bz2
file(GENERATE): Only write the file if content is different.
No policy is used to control this behavior for now.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/File_Generate/RunCMakeTest.cmake27
-rw-r--r--Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt1
-rw-r--r--Tests/RunCMake/File_Generate/WriteIfDifferent.cmake5
4 files changed, 34 insertions, 0 deletions
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index f07431c..f23fa19 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -8,3 +8,30 @@ run_cmake(EmptyCondition1)
run_cmake(EmptyCondition2)
run_cmake(BadCondition)
run_cmake(DebugEvaluate)
+
+set(timeformat "%Y%j%H%M%S")
+
+file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt")
+set(RunCMake_TEST_FILE "WriteIfDifferent")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/WriteIfDifferent-build")
+run_cmake(WriteIfDifferent-prepare)
+unset(RunCMake_TEST_FILE)
+unset(RunCMake_TEST_BINARY_DIR)
+file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp ${timeformat})
+if(NOT timestamp)
+ message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
+
+set(RunCMake_TEST_NO_CLEAN ON)
+run_cmake(WriteIfDifferent)
+file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp_after ${timeformat})
+if(NOT timestamp_after)
+ message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
+endif()
+unset(RunCMake_TEST_NO_CLEAN)
+
+if (NOT timestamp_after STREQUAL timestamp)
+ message(SEND_ERROR "WriteIfDifferent changed output file.")
+endif()
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
new file mode 100644
index 0000000..d1d832a
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE
+ OUTPUT output_file.txt
+ CONTENT "123"
+)