From 45621c71f8f67279ce0d2726cc80bce4dacc236c Mon Sep 17 00:00:00 2001 From: Colby Nyce Date: Mon, 6 Jan 2025 14:34:24 -0600 Subject: [PATCH] Fix -arch-content bug in report yaml parser --- sparta/src/Report.cpp | 102 +++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/sparta/src/Report.cpp b/sparta/src/Report.cpp index a1e0dd39fe..5ade518c91 100644 --- a/sparta/src/Report.cpp +++ b/sparta/src/Report.cpp @@ -727,6 +727,10 @@ class ReportFileParserYAML std::stringstream ss; ss << "Unexpected key \"content\" within a \"content\" section"; addError_(ss.str()); + }else{ + if (!tryHandleArchContent_(key)) { + return false; + } } return true; // Handle normally }else{ @@ -753,51 +757,8 @@ class ReportFileParserYAML in_content_stack_.push(false); return false; }else{ - const auto idx = key.find("-arch-content"); - if (idx != std::string::npos) { - app::Simulation *sim = nullptr; - if (base_report_) { - if (auto ctx = base_report_->getContext()) { - sim = ctx->getSimulation(); - } - } - - if (!sim) { - throw SpartaException("Could not get the app::Simulation to parse key: ") << key; - } - - if (auto sim_config = sim->getSimulationConfiguration()) { - skip_content_leaves_ = true; - bool dash_arch_given = false; - for (const auto &kvp : sim_config->getRunMetadata()) { - if (kvp.first == "arch") { - dash_arch_given = true; - if (kvp.second + "-arch-content" == key) { - skip_content_leaves_ = false; - break; - } - } - } - - if (!dash_arch_given) { - skip_content_leaves_ = false; - verbose() << indent_() << "WARNING: You should consider using --arch at " - << "the command line together with the *-arch-content blocks " - << "in your report definition YAML file. This content block " - << "will be treated as normal (not filtered for --arch)." - << std::endl; - } - - if (skip_content_leaves_) { - verbose() << indent_() << "Skipping '" << key << "' block since it does " - << "not match the --arch given at the command line."; - } - - in_content_stack_.push(true); - return false; - } else { - throw SpartaException("Could not get the app::SimulationConfiguration to parse key: ") << key; - } + if (!tryHandleArchContent_(key)) { + return false; } //std::stringstream ss; @@ -958,6 +919,57 @@ class ReportFileParserYAML return true; // Handle normally } + bool tryHandleArchContent_(const std::string& key) { + const auto idx = key.find("-arch-content"); + if (idx != std::string::npos) { + app::Simulation *sim = nullptr; + if (base_report_) { + if (auto ctx = base_report_->getContext()) { + sim = ctx->getSimulation(); + } + } + + if (!sim) { + throw SpartaException("Could not get the app::Simulation to parse key: ") << key; + } + + if (auto sim_config = sim->getSimulationConfiguration()) { + skip_content_leaves_ = true; + bool dash_arch_given = false; + for (const auto &kvp : sim_config->getRunMetadata()) { + if (kvp.first == "arch") { + dash_arch_given = true; + if (kvp.second + "-arch-content" == key) { + skip_content_leaves_ = false; + break; + } + } + } + + if (!dash_arch_given) { + skip_content_leaves_ = false; + verbose() << indent_() << "WARNING: You should consider using --arch at " + << "the command line together with the *-arch-content blocks " + << "in your report definition YAML file. This content block " + << "will be treated as normal (not filtered for --arch)." + << std::endl; + } + + if (skip_content_leaves_) { + verbose() << indent_() << "Skipping '" << key << "' block since it does " + << "not match the --arch given at the command line."; + } + + in_content_stack_.push(true); + return false; + } else { + throw SpartaException("Could not get the app::SimulationConfiguration to parse key: ") << key; + } + } + + return true; + } + /*! * \brief Hanle next-node generation in a way that a next generation of * nodes is assigned specific new UIDs based on what report was created