40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Exercise the distributed PCK with no source-tree fallback or player saves."""
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("pack", type=Path)
|
|
parser.add_argument("--godot", default="godot")
|
|
parser.add_argument("--capture", type=Path)
|
|
args = parser.parse_args()
|
|
pack = args.pack.resolve(strict=True)
|
|
godot = shutil.which(args.godot)
|
|
if godot is None:
|
|
parser.error(f"Godot executable not found: {args.godot}")
|
|
script = Path(__file__).resolve().parents[1] / "tests/export/test_exported_opening.gd"
|
|
env = dict(os.environ, THE_TREE_REQUIRE_EXPORTED="1")
|
|
command = [godot]
|
|
if args.capture:
|
|
output = args.capture.resolve()
|
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
env.update(THE_TREE_EXPORT_CAPTURE="1", THE_TREE_EXPORT_CAPTURE_PATH=str(output))
|
|
else:
|
|
command.append("--headless")
|
|
command.extend(["--main-pack", str(pack), "--script", str(script)])
|
|
# Running inside the checkout masks missing packed resources: FileAccess
|
|
# can read original .tres files from disk even when the PCK only has .remap.
|
|
with tempfile.TemporaryDirectory(prefix="the-tree-export-check-") as isolated:
|
|
result = subprocess.run(command, cwd=isolated, env=env, timeout=180)
|
|
return result.returncode
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|