summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/File_Generate
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-04-25 20:11:05 +0200
committerStephen Kelly <steveire@gmail.com>2014-04-30 15:18:13 +0200
commit42e1cd137c0eff0297adaea5b34abca0da254eba (patch)
treecb0911144205f1bd269c157ed99c4bc2b630f0f2 /Tests/RunCMake/File_Generate
parent3c8226e590f252977e0ab79d7fe85b2fb9e7ef78 (diff)
downloadcmake-42e1cd137c0eff0297adaea5b34abca0da254eba.tar.gz
file(GENERATE): Only write the file if content is different.
No policy is used to control this behavior for now.
Diffstat (limited to 'Tests/RunCMake/File_Generate')
-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 f07431c0e7..f23fa1983d 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 0000000000..573541ac97
--- /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 0000000000..10f32932ee
--- /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 0000000000..d1d832a111
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE
+ OUTPUT output_file.txt
+ CONTENT "123"
+)