Skip to content

Commit

Permalink
Exercise stop_on_measurement_fail option later, after multidims have …
Browse files Browse the repository at this point in the history
…been validated

Without this patch, phase with multidims will always fail if using that option even if all multdims have been set.

PiperOrigin-RevId: 682108165
  • Loading branch information
glados-verma authored and copybara-github committed Oct 8, 2024
1 parent 7a5acb8 commit 64f6879
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 0 additions & 10 deletions openhtf/core/phase_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,6 @@ def __call__(self,
else:
phase_result = self.func(**kwargs)

# Override the phase result if the user wants to treat ANY failed
# measurement of this phase as a test-stopping failure.
if self.options.stop_on_measurement_fail:
# Note: The measurement definitions do NOT have the outcome populated.
for measurement in self.measurements:
if (running_test_state.test_api.get_measurement(
measurement.name).outcome != core_measurements.Outcome.PASS):
phase_result = PhaseResult.STOP
break

return phase_result


Expand Down
8 changes: 8 additions & 0 deletions openhtf/core/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,14 @@ def _set_prediagnosis_phase_outcome(self) -> None:
elif not self._measurements_pass():
self.logger.debug(
'Phase outcome of %s is FAIL due to measurement outcome.', self.name)
if self.options.stop_on_measurement_fail:
self.logger.debug(
'Stopping test due to phase %s having stop on fail option.',
self.name,
)
self.result = phase_executor.PhaseExecutionOutcome(
phase_descriptor.PhaseResult.STOP
)
outcome = test_record.PhaseOutcome.FAIL
else:
self.logger.debug('Phase outcome of %s is PASS.', self.name)
Expand Down

0 comments on commit 64f6879

Please sign in to comment.