summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Ritter <drew@primeradiant.com>2026-09-09 17:42:29 -0700
committerDrew Ritter <drew@primeradiant.com>2026-09-09 17:42:29 -0700
commit2996ad255ca592535b552f7bef77902a620bbf91 (patch)
tree2fa75fbac4ca3cc1157a68bc40a0cc9e068ae512
parent03995d48f1b163bc2fa558bbbe145ccfbefc74f3 (diff)
test(movie): verify first subtitle cue offset
-rw-r--r--tests/proving-it-works-with-a-movie/README.md6
-rw-r--r--tests/proving-it-works-with-a-movie/test_assembly.py18
2 files changed, 20 insertions, 4 deletions
diff --git a/tests/proving-it-works-with-a-movie/README.md b/tests/proving-it-works-with-a-movie/README.md
index ed81b27..cda9db4 100644
--- a/tests/proving-it-works-with-a-movie/README.md
+++ b/tests/proving-it-works-with-a-movie/README.md
@@ -25,7 +25,7 @@ inputs exercise text comparison only. Neither is speech/ASR acceptance.
| `test-assemble.sh` | `assemble runs` | `AssemblyRegression.test_narration_padding_and_offsets` |
| `test-assemble.sh` | `segment = max(narration, visuals)` (8s +/- 0.4s) | `AssemblyRegression.test_narration_padding_and_offsets` |
| `test-assemble.sh` | `offsets.json places the narrated scene` (2s +/- 0.3s) | `AssemblyRegression.test_narration_padding_and_offsets` |
-| `test-assemble.sh` | `cues start at the scene's real offset, not zero` | `AssemblyRegression.test_narration_padding_and_offsets` |
+| `test-assemble.sh` | `cues start at the scene's real offset, not zero` (first cue start equals the measured body offset within 1ms) | `AssemblyRegression.test_narration_padding_and_offsets` |
| `test-check-movie.sh` | `front-loaded action is rejected` | `CheckerRegression.test_front_loaded_action_is_rejected` |
| `test-check-movie.sh` | `paced + subtitles is accepted` | `CheckerRegression.test_paced_with_subtitles_is_accepted` |
| `test-check-movie.sh` | `narrated without subtitles rejected` | `CheckerRegression.test_narrated_without_subtitles_is_rejected` |
@@ -40,3 +40,7 @@ inputs exercise text comparison only. Neither is speech/ASR acceptance.
| `test-narrate.sh` | `a dropped clause fails` | `NarrationDriftRegression.test_dropped_clause_fails` |
| `test-narrate.sh` | `an invented preamble fails` | `NarrationDriftRegression.test_invented_preamble_fails` |
| `test-narrate.sh` | `an empty clip fails` | `NarrationDriftRegression.test_empty_clip_fails` |
+
+The portable subtitle assertion intentionally strengthens the Bash suite's
+whole-file regex: it parses the first cue start and compares it with the actual
+assembly offset at SRT's millisecond precision.
diff --git a/tests/proving-it-works-with-a-movie/test_assembly.py b/tests/proving-it-works-with-a-movie/test_assembly.py
index 9a99aa6..4190abb 100644
--- a/tests/proving-it-works-with-a-movie/test_assembly.py
+++ b/tests/proving-it-works-with-a-movie/test_assembly.py
@@ -40,9 +40,21 @@ class AssemblyRegression(unittest.TestCase):
self.assertEqual(
subtitles.returncode, 0, fixtures.output_text(subtitles)
)
- self.assertRegex(
- (work / "out.srt").read_text(encoding="utf-8"),
- r"00:00:0[2-9]",
+ srt = (work / "out.srt").read_text(encoding="utf-8")
+ timing_line = next(line for line in srt.splitlines() if "-->" in line)
+ start = timing_line.partition("-->")[0].strip()
+ hours, minutes, seconds_millis = start.split(":")
+ seconds, millis = seconds_millis.split(",")
+ first_cue_start = (
+ int(hours) * 3600
+ + int(minutes) * 60
+ + int(seconds)
+ + int(millis) / 1000
+ )
+ self.assertAlmostEqual(
+ first_cue_start,
+ offsets["body"],
+ delta=0.001,
)