(worker_json: StrJSON)
| 81 | |
| 82 | |
| 83 | def worker_process(worker_json: StrJSON) -> NoReturn: |
| 84 | runtests = WorkerRunTests.from_json(worker_json) |
| 85 | test_name = runtests.tests[0] |
| 86 | match_tests: TestFilter = runtests.match_tests |
| 87 | json_file: JsonFile = runtests.json_file |
| 88 | |
| 89 | setup_test_dir(runtests.test_dir) |
| 90 | setup_process() |
| 91 | |
| 92 | if runtests.rerun: |
| 93 | if match_tests: |
| 94 | matching = "matching: " + ", ".join(pattern for pattern, result in match_tests if result) |
| 95 | print(f"Re-running {test_name} in verbose mode ({matching})", flush=True) |
| 96 | else: |
| 97 | print(f"Re-running {test_name} in verbose mode", flush=True) |
| 98 | |
| 99 | result = run_single_test(test_name, runtests) |
| 100 | if runtests.coverage: |
| 101 | if "test.cov" in sys.modules: # imported by -Xpresite= |
| 102 | result.covered_lines = list(sys.modules["test.cov"].coverage) |
| 103 | elif not Py_DEBUG: |
| 104 | print( |
| 105 | "Gathering coverage in worker processes requires --with-pydebug", |
| 106 | flush=True, |
| 107 | ) |
| 108 | else: |
| 109 | raise LookupError( |
| 110 | "`test.cov` not found in sys.modules but coverage wanted" |
| 111 | ) |
| 112 | |
| 113 | if json_file.file_type == JsonFileType.STDOUT: |
| 114 | print() |
| 115 | result.write_json_into(sys.stdout) |
| 116 | else: |
| 117 | with json_file.open('w', encoding='utf-8') as json_fp: |
| 118 | result.write_json_into(json_fp) |
| 119 | |
| 120 | sys.exit(0) |
| 121 | |
| 122 | |
| 123 | def main() -> NoReturn: |
no test coverage detected
searching dependent graphs…