MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / clean_js_output

Function clean_js_output

test/common.py:356–382  ·  view source on GitHub ↗

Cleanup the JS output prior to running verification steps on it. Due to minification, when we get a crash report from JS it can sometimes contains the entire program in the output (since the entire program is on a single line). In this case we can sometimes get false positives when checkin

(output)

Source from the content-addressed store, hash-verified

354
355
356def clean_js_output(output):
357 """Cleanup the JS output prior to running verification steps on it.
358
359 Due to minification, when we get a crash report from JS it can sometimes
360 contains the entire program in the output (since the entire program is
361 on a single line). In this case we can sometimes get false positives
362 when checking for strings in the output. To avoid these false positives
363 and the make the output easier to read in such cases we attempt to remove
364 such lines from the JS output.
365 """
366 lines = output.splitlines()
367 long_lines = []
368
369 def cleanup(line):
370 if len(line) > 2048 and line.startswith('var Module=typeof Module!="undefined"'):
371 long_lines.append(line)
372 line = '<REPLACED ENTIRE PROGRAM ON SINGLE LINE>'
373 return line
374
375 lines = [cleanup(l) for l in lines]
376 if not long_lines:
377 # No long lines found just return the unmodified output
378 return output
379
380 # Sanity check that we only a single long line.
381 assert len(long_lines) == 1
382 return '\n'.join(lines)
383
384
385class RunnerMeta(type):

Callers 1

run_jsMethod · 0.85

Calls 2

cleanupFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected