mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
CTest: exit nonzero after message(SEND_ERROR|FATAL_ERROR)
Fixes: #21004
This commit is contained in:
@@ -819,14 +819,16 @@ void cmCTestTestHandler::CheckLabelFilter(cmCTestTestProperties& it)
|
||||
this->CheckLabelFilterExclude(it);
|
||||
}
|
||||
|
||||
void cmCTestTestHandler::ComputeTestList()
|
||||
bool cmCTestTestHandler::ComputeTestList()
|
||||
{
|
||||
this->TestList.clear(); // clear list of test
|
||||
this->GetListOfTests();
|
||||
if (!this->GetListOfTests()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->RerunFailed) {
|
||||
this->ComputeTestListForRerunFailed();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
|
||||
@@ -882,6 +884,7 @@ void cmCTestTestHandler::ComputeTestList()
|
||||
this->TestList = finalList;
|
||||
|
||||
this->UpdateMaxTestNameWidth();
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmCTestTestHandler::ComputeTestListForRerunFailed()
|
||||
@@ -1260,7 +1263,10 @@ bool cmCTestTestHandler::GetValue(const char* tag, std::string& value,
|
||||
bool cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
|
||||
std::vector<std::string>& failed)
|
||||
{
|
||||
this->ComputeTestList();
|
||||
if (!this->ComputeTestList()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->StartTest = this->CTest->CurrentTime();
|
||||
this->StartTestTime = std::chrono::system_clock::now();
|
||||
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||
@@ -1695,7 +1701,7 @@ bool cmCTestTestHandler::ParseResourceGroupsProperty(
|
||||
return lexer.ParseString(val);
|
||||
}
|
||||
|
||||
void cmCTestTestHandler::GetListOfTests()
|
||||
bool cmCTestTestHandler::GetListOfTests()
|
||||
{
|
||||
if (!this->IncludeLabelRegExp.empty()) {
|
||||
this->IncludeLabelRegularExpression.compile(
|
||||
@@ -1748,14 +1754,15 @@ void cmCTestTestHandler::GetListOfTests()
|
||||
// does the DartTestfile.txt exist ?
|
||||
testFilename = "DartTestfile.txt";
|
||||
} else {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mf.ReadListFile(testFilename)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (cmSystemTools::GetErrorOccuredFlag()) {
|
||||
return;
|
||||
// SEND_ERROR or FATAL_ERROR in CTestTestfile or TEST_INCLUDE_FILES
|
||||
return false;
|
||||
}
|
||||
const char* specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE");
|
||||
if (this->ResourceSpecFile.empty() && specFile) {
|
||||
@@ -1764,6 +1771,7 @@ void cmCTestTestHandler::GetListOfTests()
|
||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Done constructing a list of tests" << std::endl,
|
||||
this->Quiet);
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmCTestTestHandler::UseIncludeRegExp()
|
||||
|
@@ -286,10 +286,10 @@ private:
|
||||
/**
|
||||
* Get the list of tests in directory and subdirectories.
|
||||
*/
|
||||
void GetListOfTests();
|
||||
bool GetListOfTests();
|
||||
// compute the lists of tests that will actually run
|
||||
// based on union regex and -I stuff
|
||||
void ComputeTestList();
|
||||
bool ComputeTestList();
|
||||
|
||||
// compute the lists of tests that will actually run
|
||||
// based on LastTestFailed.log
|
||||
|
@@ -704,8 +704,7 @@ bool cmCTest::UpdateCTestConfiguration()
|
||||
if (!cmSystemTools::FileExists(fileName)) {
|
||||
// No need to exit if we are not producing XML
|
||||
if (this->Impl->ProduceXML) {
|
||||
cmCTestLog(this, ERROR_MESSAGE,
|
||||
"Cannot find file: " << fileName << std::endl);
|
||||
cmCTestLog(this, WARNING, "Cannot find file: " << fileName << std::endl);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@@ -18,3 +18,12 @@ function(run_CMakeCTestArguments)
|
||||
run_cmake_command(CMakeCTestArguments-test ${CMAKE_COMMAND} --build . --config Debug --target "${test}")
|
||||
endfunction()
|
||||
run_CMakeCTestArguments()
|
||||
|
||||
function(run_TestfileErrors)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestfileErrors-build)
|
||||
run_cmake(TestfileErrors)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_command(TestfileErrors-build ${CMAKE_COMMAND} --build . --config Debug)
|
||||
run_cmake_command(TestfileErrors-test ${CMAKE_CTEST_COMMAND} -C Debug)
|
||||
endfunction()
|
||||
run_TestfileErrors()
|
||||
|
4
Tests/RunCMake/CTest/TestfileErrors-Script.cmake
Normal file
4
Tests/RunCMake/CTest/TestfileErrors-Script.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
message(SEND_ERROR "SEND_ERROR")
|
||||
message(FATAL_ERROR "FATAL_ERROR")
|
||||
# This shouldn't get printed because the script aborts on FATAL_ERROR
|
||||
message(SEND_ERROR "reaching the unreachable")
|
1
Tests/RunCMake/CTest/TestfileErrors-test-result.txt
Normal file
1
Tests/RunCMake/CTest/TestfileErrors-test-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
[^0]
|
11
Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt
Normal file
11
Tests/RunCMake/CTest/TestfileErrors-test-stderr.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
CMake Error at [^
|
||||
]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:1 \(message\):
|
||||
SEND_ERROR
|
||||
Call Stack \(most recent call first\):
|
||||
CTestTestfile.cmake:[0-9]+ \(include\)
|
||||
+
|
||||
CMake Error at [^
|
||||
]*/Tests/RunCMake/CTest/TestfileErrors-Script.cmake:2 \(message\):
|
||||
FATAL_ERROR
|
||||
Call Stack \(most recent call first\):
|
||||
CTestTestfile.cmake:[0-9]+ \(include\)
|
3
Tests/RunCMake/CTest/TestfileErrors.cmake
Normal file
3
Tests/RunCMake/CTest/TestfileErrors.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
include(CTest)
|
||||
add_test(NAME "unreachable" COMMAND ${CMAKE_COMMAND} -E true)
|
||||
set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/TestfileErrors-Script.cmake)
|
@@ -0,0 +1 @@
|
||||
[^0]
|
@@ -1,4 +1,4 @@
|
||||
^CMake Error at CTestTestfile.cmake:[0-9]+ \(subdirs\):
|
||||
subdirs called with incorrect number of arguments
|
||||
+
|
||||
No tests were found!!!$
|
||||
Errors while running CTest$
|
||||
|
@@ -1 +1,2 @@
|
||||
^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputSize/DartConfiguration.tcl
|
||||
Errors while running CTest
|
||||
|
@@ -0,0 +1 @@
|
||||
[^0]
|
@@ -0,0 +1 @@
|
||||
[^0]
|
@@ -2,4 +2,4 @@ CMake Error at CTestTestfile.cmake:[0-9]+:
|
||||
Parse error\. Function missing ending "\)"\. End of file reached\.
|
||||
|
||||
|
||||
No tests were found!!!
|
||||
Errors while running CTest
|
||||
|
@@ -0,0 +1 @@
|
||||
[^0]
|
@@ -0,0 +1 @@
|
||||
[^0]
|
@@ -2,4 +2,4 @@ CMake Error at CTestTestfile.cmake:[0-9]+:
|
||||
Parse error\. Function missing ending "\)"\. End of file reached\.
|
||||
|
||||
|
||||
No tests were found!!!
|
||||
Errors while running CTest
|
||||
|
@@ -0,0 +1 @@
|
||||
[^0]
|
Reference in New Issue
Block a user