Files
mandy/scripts/dev.py
AlxcBTW d083a2cc37 Make main's tests green: 12 test files that drifted from the code (#9896)
Twelve test files failed on main at 2d53a8055 (CI's check and semantic-tests steps, run locally): most are a test
and the code it checks changed by different pull requests in the same merge round. Each fix below is either taken
from a closed pull request that already had it, or restores what an earlier merged change intended.

From closed pull requests:
- test_make_game_resume: FakeProc gets poll(), which translate() now calls (#7018)
- test_make_game_empty_translation: the Exited stub gets poll() and the failed-shard path is checked (#7214)
- test_shader_checks: stub table_fetch_test in the Wave64Checks harness and count it (#7433)
- test_runtime_paths: runtime.yml's path filter lists tools/replace_retry.py, which rdna2spirv.py imports (#7029)
- test_psin_names: patch the same_report_path helpers that report_paths now calls (#8719)
- test_report_source_collision: the fixture is a real Bink 2 header; bink_index refuses other files (#7408)
- test_missing_input_exit_codes: tile_probe checks its inputs before it asks for numpy (#4771)

Restored:
- merge_check: a failed `git show` is an error again (5b88d58); 21016cf brought back the lenient read that
  treated it as a new file, while new files are already left out when the diff is read
- rpf_probe: a symlinked --out updates its target again (44d3595); 55d21cc's staged write replaced the link

Updated to the code:
- test_shader_stage_resume: TRANSLATION_SOURCES lists fssm_unpack.py and shader_stage_manifest.py, which the
  translator imports; existing work folders translate once more after this
- test_tool_stdout_encoding: the 15 programs merged without the stdout guard get the same block as the others
- test_rdna2spirv_decode: drop the test of decode_any_format, which SHADER-849 replaced with the table decode
  that tests/semantic/test_format_decode_table.py checks

Co-authored-by: jewmaster1337 <102986566+jewmaster1337@users.noreply.github.com>
Co-authored-by: TanmaySatyam <248538550+TanmaySatyam@users.noreply.github.com>
Co-authored-by: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com>
Co-authored-by: slint6614-dev <359954236+slint6614-dev@users.noreply.github.com>
Co-authored-by: BlackNife <108077267+Poussistar@users.noreply.github.com>
Co-authored-by: fiestorra <65175643+fiestorra@users.noreply.github.com>
Co-authored-by: fearkov <289226582+fearkov@users.noreply.github.com>
Co-authored-by: DoubleD17 <48109637+DoubleD17@users.noreply.github.com>
2026-11-24 00:21:26 +01:00

130 lines
4.5 KiB
Python

#!/usr/bin/env python3
"""Use development tools from this Leonida checkout."""
import argparse
import json
import os
import shlex
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
BOOT_TRACE = "tools/boot_trace.py"
GUEST_SCENE = "scripts/run_guest_scene.py"
TOOLS = (
(
"boot-trace",
BOOT_TRACE,
("Python 3", "Startup JSONL from gta6rt --trace or stderr from gta6rt --trace-d3d12"),
),
(
"guest-scene",
GUEST_SCENE,
(
"Python 3",
"gta6rt and tiny_guest_draw built with LEONIDA_GUEST_SCENE (static SDL3)",
"Vulkan and the synthetic M1.5 shader fixture with a spirv/ directory",
"Wine when running the Windows loader outside Windows",
),
),
)
def discover() -> dict:
tools = []
for name, path, requirements in TOOLS:
present = (ROOT / path).is_file()
tools.append({
"id": name,
"path": path,
"present": present,
"help_argv": [sys.executable, "-I", path, "--help"] if present else None,
"requirements": requirements,
})
return {
"schema_version": 1,
"tools": tools,
"live_controls": {
"available": False,
"reason": "This entry point does not expose live attach, pause, step, input or screenshots.",
},
}
def format_help_command(argv: list[str]) -> str:
if os.name == "nt":
quoted = ("'" + arg.replace("'", "''") + "'" for arg in argv)
return "& " + " ".join(quoted)
return shlex.join(argv)
def run_producer(relative_path: str, args: list[str]) -> int:
producer = ROOT / relative_path
if not producer.is_file():
print(f"error: {relative_path} is missing; use a complete Leonida checkout", file=sys.stderr)
return 2
try:
return subprocess.run(
[sys.executable, "-I", str(producer), *args],
cwd=Path.cwd(),
).returncode
except OSError as exc:
print(f"error: could not run {relative_path}: {exc}", file=sys.stderr)
return 2
def guest_scene(args: list[str]) -> int:
# Only enforce the persistent output option here. The runner parses the original argv.
parser = argparse.ArgumentParser(prog="dev.py guest-scene", add_help=False, allow_abbrev=False)
parser.add_argument("-h", "--help", action="store_true")
parser.add_argument("--out", metavar="PATH")
options, _ = parser.parse_known_args(args)
if not options.help and not options.out:
parser.error("--out PATH is required to keep the scene results")
return run_producer(GUEST_SCENE, args)
def main() -> int:
# The producer owns its arguments and help. Forward before argparse handles them.
argv = sys.argv[1:]
if argv[:1] == ["boot-trace"]:
return run_producer(BOOT_TRACE, argv[1:])
if argv[:1] == ["guest-scene"]:
return guest_scene(argv[1:])
parser = argparse.ArgumentParser(description=__doc__)
commands = parser.add_subparsers(dest="command", required=True)
inventory = commands.add_parser("discover", help="list producer scripts and their requirements")
inventory.add_argument("--json", action="store_true", help="write a JSON inventory to stdout")
commands.add_parser("boot-trace", help="summarize startup and D3D12 boot traces")
commands.add_parser("guest-scene", help="run the synthetic guest scene with a required --out")
args = parser.parse_args(argv)
result = discover()
if args.json:
print(json.dumps(result, indent=2))
else:
sys.stdout.reconfigure(encoding="utf-8")
print("Paths and help commands are relative to the Leonida checkout root.")
for tool in result["tools"]:
status = "present" if tool["present"] else "missing"
print(f"{tool['id']}: {tool['path']} ({status})")
if tool["help_argv"]:
print(f" Help: {format_help_command(tool['help_argv'])}")
print(" Requirements (not checked):")
for requirement in tool["requirements"]:
print(f" - {requirement}")
print(f"Live controls: unavailable. {result['live_controls']['reason']}")
return 0
if __name__ == "__main__":
try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
sys.stdout.reconfigure(errors="replace")
except (AttributeError, ValueError, OSError):
pass
raise SystemExit(main())