diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2020-03-06 12:41:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-03-09 15:54:02 (GMT) |
commit | a6fee09484dd467028021e2c54e9791f1b6a0cd1 (patch) | |
tree | 1bda1bde6e6693c668a406781d23abfb57571dd2 /Tests/RunCMake/File_Configure | |
parent | 4a1baca6f79557c61aafd99ae3abed533afa11a2 (diff) | |
download | CMake-a6fee09484dd467028021e2c54e9791f1b6a0cd1.zip CMake-a6fee09484dd467028021e2c54e9791f1b6a0cd1.tar.gz CMake-a6fee09484dd467028021e2c54e9791f1b6a0cd1.tar.bz2 |
file: Add CONFIGURE subcommand
Extend the `file()` command with a new `CONFIGURE` subcommand that
behaves the same as `string(CONFIGURE)` except that it writes the
resulting output immediately to a file.
Fixes: #20388
Diffstat (limited to 'Tests/RunCMake/File_Configure')
21 files changed, 88 insertions, 0 deletions
diff --git a/Tests/RunCMake/File_Configure/BadArg-result.txt b/Tests/RunCMake/File_Configure/BadArg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Configure/BadArg-stderr.txt b/Tests/RunCMake/File_Configure/BadArg-stderr.txt new file mode 100644 index 0000000..5423a28 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArg-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadArg.cmake:[0-9]+ \(file\): + file Incorrect arguments to CONFIGURE subcommand. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArg.cmake b/Tests/RunCMake/File_Configure/BadArg.cmake new file mode 100644 index 0000000..7c7fcda --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArg.cmake @@ -0,0 +1 @@ +file(CONFIGURE OUTPUT) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt new file mode 100644 index 0000000..acda654 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at BadArgGeneratorExpressionContent.cmake:[0-9]+ \(file\): + file CONFIGURE called with CONTENT containing a "<". This character is not + allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake new file mode 100644 index 0000000..75fe9e5 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake @@ -0,0 +1,4 @@ +file(CONFIGURE + OUTPUT "file.txt" + CONTENT "foo-$<CONFIG>" +) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput-result.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput-stderr.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput-stderr.txt new file mode 100644 index 0000000..329d956 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at BadArgGeneratorExpressionOutput.cmake:[0-9]+ \(file\): + file CONFIGURE called with OUTPUT containing a "<". This character is not + allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput.cmake b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput.cmake new file mode 100644 index 0000000..31a79a7 --- /dev/null +++ b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionOutput.cmake @@ -0,0 +1,4 @@ +file(CONFIGURE + OUTPUT "file-$<CONFIG>.txt" + CONTENT "foo" +) diff --git a/Tests/RunCMake/File_Configure/CMakeLists.txt b/Tests/RunCMake/File_Configure/CMakeLists.txt new file mode 100644 index 0000000..b7117bd --- /dev/null +++ b/Tests/RunCMake/File_Configure/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.17) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/File_Configure/DirOutput-stderr.txt b/Tests/RunCMake/File_Configure/DirOutput-stderr.txt new file mode 100644 index 0000000..d051f7c --- /dev/null +++ b/Tests/RunCMake/File_Configure/DirOutput-stderr.txt @@ -0,0 +1 @@ +^DirOutput test file$ diff --git a/Tests/RunCMake/File_Configure/DirOutput.cmake b/Tests/RunCMake/File_Configure/DirOutput.cmake new file mode 100644 index 0000000..aa0fadf --- /dev/null +++ b/Tests/RunCMake/File_Configure/DirOutput.cmake @@ -0,0 +1,4 @@ +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DirOutput) +configure_file(DirOutput.txt DirOutput) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/DirOutput/DirOutput.txt out) +message("${out}") diff --git a/Tests/RunCMake/File_Configure/DirOutput.txt b/Tests/RunCMake/File_Configure/DirOutput.txt new file mode 100644 index 0000000..16388a6 --- /dev/null +++ b/Tests/RunCMake/File_Configure/DirOutput.txt @@ -0,0 +1 @@ +DirOutput test file diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-NoArg-result.txt b/Tests/RunCMake/File_Configure/NewLineStyle-NoArg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-NoArg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-NoArg-stderr.txt b/Tests/RunCMake/File_Configure/NewLineStyle-NoArg-stderr.txt new file mode 100644 index 0000000..5a8ed2c --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-NoArg-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NewLineStyle-NoArg.cmake:[0-9]+ \(file\): + file CONFIGURE NEWLINE_STYLE must set a style: LF, CRLF, UNIX, DOS, or + WIN32 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-NoArg.cmake b/Tests/RunCMake/File_Configure/NewLineStyle-NoArg.cmake new file mode 100644 index 0000000..d6738b4 --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-NoArg.cmake @@ -0,0 +1,6 @@ +set(file_name ${CMAKE_CURRENT_BINARY_DIR}/NewLineStyle.txt) +file(CONFIGURE + OUTPUT ${file_name} + CONTENT "Data\n" + NEWLINE_STYLE +) diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake b/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake new file mode 100644 index 0000000..e384873 --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake @@ -0,0 +1,20 @@ +set(file_name ${CMAKE_CURRENT_BINARY_DIR}/NewLineStyle.txt) + +function(test_eol style in out) + file(CONFIGURE + OUTPUT ${file_name} + CONTENT "@in@" + NEWLINE_STYLE ${style} + ) + file(READ ${file_name} new HEX) + if(NOT "${new}" STREQUAL "${out}") + message(FATAL_ERROR "No ${style} line endings") + endif() +endfunction() + +test_eol(DOS "a" "610d0a") +test_eol(WIN32 "b" "620d0a") +test_eol(CRLF "c" "630d0a") + +test_eol(UNIX "d" "640a") +test_eol(LF "e" "650a") diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg-result.txt b/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg-stderr.txt b/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg-stderr.txt new file mode 100644 index 0000000..c1bb42c --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NewLineStyle-WrongArg.cmake:[0-9]+ \(file\): + file CONFIGURE NEWLINE_STYLE sets an unknown style, only LF, CRLF, UNIX, + DOS, and WIN32 are supported +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg.cmake b/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg.cmake new file mode 100644 index 0000000..7d38167 --- /dev/null +++ b/Tests/RunCMake/File_Configure/NewLineStyle-WrongArg.cmake @@ -0,0 +1,6 @@ +set(file_name ${CMAKE_CURRENT_BINARY_DIR}/NewLineStyle.txt) +file(CONFIGURE + OUTPUT ${file_name} + CONTENT "Data\n" + NEWLINE_STYLE FOO +) diff --git a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake new file mode 100644 index 0000000..d09d648 --- /dev/null +++ b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(BadArg) +run_cmake(BadArgGeneratorExpressionContent) +run_cmake(BadArgGeneratorExpressionOutput) +run_cmake(DirOutput) +run_cmake(NewLineStyle-NoArg) +run_cmake(NewLineStyle-ValidArg) +run_cmake(NewLineStyle-WrongArg) |