Skip to content

Commit

Permalink
Merge pull request #1194 from glados-verma:profile
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695754289
  • Loading branch information
copybara-github committed Nov 12, 2024
2 parents a7c3ce2 + d4b15b3 commit 1938ce8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion openhtf/core/test_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def trigger_phase(test):
self.make_uid(),
trigger,
self._test_options,
run_with_profiling=profile_filename is not None)
run_phases_with_profiling=profile_filename is not None)

_LOG.info('Executing test: %s', self.descriptor.code_info.name)
self.TEST_INSTANCES[self.uid] = self
Expand Down
11 changes: 5 additions & 6 deletions openhtf/core/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ def __init__(self, test_descriptor: 'test_descriptor.TestDescriptor',
execution_uid: Text,
test_start: Optional[phase_descriptor.PhaseDescriptor],
test_options: 'test_descriptor.TestOptions',
run_with_profiling: bool):
super(TestExecutor, self).__init__(
name='TestExecutorThread', run_with_profiling=run_with_profiling)
run_phases_with_profiling: bool):
super(TestExecutor, self).__init__(name='TestExecutorThread')
self.test_state = None # type: Optional[test_state.TestState]

self._run_phases_with_profiling = run_phases_with_profiling
self._test_descriptor = test_descriptor
self._test_start = test_start
self._test_options = test_options
Expand Down Expand Up @@ -276,7 +275,7 @@ def _execute_test_start(self) -> bool:
return True

outcome, profile_stats = self.phase_executor.execute_phase(
self._test_start, self._run_with_profiling
self._test_start, self._run_phases_with_profiling
)

if profile_stats is not None:
Expand Down Expand Up @@ -339,7 +338,7 @@ def _execute_phase(self, phase: phase_descriptor.PhaseDescriptor,

outcome, profile_stats = self.phase_executor.execute_phase(
phase,
run_with_profiling=self._run_with_profiling,
run_with_profiling=self._run_phases_with_profiling,
subtest_rec=subtest_rec,
)
if profile_stats is not None:
Expand Down
2 changes: 1 addition & 1 deletion openhtf/util/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _handle_test(self, test):
if profile_filepath is None:
profile_tempfile = None
else:
profile_tempfile = tempfile.NamedTemporaryFile()
profile_tempfile = tempfile.NamedTemporaryFile(delete=False)
# Mock the PlugManager to use ours instead, and execute the test.
with mock.patch.object(
plugs, 'PlugManager', new=lambda _, __: self.plug_manager):
Expand Down
32 changes: 16 additions & 16 deletions test/core/exe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def set_ev():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand All @@ -273,7 +273,7 @@ def set_ev():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)
executor.start()
executor.wait()
record = executor.running_test_state.test_record
Expand Down Expand Up @@ -331,7 +331,7 @@ def set_ev():
'uid',
cancel_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand Down Expand Up @@ -366,7 +366,7 @@ def set_ev():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand Down Expand Up @@ -408,7 +408,7 @@ def set_ev():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand Down Expand Up @@ -459,7 +459,7 @@ def teardown2_phase():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand Down Expand Up @@ -488,7 +488,7 @@ def set_ev():
'uid',
None,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)
executor.start()
executor.wait()
record = executor.running_test_state.test_record
Expand Down Expand Up @@ -522,7 +522,7 @@ def set_ev():
'uid',
fail_plug_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)
executor.start()
executor.wait()
record = executor.running_test_state.test_record
Expand All @@ -544,7 +544,7 @@ def test_error_during_teardown(self):
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)
executor.start()
executor.wait()
record = executor.running_test_state.test_record
Expand All @@ -568,7 +568,7 @@ def teardown_log(test):
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)
executor.start()
executor.wait()
record = executor.running_test_state.test_record
Expand Down Expand Up @@ -596,7 +596,7 @@ def set_ev():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand Down Expand Up @@ -628,7 +628,7 @@ def set_ev():
'uid',
start_phase,
test._test_options,
run_with_profiling=False)
run_phases_with_profiling=False)

executor.start()
executor.wait()
Expand Down Expand Up @@ -665,7 +665,7 @@ def setUp(self):
td.uid,
None,
test_descriptor.TestOptions(),
run_with_profiling=False)
run_phases_with_profiling=False)
self.test_exec.test_state = self.test_state
self.test_exec._phase_exec = self.phase_exec

Expand Down Expand Up @@ -742,7 +742,7 @@ def setUp(self):
td.uid,
None,
test_descriptor.TestOptions(),
run_with_profiling=False)
run_phases_with_profiling=False)
self.test_exec.test_state = self.test_state
patcher = mock.patch.object(self.test_exec, '_execute_node')
self.mock_execute_node = patcher.start()
Expand Down Expand Up @@ -897,7 +897,7 @@ def setUp(self):
td.uid,
None,
test_descriptor.TestOptions(),
run_with_profiling=False)
run_phases_with_profiling=False)
self.test_exec.test_state = self.test_state
patcher = mock.patch.object(self.test_exec, '_execute_sequence')
self.mock_execute_sequence = patcher.start()
Expand Down Expand Up @@ -1086,7 +1086,7 @@ def setUp(self):
td.uid,
None,
test_descriptor.TestOptions(),
run_with_profiling=False)
run_phases_with_profiling=False)
self.test_exec.test_state = self.test_state
patcher = mock.patch.object(self.test_exec, '_execute_sequence')
self.mock_execute_sequence = patcher.start()
Expand Down

0 comments on commit 1938ce8

Please sign in to comment.