mirror of
https://github.com/reactos/CMake.git
synced 2024-12-01 07:20:22 +00:00
Merge topic 'while-testing'
944b90b
add testcases for while()/endwhile() errorsf605b92
improve error message on a stray "endwhile()"
This commit is contained in:
commit
5012787c3c
@ -12,12 +12,21 @@
|
|||||||
#include "cmEndWhileCommand.h"
|
#include "cmEndWhileCommand.h"
|
||||||
|
|
||||||
bool cmEndWhileCommand
|
bool cmEndWhileCommand
|
||||||
::InvokeInitialPass(std::vector<cmListFileArgument> const&,
|
::InvokeInitialPass(std::vector<cmListFileArgument> const& args,
|
||||||
cmExecutionStatus &)
|
cmExecutionStatus &)
|
||||||
{
|
{
|
||||||
this->SetError("An ENDWHILE command was found outside of a proper "
|
if (args.empty())
|
||||||
"WHILE ENDWHILE structure. Or its arguments did not "
|
{
|
||||||
"match the opening WHILE command.");
|
this->SetError("An ENDWHILE command was found outside of a proper "
|
||||||
|
"WHILE ENDWHILE structure.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->SetError("An ENDWHILE command was found outside of a proper "
|
||||||
|
"WHILE ENDWHILE structure. Or its arguments did not "
|
||||||
|
"match the opening WHILE command.");
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
* Override cmCommand::InvokeInitialPass to get arguments before
|
* Override cmCommand::InvokeInitialPass to get arguments before
|
||||||
* expansion.
|
* expansion.
|
||||||
*/
|
*/
|
||||||
virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
|
virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const& args,
|
||||||
cmExecutionStatus &status);
|
cmExecutionStatus &status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,7 @@ AddCMakeTest(CMakeMinimumRequired "")
|
|||||||
AddCMakeTest(CompilerIdVendor "")
|
AddCMakeTest(CompilerIdVendor "")
|
||||||
AddCMakeTest(ProcessorCount "")
|
AddCMakeTest(ProcessorCount "")
|
||||||
AddCMakeTest(PushCheckState "")
|
AddCMakeTest(PushCheckState "")
|
||||||
|
AddCMakeTest(While "")
|
||||||
|
|
||||||
AddCMakeTest(FileDownload "")
|
AddCMakeTest(FileDownload "")
|
||||||
set_property(TEST CMake.FileDownload PROPERTY
|
set_property(TEST CMake.FileDownload PROPERTY
|
||||||
|
1
Tests/CMakeTests/While-Endwhile-Alone-Args.cmake
Normal file
1
Tests/CMakeTests/While-Endwhile-Alone-Args.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
endwhile(a)
|
1
Tests/CMakeTests/While-Endwhile-Alone.cmake
Normal file
1
Tests/CMakeTests/While-Endwhile-Alone.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
endwhile()
|
2
Tests/CMakeTests/While-Endwhile-Mismatch.cmake
Normal file
2
Tests/CMakeTests/While-Endwhile-Mismatch.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
while(a)
|
||||||
|
endwhile(b)
|
1
Tests/CMakeTests/While-Missing-Argument.cmake
Normal file
1
Tests/CMakeTests/While-Missing-Argument.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
while()
|
1
Tests/CMakeTests/While-Missing-Endwhile.cmake
Normal file
1
Tests/CMakeTests/While-Missing-Endwhile.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
while(a)
|
53
Tests/CMakeTests/WhileTest.cmake.in
Normal file
53
Tests/CMakeTests/WhileTest.cmake.in
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
set(NUMBERS "")
|
||||||
|
set(COUNT 0)
|
||||||
|
|
||||||
|
while(COUNT LESS 200)
|
||||||
|
set(NUMBERS "${NUMBERS} ${COUNT}")
|
||||||
|
set(COUNT "2${COUNT}")
|
||||||
|
|
||||||
|
set(NCOUNT 3)
|
||||||
|
while(NCOUNT LESS 31)
|
||||||
|
set(NUMBERS "${NUMBERS} ${NCOUNT}")
|
||||||
|
set(NCOUNT "${NCOUNT}0")
|
||||||
|
endwhile()
|
||||||
|
endwhile(COUNT LESS 200)
|
||||||
|
|
||||||
|
if(NOT NUMBERS STREQUAL " 0 3 30 20 3 30")
|
||||||
|
message(SEND_ERROR "while loop nesting error, result: '${NUMBERS}'")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(Missing-Argument-RESULT 1)
|
||||||
|
set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Missing-Argument.cmake:1 \\(while\\):.*while called with incorrect number of arguments.*")
|
||||||
|
|
||||||
|
include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake")
|
||||||
|
check_cmake_test(While
|
||||||
|
Missing-Argument
|
||||||
|
)
|
||||||
|
|
||||||
|
set(Missing-Endwhile-RESULT 1)
|
||||||
|
set(Missing-Endwhile-STDERR ".*CMake Error in (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Missing-Endwhile.cmake:.*A logical block opening on the line.*(@CMAKE_CURRENT_SOURCE_DIR@/)?While-Missing-Endwhile.cmake:1 \\(while\\).*is not closed\\..*")
|
||||||
|
|
||||||
|
check_cmake_test(While
|
||||||
|
Missing-Endwhile
|
||||||
|
)
|
||||||
|
|
||||||
|
set(Endwhile-Mismatch-RESULT 0)
|
||||||
|
set(Endwhile-Mismatch-STDERR ".*CMake Warning \\(dev\\) in (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Mismatch.cmake:.*A logical block opening on the line.*(@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Mismatch.cmake:1 \\(while\\).*with mis-matching arguments\\..*")
|
||||||
|
|
||||||
|
check_cmake_test(While
|
||||||
|
Endwhile-Mismatch
|
||||||
|
)
|
||||||
|
|
||||||
|
set(Endwhile-Alone-RESULT 1)
|
||||||
|
set(Endwhile-Alone-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Alone.cmake:1 \\(endwhile\\):.*An ENDWHILE command was found outside of a proper WHILE ENDWHILE.*structure\\.\n.*$")
|
||||||
|
|
||||||
|
check_cmake_test(While
|
||||||
|
Endwhile-Alone
|
||||||
|
)
|
||||||
|
|
||||||
|
set(Endwhile-Alone-Args-RESULT 1)
|
||||||
|
set(Endwhile-Alone-Args-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Alone-Args.cmake:1 \\(endwhile\\):.*An ENDWHILE command was found outside of a proper WHILE ENDWHILE.*structure\\. Or its arguments did not.*$")
|
||||||
|
|
||||||
|
check_cmake_test(While
|
||||||
|
Endwhile-Alone-Args
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user