check "1: the section body starts after the heading line"'[ "$(printf "%s\n" "$N" | head -1)" = "_A summary line._" ]'
check "1: the section stops at the next version"'! printf "%s" "$N" | grep -q "no upgrade part"'
check "1: the section keeps its own sub-sections"'printf "%s" "$N" | grep -q "^- a fix$"'
check "1: an unknown version extracts nothing"'[ -z "$(release_notes_extract "$CL" 3.0.0)" ]'
check "1: the last section of the file extracts (no following heading)"'release_notes_extract "$CL" 0.9.0 | grep -q "The last section of the file."'
check "1: 1.0.0-beta1 does not match 1.0.0-beta12"'[ "$(release_notes_extract "$CL" 1.0.0-beta1 | tail -1)" = "- the first beta, without an upgrade part" ]'
check "1: dots are literal (1x2x0 is not 1.2.0)"'[ -z "$(release_notes_extract "$CL" 1x2x0)" ]'
check "2: a missing section is refused with status 1"'[ "$(rc "" 3.0.0)" = 1 ] && grep -q "has no .## \[3.0.0\]. section" "$ROOT/err"'
check "2: a section without the upgrade part is refused with status 2"'[ "$(rc "$(release_notes_extract "$CL" Unreleased)" Unreleased)" = 2 ] && grep -q "does not open with" "$ROOT/err"'
check "2: the refusal names the first heading it found"'grep -q "is: .### Added." "$ROOT/err"'
check "2: an upgrade part that is not FIRST is refused"'[ "$(rc "$(release_notes_extract "$CL" 1.1.0)" 1.1.0)" = 2 ]'
check "2: the next section's upgrade part is not borrowed"'[ "$(rc "$(release_notes_extract "$CL" 1.0.0-beta1)" 1.0.0-beta1)" = 2 ]'
check "2: a near-miss heading is refused"'[ "$(rc "$(printf "### Upgrading\n\nx\n")" 9.9.9)" = 2 ]'
check "2: a heading only in body text does not count"'[ "$(rc "$(printf "### Added\n\nsee ### Upgrading — read this first\n")" 9.9.9)" = 2 ]'
check "5: publish-release.sh refuses a section without the upgrade part"'[ "$r" -ne 0 ] && grep -q "does not open with" "$ROOT/pub.err"'
check "5: ...before looking for artifacts, the tag or a credential"'! grep -q "missing artifact\|is not on origin\|no stored credential" "$ROOT/pub.err"'
else
fail "5: runway-dist/target does not exist — run this from the dist module's test phase (mvn test)"