1919from tools .colored_logger import CYAN , GREEN , RED , with_color
2020from tools .utils import WINDOWS
2121
22+ EMTEST_VISUALIZE = os .getenv ('EMTEST_VISUALIZE' )
2223NUM_CORES = None
2324seen_class = set ()
2425torn_down = False
@@ -270,7 +271,7 @@ def combine_results(self, result, buffered_results):
270271 r .updateResult (result )
271272
272273 # Generate the parallel test run visualization
273- if os . getenv ( ' EMTEST_VISUALIZE' ) :
274+ if EMTEST_VISUALIZE :
274275 emprofile .create_profiling_graph (utils .path_from_root ('out/graph' ))
275276 # Cleanup temp files that were used for the visualization
276277 emprofile .delete_profiler_logs ()
@@ -309,7 +310,7 @@ def updateResult(self, result):
309310 self .log_test_run_for_visualization ()
310311
311312 def log_test_run_for_visualization (self ):
312- if os . getenv ( ' EMTEST_VISUALIZE' ) and (self .test_result != 'skipped' or self .test_duration > 0.2 ):
313+ if EMTEST_VISUALIZE and (self .test_result != 'skipped' or self .test_duration > 0.2 ):
313314 profiler_logs_path = os .path .join (tempfile .gettempdir (), 'emscripten_toolchain_profiler_logs' )
314315 os .makedirs (profiler_logs_path , exist_ok = True )
315316 profiler_log_file = os .path .join (profiler_logs_path , 'toolchain_profiler.pid_0.json' )
@@ -326,7 +327,7 @@ def log_test_run_for_visualization(self):
326327 # block, so generate one on the fly.
327328 dummy_test_task_counter = os .path .getsize (profiler_log_file ) if os .path .isfile (profiler_log_file ) else 0
328329 # Remove the redundant 'test_' prefix from each test, since character space is at a premium in the visualized graph.
329- test_name = self .test_short_name (). removeprefix ( 'test_' )
330+ test_name = utils . removeprefix ( self .test_short_name (), 'test_' )
330331 with open (profiler_log_file , 'a' ) as prof :
331332 prof .write (f',\n {{"pid":{ dummy_test_task_counter } ,"op":"start","time":{ self .start_time } ,"cmdLine":["{ test_name } "],"color":"{ colors [self .test_result ]} "}}' )
332333 prof .write (f',\n {{"pid":{ dummy_test_task_counter } ,"op":"exit","time":{ self .start_time + self .test_duration } ,"returncode":0}}' )
0 commit comments