Skip to content

Commit 3d33c0c

Browse files
authored
Move browser init code to browser_common.py (#25749)
1 parent c1ee2b2 commit 3d33c0c

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

test/browser_common.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# University of Illinois/NCSA Open Source License. Both these licenses can be
44
# found in the LICENSE file.
55

6+
import atexit
67
import logging
78
import os
89
import plistlib
@@ -118,6 +119,23 @@ def terminate_list_of_processes(proc_list):
118119
pass
119120

120121

122+
def init(force_browser_process_termination):
123+
utils.delete_file(browser_spawn_lock_filename)
124+
utils.delete_file(f'{browser_spawn_lock_filename}_counter')
125+
if force_browser_process_termination or os.getenv('EMTEST_FORCE_BROWSER_PROCESS_TERMINATION'):
126+
config = get_browser_config()
127+
128+
if config and hasattr(config, 'executable_name'):
129+
def terminate_all_browser_processes():
130+
procs = list_processes_by_name(config.executable_name)
131+
if len(procs) > 0:
132+
print(f'Terminating {len(procs)} stray browser processes.')
133+
terminate_list_of_processes(procs)
134+
135+
atexit.register(terminate_all_browser_processes)
136+
terminate_all_browser_processes()
137+
138+
121139
def find_browser_test_file(filename):
122140
"""Looks for files in test/browser and then in test/
123141
"""

test/runner.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -581,20 +581,8 @@ def set_env(name, option_value):
581581
# Remove any old test files before starting the run
582582
cleanup_emscripten_temp()
583583
utils.delete_file(common.flaky_tests_log_filename)
584-
utils.delete_file(browser_common.browser_spawn_lock_filename)
585-
utils.delete_file(f'{browser_common.browser_spawn_lock_filename}_counter')
586-
if options.force_browser_process_termination or os.getenv('EMTEST_FORCE_BROWSER_PROCESS_TERMINATION'):
587-
config = browser_common.get_browser_config()
588-
589-
def terminate_all_browser_processes():
590-
procs = browser_common.list_processes_by_name(config.executable_name)
591-
if len(procs) > 0:
592-
print(f'Terminating {len(procs)} stray browser processes.')
593-
browser_common.terminate_list_of_processes(procs)
594-
595-
if config and hasattr(config, 'executable_name'):
596-
atexit.register(terminate_all_browser_processes)
597-
terminate_all_browser_processes()
584+
585+
browser_common.init(options.force_browser_process_termination)
598586

599587
def prepend_default(arg):
600588
if arg.startswith('test_'):

0 commit comments

Comments
 (0)