crashtest.run
Functions to run tests, collect results, and produce run reports.
compare_opcodes
def compare_opcodes(original_code: Bytecode, recompiled_code: Bytecode, class_name: str) -> OpcodeComparison
Compare per-method opcode sequences between original and recompiled bytecode.
file_to_name
def file_to_name(file: str) -> str
gen_id
def gen_id() -> str
Generate a unique ID for a test run.
gen_status
def gen_status(results: List[TestCase]) -> Tuple[str, str]
Generate a status message and color based on test results. Returns a tuple of (status_message, color_hex).
Colors:
- Green (#22C55E): All tests passed
- Yellow (#EAB308): < 10% failures
- Orange (#F97316): 10-20% failures
- Red-Orange (#EF4444): 20-50% failures
- Red (#DC2626): > 50% failures
- Dark Red (#991B1B): All tests failed
get_repo_info
def get_repo_info() -> GitInfo
Get the git branch and commit hash, if available.
op_similarity
def op_similarity(a: List[str], b: List[str]) -> float
Sequence similarity of two opcode name lists, 0.0-1.0.
op_source_lines
def op_source_lines(func: Function) -> List[int]
Per-op source line numbers (1-indexed), parallel to to_asm_resolved's output
line-for-line. Each op's debug entry points back into whatever source file was
compiled to produce this bytecode (the original .hx for the original function,
or the decompiled pseudocode .hx for the recompiled one) — this is what lets the
UI match a diffed opcode line up with the source line that produced it. -1 where
no debug info is available.
recompile_pseudo
def recompile_pseudo(pseudo_content: str, class_name: str) -> Tuple[Optional[Bytecode], Optional[str]]
Write pseudocode to a temp file, compile with haxe, return loaded Bytecode or error string.
run
def run() -> None
Run all tests.
run_case
def run_case(case: str, id: int) -> TestCase
Runs a single test case by decompiling the main class in the file. It generates both class-level pseudocode and a combined IR view of all methods, then recompiles the pseudocode and compares opcodes with the original.
run_single_case
def run_single_case(args: Any) -> None
Run a single test case by name and print results to the terminal.
sweep
def sweep(bytecode_path: str, count: int, out_path: str) -> None
Decompile the first count functions of a bytecode image to a file.
to_asm_resolved
def to_asm_resolved(func: Function, code: Bytecode) -> str
Like to_asm but resolves constant-pool indices to their actual values.