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)
| 354 | |
| 355 | |
| 356 | def 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 | |
| 385 | class RunnerMeta(type): |