mirror of
https://github.com/Dasemu/faust-vn.git
synced 2026-11-26 15:26:20 +00:00
refactor: flatten Faust work to the repo root
Move works/faust/{work.toml,data,annotations,assets} to the root and the
generated project vn/faust/ to vn/. Update ignore patterns and add the Faust
integration tests (real text, e2e playthrough) reading the new paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6486ab10f4
commit
5fd43de875
160 files changed
+124
-13
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""End-to-end playthrough of the generated Faust project (needs the Ren'Py SDK)."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from vnpipe import renpy_gen
|
||||
from vnpipe.config import load_work
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
SDK = Path(os.environ.get("RENPY_SDK") or ROOT / "tools/renpy-sdk") / "renpy.sh"
|
||||
|
||||
|
||||
@pytest.mark.skipif(not SDK.exists(), reason="Ren'Py SDK not found (set RENPY_SDK)")
|
||||
def test_e2e_playthrough_faust(tmp_path):
|
||||
work = load_work(ROOT)
|
||||
data = json.loads((ROOT / "data/annotated.json").read_text(encoding="utf-8"))
|
||||
out = tmp_path / "faust"
|
||||
renpy_gen.generate(work, data, out, with_test=True)
|
||||
home = tmp_path / "home"
|
||||
home.mkdir()
|
||||
env = {
|
||||
**os.environ,
|
||||
"HOME": str(home),
|
||||
"SDL_VIDEODRIVER": "dummy",
|
||||
"SDL_AUDIODRIVER": "dummy",
|
||||
"RENPY_RENDERER": "sw",
|
||||
}
|
||||
result = subprocess.run(
|
||||
[str(SDK), str(out), "test"], capture_output=True, text=True, env=env, timeout=900
|
||||
)
|
||||
report = result.stdout + result.stderr
|
||||
for name in ("traceback.txt", "errors.txt"):
|
||||
assert not (out / name).exists(), (out / name).read_text(encoding="utf-8")
|
||||
assert result.returncode == 0, report
|
||||
assert "Traceback" not in report and "FAIL" not in report, report
|
||||
@@ -0,0 +1,73 @@
|
||||
"""Faust-specific checks on the real text and the committed data."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from vnpipe import renpy_gen, text
|
||||
from vnpipe.config import load_work
|
||||
from vnpipe.schema import validate
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
RAW = ROOT / "data/raw/pg68566.txt"
|
||||
|
||||
|
||||
@pytest.mark.skipif(not RAW.is_file(), reason="raw Gutenberg file not downloaded")
|
||||
def test_real_file_integration():
|
||||
work = load_work(ROOT)
|
||||
_, parsed = text.build(RAW.read_bytes(), work.data)
|
||||
assert [s["id"] for s in parsed["scenes"]] == [
|
||||
"dedicatoria",
|
||||
"prologo_teatro",
|
||||
"prologo_cielo",
|
||||
"noche",
|
||||
]
|
||||
known = set(work.speakers.values())
|
||||
for s in parsed["scenes"]:
|
||||
assert s["lines"]
|
||||
assert {ln["speaker"] for ln in s["lines"]} - {None} <= known
|
||||
|
||||
|
||||
@pytest.mark.skipif(not RAW.is_file(), reason="raw Gutenberg file not downloaded")
|
||||
def test_cli_parse_is_byte_identical(tmp_path):
|
||||
work_dir = tmp_path / "faust"
|
||||
(work_dir / "data/raw").mkdir(parents=True)
|
||||
shutil.copy(ROOT / "work.toml", work_dir / "work.toml")
|
||||
shutil.copy(RAW, work_dir / "data/raw/pg68566.txt")
|
||||
args = argparse.Namespace(work=work_dir)
|
||||
assert text.cmd_parse(args) == 0
|
||||
first = (work_dir / "data/parsed.json").read_bytes()
|
||||
assert text.cmd_parse(args) == 0
|
||||
assert (work_dir / "data/parsed.json").read_bytes() == first
|
||||
assert first.endswith(b"\n")
|
||||
assert (work_dir / "data/play.txt").read_text(encoding="utf-8").startswith("DEDICATORIA\n")
|
||||
# the committed data is what the parser produces
|
||||
assert first == (ROOT / "data/parsed.json").read_bytes()
|
||||
|
||||
|
||||
def test_from_parsed_annotations():
|
||||
work = load_work(ROOT)
|
||||
parsed = json.loads((ROOT / "data/parsed.json").read_text(encoding="utf-8"))
|
||||
annotated = renpy_gen.annotations_from_parsed(work, parsed)
|
||||
validate(annotated, "annotated")
|
||||
teatro = next(s for s in annotated["scenes"] if s["id"] == "prologo_teatro")
|
||||
stage = [ln["ann"]["on_stage"] for ln in teatro["lines"] if ln["kind"] == "verse"]
|
||||
assert stage[0] == [{"character": "director", "position": "left"}]
|
||||
assert {e["character"]: e["position"] for e in stage[-1]} == {
|
||||
"director": "left",
|
||||
"poet": "right",
|
||||
"clown": "center",
|
||||
}
|
||||
dedication = annotated["scenes"][0]["lines"][0]["ann"]
|
||||
assert dedication["speaker"] == "poet_voice" and dedication["on_stage"] == []
|
||||
cielo = next(s for s in annotated["scenes"] if s["id"] == "prologo_cielo")
|
||||
assert cielo["lines"][0]["ann"]["on_stage"] == []
|
||||
# the real project generates (cues all resolve) without writing anything
|
||||
renpy_gen.render_script(work, annotated, set())
|
||||
|
||||
|
||||
def test_annotated_data_is_valid():
|
||||
data = json.loads((ROOT / "data/annotated.json").read_text(encoding="utf-8"))
|
||||
validate(data, "annotated")
|
||||
Reference in new issue
Block a user