From 7ad31e78d507b477f78adb779c726d80d179dcaf Mon Sep 17 00:00:00 2001 From: kwy404 Date: Thu, 24 Sep 2026 19:48:40 -0300 Subject: [PATCH] Fix instrumentation parsing when a result line follows a status block When the instrumentation run crashes after some INSTRUMENTATION_STATUS lines but before the INSTRUMENTATION_STATUS_CODE line, the parser called _parse_result_line, which does not exist, so the run failed with an AttributeError instead of reporting the crash. Call _parse_result_block_line instead. --- mobly/base_instrumentation_test.py | 2 +- tests/mobly/base_instrumentation_test_test.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mobly/base_instrumentation_test.py b/mobly/base_instrumentation_test.py index 57134222..ce03fd6a 100644 --- a/mobly/base_instrumentation_test.py +++ b/mobly/base_instrumentation_test.py @@ -795,7 +795,7 @@ def _parse_method_block_line(self, instrumentation_block, line): instrumentation_block.set_key( _InstrumentationStructurePrefixes.RESULT, line ) - return self._parse_result_line( + return self._parse_result_block_line( self._transition_instrumentation_block( instrumentation_block, new_state=_InstrumentationBlockStates.RESULT, diff --git a/tests/mobly/base_instrumentation_test_test.py b/tests/mobly/base_instrumentation_test_test.py index fcf52fb4..a811bf66 100755 --- a/tests/mobly/base_instrumentation_test_test.py +++ b/tests/mobly/base_instrumentation_test_test.py @@ -760,6 +760,21 @@ def test_run_instrumentation_test_with_runner_setup_crash(self): instrumentation_output, expected_has_error=True ) + def test_run_instrumentation_test_with_crash_before_status_code(self): + instrumentation_output = """\ +INSTRUMENTATION_STATUS: class=com.my.package.test.BasicTest +INSTRUMENTATION_STATUS: test=crashTest +INSTRUMENTATION_RESULT: shortMsg=Process crashed. +INSTRUMENTATION_CODE: 0""" + expected_executed = [ + ('com.my.package.test.BasicTest#crashTest', signals.TestFailure), + ] + self.assert_run_instrumentation_test( + instrumentation_output, + expected_executed=expected_executed, + expected_has_error=True, + ) + def test_run_instrumentation_test_with_runner_teardown_crash(self): instrumentation_output = """\ INSTRUMENTATION_STATUS: numtests=1