From 9270a02003a86cdb5025252f61a8baf4a40e2ddc Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 18 Oct 2022 13:17:49 -0400 Subject: CMakePresets.json: Add outputJUnitFile to test presets schema --- Source/cmCMakePresetsGraph.cxx | 5 +++++ Source/cmCMakePresetsGraph.h | 2 ++ Source/cmCMakePresetsGraphReadJSON.cxx | 5 +++++ Source/cmCMakePresetsGraphReadJSONTestPresets.cxx | 2 ++ 4 files changed, 14 insertions(+) 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 OutputOnFailure; cm::optional Quiet; std::string OutputLogFile; + std::string OutputJUnitFile; cm::optional LabelSummary; cm::optional SubprojectSummary; cm::optional 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, -- cgit v0.12