Skip to content

Commit 19d3d9e

Browse files
authored
Add some basic testing for EMTEST_VISUALIZE. NFC (#25750)
This required the removal of usage of str.removeprefix which is python 3.9+ feature. See #25743
1 parent 3d33c0c commit 19d3d9e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ jobs:
11011101
executor: focal
11021102
environment:
11031103
EMTEST_LACKS_WEBGPU: "1"
1104+
EMTEST_VISUALIZE: "1"
11041105
steps:
11051106
- run-tests-chrome:
11061107
title: "browser64"
@@ -1123,6 +1124,9 @@ jobs:
11231124
browser64.test_pthread_asan*
11241125
browser64.test_webgl_multi_draw*
11251126
browser64.test_pthread_growth*"
1127+
- run:
1128+
name: Check profile
1129+
command: file -E out/graph.html
11261130
test-browser-chrome-2gb:
11271131
executor: focal
11281132
environment:

test/parallel_testsuite.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from tools.colored_logger import CYAN, GREEN, RED, with_color
2020
from tools.utils import WINDOWS
2121

22+
EMTEST_VISUALIZE = os.getenv('EMTEST_VISUALIZE')
2223
NUM_CORES = None
2324
seen_class = set()
2425
torn_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

Comments
 (0)