From 64f6879d7d22675926aa3641f5638a445880200a Mon Sep 17 00:00:00 2001 From: glados-verma Date: Thu, 3 Oct 2024 18:14:04 -0700 Subject: [PATCH] Exercise stop_on_measurement_fail option later, after multidims have 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 --- openhtf/core/phase_descriptor.py | 10 ---------- openhtf/core/test_state.py | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/openhtf/core/phase_descriptor.py b/openhtf/core/phase_descriptor.py index fb0f8af1..0dcf0069 100644 --- a/openhtf/core/phase_descriptor.py +++ b/openhtf/core/phase_descriptor.py @@ -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 diff --git a/openhtf/core/test_state.py b/openhtf/core/test_state.py index b3d5d54f..c55cd7e3 100644 --- a/openhtf/core/test_state.py +++ b/openhtf/core/test_state.py @@ -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)