Runs a single test and gathers detailed investigation artifacts.
(test_name: str, release_mode: bool)
| 34 | path.write_text( |
| 35 | f"--- COMMAND ---\n{rendered_command}\n\n" |
| 36 | f"--- RETURN CODE: {proc.returncode} ---\n\n" |
| 37 | f"--- STDOUT ---\n{proc.stdout}\n\n--- STDERR ---\n{proc.stderr}", |
| 38 | encoding="utf-8", |
| 39 | ) |
| 40 | |
| 41 | |
| 42 | def find_test(name: str) -> TestCase: |
| 43 | matches = [test for test in discover_tests() if test.name == name] |
| 44 | if not matches: |
| 45 | raise ValueError(f"unknown test: {name}") |
| 46 | if len(matches) > 1: |
| 47 | kinds = ", ".join(test.kind for test in matches) |
| 48 | raise ValueError(f"test name {name!r} is ambiguous across: {kinds}") |
| 49 | return matches[0] |
| 50 | |
| 51 | |
| 52 | def investigate(name: str, release: bool) -> int: |
| 53 | test = find_test(name) |
| 54 | mode = "release" if release else "debug" |
| 55 | output_dir = ROOT / "investigation" / f"{test.name}_{mode}" |
| 56 | extracted_dir = output_dir / "extracted_jar" |
| 57 | javap_dir = output_dir / "javap_output" |
| 58 | |
| 59 | if output_dir.exists(): |
| 60 | shutil.rmtree(output_dir) |
| 61 | extracted_dir.mkdir(parents=True) |
| 62 | javap_dir.mkdir() |
| 63 | |
| 64 | invalidated = prepare_shared_cache() |
| 65 | print(f"🔬 Investigating {test.name} [{test.kind}, {mode}, jvm-unknown-jvm]") |
| 66 | if invalidated: |
| 67 | print("|- Compiler inputs changed; reset the shared test cache") |
| 68 | print("|- Building shared core/compiler_builtins cache...") |
| 69 | proc = prime_core(release) |
| 70 | write_process_log(output_dir / "core_build.log", [], proc) |
| 71 | if proc.returncode != 0: |
| 72 | print(f"|- ❌ Shared core build failed; see {output_dir / 'core_build.log'}") |
| 73 | return 1 |
| 74 | |
| 75 | print("|- Building test with the JVM target...") |
| 76 | proc = build_test(test, release, cpu_count()) |
| 77 | write_process_log(output_dir / "cargo_build.log", [], proc) |
| 78 | if proc.returncode != 0: |
| 79 | print(f"|- ❌ Cargo build failed; see {output_dir / 'cargo_build.log'}") |
| 80 | return 1 |
| 81 | |
| 82 | jar = jar_path(test, release) |
| 83 | if not jar.exists(): |
| 84 | print(f"|- ❌ Expected JAR is missing: {jar}") |
| 85 | return 1 |
| 86 | print(f"|- JAR: {jar}") |
| 87 | |
| 88 | with zipfile.ZipFile(jar) as archive: |
| 89 | archive.extractall(extracted_dir) |
| 90 | (output_dir / "jar_contents.txt").write_text( |
| 91 | "\n".join(sorted(archive.namelist())) + "\n", |
| 92 | encoding="utf-8", |
| 93 | ) |
no test coverage detected