(selenium_standalone_refresh)
| 1010 | @pytest.mark.xfail_browsers(safari="TODO: traceback is not the same on Safari") |
| 1011 | @pytest.mark.skip_refcount_check |
| 1012 | def test_fatal_error(selenium_standalone_refresh): |
| 1013 | assert selenium_standalone_refresh.run_js( |
| 1014 | """ |
| 1015 | try { |
| 1016 | pyodide.runPython(` |
| 1017 | from _pyodide_core import trigger_fatal_error |
| 1018 | def f(): |
| 1019 | g() |
| 1020 | def g(): |
| 1021 | h() |
| 1022 | def h(): |
| 1023 | trigger_fatal_error() |
| 1024 | f() |
| 1025 | `); |
| 1026 | } catch(e){ |
| 1027 | return e.toString(); |
| 1028 | } |
| 1029 | """ |
| 1030 | ) |
| 1031 | import re |
| 1032 | |
| 1033 | def strip_stack_trace(x): |
| 1034 | # Remove ANSI color codes |
| 1035 | x = re.sub(r"\x1b\[[0-9;]*[a-zA-Z]", "", x) |
| 1036 | x = re.sub("\n.*site-packages.*", "", x) |
| 1037 | x = re.sub("/lib/python.*/", "", x) |
| 1038 | x = re.sub("/lib/python.*/", "", x) |
| 1039 | x = re.sub("warning: no [bB]lob.*\n", "", x) |
| 1040 | x = re.sub("Error: intentionally triggered fatal error!\n", "", x) |
| 1041 | x = re.sub(" +at .*\n", "", x) |
| 1042 | x = re.sub(".*@https?://[0-9.:]*/.*\n", "", x) |
| 1043 | x = re.sub(".*@debugger.*\n", "", x) |
| 1044 | x = re.sub(".*@chrome.*\n", "", x) |
| 1045 | x = re.sub("line [0-9]*", "line xxx", x) |
| 1046 | x = x.replace("\n\n", "\n") |
| 1047 | return x |
| 1048 | |
| 1049 | err_msg = strip_stack_trace(selenium_standalone_refresh.logs) |
| 1050 | err_msg = "".join(strip_assertions_stderr(err_msg.splitlines(keepends=True))) |
| 1051 | assert ( |
| 1052 | err_msg |
| 1053 | == dedent( |
| 1054 | strip_stack_trace( |
| 1055 | """ |
| 1056 | Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers. |
| 1057 | The cause of the fatal error was: |
| 1058 | Stack (most recent call first): |
| 1059 | File "<exec>", line 8 in h |
| 1060 | File "<exec>", line 6 in g |
| 1061 | File "<exec>", line 4 in f |
| 1062 | File "<exec>", line 9 in <module> |
| 1063 | File "/lib/pythonxxx/pyodide/_base.py", line 242 in run |
| 1064 | File "/lib/pythonxxx/pyodide/_base.py", line 344 in eval_code |
| 1065 | """ |
| 1066 | ) |
| 1067 | ).strip() |
| 1068 | ) |
| 1069 | selenium_standalone_refresh.run_js( |
nothing calls this directly
no test coverage detected
searching dependent graphs…