GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 62.6% 424 / 0 / 677
Functions: 53.1% 43 / 0 / 81
Branches: 56.4% 597 / 0 / 1058

src/measure/OSRunner.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "OSRunner.hpp"
7
8 #include "OSArgument.hpp"
9 #include "OSMeasure.hpp"
10
11 #include "../utilities/core/Assert.hpp"
12 #include "../utilities/core/Containers.hpp"
13 #include "../utilities/core/PathHelpers.hpp"
14 #include "../utilities/core/StringHelpers.hpp"
15 #include "../utilities/filetypes/WorkflowStep.hpp"
16 #include "../utilities/filetypes/WorkflowStep_Impl.hpp"
17 #include "../utilities/idf/Workspace.hpp"
18 #include "../utilities/idf/WorkspaceObject.hpp"
19 #include "../utilities/math/FloatCompare.hpp"
20
21 #include <fmt/format.h>
22 #include <cstdio>
23 #include <cstdlib>
24
25 namespace openstudio {
26 namespace measure {
27
28 53 OSRunner::OSRunner(const WorkflowJSON& workflow)
29 53 : m_workflow(workflow),
30 53 m_startedStep(false),
31 53 m_streamsCaptured(false),
32
1/1
✓ Branch 1 taken 53 times.
106 m_unitsPreference("IP"),
33
1/1
✓ Branch 1 taken 53 times.
106 m_languagePreference("en"),
34 53 m_halted(false),
35 53 m_originalStdOut(nullptr),
36
5/5
✓ Branch 2 taken 53 times.
✓ Branch 14 taken 53 times.
✓ Branch 17 taken 53 times.
✓ Branch 22 taken 53 times.
✓ Branch 25 taken 53 times.
106 m_originalStdErr(nullptr) {}
37
38 59 OSRunner::~OSRunner() {
39 48 restoreStreams();
40 59 }
41
42 2 WorkflowJSON OSRunner::workflow() const {
43 // return a clone because the workflow is immutable
44 2 return m_workflow.clone();
45 }
46
47 26 alfalfa::AlfalfaJSON OSRunner::alfalfa() const {
48 26 return m_alfalfa;
49 }
50
51 ✗ ModelicaParameters OSRunner::modelicaParameters() const {
52 ✗ return m_modelicaParameters;
53 }
54
55 ✗ std::string OSRunner::unitsPreference() const {
56 ✗ return m_unitsPreference;
57 }
58
59 ✗ std::string OSRunner::languagePreference() const {
60 ✗ return m_languagePreference;
61 }
62
63 73 WorkflowStepResult OSRunner::result() const {
64 73 return m_result;
65 }
66
67 143 bool OSRunner::halted() const {
68 143 return m_halted;
69 }
70
71 25 boost::optional<openstudio::model::Model> OSRunner::lastOpenStudioModel() const {
72
2/2
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 4 times.
50 if (m_lastOpenStudioModel) {
73 21 return m_lastOpenStudioModel;
74 }
75
76
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
8 if (m_lastOpenStudioModelPath) {
77
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 m_lastOpenStudioModel = model::Model::load(*m_lastOpenStudioModelPath);
78 }
79
80 4 return m_lastOpenStudioModel;
81 }
82
83 ✗ boost::optional<openstudio::Workspace> OSRunner::lastEnergyPlusWorkspace() const {
84 ✗ if (m_lastEnergyPlusWorkspace) {
85 ✗ return m_lastEnergyPlusWorkspace;
86 }
87
88 ✗ if (m_lastEnergyPlusWorkspacePath) {
89 ✗ m_lastEnergyPlusWorkspace = Workspace::load(*m_lastEnergyPlusWorkspacePath);
90 }
91
92 ✗ return m_lastEnergyPlusWorkspace;
93 }
94
95 17 boost::optional<openstudio::SqlFile> OSRunner::lastEnergyPlusSqlFile() const {
96
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
34 if (m_lastEnergyPlusSqlFile) {
97 2 return m_lastEnergyPlusSqlFile;
98 }
99
100
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
30 if (m_lastEnergyPlusSqlFilePath) {
101 try {
102
3/3
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
15 m_lastEnergyPlusSqlFile = SqlFile(*m_lastEnergyPlusSqlFilePath);
103 ✗ } catch (const std::exception&) {
104 ✗ }
105 }
106
107 15 return m_lastEnergyPlusSqlFile;
108 }
109
110 ✗ boost::optional<openstudio::path> OSRunner::lastModelicaResultPath() const {
111 ✗ return m_lastModelicaResultPath;
112 }
113
114 ✗ boost::optional<openstudio::EpwFile> OSRunner::lastEpwFile() const {
115 ✗ if (m_lastEpwFile) {
116 ✗ return m_lastEpwFile;
117 }
118
119 ✗ if (m_lastEpwFilePath) {
120 try {
121 ✗ m_lastEpwFile = EpwFile(*m_lastEpwFilePath);
122 ✗ } catch (const std::exception&) {
123 ✗ }
124 }
125
126 ✗ return m_lastEpwFile;
127 }
128
129 ✗ boost::optional<openstudio::path> OSRunner::lastEpwFilePath() const {
130 ✗ return m_lastEpwFilePath;
131 }
132
133 ✗ bool OSRunner::inSelection(const openstudio::model::ModelObject& /*modelObject*/) const {
134 ✗ return true;
135 }
136
137 3 std::map<std::string, OSArgument> OSRunner::getUserInput(std::vector<OSArgument>& arguments) const {
138 3 return convertOSArgumentVectorToMap(arguments);
139 }
140
141 7 void OSRunner::reset() {
142 7 m_workflow.reset();
143 7 m_startedStep = false;
144
145 7 restoreStreams();
146
147 //m_unitsPreference // do not reset
148 //m_languagePreference; // do not reset
149
150 7 m_halted = false;
151
152
1/1
✓ Branch 1 taken 7 times.
7 m_result = WorkflowStepResult();
153
154 7 m_lastOpenStudioModel.reset();
155 7 m_lastOpenStudioModelPath.reset();
156 7 m_lastEnergyPlusWorkspace.reset();
157 7 m_lastEnergyPlusWorkspacePath.reset();
158 7 m_lastEnergyPlusSqlFile.reset();
159 7 m_lastEnergyPlusSqlFilePath.reset();
160 7 m_lastModelicaResultPath.reset();
161 7 m_lastEpwFile.reset();
162 7 m_lastEpwFilePath.reset();
163
164 7 m_currentDir.reset();
165 7 m_currentDirFiles.clear();
166 7 }
167
168 55 bool OSRunner::incrementStep() {
169 // DLM: increment step is called when halted, just skips the steps
170 //if (m_halted){
171 // LOG(Error, "Wokflow halted, cannot increment step");
172 // return false;
173 //}
174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if (!m_startedStep) {
175 ✗ LOG(Error, "Not prepared for step");
176 ✗ return false;
177 }
178
1/1
✓ Branch 1 taken 55 times.
55 boost::optional<WorkflowStep> currentStep = m_workflow.currentStep();
179
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
55 if (!currentStep) {
180 ✗ LOG(Error, "Cannot find current Workflow Step");
181 ✗ return false;
182 }
183
184
2/3
✓ Branch 1 taken 55 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 55 times.
55 if (!m_result.stepResult()) {
185 // must have been skipped
186 ✗ m_result.setStepResult(StepResult::Skip);
187 }
188
189 // restore stdout and stderr
190
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 m_result.setStdOut(m_bufferStdOut.str());
191
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 m_result.setStdErr(m_bufferStdErr.str());
192
1/1
✓ Branch 1 taken 55 times.
55 restoreStreams();
193
194 // check for created files
195
196 // get list of new files
197
1/2
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
110 if (m_currentDir) {
198
1/1
✓ Branch 1 taken 55 times.
55 const openstudio::path absoluteRootDir = m_workflow.absoluteRootDir();
199
7/10
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 6 taken 55 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 55 times.
✓ Branch 12 taken 55 times.
✓ Branch 14 taken 55 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
55 if (boost::filesystem::exists(*m_currentDir) && boost::filesystem::is_directory(*m_currentDir)) {
200
6/6
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 8 taken 23 times.
✓ Branch 11 taken 78 times.
✓ Branch 13 taken 23 times.
✓ Branch 14 taken 55 times.
78 for (boost::filesystem::directory_iterator dir_iter(*m_currentDir), end_iter; dir_iter != end_iter; ++dir_iter) {
201
4/4
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 2 times.
23 if (boost::filesystem::is_regular_file(dir_iter->status())) {
202
4/4
✓ Branch 2 taken 21 times.
✓ Branch 6 taken 21 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 8 times.
21 if (m_currentDirFiles.find(dir_iter->path()) == m_currentDirFiles.end()) {
203
204
1/1
✓ Branch 1 taken 13 times.
13 const openstudio::path& fPath = dir_iter->path();
205
2/4
✓ Branch 1 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 6 not taken.
13 OS_ASSERT(fPath.is_absolute());
206
207 // DLM: we need to figure out what these should be
208 // are they absolute, relative to root dir, relative to measure dir, valid after reports have been packed up?
209 //try{
210 // path = relativePath(path, absoluteRootDir);
211 //} catch (const std::exception&){
212 //}
213
1/1
✓ Branch 1 taken 13 times.
13 m_result.addStepFile(fPath);
214 }
215 }
216 55 }
217 }
218 55 }
219 55 m_currentDir.reset();
220 55 m_currentDirFiles.clear();
221
222
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 m_result.setCompletedAt(DateTime::nowUTC());
223
224
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 currentStep->setResult(m_result);
225
226
1/1
✓ Branch 1 taken 55 times.
55 m_result = WorkflowStepResult();
227 55 m_startedStep = false;
228
229
1/1
✓ Branch 1 taken 55 times.
55 return m_workflow.incrementStep();
230 55 }
231
232 //void OSRunner::setCurrentStep(unsigned currentStep)
233 //{
234 // m_previousResults.resize(currentStep);
235 // m_result = WorkflowStepResult();
236 // m_result.setStepResult(StepResult::Skip);
237 //
238 // m_currentStep = currentStep;
239 //}
240
241 74 void OSRunner::prepareForMeasureRun(const OSMeasure& /*measure*/) {
242 74 prepareForMeasureRun();
243 74 }
244
245 74 void OSRunner::prepareForMeasureRun() {
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if (m_halted) {
247 ✗ LOG(Error, "Wokflow halted, cannot prepate for measure run");
248 7 return;
249 }
250
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 73 times.
74 if (m_startedStep) {
251
5/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
1 LOG(Error, "Step already started");
252 1 return;
253 }
254
1/1
✓ Branch 1 taken 73 times.
73 const boost::optional<WorkflowStep> currentStep = m_workflow.currentStep();
255
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 67 times.
73 if (!currentStep) {
256
5/5
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✓ Branch 13 taken 6 times.
6 LOG(Error, "Cannot find current Workflow Step");
257 6 return;
258 }
259
260 67 m_startedStep = true;
261
262 // create a new result
263
1/1
✓ Branch 1 taken 67 times.
67 m_result = WorkflowStepResult();
264
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
67 m_result.setStartedAt(DateTime::nowUTC());
265
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
67 m_result.setStepResult(StepResult::Success);
266
267 // capture std out and err
268
1/1
✓ Branch 1 taken 67 times.
67 captureStreams();
269
270 // get initial list of files
271
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
67 m_currentDir = boost::filesystem::current_path();
272
7/10
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
✓ Branch 6 taken 67 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 67 times.
✓ Branch 12 taken 67 times.
✓ Branch 14 taken 67 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 67 times.
✗ Branch 17 not taken.
67 if (boost::filesystem::exists(*m_currentDir) && boost::filesystem::is_directory(*m_currentDir)) {
273
6/6
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
✓ Branch 8 taken 127 times.
✓ Branch 11 taken 194 times.
✓ Branch 13 taken 127 times.
✓ Branch 14 taken 67 times.
321 for (boost::filesystem::directory_iterator dir_iter(*m_currentDir), end_iter; dir_iter != end_iter; ++dir_iter) {
274
4/4
✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 25 times.
127 if (boost::filesystem::is_regular_file(dir_iter->status())) {
275
2/2
✓ Branch 1 taken 102 times.
✓ Branch 5 taken 102 times.
102 m_currentDirFiles.insert(dir_iter->path());
276 }
277 67 }
278 }
279 73 }
280
281 ✗ bool OSRunner::registerMsgAlsoLogs() const {
282 ✗ return m_registerMsgAlsoLogs;
283 }
284
285 22 void OSRunner::setRegisterMsgAlsoLogs(bool registerMsgAlsoLogs) {
286 22 m_registerMsgAlsoLogs = registerMsgAlsoLogs;
287 22 }
288
289 10 void OSRunner::registerError(const std::string& message) {
290
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 m_result.setStepResult(StepResult::Fail);
291 10 m_result.addStepError(message);
292
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (m_registerMsgAlsoLogs) {
293
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
2 LOG(Error, message);
294 }
295 10 }
296
297 14 bool OSRunner::registerWarning(const std::string& message) {
298 14 m_result.addStepWarning(message);
299
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 if (m_registerMsgAlsoLogs) {
300
5/5
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
✓ Branch 13 taken 7 times.
7 LOG(Warn, message);
301 }
302 14 return true;
303 }
304
305 62 bool OSRunner::registerInfo(const std::string& message) {
306 62 m_result.addStepInfo(message);
307
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 28 times.
62 if (m_registerMsgAlsoLogs) {
308
5/5
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 7 taken 34 times.
✓ Branch 10 taken 34 times.
✓ Branch 13 taken 34 times.
34 LOG(Info, message);
309 }
310 62 return true;
311 }
312
313 5 void OSRunner::registerAsNotApplicable(const std::string& message) {
314
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 m_result.setStepResult(StepResult::NA);
315 5 m_result.addStepInfo(message);
316 // even though openstudio-workflow-gem didn't do that that one, still doing it
317
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 time.
5 if (m_registerMsgAlsoLogs) {
318
5/5
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
4 LOG(Warn, message);
319 }
320 5 }
321
322 28 void OSRunner::registerInitialCondition(const std::string& message) {
323 28 m_result.setStepInitialCondition(message);
324
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 15 times.
28 if (m_registerMsgAlsoLogs) {
325
5/5
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 13 taken 13 times.
13 LOG(Info, message);
326 }
327 28 }
328
329 40 void OSRunner::registerFinalCondition(const std::string& message) {
330 40 m_result.setStepFinalCondition(message);
331
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 22 times.
40 if (m_registerMsgAlsoLogs) {
332
5/5
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
✓ Branch 13 taken 18 times.
18 LOG(Info, message);
333 }
334 40 }
335
336 12 void OSRunner::registerValue(const std::string& name, bool value) {
337
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 const WorkflowStepValue stepValue(cleanValueName(name), value);
338
1/1
✓ Branch 1 taken 12 times.
12 m_result.addStepValue(stepValue);
339 12 }
340
341 ✗ void OSRunner::registerValue(const std::string& name, const std::string& displayName, bool value) {
342 ✗ WorkflowStepValue stepValue(cleanValueName(name), value);
343 ✗ stepValue.setDisplayName(displayName);
344 ✗ m_result.addStepValue(stepValue);
345 ✗ }
346
347 ✗ void OSRunner::registerValue(const std::string& name, double value) {
348 ✗ const WorkflowStepValue stepValue(cleanValueName(name), value);
349 ✗ m_result.addStepValue(stepValue);
350 ✗ }
351
352 ✗ void OSRunner::registerValue(const std::string& name, double value, const std::string& units) {
353 ✗ WorkflowStepValue stepValue(cleanValueName(name), value);
354 ✗ stepValue.setUnits(units);
355 ✗ m_result.addStepValue(stepValue);
356 ✗ }
357
358 ✗ void OSRunner::registerValue(const std::string& name, const std::string& displayName, double value) {
359 ✗ WorkflowStepValue stepValue(cleanValueName(name), value);
360 ✗ stepValue.setDisplayName(displayName);
361 ✗ m_result.addStepValue(stepValue);
362 ✗ }
363
364 23 void OSRunner::registerValue(const std::string& name, const std::string& displayName, double value, const std::string& units) {
365
2/2
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
23 WorkflowStepValue stepValue(cleanValueName(name), value);
366
1/1
✓ Branch 1 taken 23 times.
23 stepValue.setDisplayName(displayName);
367
1/1
✓ Branch 1 taken 23 times.
23 stepValue.setUnits(units);
368
1/1
✓ Branch 1 taken 23 times.
23 m_result.addStepValue(stepValue);
369 23 }
370
371 10 void OSRunner::registerValue(const std::string& name, int value) {
372
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 const WorkflowStepValue stepValue(cleanValueName(name), value);
373
1/1
✓ Branch 1 taken 10 times.
10 m_result.addStepValue(stepValue);
374 10 }
375
376 ✗ void OSRunner::registerValue(const std::string& name, int value, const std::string& units) {
377 ✗ WorkflowStepValue stepValue(cleanValueName(name), value);
378 ✗ stepValue.setUnits(units);
379 ✗ m_result.addStepValue(stepValue);
380 ✗ }
381
382 ✗ void OSRunner::registerValue(const std::string& name, const std::string& displayName, int value) {
383 ✗ WorkflowStepValue stepValue(cleanValueName(name), value);
384 ✗ stepValue.setDisplayName(displayName);
385 ✗ m_result.addStepValue(stepValue);
386 ✗ }
387
388 15 void OSRunner::registerValue(const std::string& name, const std::string& displayName, int value, const std::string& units) {
389
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
15 WorkflowStepValue stepValue(cleanValueName(name), value);
390
1/1
✓ Branch 1 taken 15 times.
15 stepValue.setDisplayName(displayName);
391
1/1
✓ Branch 1 taken 15 times.
15 stepValue.setUnits(units);
392
1/1
✓ Branch 1 taken 15 times.
15 m_result.addStepValue(stepValue);
393 15 }
394
395 3 void OSRunner::registerValue(const std::string& name, const std::string& value) {
396
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 const WorkflowStepValue stepValue(cleanValueName(name), value);
397
1/1
✓ Branch 1 taken 3 times.
3 m_result.addStepValue(stepValue);
398 3 }
399
400 ✗ void OSRunner::registerValue(const std::string& name, const std::string& displayName, const std::string& value) {
401 ✗ WorkflowStepValue stepValue(cleanValueName(name), value);
402 ✗ stepValue.setDisplayName(displayName);
403 ✗ m_result.addStepValue(stepValue);
404 ✗ }
405
406 ✗ void OSRunner::haltWorkflow(const std::string& completedStatus) {
407 ✗ m_halted = true;
408 ✗ m_workflow.setCompletedStatus(completedStatus);
409 ✗ }
410
411 ✗ void OSRunner::createProgressBar(const std::string& text) const {}
412
413 ✗ void OSRunner::updateProgress(double value) const {}
414
415 ✗ void OSRunner::destroyProgressBar() const {}
416
417 81 bool OSRunner::validateUserArguments(const std::vector<OSArgument>& script_arguments, const std::map<std::string, OSArgument>& user_arguments) {
418 81 bool result = true;
419 81 std::vector<WorkflowStepValue> stepValues;
420
2/2
✓ Branch 5 taken 91 times.
✓ Branch 6 taken 81 times.
172 for (const OSArgument& script_argument : script_arguments) {
421
4/4
✓ Branch 1 taken 91 times.
✓ Branch 4 taken 91 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 89 times.
91 if (script_argument.type().value() == OSArgumentType::Separator) {
422 // skip separators
423 2 continue;
424 }
425
2/2
✓ Branch 1 taken 89 times.
✓ Branch 4 taken 89 times.
89 auto it = user_arguments.find(script_argument.name());
426
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 87 times.
89 if (it == user_arguments.end()) {
427 // script_argument is not in user_arguments
428 // this is only okay for purely optional arguments
429
6/8
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 if (script_argument.required() || script_argument.hasDefaultValue()) {
430
2/2
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
4 registerError(fmt::format("Argument '{}' is required or has a default value, but is not in user_arguments.", script_argument.name()));
431 2 result = false;
432 }
433 } else {
434 // script_argument is in user_arguments
435 87 const OSArgument& user_argument = it->second;
436
437 // check that names still match
438
3/4
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 87 times.
87 if (user_argument.name() != script_argument.name()) {
439 ✗ registerWarning(fmt::format("User argument name '{}' does not match map key ", user_argument.name()));
440 }
441
442 // check that types still match
443
3/4
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 87 times.
87 if (user_argument.type() != script_argument.type()) {
444 ✗ registerError(fmt::format("User argument type {} does not match script argument type {}.", user_argument.type().valueName(),
445 ✗ script_argument.type().valueName()));
446 ✗ result = false;
447 }
448
449 // check that we have values
450
9/11
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 11 times.
✓ Branch 6 taken 76 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 52 times.
✓ Branch 11 taken 24 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 24 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 87 times.
87 if ((script_argument.required()) && !(user_argument.hasValue() || user_argument.hasDefaultValue())) {
451 ✗ registerError(fmt::format("Script argument '{}' is required, but the user argument does not have a value or default value set.",
452 ✗ script_argument.name()));
453 ✗ result = false;
454 }
455
456 // check for default value mismatch
457
6/8
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 48 times.
✓ Branch 6 taken 39 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 39 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 87 times.
87 if (script_argument.hasDefaultValue() && !user_argument.hasDefaultValue()) {
458 ✗ registerWarning(fmt::format("Script argument '{}' has a default value, but the user-supplied version does not.", script_argument.name()));
459 }
460
6/8
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 39 times.
✓ Branch 6 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 48 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 87 times.
87 if (!script_argument.hasDefaultValue() && user_argument.hasDefaultValue()) {
461 ✗ registerWarning(
462 ✗ fmt::format("Script argument '{}' does not have a default value, but the user-supplied version does.", script_argument.name()));
463 }
464
10/12
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 48 times.
✓ Branch 6 taken 39 times.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 39 times.
✓ Branch 14 taken 39 times.
✓ Branch 17 taken 39 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 39 times.
✓ Branch 20 taken 48 times.
87 if (script_argument.hasDefaultValue() && user_argument.hasDefaultValue() && (user_argument.type() == script_argument.type())) {
465
1/1
✓ Branch 1 taken 39 times.
39 std::stringstream ss;
466
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 ss << "The default value of script argument " << '\n'
467
1/1
✓ Branch 1 taken 39 times.
39 << script_argument << '\n'
468
3/3
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
39 << "does not match that of the corresponding user argument " << '\n'
469
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 << user_argument << ".";
470
4/7
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 19 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
39 switch (script_argument.type().value()) {
471 20 case OSArgumentType::Boolean:
472
3/4
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
20 if (user_argument.defaultValueAsBool() != script_argument.defaultValueAsBool()) {
473 ✗ registerWarning(ss.str());
474 }
475 20 break;
476 19 case OSArgumentType::Double:
477
3/4
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 19 times.
19 if (user_argument.defaultValueAsDouble() != script_argument.defaultValueAsDouble()) {
478 ✗ registerWarning(ss.str());
479 }
480 19 break;
481 ✗ case OSArgumentType::Integer:
482 ✗ if (user_argument.defaultValueAsInteger() != script_argument.defaultValueAsInteger()) {
483 ✗ registerWarning(ss.str());
484 }
485 ✗ break;
486 ✗ case OSArgumentType::String:
487 case OSArgumentType::Choice:
488 case OSArgumentType::Path:
489 ✗ if (user_argument.defaultValueAsString() != script_argument.defaultValueAsString()) {
490 ✗ registerWarning(ss.str());
491 }
492 ✗ break;
493 ✗ default:
494 ✗ OS_ASSERT(false);
495 }
496 39 }
497
498 // check for domain mismatch
499
6/8
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 77 times.
✓ Branch 6 taken 10 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 87 times.
87 if (script_argument.hasDomain() && !user_argument.hasDomain()) {
500 ✗ registerWarning(
501 ✗ fmt::format("Script argument '{}' has a specified domain, but the user-supplied version does not.", script_argument.name()));
502 }
503
6/8
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 77 times.
✓ Branch 4 taken 10 times.
✓ Branch 6 taken 77 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 77 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 87 times.
87 if (!script_argument.hasDomain() && user_argument.hasDomain()) {
504 ✗ registerWarning(
505 ✗ fmt::format("Script argument '{}' does not have a specified domain, but the user-supplied version does.", script_argument.name()));
506 }
507
10/12
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 77 times.
✓ Branch 6 taken 10 times.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 10 times.
✓ Branch 14 taken 10 times.
✓ Branch 17 taken 10 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 77 times.
87 if (script_argument.hasDomain() && user_argument.hasDomain() && (user_argument.type() == script_argument.type())) {
508
1/1
✓ Branch 1 taken 10 times.
10 std::stringstream ss;
509
4/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
10 ss << "The domain of script argument " << '\n' << script_argument << '\n';
510
4/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
10 ss << "does not match that of the corresponding user argument " << '\n' << user_argument << ".";
511
4/8
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
10 switch (script_argument.type().value()) {
512 ✗ case OSArgumentType::Boolean:
513 // DLM: should bool's even have domains?
514 ✗ if (user_argument.domainAsBool() != script_argument.domainAsBool()) {
515 ✗ registerWarning(ss.str());
516 }
517 ✗ break;
518 5 case OSArgumentType::Double:
519
4/5
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
5 if (user_argument.domainAsDouble() != script_argument.domainAsDouble()) {
520 ✗ registerWarning(ss.str());
521 }
522 5 break;
523 ✗ case OSArgumentType::Quantity:
524 // DLM: deprecated forget about getting this to compile
525 //if (user_argument.domainAsQuantity() != script_argument.domainAsQuantity()) {
526 // registerWarning(ss.str());
527 //}
528 ✗ break;
529 5 case OSArgumentType::Integer:
530
4/5
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
5 if (user_argument.domainAsInteger() != script_argument.domainAsInteger()) {
531 ✗ registerWarning(ss.str());
532 }
533 5 break;
534 ✗ case OSArgumentType::String:
535 case OSArgumentType::Choice:
536 case OSArgumentType::Path:
537 ✗ if (user_argument.domainAsString() != script_argument.domainAsString()) {
538 ✗ registerWarning(ss.str());
539 }
540 ✗ break;
541 ✗ default:
542 ✗ OS_ASSERT(false);
543 }
544 10 }
545
546 // success, set the values
547
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 1 time.
87 if (result) {
548
2/2
✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
86 auto typeValue = user_argument.type().value();
549
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 55 times.
86 if (typeValue == OSArgumentType::Boolean) {
550
3/3
✓ Branch 1 taken 31 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 19 times.
31 if (user_argument.hasValue()) {
551
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 stepValues.emplace_back(user_argument.name(), user_argument.valueAsBool());
552
3/3
✓ Branch 1 taken 19 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 1 time.
19 } else if (user_argument.hasDefaultValue()) {
553
3/3
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
18 stepValues.emplace_back(user_argument.name(), user_argument.defaultValueAsBool());
554 }
555
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 19 times.
55 } else if (typeValue == OSArgumentType::Double) {
556
8/8
✓ Branch 1 taken 36 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 25 times.
✓ Branch 6 taken 11 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 34 times.
✓ Branch 11 taken 2 times.
36 if (user_argument.hasValue() || user_argument.hasDefaultValue()) {
557
5/5
✓ Branch 1 taken 34 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 9 times.
✓ Branch 6 taken 25 times.
✓ Branch 9 taken 9 times.
34 auto value = user_argument.hasValue() ? user_argument.valueAsDouble() : user_argument.defaultValueAsDouble();
558
3/3
✓ Branch 1 taken 34 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 29 times.
34 if (script_argument.hasDomain()) {
559 // Validate it's in the domain
560
1/1
✓ Branch 1 taken 5 times.
5 auto domain = script_argument.domainAsDouble();
561 5 auto& low = domain.front();
562 5 auto& high = domain.back();
563
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 4 times.
5 if (value < low || value > high) {
564
1/1
✓ Branch 2 taken 1 time.
2 registerError(fmt::format("{} User argument '{}' has a value '{}' that is not in the domain [{}, {}].",
565
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
2 user_argument.type().valueName(), script_argument.name(), value, low, high));
566 1 result = false;
567 }
568 5 }
569
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 time.
34 if (result) {
570
2/2
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
33 stepValues.emplace_back(user_argument.name(), value);
571 }
572 }
573
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 14 times.
19 } else if (typeValue == OSArgumentType::Integer) {
574
3/8
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
5 if (user_argument.hasValue() || user_argument.hasDefaultValue()) {
575
3/5
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 9 not taken.
5 auto value = user_argument.hasValue() ? user_argument.valueAsInteger() : user_argument.defaultValueAsInteger();
576
3/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 time.
5 if (script_argument.hasDomain()) {
577 // Validate it's in the domain
578
1/1
✓ Branch 1 taken 4 times.
4 auto domain = script_argument.domainAsInteger();
579 4 auto& low = domain.front();
580 4 auto& high = domain.back();
581
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
4 if (value < low || value > high) {
582
1/1
✓ Branch 2 taken 2 times.
4 registerError(fmt::format("{} User argument '{}' has a value '{}' that is not in the domain [{}, {}].",
583
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
4 user_argument.type().valueName(), script_argument.name(), value, low, high));
584 2 result = false;
585 }
586 4 }
587
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (result) {
588
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 stepValues.emplace_back(user_argument.name(), value);
589 }
590 }
591
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14 } else if ((typeValue == OSArgumentType::String) || (typeValue == OSArgumentType::Choice) || (typeValue == OSArgumentType::Path)) {
592
3/3
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2 times.
28 if (user_argument.hasValue()) {
593
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 stepValues.emplace_back(user_argument.name(), user_argument.valueAsString());
594
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 } else if (user_argument.hasDefaultValue()) {
595 ✗ stepValues.emplace_back(user_argument.name(), user_argument.defaultValueAsString());
596 }
597 } else {
598 ✗ OS_ASSERT(false);
599 }
600 } // end if result
601 }
602 } // end for loop on arguments
603
604
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 4 times.
81 if (result) {
605
2/2
✓ Branch 5 taken 76 times.
✓ Branch 6 taken 77 times.
153 for (const auto& stepValue : stepValues) {
606
1/1
✓ Branch 1 taken 76 times.
76 m_result.addStepValue(stepValue);
607 }
608 }
609
610 81 return result;
611 81 }
612
613 22 bool OSRunner::getBoolArgumentValue(const std::string& argument_name, const std::map<std::string, OSArgument>& user_arguments) {
614
1/1
✓ Branch 1 taken 22 times.
22 std::stringstream ss;
615
616
1/1
✓ Branch 1 taken 22 times.
22 auto it = user_arguments.find(argument_name);
617
1/2
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if (it != user_arguments.end()) {
618
3/3
✓ Branch 2 taken 22 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 10 times.
22 if (it->second.hasValue()) {
619
1/1
✓ Branch 2 taken 12 times.
12 return it->second.valueAsBool();
620
2/3
✓ Branch 2 taken 10 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 } else if (it->second.hasDefaultValue()) {
621
1/1
✓ Branch 2 taken 10 times.
10 return it->second.defaultValueAsBool();
622 }
623 }
624
625 ✗ ss << "No value found for argument '" << argument_name << "'.";
626 ✗ if (it != user_arguments.end()) {
627 ✗ ss << " Full argument as passed in by user:" << '\n' << it->second;
628 }
629 ✗ registerError(ss.str());
630 ✗ LOG_AND_THROW(ss.str());
631 return false;
632 22 }
633
634 3 boost::optional<bool> OSRunner::getOptionalBoolArgumentValue(const std::string& argument_name,
635 const std::map<std::string, OSArgument>& user_arguments) {
636
1/1
✓ Branch 1 taken 3 times.
3 auto it = user_arguments.find(argument_name);
637
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if (it != user_arguments.end()) {
638
3/3
✓ Branch 2 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 time.
3 if (it->second.hasValue()) {
639
2/2
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
2 return it->second.valueAsBool();
640
2/3
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
1 } else if (it->second.hasDefaultValue()) {
641 ✗ return it->second.defaultValueAsBool();
642 }
643 }
644
645 1 return boost::none;
646 }
647
648 26 double OSRunner::getDoubleArgumentValue(const std::string& argument_name, const std::map<std::string, OSArgument>& user_arguments) {
649
1/1
✓ Branch 1 taken 26 times.
26 std::stringstream ss;
650
651
1/1
✓ Branch 1 taken 26 times.
26 auto it = user_arguments.find(argument_name);
652
1/2
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 if (it != user_arguments.end()) {
653
3/3
✓ Branch 2 taken 26 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 7 times.
26 if (it->second.hasValue()) {
654
1/1
✓ Branch 2 taken 19 times.
19 return it->second.valueAsDouble();
655
2/3
✓ Branch 2 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 } else if (it->second.hasDefaultValue()) {
656
1/1
✓ Branch 2 taken 7 times.
7 return it->second.defaultValueAsDouble();
657 }
658 }
659
660 ✗ ss << "No value found for argument '" << argument_name << "'.";
661 ✗ if (it != user_arguments.end()) {
662 ✗ ss << " Full argument as passed in by user:" << '\n' << it->second;
663 }
664 ✗ registerError(ss.str());
665 ✗ LOG_AND_THROW(ss.str());
666 return 0.0;
667 26 }
668
669 ✗ boost::optional<double> OSRunner::getOptionalDoubleArgumentValue(const std::string& argument_name,
670 const std::map<std::string, OSArgument>& user_arguments) {
671 ✗ auto it = user_arguments.find(argument_name);
672 ✗ if (it != user_arguments.end()) {
673 ✗ if (it->second.hasValue()) {
674 ✗ return it->second.valueAsDouble();
675 ✗ } else if (it->second.hasDefaultValue()) {
676 ✗ return it->second.defaultValueAsDouble();
677 }
678 }
679
680 ✗ return boost::none;
681 }
682
683 1 int OSRunner::getIntegerArgumentValue(const std::string& argument_name, const std::map<std::string, OSArgument>& user_arguments) {
684
1/1
✓ Branch 1 taken 1 time.
1 std::stringstream ss;
685
686
1/1
✓ Branch 1 taken 1 time.
1 auto it = user_arguments.find(argument_name);
687
1/2
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1 if (it != user_arguments.end()) {
688
2/3
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
1 if (it->second.hasValue()) {
689
1/1
✓ Branch 2 taken 1 time.
1 return it->second.valueAsInteger();
690 ✗ } else if (it->second.hasDefaultValue()) {
691 ✗ return it->second.defaultValueAsInteger();
692 }
693 }
694
695 ✗ ss << "No value found for argument '" << argument_name << "'.";
696 ✗ if (it != user_arguments.end()) {
697 ✗ ss << " Full argument as passed in by user:" << '\n' << it->second;
698 }
699 ✗ registerError(ss.str());
700 ✗ LOG_AND_THROW(ss.str());
701 return 0;
702 1 }
703
704 ✗ boost::optional<int> OSRunner::getOptionalIntegerArgumentValue(const std::string& argument_name,
705 const std::map<std::string, OSArgument>& user_arguments) {
706 ✗ auto it = user_arguments.find(argument_name);
707 ✗ if (it != user_arguments.end()) {
708 ✗ if (it->second.hasValue()) {
709 ✗ return it->second.valueAsInteger();
710 ✗ } else if (it->second.hasDefaultValue()) {
711 ✗ return it->second.defaultValueAsInteger();
712 }
713 }
714
715 ✗ return boost::none;
716 }
717
718 11 std::string OSRunner::getStringArgumentValue(const std::string& argument_name, const std::map<std::string, OSArgument>& user_arguments) {
719
1/1
✓ Branch 1 taken 11 times.
11 std::stringstream ss;
720
721
1/1
✓ Branch 1 taken 11 times.
11 auto it = user_arguments.find(argument_name);
722
1/2
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if (it != user_arguments.end()) {
723
2/3
✓ Branch 2 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if (it->second.hasValue()) {
724
1/1
✓ Branch 2 taken 11 times.
11 return it->second.valueAsString();
725 ✗ } else if (it->second.hasDefaultValue()) {
726 ✗ return it->second.defaultValueAsString();
727 }
728 }
729
730 ✗ ss << "No value found for argument '" << argument_name << "'.";
731 ✗ if (it != user_arguments.end()) {
732 ✗ ss << " Full argument as passed in by user:" << '\n' << it->second;
733 }
734 ✗ registerError(ss.str());
735 ✗ LOG_AND_THROW(ss.str());
736 return {};
737 11 }
738
739 ✗ boost::optional<std::string> OSRunner::getOptionalStringArgumentValue(const std::string& argument_name,
740 const std::map<std::string, OSArgument>& user_arguments) {
741 ✗ auto it = user_arguments.find(argument_name);
742 ✗ if (it != user_arguments.end()) {
743 ✗ if (it->second.hasValue()) {
744 ✗ return it->second.valueAsString();
745 ✗ } else if (it->second.hasDefaultValue()) {
746 ✗ return it->second.defaultValueAsString();
747 }
748 }
749
750 ✗ return boost::none;
751 }
752
753 ✗ openstudio::path OSRunner::getPathArgumentValue(const std::string& argument_name, const std::map<std::string, OSArgument>& user_arguments) {
754 ✗ std::stringstream ss;
755
756 ✗ auto it = user_arguments.find(argument_name);
757 ✗ if (it != user_arguments.end()) {
758 ✗ if (it->second.hasValue()) {
759 ✗ return it->second.valueAsPath();
760 ✗ } else if (it->second.hasDefaultValue()) {
761 ✗ return it->second.defaultValueAsPath();
762 }
763 }
764
765 ✗ ss << "No value found for argument '" << argument_name << "'.";
766 ✗ if (it != user_arguments.end()) {
767 ✗ ss << " Full argument as passed in by user:" << '\n' << it->second;
768 }
769 ✗ registerError(ss.str());
770 ✗ LOG_AND_THROW(ss.str());
771 return {};
772 ✗ }
773
774 ✗ boost::optional<openstudio::path> OSRunner::getOptionalPathArgumentValue(const std::string& argument_name,
775 const std::map<std::string, OSArgument>& user_arguments) {
776 ✗ auto it = user_arguments.find(argument_name);
777 ✗ if (it != user_arguments.end()) {
778 ✗ if (it->second.hasValue()) {
779 ✗ return it->second.valueAsPath();
780 ✗ } else if (it->second.hasDefaultValue()) {
781 ✗ return it->second.defaultValueAsPath();
782 }
783 }
784
785 ✗ return boost::none;
786 }
787
788 boost::optional<openstudio::WorkspaceObject>
789 1 OSRunner::getOptionalWorkspaceObjectChoiceValue(const std::string& argument_name, const std::map<std::string, OSArgument>& user_arguments,
790 const openstudio::Workspace& workspace)
791
792 {
793
1/1
✓ Branch 1 taken 1 time.
1 auto it = user_arguments.find(argument_name);
794 1 std::string handleString;
795
1/2
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1 if (it != user_arguments.end()) {
796
2/3
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
1 if (it->second.hasValue()) {
797
1/1
✓ Branch 2 taken 1 time.
1 handleString = it->second.valueAsString();
798 ✗ } else if (it->second.hasDefaultValue()) {
799 ✗ handleString = it->second.defaultValueAsString();
800 }
801 }
802
803
1/1
✓ Branch 1 taken 1 time.
1 Handle handle = toUUID(handleString);
804
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<WorkspaceObject> result = workspace.getObject(handle);
805
806 2 return result;
807 1 }
808
809 1 Json::Value OSRunner::getArgumentValues(std::vector<OSArgument>& script_arguments, const std::map<std::string, OSArgument>& user_arguments) {
810 // This function aims to replace OsLib_HelperMethods.createRunVariables
811 // TODO: should this call validateUserArguments like the ruby counterpart? At least it validates that the defaults are supposed to match etc
812
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!validateUserArguments(script_arguments, user_arguments)) {
813 ✗ registerError("Invalid argument values.");
814 ✗ LOG_AND_THROW("Invalid argument values.");
815 }
816
817 1 Json::Value argument_values;
818
2/2
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 1 time.
15 for (const OSArgument& script_argument : script_arguments) {
819
1/1
✓ Branch 1 taken 14 times.
14 const std::string name = script_argument.name();
820
1/1
✓ Branch 1 taken 14 times.
14 auto it = user_arguments.find(name);
821
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if (it != user_arguments.end()) {
822 14 const auto& arg = it->second;
823
3/3
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 5 times.
14 if (arg.hasValue()) {
824
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 argument_values[name] = arg.valueAsJSON();
825
2/3
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
5 } else if (arg.hasDefaultValue()) {
826 // TODO: is this wanted?
827 // JJR: I believe it is.
828 ✗ argument_values[name] = arg.defaultValueAsJSON();
829 }
830 }
831 14 }
832 1 return argument_values;
833 ✗ }
834
835 9 Json::Value OSRunner::getPastStepValuesForMeasure(const std::string& measureName) const {
836 9 Json::Value step_values(Json::objectValue);
837
4/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 12 taken 14 times.
✓ Branch 13 taken 3 times.
17 for (const MeasureStep& step : subsetCastVector<MeasureStep>(m_workflow.workflowSteps())) {
838
1/1
✓ Branch 1 taken 14 times.
14 boost::optional<WorkflowStepResult> stepResult_ = step.result();
839
14/22
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✓ Branch 10 taken 14 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 14 times.
✓ Branch 16 taken 14 times.
✓ Branch 19 taken 14 times.
✓ Branch 22 taken 14 times.
✓ Branch 25 taken 5 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 14 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 14 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 5 times.
✓ Branch 34 taken 9 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
14 if (!stepResult_ || !stepResult_->stepResult() || stepResult_->stepResult().get() != StepResult::Success) {
840 5 continue;
841 }
842 // TODO: should we match on any of these three?
843
4/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 5 times.
9 if (istringEqual(measureName, step.measureDirName())) { // The directory name, eg `IncreaseWallRValue`
844
5/5
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
4 LOG(Trace, "Step matches on measureDirName");
845
9/9
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 time.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 4 times.
5 } else if (auto s_ = step.name(); s_.is_initialized() && istringEqual(measureName, *s_)) { // An optional, abritrary one
846
5/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
1 LOG(Trace, "Step matches on name");
847
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 } else if (auto s_ = stepResult_->measureName();
848 4 s_.is_initialized()
849
7/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 3 times.
4 && istringEqual(measureName, *s_)) { // The xml one, eg `increase_insulation_r_value_for_exterior_walls_by_percentage`
850
5/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
1 LOG(Trace, "Step matches on Step Result's measureName");
851 } else {
852 3 continue;
853 9 }
854
855
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 6 times.
15 for (const WorkflowStepValue& step_value : stepResult_->stepValues()) {
856
1/1
✓ Branch 1 taken 9 times.
9 Json::Value root = step_value.toJSON();
857
4/5
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
9 if (auto value = root["value"]) {
858
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 step_values[step_value.name()] = value;
859 9 }
860 15 }
861 6 break;
862 23 }
863 9 return step_values;
864 ✗ }
865
866 2 Json::Value OSRunner::getPastStepValuesForName(const std::string& stepName) const {
867 // This function aims to replace OsLib_HelperMethods.check_upstream_measure_for_arg
868 2 Json::Value step_values(Json::objectValue);
869
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 2 times.
8 for (const MeasureStep& step : subsetCastVector<MeasureStep>(m_workflow.workflowSteps())) {
870
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<WorkflowStepResult> stepResult_ = step.result();
871
14/22
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
✓ Branch 25 taken 2 times.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 6 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 6 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 2 times.
✓ Branch 34 taken 4 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
6 if (!stepResult_ || !stepResult_->stepResult() || stepResult_->stepResult().get() != StepResult::Success) {
872 2 continue;
873 }
874
875
1/1
✓ Branch 1 taken 4 times.
4 std::string measure_name = step.measureDirName(); // The directory name, eg `IncreaseWallRValue`
876
3/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
8 if (auto s_ = step.name()) { // An optional, abritrary one
877
1/1
✓ Branch 1 taken 2 times.
2 measure_name = std::move(*s_);
878 4 }
879 // if (auto s_ = stepResult_->measureName()) { // The xml one, eg `increase_insulation_r_value_for_exterior_walls_by_percentage`
880 // measure_name = std::move(*s_);
881 // }
882
883
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 4 times.
10 for (const WorkflowStepValue& stepValue : stepResult_->stepValues()) {
884
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 4 times.
6 if (istringEqual(stepName, stepValue.name())) {
885
1/1
✓ Branch 1 taken 2 times.
2 Json::Value root = stepValue.toJSON();
886
4/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
2 if (auto value = root["value"]) {
887
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 step_values[measure_name] = value;
888 // TODO: check_upstream_measure_for_arg was breaking early, and returning a {:value => value, :measure_name => measure_name} format
889 2 }
890 2 }
891 4 }
892 8 }
893 2 return step_values;
894 ✗ }
895
896 75 void OSRunner::setLastOpenStudioModel(const openstudio::model::Model& lastOpenStudioModel) {
897 75 m_lastOpenStudioModel = lastOpenStudioModel;
898 75 m_lastOpenStudioModelPath.reset();
899 75 }
900
901 ✗ void OSRunner::resetLastOpenStudioModel() {
902 ✗ m_lastOpenStudioModel.reset();
903 ✗ m_lastOpenStudioModelPath.reset();
904 ✗ }
905
906 4 void OSRunner::setLastOpenStudioModelPath(const openstudio::path& lastOpenStudioModelPath) {
907
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 if (openstudio::filesystem::exists(lastOpenStudioModelPath)) {
908
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 m_lastOpenStudioModelPath = openstudio::filesystem::canonical(lastOpenStudioModelPath);
909 } else {
910 ✗ m_lastOpenStudioModelPath = lastOpenStudioModelPath;
911 }
912 4 m_lastOpenStudioModel.reset();
913 4 }
914
915 ✗ void OSRunner::resetLastOpenStudioModelPath() {
916 ✗ m_lastOpenStudioModel.reset();
917 ✗ m_lastOpenStudioModelPath.reset();
918 ✗ }
919
920 47 void OSRunner::setLastEnergyPlusWorkspace(const openstudio::Workspace& lastEnergyPlusWorkspace) {
921 47 m_lastEnergyPlusWorkspace = lastEnergyPlusWorkspace;
922 47 m_lastEnergyPlusWorkspacePath.reset();
923 47 }
924
925 ✗ void OSRunner::resetLastEnergyPlusWorkspace() {
926 ✗ m_lastEnergyPlusWorkspace.reset();
927 ✗ m_lastEnergyPlusWorkspacePath.reset();
928 ✗ }
929
930 ✗ void OSRunner::setLastEnergyPlusWorkspacePath(const openstudio::path& lastEnergyPlusWorkspacePath) {
931 ✗ if (openstudio::filesystem::exists(lastEnergyPlusWorkspacePath)) {
932 ✗ m_lastEnergyPlusWorkspacePath = openstudio::filesystem::canonical(lastEnergyPlusWorkspacePath);
933 } else {
934 ✗ m_lastEnergyPlusWorkspacePath = lastEnergyPlusWorkspacePath;
935 }
936 ✗ m_lastEnergyPlusWorkspace.reset();
937 ✗ }
938
939 ✗ void OSRunner::resetLastEnergyPlusWorkspacePath() {
940 ✗ m_lastEnergyPlusWorkspace.reset();
941 ✗ m_lastEnergyPlusWorkspacePath.reset();
942 ✗ }
943
944 15 void OSRunner::setLastEnergyPlusSqlFilePath(const openstudio::path& lastEnergyPlusSqlFilePath) {
945
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 if (openstudio::filesystem::exists(lastEnergyPlusSqlFilePath)) {
946
3/3
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
15 m_lastEnergyPlusSqlFilePath = openstudio::filesystem::canonical(lastEnergyPlusSqlFilePath);
947 } else {
948 ✗ m_lastEnergyPlusSqlFilePath = lastEnergyPlusSqlFilePath;
949 }
950 15 m_lastEnergyPlusSqlFile.reset();
951 15 }
952
953 ✗ void OSRunner::resetLastEnergyPlusSqlFilePath() {
954 ✗ m_lastEnergyPlusSqlFilePath.reset();
955 ✗ m_lastEnergyPlusSqlFile.reset();
956 ✗ }
957
958 ✗ void OSRunner::setLastModelicaResultPath(const openstudio::path& lastModelicaResultPath) {
959 ✗ if (openstudio::filesystem::exists(lastModelicaResultPath)) {
960 ✗ m_lastModelicaResultPath = openstudio::filesystem::canonical(lastModelicaResultPath);
961 } else {
962 ✗ m_lastModelicaResultPath = lastModelicaResultPath;
963 }
964 ✗ }
965
966 ✗ void OSRunner::resetLastModelicaResultPath() {
967 ✗ m_lastModelicaResultPath.reset();
968 ✗ }
969
970 97 void OSRunner::setLastEpwFilePath(const openstudio::path& lastEpwFilePath) {
971
1/2
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
97 if (openstudio::filesystem::exists(lastEpwFilePath)) {
972
3/3
✓ Branch 1 taken 97 times.
✓ Branch 4 taken 97 times.
✓ Branch 7 taken 97 times.
97 m_lastEpwFilePath = openstudio::filesystem::canonical(lastEpwFilePath);
973 } else {
974 ✗ m_lastEpwFilePath = lastEpwFilePath;
975 }
976 97 m_lastEpwFile.reset();
977 97 }
978
979 ✗ void OSRunner::resetLastEpwFilePath() {
980 ✗ m_lastEpwFilePath.reset();
981 ✗ m_lastEpwFile.reset();
982 ✗ }
983
984 ✗ bool OSRunner::setUnitsPreference(const std::string& unitsPreference) {
985 ✗ m_unitsPreference = unitsPreference;
986 ✗ return true;
987 }
988
989 ✗ void OSRunner::resetUnitsPreference() {
990 ✗ m_unitsPreference = "IP";
991 ✗ }
992
993 ✗ bool OSRunner::setLanguagePreference(const std::string& languagePreference) {
994 ✗ m_languagePreference = languagePreference;
995 ✗ return true;
996 }
997
998 ✗ void OSRunner::resetLanguagePreference() {
999 ✗ m_languagePreference = "en";
1000 ✗ }
1001
1002 63 std::string OSRunner::cleanValueName(const std::string& name) {
1003
4/7
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
63 static const boost::regex allowableCharacters("[^0-9a-zA-Z]");
1004
4/7
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
63 static const boost::regex leadingUnderscore("^_+");
1005
4/7
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
63 static const boost::regex trailingUnderscore("_+$");
1006
4/7
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
63 static const boost::regex leadingNumber("^([0-9])");
1007
4/7
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
63 static const boost::regex multipleUnderscore("[_]+");
1008
1009 63 std::string result = boost::regex_replace(name, allowableCharacters, "_");
1010
1/1
✓ Branch 1 taken 63 times.
63 result = boost::regex_replace(result, leadingUnderscore, "");
1011
1/1
✓ Branch 1 taken 63 times.
63 result = boost::regex_replace(result, trailingUnderscore, "");
1012
1/1
✓ Branch 1 taken 63 times.
63 result = boost::regex_replace(result, leadingNumber, "_$1");
1013
1/1
✓ Branch 1 taken 63 times.
63 result = boost::regex_replace(result, multipleUnderscore, "_");
1014
1/1
✓ Branch 1 taken 63 times.
63 result = toUnderscoreCase(result);
1015 63 return result;
1016 ✗ }
1017
1018 67 void OSRunner::captureStreams() {
1019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if (m_streamsCaptured) {
1020 ✗ return;
1021 }
1022 67 m_streamsCaptured = true;
1023
1024 67 std::cout.flush();
1025 67 std::cout.rdbuf()->pubsync();
1026 67 m_originalStdOut = std::cout.rdbuf();
1027
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
134 m_bufferStdOut.str("");
1028 67 std::cout.rdbuf(m_bufferStdOut.rdbuf());
1029
1030 67 std::cerr.flush();
1031 67 std::cerr.rdbuf()->pubsync();
1032 67 m_originalStdErr = std::cerr.rdbuf();
1033
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
134 m_bufferStdErr.str("");
1034 67 std::cerr.rdbuf(m_bufferStdErr.rdbuf());
1035 }
1036
1037 110 void OSRunner::restoreStreams() {
1038
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 67 times.
110 if (!m_streamsCaptured) {
1039 43 return;
1040 }
1041 67 m_streamsCaptured = false;
1042
1043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 OS_ASSERT(m_originalStdOut);
1044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 OS_ASSERT(m_originalStdErr);
1045
1046 67 std::cout.rdbuf(m_originalStdOut);
1047
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
67 std::cout << m_bufferStdOut.str();
1048 67 std::cout.flush();
1049 67 m_originalStdOut = nullptr;
1050
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
134 m_bufferStdOut.str("");
1051
1052 67 std::cerr.rdbuf(m_originalStdErr);
1053
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
67 std::cerr << m_bufferStdErr.str();
1054 67 std::cerr.flush();
1055 67 m_originalStdErr = nullptr;
1056
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
201 m_bufferStdErr.str("");
1057 }
1058
1059 } // namespace measure
1060 } // namespace openstudio
1061