Update fmt check script, cleanup a few issues#11311
Conversation
| for (int i = 1; i <= nReportPeriods; i++) { | ||
| std::string ReportPeriod_Resilience_Summary = fmt::format( | ||
| "{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse); | ||
| "{} Resilience Summary for Reporting Period {}: {} {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse); |
There was a problem hiding this comment.
Found this issue. We might want to add a bit more here.
| format("...Reheat coil outlet node name = {}" + state.dataLoopNodes->NodeID(SupHeatCoilOutletNode))); | ||
| ShowContinueError(state, format("...UnitarySystem outlet node name = {}" + state.dataLoopNodes->NodeID(this->AirOutNode))); | ||
| format("...Reheat coil outlet node name = {}", state.dataLoopNodes->NodeID(SupHeatCoilOutletNode))); | ||
| ShowContinueError(state, format("...UnitarySystem outlet node name = {}", state.dataLoopNodes->NodeID(this->AirOutNode))); |
There was a problem hiding this comment.
I think this concatenates the strings instead of replacing the argument in the placeholder. Updated here.
| class TestCheckFormatStrings(unittest.TestCase): | ||
| PASS = 0 | ||
| FAIL = 1 | ||
|
|
||
| def test_valid_cases(self): | ||
| test_options = [ | ||
| 'format("{}", arg1)', | ||
| 'format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))', | ||
| 'fmt::format("PLR = {:7." + std::to_string(DecimalPrecision) + "F}", fmt::join(PLRArray, ","))', | ||
| 'format("...{} is < 2 {{C}}. Freezing could occur.", cNumericFields(17))', | ||
| 'format(R"({}="{}" invalid {}="{}" not found.)",\n CurrentModuleObject,\n ventSlab.Name,\n cAlphaFields(4),\n state.dataIPShortCut->cAlphaArgs(4))', | ||
| 'format("{}{}{}{}{}{}", "Occurs for Node=", NodeName, ", ObjectType=", ObjectType, ", ObjectName=", ObjectName)', | ||
| 'format("{}{}", RoutineName, "Node registered for both Parent and \"not\" Parent")' | ||
| 'format("{}\n", EnergyPlus::Constant::unitNames[(int)meter->units])' | ||
| ] | ||
|
|
||
| tmp_dir = Path(tempfile.mkdtemp()) | ||
| tmp_file = tmp_dir / "valid.cc" | ||
|
|
||
| with open(tmp_file, 'w') as f: | ||
| for line in test_options: | ||
| f.write(line) | ||
|
|
||
| self.assertEqual(self.PASS, check_format_statements([tmp_file])) | ||
|
|
||
| def test_invalid_cases(self): | ||
| test_options = [ | ||
| 'format("{}", arg1, arg2)', | ||
| 'format("{}{}=\"{}\"")', | ||
| ] | ||
|
|
||
| tmp_dir = Path(tempfile.mkdtemp()) | ||
| tmp_file = tmp_dir / "invalid.cc" | ||
|
|
||
| with open(tmp_file, 'w') as f: | ||
| for line in test_options: | ||
| f.write(line) | ||
|
|
||
| self.assertEqual(self.FAIL, check_format_statements([tmp_file])) |
There was a problem hiding this comment.
There's a bunch of parsing voodoo in this script. These tests seem to be enough to capture most of our format uses.
| std::string ReportPeriod_Resilience_Summary = fmt::format("{} Resilience Summary for Reporting Period {}: {} {}", | ||
| kw, | ||
| i, | ||
| ReportPeriodInputData(i).title, | ||
| ReportPeriodInputData(i).totalElectricityUse); |
There was a problem hiding this comment.
I ran regressions locally without issue, and CI similarly is not reporting any diffs here, which I assume means these lines are not being hit. Anyone care to comment on whether more should be added here?
There was a problem hiding this comment.
I think the resilience reports only run for annual simulations?
There was a problem hiding this comment.
Maybe. Just ran regressions forcing annual simulations on the following and there were no diffs.
1ZoneUncontrolled_Win_ResilienceReports_ReportingPeriod_AllTable.idf
1ZoneUncontrolled_Win_ASH55_Thermal_Comfort.idf
1ZoneEvapCooler_ReportPeriodPowerOutage.idf
1ZoneEvapCooler_ReportPeriodPowerOutage_naturalVent.idf
1ZoneUncontrolled_Win_ResilienceReports_ReportingPeriod.idf
1ZoneUncontrolled_Win_ResilienceReports.idf
|
Good enough for now on this, but we may need a follow-up issue on the resiliency tables. |
Pull request overview
While reviewing #11165, I noticed the code integrity check was failing due to a false positive on a new
formatstring. This PR updates the script to handle that new case and fixes a couple issues found during the process.Pull Request Author
Reviewer