File tree Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 33# University of Illinois/NCSA Open Source License. Both these licenses can be
44# found in the LICENSE file.
55
6+ import atexit
67import logging
78import os
89import 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+
121139def find_browser_test_file (filename ):
122140 """Looks for files in test/browser and then in test/
123141 """
Original file line number Diff line number Diff 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_' ):
You can’t perform that action at this time.
0 commit comments