From 229b67a2499586a9aaf54d3d5a88fee7a3f37e2c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Sep 2009 15:09:58 -0400 Subject: Create CMake.ConfigureFile test for configure_file This test checks that configure_file() handles input and output file arguments as documented. --- Tests/CMakeTests/CMakeLists.txt | 1 + Tests/CMakeTests/ConfigureFile-BadArg.cmake | 1 + Tests/CMakeTests/ConfigureFile-DirInput.cmake | 1 + Tests/CMakeTests/ConfigureFile-DirOutput.cmake | 5 +++++ Tests/CMakeTests/ConfigureFile-Relative.cmake | 4 ++++ Tests/CMakeTests/ConfigureFileTest.cmake.in | 16 ++++++++++++++++ 6 files changed, 28 insertions(+) create mode 100644 Tests/CMakeTests/ConfigureFile-BadArg.cmake create mode 100644 Tests/CMakeTests/ConfigureFile-DirInput.cmake create mode 100644 Tests/CMakeTests/ConfigureFile-DirOutput.cmake create mode 100644 Tests/CMakeTests/ConfigureFile-Relative.cmake create mode 100644 Tests/CMakeTests/ConfigureFileTest.cmake.in diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 2d57dd0..e693996 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -18,6 +18,7 @@ AddCMakeTest(GetFilenameComponentRealpath "") AddCMakeTest(Version "") AddCMakeTest(Message "") AddCMakeTest(File "") +AddCMakeTest(ConfigureFile "") AddCMakeTest(SeparateArguments "") AddCMakeTest(ImplicitLinkInfo "") diff --git a/Tests/CMakeTests/ConfigureFile-BadArg.cmake b/Tests/CMakeTests/ConfigureFile-BadArg.cmake new file mode 100644 index 0000000..769fae1 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-BadArg.cmake @@ -0,0 +1 @@ +configure_file(.) diff --git a/Tests/CMakeTests/ConfigureFile-DirInput.cmake b/Tests/CMakeTests/ConfigureFile-DirInput.cmake new file mode 100644 index 0000000..920ea28 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-DirInput.cmake @@ -0,0 +1 @@ +configure_file(. .) diff --git a/Tests/CMakeTests/ConfigureFile-DirOutput.cmake b/Tests/CMakeTests/ConfigureFile-DirOutput.cmake new file mode 100644 index 0000000..d682a2d --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-DirOutput.cmake @@ -0,0 +1,5 @@ +file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-DirOutput.txt "DirOutput test file\n") +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ConfigureFile-DirOutput) +configure_file(ConfigureFile-DirOutput.txt ConfigureFile-DirOutput) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/ConfigureFile-DirOutput/ConfigureFile-DirOutput.txt out) +message("${out}") diff --git a/Tests/CMakeTests/ConfigureFile-Relative.cmake b/Tests/CMakeTests/ConfigureFile-Relative.cmake new file mode 100644 index 0000000..532580a --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-Relative.cmake @@ -0,0 +1,4 @@ +file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-Relative-In.txt "Relative test file\n") +configure_file(ConfigureFile-Relative-In.txt ConfigureFile-Relative-Out.txt) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/ConfigureFile-Relative-Out.txt out) +message("${out}") diff --git a/Tests/CMakeTests/ConfigureFileTest.cmake.in b/Tests/CMakeTests/ConfigureFileTest.cmake.in new file mode 100644 index 0000000..c78a470 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -0,0 +1,16 @@ +set(DirInput-RESULT 1) +set(DirInput-STDERR "is a directory") +set(DirOutput-RESULT 0) +set(DirOutput-STDERR "DirOutput test file") +set(Relative-RESULT 0) +set(Relative-STDERR "Relative test file") +set(BadArg-RESULT 1) +set(BadArg-STDERR "called with incorrect number of arguments") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(ConfigureFile + DirInput + DirOutput + Relative + BadArg + ) -- cgit v0.12