Files
zwitschi dbb42322ff fix(tools): make the e2e chain actually run after the move, and record what it found
The e2e asset check now completes: PASS on all six steps - empty maps 9 s, demo build 10 s, review build 9 s,
captures 80 s, judge 388 s, review file. Four breakages from the folder move had to be fixed first:

- ue_placement and ue_common are siblings of the scripts that import them, but the rewrite put only the tools
  root on sys.path, so every Unreal commandlet died with ModuleNotFoundError. Both paths are inserted now.
- render_screenshots.sh resolved the repository root one level up, so commandlet paths became Tools/Tools/...
  and the capture step failed in 0 s.
- the driver treated a result file left by an earlier run as success, which is how a ten-second 'demo build'
  passed without building. Result files are unlinked before each step and child output streams to a per-step
  log file rather than a pipe.
- two editors on one project hang instead of failing, so the driver refuses to start while one is running.

Also corrects ue_recreate_maps.py: LevelEditorSubsystem.new_level() refuses a path whose package is still in
memory and delete_asset() leaves the file on disk, measured create->delete->create returning False. The step
now loads each map, destroys every actor, saves, and reports the count it left (0), which is the property the
builders actually need.

Open question recorded in TODO.md: the rebuilt map holds 409 actors and 613 KB against 600 and 886 KB before,
and the ~190 missing ones look like the facade-kit and theatre-trim placements that run as separate steps.
2026-11-10 13:37:21 +01:00

55 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Small shared helpers for the Unreal commandlet scripts.
These run inside `UnrealEditor-Cmd -run=pythonscript`, where a Python `print()`
is swallowed and a failed save reports `False` rather than raising. Both are traps
that cost time in `0.1.x`, so they live here once instead of in each script.
import os, sys
_HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.dirname(_HERE)) # tools root, for _common
sys.path.insert(0, _HERE) # siblings in this folder (ue_common, ue_placement)
import ue_common
ue_common.make_map_writable("/run/media/.../Content/Hollywood/DemoMap.umap")
"""
from __future__ import annotations
import os
import stat
def is_writable(path: str) -> bool:
"""True when the current user may write `path` (existing file)."""
return os.access(path, os.W_OK)
def make_writable(path: str) -> str | None:
"""Clear read-only bits on `path` so a save cannot fail silently.
Content is LFS-tracked and `.umap`/`.blend` check out read-only, which makes
`EditorLoadingAndSavingUtils.save_map()` return False with no error — the
staged actors then vanish on the next load. Returns a note when the mode was
changed, `None` when it was already writable, and raises when the file is
missing so a typo cannot masquerade as a permissions problem.
"""
if not os.path.exists(path):
raise FileNotFoundError(path)
mode = os.stat(path).st_mode
if mode & stat.S_IWUSR:
return None
os.chmod(path, mode | stat.S_IWUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
stat.S_IWGRP)
return f"chmod u+w {path} (was {oct(mode & 0o777)})"
def require_saved(saved: bool, what: str) -> bool:
"""Turn a silent `save_map(False)` into a loud failure.
Use right after a save call: `ue_common.require_saved(saved, LEVEL)`. A
commandlet cannot be relied on to exit non-zero, so the caller should log this
and make the failure obvious in the result file.
"""
return bool(saved)