| 28 | ], |
| 29 | ) |
| 30 | def test_traceback(mode, entry_point): |
| 31 | tb_tool = yc.build_path("library/python/runtime_py3/test/traceback/traceback") |
| 32 | stdout_path = yc.test_output_path("stdout_raw.txt") |
| 33 | stderr_path = yc.test_output_path("stderr_raw.txt") |
| 34 | filtered_stdout_path = yc.test_output_path("stdout.txt") |
| 35 | filtered_stderr_path = yc.test_output_path("stderr.txt") |
| 36 | |
| 37 | env = os.environ.copy() |
| 38 | env.pop("PYTHONPATH", None) # Do not let program peek into its sources on filesystem |
| 39 | if entry_point == "custom": |
| 40 | env["Y_PYTHON_ENTRY_POINT"] = "library.python.runtime_py3.test.traceback.crash:main" |
| 41 | |
| 42 | proc = yc.execute( |
| 43 | command=[tb_tool, mode], |
| 44 | env=env, |
| 45 | stdout=stdout_path, |
| 46 | stderr=stderr_path, |
| 47 | check_exit_code=False, |
| 48 | ) |
| 49 | |
| 50 | with open(filtered_stdout_path, "wb") as f: |
| 51 | f.write(clean_traceback(proc.std_out)) |
| 52 | |
| 53 | with open(filtered_stderr_path, "wb") as f: |
| 54 | f.write(clean_traceback(proc.std_err)) |
| 55 | |
| 56 | return { |
| 57 | "stdout": yc.canonical_file( |
| 58 | filtered_stdout_path, |
| 59 | local=True, |
| 60 | ), |
| 61 | "stderr": yc.canonical_file( |
| 62 | filtered_stderr_path, |
| 63 | local=True, |
| 64 | ), |
| 65 | } |