mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
ctest: report make-level errors to CDash when using launchers
Fixes: #19545
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "cmsys/Process.h"
|
||||
|
||||
#include "cmCTest.h"
|
||||
#include "cmCTestLaunchReporter.h"
|
||||
#include "cmDuration.h"
|
||||
#include "cmFileTimeCache.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
@@ -887,15 +888,28 @@ int cmCTestBuildHandler::RunMakeCommand(const std::string& command,
|
||||
if (*retVal) {
|
||||
// If there was an error running command, report that on the
|
||||
// dashboard.
|
||||
cmCTestBuildErrorWarning errorwarning;
|
||||
errorwarning.LogLine = 1;
|
||||
errorwarning.Text = cmStrCat(
|
||||
"*** WARNING non-zero return value in ctest from: ", argv[0]);
|
||||
errorwarning.PreContext.clear();
|
||||
errorwarning.PostContext.clear();
|
||||
errorwarning.Error = false;
|
||||
this->ErrorsAndWarnings.push_back(std::move(errorwarning));
|
||||
this->TotalWarnings++;
|
||||
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();
|
||||
} else {
|
||||
cmCTestBuildErrorWarning errorwarning;
|
||||
errorwarning.LogLine = 1;
|
||||
errorwarning.Text = cmStrCat(
|
||||
"*** WARNING non-zero return value in ctest from: ", argv[0]);
|
||||
errorwarning.PreContext.clear();
|
||||
errorwarning.PostContext.clear();
|
||||
errorwarning.Error = false;
|
||||
this->ErrorsAndWarnings.push_back(std::move(errorwarning));
|
||||
this->TotalWarnings++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (result == cmsysProcess_State_Exception) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "cmCTest.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
cmCTestGenericHandler::cmCTestGenericHandler()
|
||||
@@ -122,6 +123,8 @@ bool cmCTestGenericHandler::StartLogFile(const char* name,
|
||||
ostr << "_" << this->CTest->GetCurrentTag();
|
||||
}
|
||||
ostr << ".log";
|
||||
this->LogFileNames[name] =
|
||||
cmStrCat(this->CTest->GetBinaryDir(), "/Testing/Temporary/", ostr.str());
|
||||
if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) {
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Cannot create log file: " << ostr.str() << std::endl);
|
||||
|
||||
@@ -100,6 +100,7 @@ protected:
|
||||
cmCTest* CTest;
|
||||
t_StringToString Options;
|
||||
t_StringToString PersistentOptions;
|
||||
t_StringToString LogFileNames;
|
||||
|
||||
cmCTestCommand* Command;
|
||||
int SubmitIndex;
|
||||
|
||||
@@ -311,7 +311,11 @@ add_RunCMake_test(cmake_parse_arguments)
|
||||
add_RunCMake_test(cmake_path)
|
||||
add_RunCMake_test(continue)
|
||||
add_executable(color_warning color_warning.c)
|
||||
add_RunCMake_test(ctest_build -DCOLOR_WARNING=$<TARGET_FILE:color_warning>)
|
||||
add_executable(fake_build_command fake_build_command.c)
|
||||
add_RunCMake_test(ctest_build
|
||||
-DCOLOR_WARNING=$<TARGET_FILE:color_warning>
|
||||
-DFAKE_BUILD_COMMAND_EXE=$<TARGET_FILE:fake_build_command>
|
||||
)
|
||||
add_RunCMake_test(ctest_cmake_error)
|
||||
add_RunCMake_test(ctest_configure)
|
||||
if(COVERAGE_COMMAND)
|
||||
|
||||
12
Tests/RunCMake/ctest_build/BuildCommandFailure-check.cmake
Normal file
12
Tests/RunCMake/ctest_build/BuildCommandFailure-check.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml")
|
||||
if(build_xml_file)
|
||||
file(READ "${build_xml_file}" build_xml LIMIT 4096)
|
||||
if(NOT build_xml MATCHES [[this command failed]])
|
||||
string(REPLACE "\n" "\n " build_xml " ${build_xml}")
|
||||
set(RunCMake_TEST_FAILED
|
||||
"Build.xml does not have expected error message:\n${build_xml}"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(RunCMake_TEST_FAILED "Build.xml not found")
|
||||
endif()
|
||||
@@ -0,0 +1 @@
|
||||
(-1|255)
|
||||
@@ -0,0 +1 @@
|
||||
^Error\(s\) when building project
|
||||
@@ -48,8 +48,12 @@ function(run_BuildChangeId)
|
||||
endfunction()
|
||||
run_BuildChangeId()
|
||||
|
||||
set(RunCMake_USE_LAUNCHERS FALSE)
|
||||
set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE)
|
||||
set(RunCMake_BUILD_COMMAND "${FAKE_BUILD_COMMAND_EXE}")
|
||||
run_ctest(BuildCommandFailure)
|
||||
unset(RunCMake_BUILD_COMMAND)
|
||||
|
||||
set(RunCMake_USE_LAUNCHERS FALSE)
|
||||
set(RunCMake_BUILD_COMMAND "${COLOR_WARNING}")
|
||||
run_ctest(IgnoreColor)
|
||||
unset(RunCMake_BUILD_COMMAND)
|
||||
|
||||
6
Tests/RunCMake/fake_build_command.c
Normal file
6
Tests/RunCMake/fake_build_command.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
printf("this command failed\n");
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user