mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 04:40:18 -05:00
ctest: Display test labels in failure summary
In a complex test environment, there may be a desire to add a test
property label to indicate context. Here is one such example:
set_property(TEST mygoofytest PROPERTY LABELS might-fail-on-config-change)
Upon looking at the failed test summary, one can quickly decide whether
the failure might be expected or not.
198 - mygoofytest (Failed) might-fail-on-config-change
This commit is contained in:
@@ -702,13 +702,23 @@ void cmCTestTestHandler::LogFailedTests(const std::vector<std::string>& failed,
|
|||||||
if (this->GetTestStatus(ft) == "Not Run") {
|
if (this->GetTestStatus(ft) == "Not Run") {
|
||||||
testColor = cmCTest::Color::YELLOW;
|
testColor = cmCTest::Color::YELLOW;
|
||||||
}
|
}
|
||||||
|
std::string ft_name_and_status =
|
||||||
|
cmStrCat(ft.Name, " (", this->GetTestStatus(ft), ")");
|
||||||
|
std::string labels;
|
||||||
|
const cmCTestTestProperties& p = *ft.Properties;
|
||||||
|
if (!p.Labels.empty()) {
|
||||||
|
static size_t const maxLen = 50;
|
||||||
|
size_t const ns = ft_name_and_status.size() >= maxLen
|
||||||
|
? 1
|
||||||
|
: maxLen - ft_name_and_status.size();
|
||||||
|
labels = cmStrCat(std::string(ns, ' '), cmJoin(p.Labels, " "));
|
||||||
|
}
|
||||||
cmCTestLog(
|
cmCTestLog(
|
||||||
this->CTest, HANDLER_OUTPUT,
|
this->CTest, HANDLER_OUTPUT,
|
||||||
"\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
|
"\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
|
||||||
<< ft.TestCount << " - " << ft.Name << " ("
|
<< ft.TestCount << " - " << ft_name_and_status
|
||||||
<< this->GetTestStatus(ft) << ")"
|
|
||||||
<< this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
|
<< this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
|
||||||
<< std::endl);
|
<< labels << std::endl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
8
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Errors while running CTest
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
The following tests FAILED:
|
||||||
|
[ ]+1 - ShortName \(Failed\) Label1 Label2
|
||||||
|
[ ]+2 - LongerName \(Failed\) Label3
|
||||||
|
[ ]+3 - Long_Test_Name_That_Is_Over_Fifty_Characters_In_Length \(Failed\) Label4
|
||||||
@@ -7,6 +7,22 @@ set(ENV{no_proxy} "$ENV{no_proxy},badhostname.invalid")
|
|||||||
|
|
||||||
set(RunCMake_TEST_TIMEOUT 60)
|
set(RunCMake_TEST_TIMEOUT 60)
|
||||||
|
|
||||||
|
block()
|
||||||
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/FailureLabels)
|
||||||
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
|
||||||
|
add_test(ShortName \"${CMAKE_COMMAND}\" -E false)
|
||||||
|
set_tests_properties(ShortName PROPERTIES LABELS \"Label1;Label2\")
|
||||||
|
add_test(LongerName \"${CMAKE_COMMAND}\" -E false)
|
||||||
|
set_tests_properties(LongerName PROPERTIES LABELS \"Label3\")
|
||||||
|
add_test(Long_Test_Name_That_Is_Over_Fifty_Characters_In_Length \"${CMAKE_COMMAND}\" -E false)
|
||||||
|
set_tests_properties(Long_Test_Name_That_Is_Over_Fifty_Characters_In_Length PROPERTIES LABELS \"Label4\")
|
||||||
|
")
|
||||||
|
run_cmake_command(FailureLabels ${CMAKE_CTEST_COMMAND})
|
||||||
|
endblock()
|
||||||
|
|
||||||
run_cmake_command(repeat-opt-bad1
|
run_cmake_command(repeat-opt-bad1
|
||||||
${CMAKE_CTEST_COMMAND} --repeat until-pass
|
${CMAKE_CTEST_COMMAND} --repeat until-pass
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user