Skip to content

Commit 27ca336

Browse files
committed
Update verbosity behavior in hierarchical tests.
1 parent ef60cbe commit 27ca336

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

‎tests/UnitTests/PhasorDynamics/SubsystemModelTests.hpp‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ namespace GridKit
116116
{
117117
TestStatus success = true;
118118

119-
const auto previous_verbosity = Log::verbosity();
120-
Log::setVerbosity(Log::Verbosity::EVERYTHING);
121-
Log::misc() << "Testing lookups of unknown components, branches and signals. "
122-
<< "Logged errors are expected.\n";
123-
Log::setVerbosity(previous_verbosity);
124-
125119
// Signal in subsystem C, added to any existing ones
126120
json input = readJson("SubsystemHierarchical.json");
127121
input["subsystems"][1]["subsystems"][0]["signals"].push_back({{"signal_id", 5}, {"name", "s"}});
@@ -147,12 +141,17 @@ namespace GridKit
147141
success *= top.getSignalNode(5) == c->getSignalNode(5);
148142

149143
// Unknown labels and IDs, and those only in a sibling subsystem
144+
const auto previous_verbosity = Log::verbosity();
145+
// Suppress expected errors from the failed lookups below.
146+
// Use EVERYTHING to inspect those diagnostics.
147+
Log::setVerbosity(Log::Verbosity::NONE);
150148
success *= componentLookupThrows(top, "LoadZ_2");
151149
success *= componentLookupThrows(*a, "LoadZ_1");
152150
success *= branchLookupThrows(top, "4");
153151
success *= branchLookupThrows(*a, "3");
154152
success *= signalLookupThrows(top, 6);
155153
success *= signalLookupThrows(*a, 5);
154+
Log::setVerbosity(previous_verbosity);
156155

157156
return success.report(__func__);
158157
}
@@ -165,10 +164,9 @@ namespace GridKit
165164
TestStatus success = true;
166165

167166
const auto previous_verbosity = Log::verbosity();
168-
Log::setVerbosity(Log::Verbosity::EVERYTHING);
169-
Log::misc() << "Testing that invalid hierarchies are rejected. "
170-
<< "Logged errors are expected.\n";
171-
Log::setVerbosity(previous_verbosity);
167+
// Suppress expected errors from the invalid hierarchies below.
168+
// Use EVERYTHING to inspect those diagnostics.
169+
Log::setVerbosity(Log::Verbosity::NONE);
172170

173171
const json hierarchical = readJson("SubsystemHierarchical.json");
174172
json input;
@@ -243,6 +241,7 @@ namespace GridKit
243241
input["subsystems"][1]["subsystems"][0]["level"] = 1;
244242
success *= constructionThrows(input);
245243

244+
Log::setVerbosity(previous_verbosity);
246245
return success.report(__func__);
247246
}
248247

@@ -262,10 +261,9 @@ namespace GridKit
262261

263262
b.setSystemBase(50.0, 100.0e6);
264263
const auto previous_verbosity = Log::verbosity();
265-
Log::setVerbosity(Log::Verbosity::EVERYTHING);
266-
Log::misc() << "Testing that a subsystem with different bases is rejected. "
267-
<< "Logged errors are expected.\n";
268-
Log::setVerbosity(previous_verbosity);
264+
// Suppress the expected error from the mismatched bases below.
265+
// Use EVERYTHING to inspect that diagnostic.
266+
Log::setVerbosity(Log::Verbosity::NONE);
269267
try
270268
{
271269
a.addSubsystem(&b);
@@ -274,6 +272,7 @@ namespace GridKit
274272
catch (const std::exception&)
275273
{
276274
}
275+
Log::setVerbosity(previous_verbosity);
277276

278277
// A gets the new bases from top, so B now fits.
279278
top.setSystemBase(50.0, 100.0e6);

0 commit comments

Comments
 (0)