CTest: Add options to limit output of passed and failed tests
Add ctest command-line options: --test-output-size-passed <n> --test-output-size-failed <n> to set the amount of test output to store in Test.xml as a command-line dashboard client.
This commit is contained in:
parent
6e3151f6cc
commit
fd47df4503
|
@ -302,6 +302,12 @@ Options
|
|||
``--test-command``
|
||||
The test to run with the --build-and-test option.
|
||||
|
||||
``--test-output-size-passed <size>``
|
||||
Limit the output for passed tests to <size> bytes.
|
||||
|
||||
``--test-output-size-failed <size>``
|
||||
Limit the output for failed tests to <size> bytes.
|
||||
|
||||
``--test-timeout``
|
||||
The time limit in seconds, internal use only.
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
ctest-custom-output-size
|
||||
------------------------
|
||||
|
||||
* :manual:`ctest(1)` learned options
|
||||
``--test-output-size-passed`` and ``--test-output-size-failed``
|
||||
to customize the limit on test output size submitted when
|
||||
running as a :ref:`Dashboard Client`.
|
|
@ -65,6 +65,11 @@ public:
|
|||
void SetMaxIndex(int n) {this->MaxIndex = n;}
|
||||
int GetMaxIndex() {return this->MaxIndex;}
|
||||
|
||||
void SetTestOutputSizePassed(int n)
|
||||
{ this->CustomMaximumPassedTestOutputSize = n; }
|
||||
void SetTestOutputSizeFailed(int n)
|
||||
{ this->CustomMaximumFailedTestOutputSize = n; }
|
||||
|
||||
///! pass the -I argument down
|
||||
void SetTestsToRunInformation(const char*);
|
||||
|
||||
|
|
|
@ -2165,7 +2165,46 @@ bool cmCTest::HandleCommandLineArguments(size_t &i,
|
|||
{
|
||||
this->OutputTestOutputOnTestFailure = true;
|
||||
}
|
||||
|
||||
if (this->CheckArgument(arg, "--test-output-size-passed") &&
|
||||
i < args.size() - 1)
|
||||
{
|
||||
i++;
|
||||
long outputSize;
|
||||
if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize))
|
||||
{
|
||||
if (cmCTestTestHandler *pCTestTestHandler =
|
||||
static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"]))
|
||||
{
|
||||
pCTestTestHandler->SetTestOutputSizePassed(int(outputSize));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cmCTestLog(this, WARNING,
|
||||
"Invalid value for '--test-output-size-passed': " <<
|
||||
args[i] << "\n");
|
||||
}
|
||||
}
|
||||
if (this->CheckArgument(arg, "--test-output-size-failed") &&
|
||||
i < args.size() - 1)
|
||||
{
|
||||
i++;
|
||||
long outputSize;
|
||||
if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize))
|
||||
{
|
||||
if (cmCTestTestHandler *pCTestTestHandler =
|
||||
static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"]))
|
||||
{
|
||||
pCTestTestHandler->SetTestOutputSizeFailed(int(outputSize));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cmCTestLog(this, WARNING,
|
||||
"Invalid value for '--test-output-size-failed': " <<
|
||||
args[i] << "\n");
|
||||
}
|
||||
}
|
||||
if(this->CheckArgument(arg, "-N", "--show-only"))
|
||||
{
|
||||
this->ShowOnly = true;
|
||||
|
|
|
@ -46,6 +46,10 @@ static const char * cmDocumentationOptions[][2] =
|
|||
{"--debug", "Displaying more verbose internals of CTest."},
|
||||
{"--output-on-failure", "Output anything outputted by the test program "
|
||||
"if the test should fail."},
|
||||
{"--test-output-size-passed <size>", "Limit the output for passed tests "
|
||||
"to <size> bytes"},
|
||||
{"--test-output-size-failed <size>", "Limit the output for failed tests "
|
||||
"to <size> bytes"},
|
||||
{"-F", "Enable failover."},
|
||||
{"-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the "
|
||||
"given number of jobs."},
|
||||
|
|
|
@ -108,3 +108,20 @@ run_TestLoad(test-load-invalid 'two')
|
|||
run_TestLoad(test-load-pass 10)
|
||||
|
||||
unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})
|
||||
|
||||
function(run_TestOutputSize)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestOutputSize)
|
||||
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(PassingTest \"${CMAKE_COMMAND}\" -E echo PassingTestOutput)
|
||||
add_test(FailingTest \"${CMAKE_COMMAND}\" -E no_such_command)
|
||||
")
|
||||
run_cmake_command(TestOutputSize
|
||||
${CMAKE_CTEST_COMMAND} -M Experimental -T Test
|
||||
--test-output-size-passed 10
|
||||
--test-output-size-failed 12
|
||||
)
|
||||
endfunction()
|
||||
run_TestOutputSize()
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
|
||||
if(test_xml_file)
|
||||
file(READ "${test_xml_file}" test_xml LIMIT 4096)
|
||||
if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>).*(<Test Status="failed">.*</Test>)]])
|
||||
set(test_passed "${CMAKE_MATCH_1}")
|
||||
set(test_failed "${CMAKE_MATCH_2}")
|
||||
else()
|
||||
set(RunCMake_TEST_FAILED "Test.xml does not contain a passed then failed test:\n ${test_xml}")
|
||||
endif()
|
||||
if(NOT "${test_passed}" MATCHES [[<Value>PassingTes\.\.\..*10 bytes]])
|
||||
set(RunCMake_TEST_FAILED "Test.xml passed test output not truncated at 10 bytes:\n ${test_passed}")
|
||||
elseif(NOT "${test_failed}" MATCHES [[<Value>CMake Error:\.\.\..*12 bytes]])
|
||||
set(RunCMake_TEST_FAILED "Test.xml failed test output not truncated at 12 bytes:\n ${test_failed}")
|
||||
endif()
|
||||
else()
|
||||
set(RunCMake_TEST_FAILED "Test.xml not found")
|
||||
endif()
|
|
@ -0,0 +1 @@
|
|||
.
|
|
@ -0,0 +1 @@
|
|||
Errors while running CTest
|
Loading…
Reference in New Issue