diff options
author | Peter Kuemmel <syntheticpp@gmx.net> | 2011-11-20 13:04:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-11-28 18:48:59 (GMT) |
commit | a087490697c416d429d30fdf389cca2f13d9d14e (patch) | |
tree | cad0b1147f3451b012f0b4d2cd474452721315fb /Tests/CMakeTests | |
parent | 6580434f16cf4c6db1fde6d804e95d40f27c0f45 (diff) | |
download | CMake-a087490697c416d429d30fdf389cca2f13d9d14e.zip CMake-a087490697c416d429d30fdf389cca2f13d9d14e.tar.gz CMake-a087490697c416d429d30fdf389cca2f13d9d14e.tar.bz2 |
Add NEWLINE_STYLE option to configure_file (#3957)
Diffstat (limited to 'Tests/CMakeTests')
5 files changed, 38 insertions, 0 deletions
diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake new file mode 100644 index 0000000..3b09eb0 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out COPYONLY NEWLINE_STYLE DOS) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake new file mode 100644 index 0000000..133a67a --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake new file mode 100644 index 0000000..b7e619c --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake @@ -0,0 +1,17 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) + +function(test_eol style in out) + file(WRITE ${file_name} "${in}") + configure_file(${file_name} ${file_name}.out NEWLINE_STYLE ${style}) + file(READ ${file_name}.out new HEX) + if(NOT "${new}" STREQUAL "${out}") + message(FATAL_ERROR "No ${style} line endings") + endif() +endfunction() + +test_eol(DOS "a\n" "610d0a") +test_eol(WIN32 "b\n" "620d0a") +test_eol(CRLF "c\n" "630d0a") + +test_eol(UNIX "d\n" "640a") +test_eol(LF "e\n" "650a") diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake new file mode 100644 index 0000000..e8887c1 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE FOO) diff --git a/Tests/CMakeTests/ConfigureFileTest.cmake.in b/Tests/CMakeTests/ConfigureFileTest.cmake.in index c78a470..6cc61d9 100644 --- a/Tests/CMakeTests/ConfigureFileTest.cmake.in +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -6,6 +6,14 @@ set(Relative-RESULT 0) set(Relative-STDERR "Relative test file") set(BadArg-RESULT 1) set(BadArg-STDERR "called with incorrect number of arguments") +set(NewLineStyle-NoArg-RESULT 1) +set(NewLineStyle-NoArg-STDERR "NEWLINE_STYLE must set a style:") +set(NewLineStyle-WrongArg-RESULT 1) +set(NewLineStyle-WrongArg-STDERR "NEWLINE_STYLE sets an unknown style") +set(NewLineStyle-ValidArg-RESULT 0) +set(NewLineStyle-ValidArg-STDERR ) +set(NewLineStyle-COPYONLY-RESULT 1) +set(NewLineStyle-COPYONLY-STDERR "COPYONLY could not be used in combination") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(ConfigureFile @@ -13,4 +21,8 @@ check_cmake_test(ConfigureFile DirOutput Relative BadArg + NewLineStyle-NoArg + NewLineStyle-WrongArg + NewLineStyle-ValidArg + NewLineStyle-COPYONLY ) |