Before this commit, `unset SYLPHEED_DISC` did not disable the disc-backed
suites on the machine that has the disc: every `disc_root()` fell back to a
hardcoded absolute path that exists on this box. The env var looked like a
control and was not one. Same for $SYLPHEED_RES3D and $SYLPHEED_ISO.
Replace the duplicated resolvers with one `tests/common/mod.rs`:
- 17 local `disc_root()` definitions -> 1
- 7 copies of the skip macro -> 1 (`skip_without_disc!` and siblings)
- 16 hardcoded absolute paths -> 0 executable ones
(3 of those were inline in `mesh_disc.rs`, in no resolver at all,
and 2 were in `examples/`)
- `corpus_report.rs` now reports on the SAME resolver the suites use,
instead of a second copy of the logic its own comments flagged as a
drift risk.
The 17 copies had already drifted into FIVE variants, and they were not all
the same function. `movie_manifest_disc`, `movie_subtitle_disc` and `slb_disc`
honoured $SYLPHEED_DISC and nothing else, while the other 14 fell back. So one
name already meant two things -- a third instance of the shape #16 is about.
The shared helper adopts the env-only behaviour those three already had, rather
than inventing a sixth variant.
Two module docs still described the fallback after it was deleted, which is the
same defect in prose: `texture_disc` claimed "or the default dev path exists"
and `pak_idxd_disc` said "or drop it at the default dev path below". Both now
say what the code does.
Verified both ways on the machine that HAS the corpus, which is the only place
this refactor can be falsified:
A env unset -> "ABSENT -- $SYLPHEED_DISC unset; its suites self-skip"
suites=31 passed=209 failed=0 ignored=14, slowest 0.12s
B env set -> "PRESENT via $SYLPHEED_DISC" (all three corpora)
suites=31 passed=209 failed=0 ignored=14,
slowest 1235.53s (mesh_consistency_disc)
Identical tallies, opposite corpus states, ~10000x apart in wall clock. (A) is
new behaviour -- it was previously unreachable here. (B) proves nothing broke.
`just test-disc` sources `.env` (already gitignored) for the set case. Note the
quoting trap documented there: the corpus paths contain spaces, and an unquoted
`VAR=a b c` parses as "run command `b`", failing silently into ABSENT -- which
looks exactly like a working skip.
Remedy (1) (`#[ignore]` + `--ignored`) is deliberately NOT done here: (3) already
moves the mode from the filesystem into the environment, and `#[ignore]` already
carries three meanings in this directory (corpus-absent, known-failing, bare).
Overloading it a fourth time would re-create the defect.
`cargo fmt --all --check` clean; no new compiler warnings.
Refs #16
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
65 lines
2.4 KiB
Rust
65 lines
2.4 KiB
Rust
//! Real-disc test for the movie subtitle chain. Skipped when the extracted disc
|
|
//! is absent (set `SYLPHEED_DISC` to the extract root to enable).
|
|
|
|
use sylpheed_formats::movie_subtitle::{self, SubLang};
|
|
use sylpheed_formats::PakArchive;
|
|
|
|
mod common;
|
|
use common::disc_root;
|
|
|
|
#[test]
|
|
fn resolves_english_radio_subtitles() {
|
|
let Some(root) = disc_root() else {
|
|
eprintln!("SKIP: set SYLPHEED_DISC");
|
|
return;
|
|
};
|
|
let lang = SubLang::English;
|
|
let lang_pak =
|
|
PakArchive::open(root.join(format!("dat/movie/{}.pak", lang.pak_code()))).unwrap();
|
|
let text_pak =
|
|
PakArchive::open(root.join(format!("dat/GP_MAIN_GAME_{}.pak", lang.game_code()))).unwrap();
|
|
|
|
// A radio movie: real timed English dialogue.
|
|
let cues = movie_subtitle::load("RT01C_1", &lang_pak, &text_pak);
|
|
assert!(!cues.is_empty(), "RT01C_1 should have timed cues");
|
|
assert!(cues[0].start >= 0.0 && cues[0].start < 5.0);
|
|
assert!(
|
|
cues.iter().any(|c| c.text.contains("Rhino Leader")),
|
|
"expected recognizable dialogue, got: {:?}",
|
|
cues.iter().map(|c| &c.text).collect::<Vec<_>>()
|
|
);
|
|
|
|
// No MSG_DEMO keys should leak into resolved caption text.
|
|
assert!(
|
|
cues.iter().all(|c| !c.text.contains("MSG_DEMO")),
|
|
"unresolved key leaked: {:?}",
|
|
cues.iter().map(|c| &c.text).collect::<Vec<_>>()
|
|
);
|
|
|
|
// A resupply movie: the canonical resupply line.
|
|
let hokyu = movie_subtitle::load("hokyu_DS_s02A", &lang_pak, &text_pak);
|
|
assert!(hokyu.iter().any(|c| c.text.contains("Resupply complete")));
|
|
|
|
// S00A carries inline narration text (not MSG_DEMO refs) with timecodes.
|
|
let story = movie_subtitle::load("S00A", &lang_pak, &text_pak);
|
|
assert!(!story.is_empty() && story.iter().any(|c| c.text.contains("27th century")));
|
|
|
|
// S13A stores a two-line caption as two consecutive text tokens sharing one
|
|
// timing; both lines must survive (the "Look at it father" regression — the
|
|
// first line used to be dropped).
|
|
let s13 = movie_subtitle::load("S13A", &lang_pak, &text_pak);
|
|
let multiline = s13
|
|
.iter()
|
|
.find(|c| c.text.contains("Look at it father"))
|
|
.expect("S13A should contain the 'Look at it father' caption");
|
|
assert_eq!(
|
|
multiline.text, "Look at it father\n& beautiful isn't it",
|
|
"both lines of the caption must be present"
|
|
);
|
|
assert!(
|
|
(multiline.start - 74.8).abs() < 0.1,
|
|
"start {}",
|
|
multiline.start
|
|
);
|
|
}
|