summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-19 14:04:18 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-10-19 14:04:30 (GMT)
commit1cbf176b97c38347e5c710d2c3c43a16d7268bea (patch)
tree8fe67446bd092d2c29785884e63b8f5cbc49a75a /Source
parentc1f8d29f9ef133a5f640369a5e70ed2fc35227c5 (diff)
parentbea4ed543058ef36503503cda2adf669c09671f5 (diff)
downloadCMake-1cbf176b97c38347e5c710d2c3c43a16d7268bea.zip
CMake-1cbf176b97c38347e5c710d2c3c43a16d7268bea.tar.gz
CMake-1cbf176b97c38347e5c710d2c3c43a16d7268bea.tar.bz2
Merge topic 'cmake-presets-output-junit'
bea4ed5430 CTest: Add support for outputJUnitFile in presets 9270a02003 CMakePresets.json: Add outputJUnitFile to test presets schema 757786bb73 Tests: Add test for outputLogFile in CMakePresets.json b68c3596e7 CMakePresets.json: Disallow extra properties in test output schema Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: scivision <michael@scivision.dev> Merge-request: !7806
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakePresetsGraph.cxx5
-rw-r--r--Source/cmCMakePresetsGraph.h2
-rw-r--r--Source/cmCMakePresetsGraphReadJSON.cxx5
-rw-r--r--Source/cmCMakePresetsGraphReadJSONTestPresets.cxx2
-rw-r--r--Source/cmCTest.cxx18
-rw-r--r--Source/cmCTest.h3
6 files changed, 30 insertions, 5 deletions
diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx
index fb3d042..7325e44 100644
--- a/Source/cmCMakePresetsGraph.cxx
+++ b/Source/cmCMakePresetsGraph.cxx
@@ -265,6 +265,8 @@ bool ExpandMacros(const cmCMakePresetsGraph& graph, const TestPreset& preset,
if (out->Output) {
CHECK_EXPAND(out, out->Output->OutputLogFile, macroExpanders,
graph.GetVersion(preset));
+ CHECK_EXPAND(out, out->Output->OutputJUnitFile, macroExpanders,
+ graph.GetVersion(preset));
}
if (out->Filter) {
@@ -851,6 +853,7 @@ cmCMakePresetsGraph::TestPreset::VisitPresetInherit(
parentOutput.OutputOnFailure);
InheritOptionalValue(output.Quiet, parentOutput.Quiet);
InheritString(output.OutputLogFile, parentOutput.OutputLogFile);
+ InheritString(output.OutputJUnitFile, parentOutput.OutputJUnitFile);
InheritOptionalValue(output.LabelSummary, parentOutput.LabelSummary);
InheritOptionalValue(output.SubprojectSummary,
parentOutput.SubprojectSummary);
@@ -1253,6 +1256,8 @@ const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result)
return "Invalid workflow steps";
case ReadFileResult::WORKFLOW_STEP_UNREACHABLE_FROM_FILE:
return "Workflow step is unreachable from preset's file";
+ case ReadFileResult::CTEST_JUNIT_UNSUPPORTED:
+ return "File version must be 6 or higher for CTest JUnit output support";
}
return "Unknown error";
diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h
index 5b3e812..17c902b 100644
--- a/Source/cmCMakePresetsGraph.h
+++ b/Source/cmCMakePresetsGraph.h
@@ -54,6 +54,7 @@ public:
TEST_OUTPUT_TRUNCATION_UNSUPPORTED,
INVALID_WORKFLOW_STEPS,
WORKFLOW_STEP_UNREACHABLE_FROM_FILE,
+ CTEST_JUNIT_UNSUPPORTED,
};
std::string errors;
@@ -230,6 +231,7 @@ public:
cm::optional<bool> OutputOnFailure;
cm::optional<bool> Quiet;
std::string OutputLogFile;
+ std::string OutputJUnitFile;
cm::optional<bool> LabelSummary;
cm::optional<bool> SubprojectSummary;
cm::optional<int> MaxPassedTestOutputSize;
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index 5aa4284..eec53c1 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -588,6 +588,11 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile(
return ReadFileResult::TEST_OUTPUT_TRUNCATION_UNSUPPORTED;
}
+ // Support for outputJUnitFile added in version 6.
+ if (v < 6 && preset.Output && !preset.Output->OutputJUnitFile.empty()) {
+ return ReadFileResult::CTEST_JUNIT_UNSUPPORTED;
+ }
+
this->TestPresetOrder.push_back(preset.Name);
}
diff --git a/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx b/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx
index c07d380..3856f63 100644
--- a/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx
+++ b/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx
@@ -104,6 +104,8 @@ auto const TestPresetOptionalOutputHelper =
cmCMakePresetsGraphInternal::PresetOptionalBoolHelper, false)
.Bind("outputLogFile"_s, &TestPreset::OutputOptions::OutputLogFile,
cmCMakePresetsGraphInternal::PresetStringHelper, false)
+ .Bind("outputJUnitFile"_s, &TestPreset::OutputOptions::OutputJUnitFile,
+ cmCMakePresetsGraphInternal::PresetStringHelper, false)
.Bind("labelSummary"_s, &TestPreset::OutputOptions::LabelSummary,
cmCMakePresetsGraphInternal::PresetOptionalBoolHelper, false)
.Bind("subprojectSummary"_s,
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 66507a7..f60a1e9 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2116,11 +2116,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
return false;
}
i++;
- this->Impl->TestHandler.SetJUnitXMLFileName(std::string(args[i]));
- // Turn test output compression off.
- // This makes it easier to include test output in the resulting
- // JUnit XML report.
- this->Impl->CompressTestOutput = false;
+ this->SetOutputJUnitFileName(std::string(args[i]));
}
cm::string_view noTestsPrefix = "--no-tests=";
@@ -2458,6 +2454,9 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName,
if (!expandedPreset->Output->OutputLogFile.empty()) {
this->SetOutputLogFileName(expandedPreset->Output->OutputLogFile);
}
+ if (!expandedPreset->Output->OutputJUnitFile.empty()) {
+ this->SetOutputJUnitFileName(expandedPreset->Output->OutputJUnitFile);
+ }
this->Impl->LabelSummary =
expandedPreset->Output->LabelSummary.value_or(true);
@@ -3541,6 +3540,15 @@ void cmCTest::SetOutputLogFileName(const std::string& name)
}
}
+void cmCTest::SetOutputJUnitFileName(const std::string& name)
+{
+ this->Impl->TestHandler.SetJUnitXMLFileName(name);
+ // Turn test output compression off.
+ // This makes it easier to include test output in the resulting
+ // JUnit XML report.
+ this->Impl->CompressTestOutput = false;
+}
+
static const char* cmCTestStringLogType[] = { "DEBUG",
"OUTPUT",
"HANDLER_OUTPUT",
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 551c116..0017b3e 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -359,6 +359,9 @@ public:
/** Set the output log file name */
void SetOutputLogFileName(const std::string& name);
+ /** Set the output JUnit file name */
+ void SetOutputJUnitFileName(const std::string& name);
+
/** Set the visual studio or Xcode config type */
void SetConfigType(const std::string& ct);