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:
parent
4a382aa8dd
commit
49e9f817de
@ -702,13 +702,23 @@ void cmCTestTestHandler::LogFailedTests(const std::vector<std::string>& failed,
|
||||
if (this->GetTestStatus(ft) == "Not Run") {
|
||||
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(
|
||||
this->CTest, HANDLER_OUTPUT,
|
||||
"\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
|
||||
<< ft.TestCount << " - " << ft.Name << " ("
|
||||
<< this->GetTestStatus(ft) << ")"
|
||||
<< ft.TestCount << " - " << ft_name_and_status
|
||||
<< this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
|
||||
<< std::endl);
|
||||
<< labels << std::endl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
Tests/RunCMake/CTestCommandLine/FailureLabels-result.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/FailureLabels-result.txt
Normal file
@ -0,0 +1 @@
|
||||
8
|
1
Tests/RunCMake/CTestCommandLine/FailureLabels-stderr.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/FailureLabels-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
Errors while running CTest
|
4
Tests/RunCMake/CTestCommandLine/FailureLabels-stdout.txt
Normal file
4
Tests/RunCMake/CTestCommandLine/FailureLabels-stdout.txt
Normal file
@ -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)
|
||||
|
||||
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
|
||||
${CMAKE_CTEST_COMMAND} --repeat until-pass
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user