test(mux): replace a false-green discontinuity test with the property it named

a_signalled_discontinuity_survives_a_backstop_discard asserted that a
SOURCE-signalled discontinuity on discarded bytes still reaches the AU
that follows. It did not test that. Deleting the disc_marks push, or the
mark-retirement loop inside discard_gap_before, left it passing.

The mechanism: the `discontinuity = true` rode the FIRST over-cap push,
which still has the next AU's delimiter at buf[0] — so it force-flushes
as an over-long AU rather than discarding, and THAT AU consumes the
mark. The assertion's `.find(|x| x.data.contains(&0x22))` then filters
it out, and the flag it reads comes entirely from `pending_gap`, set by
the second push's backstop. Behaviourally identical to the test 40 lines
above it, under a name promising something else.

I wrote it this morning, in the same commit that fixed a different test
for having a fixture that never reached the code it named, while
cataloguing that exact shape. Third instance today of writing the bug I
was hunting.

The two mechanisms cannot be isolated in one fixture — a fragment that
trips the backstop sets pending_gap regardless — so they now get one
test each. The replacement drives disc_marks end to end with no backstop
involved: a flagged fragment that carries a complete AU and is emitted,
not discarded. Nothing else pinned that path. Removing the disc_marks
push reds it.

Found by the round-9 opus escalation over test quality, dispatched
because the sonnet pass over the same 17,000 lines of new test code
returned zero findings.
This commit is contained in:
Matthew Jackson
2026-07-30 20:07:11 -07:00
parent 72bcc371fb
commit 5559987325
+32 -20
View File
@@ -1023,36 +1023,48 @@ mod tests {
); );
} }
/// A discontinuity the SOURCE signalled, on bytes the backstop later throws /// A source-signalled discontinuity reaches the AU it opens.
/// away, must not be lost either — the gap is real regardless of which ///
/// mechanism noticed it first, and the two must not cancel out. /// This is the `disc_marks` path — the ORIGINAL mechanism, distinct from
/// the sticky `pending_gap` the backstop sets. Nothing else pins it: the
/// two tests above drive `pending_gap`, and a mark placed on a fragment
/// that is later discarded is retired by design.
///
/// Deliberately NOT combined with the backstop. A previous version of this
/// test signalled the discontinuity on the first over-cap push and asserted
/// the flag on the AU after the discard — but that first run still has the
/// next AU's delimiter at `buf[0]`, so it force-flushes as an over-long AU,
/// and THAT AU consumes the mark. The assertion was then satisfied entirely
/// by `pending_gap`, making the test a duplicate of the one above it under
/// a name promising something else. The two mechanisms cannot be isolated
/// in one fixture, so they get one test each.
#[test] #[test]
fn a_signalled_discontinuity_survives_a_backstop_discard() { fn a_source_signalled_discontinuity_reaches_the_au_it_opens() {
let mut a = AuAssembler::for_codec(Codec::H264); let mut a = AuAssembler::for_codec(Codec::H264);
let mut stream = au(0x11, 64); // A clean AU first, so there is a prior AU and the gate has somewhere
stream.extend_from_slice(AUD); // to be discontinuous FROM.
a.push(&stream, Some(1000), None, None, false); let mut first = au(0x11, 64);
first.extend_from_slice(AUD);
let out = a.push(&first, Some(1000), None, None, false);
assert_eq!(out.len(), 1);
assert!(!out[0].discontinuity, "a clean run is continuous");
// The source says this fragment follows a gap, AND it is start-code-free // The source flags this fragment as following a gap. It carries the
// and long enough to trip the backstop. Two runs, so the second reaches // body of the next AU and its closing delimiter, so it is emitted
// the discard rather than the force-flush (see the test above). // rather than discarded — the mark must ride through to it.
let junk = vec![0xAB; MAX_AU_BUFFER + 4096]; let mut second = au(0x22, 64);
a.push(&junk, Some(2000), None, None, true); second.extend_from_slice(AUD);
a.push(&junk, Some(2100), None, None, false); let out = a.push(&second, Some(2000), None, None, true);
let mut resumed = au(0x22, 64);
resumed.extend_from_slice(AUD);
let out = a.push(&resumed, Some(3000), None, None, false);
let au2 = out let au2 = out
.iter() .iter()
.find(|x| x.data.contains(&0x22)) .find(|x| x.data.contains(&0x22))
.expect("the post-gap AU must emit"); .expect("the flagged AU must emit");
assert!( assert!(
au2.discontinuity, au2.discontinuity,
"a source-signalled discontinuity on discarded bytes must still \ "a discontinuity the SOURCE signalled must reach the AU whose bytes \
reach the AU that follows them" carried it; this is the disc_marks path and no other test drives it"
); );
} }