mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-03 20:29:56 -06:00
ctest: only report make-level errors when no others are found
In commit ab9ad2a6a0 (ctest: report make-level errors to CDash when
using launchers, 2020-09-24, v3.19.0-rc1~84^2~1) we taught CTest to
capture and report errors from the build command when using launchers.
This had the unintended side effect of reporting a separate build error containing
the full build output when the build command returns non-zero. To fix this problem,
we now only report build command errors from CTest launchers when no other
more specific build errors are found.
Fixes: #23991
This commit is contained in:
committed by
Brad King
parent
e7fd69fa36
commit
65260d6c1e
@@ -893,16 +893,31 @@ int cmCTestBuildHandler::RunMakeCommand(const std::string& command,
|
||||
// If there was an error running command, report that on the
|
||||
// dashboard.
|
||||
if (this->UseCTestLaunch) {
|
||||
cmCTestLaunchReporter reporter;
|
||||
reporter.RealArgs = args;
|
||||
reporter.ComputeFileNames();
|
||||
reporter.ExitCode = *retVal;
|
||||
reporter.Process = cp;
|
||||
// Use temporary BuildLog file to populate this error for CDash.
|
||||
ofs.flush();
|
||||
reporter.LogOut = this->LogFileNames["Build"];
|
||||
reporter.LogOut += ".tmp";
|
||||
reporter.WriteXML();
|
||||
// For launchers, do not record this top-level error if other
|
||||
// more granular build errors have already been captured.
|
||||
bool launcherXMLFound = false;
|
||||
cmsys::Directory launchDir;
|
||||
launchDir.Load(this->CTestLaunchDir);
|
||||
unsigned long n = launchDir.GetNumberOfFiles();
|
||||
for (unsigned long i = 0; i < n; ++i) {
|
||||
const char* fname = launchDir.GetFile(i);
|
||||
if (cmHasLiteralSuffix(fname, ".xml")) {
|
||||
launcherXMLFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!launcherXMLFound) {
|
||||
cmCTestLaunchReporter reporter;
|
||||
reporter.RealArgs = args;
|
||||
reporter.ComputeFileNames();
|
||||
reporter.ExitCode = *retVal;
|
||||
reporter.Process = cp;
|
||||
// Use temporary BuildLog file to populate this error for CDash.
|
||||
ofs.flush();
|
||||
reporter.LogOut = this->LogFileNames["Build"];
|
||||
reporter.LogOut += ".tmp";
|
||||
reporter.WriteXML();
|
||||
}
|
||||
} else {
|
||||
cmCTestBuildErrorWarning errorwarning;
|
||||
errorwarning.LineNumber = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
@CASE_CMAKELISTS_PREFIX_CODE@
|
||||
project(CTestBuild@CASE_NAME@ NONE)
|
||||
project(CTestBuild@CASE_NAME@ @LANG@)
|
||||
include(CTest)
|
||||
add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version)
|
||||
@CASE_CMAKELISTS_SUFFIX_CODE@
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml")
|
||||
if(build_xml_file)
|
||||
file(READ "${build_xml_file}" build_xml LIMIT 8192)
|
||||
string(FIND "${build_xml}" [[This should not be compiled]] expected_failure_pos)
|
||||
if(expected_failure_pos EQUAL "-1")
|
||||
string(REPLACE "\n" "\n " build_xml " ${build_xml}")
|
||||
set(RunCMake_TEST_FAILED
|
||||
"Build.xml does not have expected error message:\n${build_xml}"
|
||||
)
|
||||
else()
|
||||
string(SUBSTRING "${build_xml}" "${expected_failure_pos}" -1 remaining_xml)
|
||||
string(FIND "${remaining_xml}" [[<Failure type="Error">]] unexpected_failure_pos)
|
||||
if(NOT unexpected_failure_pos EQUAL "-1")
|
||||
string(SUBSTRING "${remaining_xml}" "${unexpected_failure_pos}" -1 error_msg_xml)
|
||||
string(REPLACE "\n" "\n " error_msg_xml " ${error_msg_xml}")
|
||||
set(RunCMake_TEST_FAILED
|
||||
"Build.xml contains unexpected extra <Failure> elements:\n${error_msg_xml}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(RunCMake_TEST_FAILED "Build.xml not found")
|
||||
endif()
|
||||
@@ -0,0 +1 @@
|
||||
(-1|255)
|
||||
@@ -0,0 +1 @@
|
||||
^Error\(s\) when building project
|
||||
@@ -1,5 +1,6 @@
|
||||
include(RunCTest)
|
||||
|
||||
set(LANG NONE)
|
||||
set(CASE_CTEST_BUILD_ARGS "")
|
||||
set(RunCMake_USE_LAUNCHERS TRUE)
|
||||
set(RunCMake_USE_CUSTOM_BUILD_COMMAND FALSE)
|
||||
@@ -70,3 +71,18 @@ set(RunCMake_USE_LAUNCHERS FALSE)
|
||||
set(RunCMake_BUILD_COMMAND "${COLOR_WARNING}")
|
||||
run_ctest(IgnoreColor)
|
||||
unset(RunCMake_BUILD_COMMAND)
|
||||
|
||||
set(RunCMake_USE_CUSTOM_BUILD_COMMAND FALSE)
|
||||
if(RunCMake_GENERATOR MATCHES "Ninja")
|
||||
function(run_NinjaLauncherSingleBuildFailure)
|
||||
set(LANG C)
|
||||
set(RunCMake_USE_LAUNCHERS TRUE)
|
||||
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/NinjaLauncherSingleBuildFailure")
|
||||
configure_file("${RunCMake_SOURCE_DIR}/error.c" "${RunCMake_TEST_SOURCE_DIR}/error.c" COPYONLY)
|
||||
set(CASE_CMAKELISTS_SUFFIX_CODE [=[
|
||||
add_executable(error error.c)
|
||||
]=])
|
||||
run_ctest(NinjaLauncherSingleBuildFailure)
|
||||
endfunction()
|
||||
run_NinjaLauncherSingleBuildFailure()
|
||||
endif()
|
||||
|
||||
1
Tests/RunCMake/ctest_build/error.c
Normal file
1
Tests/RunCMake/ctest_build/error.c
Normal file
@@ -0,0 +1 @@
|
||||
#error "This should not be compiled"
|
||||
Reference in New Issue
Block a user