From cbb861ade85e3b7e550bb1f150513b237efc1f02 Mon Sep 17 00:00:00 2001 From: Daniel Eiband Date: Sat, 21 Sep 2019 15:16:36 +0200 Subject: add_custom_command: Add tests for custom command output checks --- Source/cmAddCustomCommandCommand.cxx | 4 +-- .../add_custom_command/BadByproduct-result.txt | 1 + .../add_custom_command/BadByproduct-stderr.txt | 36 ++++++++++++++++++++++ .../RunCMake/add_custom_command/BadByproduct.cmake | 6 ++++ .../add_custom_command/BadOutput-result.txt | 1 + .../add_custom_command/BadOutput-stderr.txt | 36 ++++++++++++++++++++++ Tests/RunCMake/add_custom_command/BadOutput.cmake | 6 ++++ .../RunCMake/add_custom_command/RunCMakeTest.cmake | 2 ++ 8 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct-result.txt create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct.cmake create mode 100644 Tests/RunCMake/add_custom_command/BadOutput-result.txt create mode 100644 Tests/RunCMake/add_custom_command/BadOutput-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/BadOutput.cmake diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 35db6a4..defefaf 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -396,8 +396,8 @@ bool cmAddCustomCommandCommandCheckOutputs( // Make sure the file will not be generated into the source // directory during an out of source build. if (!mf.CanIWriteThisFile(o)) { - std::string e = "attempted to have a file \"" + o + - "\" in a source directory as an output of custom command."; + std::string e = "attempted to have a file\n\"" + o + + "\"\nin a source directory as an output of custom command."; status.SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-result.txt b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt new file mode 100644 index 0000000..6315c8b --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt @@ -0,0 +1,36 @@ +CMake Error at BadByproduct.cmake:2 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "#". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:3 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:4 \(add_custom_command\): + add_custom_command called with OUTPUT containing a ">". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:5 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:6 \(add_custom_command\): + add_custom_command attempted to have a file + + .*/f".* + + in a source directory as an output of custom command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/BadByproduct.cmake b/Tests/RunCMake/add_custom_command/BadByproduct.cmake new file mode 100644 index 0000000..91bca52 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadByproduct.cmake @@ -0,0 +1,6 @@ +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +add_custom_command(OUTPUT a BYPRODUCTS "a#") +add_custom_command(OUTPUT b BYPRODUCTS "a<") +add_custom_command(OUTPUT c BYPRODUCTS "a>") +add_custom_command(OUTPUT d BYPRODUCTS "$/#") +add_custom_command(OUTPUT e BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/f) diff --git a/Tests/RunCMake/add_custom_command/BadOutput-result.txt b/Tests/RunCMake/add_custom_command/BadOutput-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadOutput-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt new file mode 100644 index 0000000..584aa88 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt @@ -0,0 +1,36 @@ +CMake Error at BadOutput.cmake:2 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "#". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:3 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:4 \(add_custom_command\): + add_custom_command called with OUTPUT containing a ">". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:5 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:6 \(add_custom_command\): + add_custom_command attempted to have a file + + .*/e".* + + in a source directory as an output of custom command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/BadOutput.cmake b/Tests/RunCMake/add_custom_command/BadOutput.cmake new file mode 100644 index 0000000..6875fe9 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadOutput.cmake @@ -0,0 +1,6 @@ +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +add_custom_command(OUTPUT "a#" COMMAND a) +add_custom_command(OUTPUT "a<" COMMAND b) +add_custom_command(OUTPUT "a>" COMMAND c) +add_custom_command(OUTPUT "$/#" COMMAND d) +add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/e COMMAND f) diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 270df2f..96642fa 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -4,6 +4,8 @@ run_cmake(AppendLiteralQuotes) run_cmake(AppendNoOutput) run_cmake(AppendNotOutput) run_cmake(BadArgument) +run_cmake(BadByproduct) +run_cmake(BadOutput) run_cmake(GeneratedProperty) run_cmake(LiteralQuotes) run_cmake(NoArguments) -- cgit v0.12