Files
LGUG2Z 1afac08af5 fix(scripts): the Linux scripts find the repository from scripts/linux/
The scripts were written for a KDE-only repository root (komorebi-for-kde/, scripts/ one
level below it). They now live in scripts/linux/ of the consolidated repository:
- run-kde looks for the repository two directories above itself (flake.nix at the root) and
  no longer knows the komorebi-for-kde/ subdirectory; its comments name nix/linux and docs/linux
- vm-mac cd`s two levels up, usage and comments name scripts/linux/vm-mac
- sync-e2e-core and scenario-status read nix/linux/tests/vm/lib, and usage lines name the new
  paths (scenario-status resolves the library with parents[2])
- wsl2-probe.sh names docs/linux/dev/wsl2-probe.md and prints "komorebi (KDE Plasma)" instead of
  komorebi-for-kde in its report header
- compare-gen.py is stale by design: the docstring now says so a second time (layout) and
  names the new path of COMPARE.md; the logic is not repaired

Flake attribute names the scripts call (nix run .#run-kde, .#wsl2-probe, legacyPackages.*.vm.NAME
in vm-mac) are left for the one-flake revision.

Verified: bash -n and shellcheck -S warning pass on the four shell scripts; the two Python
scripts parse (ast); `bash run-kde --dry-run` run from /tmp prints KOMOREBI_REPO as this
checkout; `sync-e2e-core --check e2e/lib` prints "in step"; `scenario-status --help` runs.
Not run: the VM, vm-mac, wsl2-probe.
2026-11-05 15:03:27 -08:00

40 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python3
"""Makes the scenario-by-port status table from the logs of runs on KDE and the result files of
kfw (see nix/linux/tests/vm/lib/komorebi_vm/status.py).
scripts/linux/scenario-status --kde LOG... [--windows DIR...] [--update docs/linux/dev/BEHAVIOUR.md]
Without --update the table is printed. With it, what is between the two comment markers
(`<!-- scenario-status:begin -->` and `<!-- scenario-status:end -->`) of the file is replaced.
"""
import argparse
import importlib.util
from pathlib import Path
path = Path(__file__).resolve().parents[2] / "nix/linux/tests/vm/lib/komorebi_vm/status.py"
spec = importlib.util.spec_from_file_location("status", path)
assert spec and spec.loader
status = importlib.util.module_from_spec(spec)
spec.loader.exec_module(status)
parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
parser.add_argument("--kde", nargs="*", default=[], type=Path, help="logs of runs on KDE")
parser.add_argument("--windows", nargs="*", default=[], type=Path, help="directories of kfw results")
parser.add_argument("--update", type=Path, help="the document to put the table in")
args = parser.parse_args()
found = status.Status()
# oldest first, so that a scenario two logs have is counted from the newer
for log in sorted(args.kde, key=lambda path: path.stat().st_mtime):
one = status.Status()
status.read_kde(one, log.read_text(errors="replace"))
status.merge(found, one)
for directory in args.windows:
status.read_windows(found, directory)
text = status.table(found)
if args.update:
args.update.write_text(status.replace_region(args.update.read_text(), text))
else:
print(text, end="")