diff --git a/crates/polymodel-renderer-worker/src/tests.rs b/crates/polymodel-renderer-worker/src/tests.rs index 6a7b872..5b774a5 100644 --- a/crates/polymodel-renderer-worker/src/tests.rs +++ b/crates/polymodel-renderer-worker/src/tests.rs @@ -38,9 +38,9 @@ fn glossmap_decode_uses_alpha_not_rgb() { #[test] fn texture_resource_selection_uses_canonical_root_and_path() { let path = polymodel_ldraw_core::NormalizedPath::new("textures/decal.png").unwrap(); - let resource = |key: &str, root: &str, marker: u8| ModelResource { + let resource = |key: &str, resource_path: &str, root: &str, marker: u8| ModelResource { key: key.into(), - path: path.as_str().into(), + path: resource_path.into(), root: root.into(), byte_length: 1, sha256: vec![marker; 32], @@ -49,8 +49,9 @@ fn texture_resource_selection_uses_canonical_root_and_path() { bytes: vec![marker], }; let resources = [ - resource("official-texture", "official-parts", 1), - resource("mpd-texture", "mpd", 2), + resource("other-mpd-texture", "textures/other.png", "mpd", 0), + resource("official-texture", path.as_str(), "official-parts", 1), + resource("mpd-texture", path.as_str(), "mpd", 2), ]; assert_eq!( diff --git a/justfile b/justfile index 79d5d6b..ef9459c 100644 --- a/justfile +++ b/justfile @@ -268,7 +268,7 @@ _ldraw-bench: mkdir -p "$(dirname "$output")"; \ printf '%s\n' '{"schema":"polymodel-ldraw-bench-v1","model":"omr-10030-1.mpd","thresholds":{"parse_ms":5000},"measurement":"cargo test -p polymodel-renderer-worker --test ldraw_preview ldraw_preview_uses_pinned_corpus_and_scene_stats -- --nocapture"}' >"$output"; \ POLYMODEL_LDRAW_TIMING=1 cargo test -p polymodel-renderer-worker --test ldraw_preview ldraw_preview_uses_pinned_corpus_and_scene_stats -- --nocapture 2>&1 | tee "${output%.json}.log"; \ - python3 -c 'import json,pathlib,re,sys; p=pathlib.Path(sys.argv[1]); report=json.loads(p.read_text()); log=pathlib.Path(sys.argv[2]); lines=[line for line in log.read_text().splitlines() if "[ldraw-metrics]" in line]; threshold=report["thresholds"]["parse_ms"]; observed=[]; failures=[]; pattern=re.compile(r"phase=(?P\S+).*?elapsed_ms=(?P\d+)"); [ (observed.append({"phase":m.group("phase"),"elapsed_ms":int(m.group("elapsed"))}), failures.append(line) if m.group("phase") in ("scanned-root","split-root","parsed-root-models","parsed-materializations","traversed") and int(m.group("elapsed")) > threshold else None ) for line in lines for m in [pattern.search(line)] if m ]; report["observed"]={"timing_lines":lines,"metrics":observed,"log":sys.argv[2]}; p.write_text(json.dumps(report,indent=2)+chr(10)); [print(f"benchmark threshold exceeded: {line}",file=sys.stderr) for line in failures]; sys.exit(bool(failures))' "$output" "${output%.json}.log" + python3 -c 'import json,pathlib,re,sys; p=pathlib.Path(sys.argv[1]); report=json.loads(p.read_text()); log=pathlib.Path(sys.argv[2]); lines=[line for line in log.read_text().splitlines() if "[ldraw-metrics]" in line]; threshold=report["thresholds"]["parse_ms"]; expected={"scanned-root","split-root","parsed-root-models","parsed-materializations","traversed"}; observed=[]; failures=[]; pattern=re.compile(r"phase=(?P\S+).*?elapsed_ms=(?P\d+)"); [ (observed.append({"phase":m.group("phase"),"elapsed_ms":int(m.group("elapsed"))}), failures.append(line) if m.group("phase") in expected and int(m.group("elapsed")) > threshold else None ) for line in lines for m in [pattern.search(line)] if m ]; missing=expected-{metric["phase"] for metric in observed}; report["observed"]={"timing_lines":lines,"metrics":observed,"log":sys.argv[2]}; p.write_text(json.dumps(report,indent=2)+chr(10)); [print(f"benchmark threshold exceeded: {line}",file=sys.stderr) for line in failures]; print(f"benchmark missing expected phases: {sorted(missing)}",file=sys.stderr) if missing else None; sys.exit(bool(failures or missing))' "$output" "${output%.json}.log" _ldraw-visual: @set -eu; \