Skip to content

tests: fail when a merge leaves a whole paragraph twice in one Markdown file - #7813

Open
iTzAlvar wants to merge 1 commit into
ItsNotRexed:mainfrom
iTzAlvar:tests/docs-repeated-paragraphs
Open

iTzAlvar wants to merge 1 commit into
ItsNotRexed:mainfrom
iTzAlvar:tests/docs-repeated-paragraphs

Conversation

@iTzAlvar

Copy link
Copy Markdown

Claimed in the coordination issue as: new item, claim

What and why

A merge that keeps both copies of a section leaves a whole block twice in a doc, usually dozens of lines apart. tests/test_docs_repeated_lines.py only compares lines within three of each other, so it misses these. Each one has been found by hand so far, and at least seven open PRs each remove one (#6552, #5755, #5350, #5169, #5598, #4855, #6969, #5358, #5345).

New tests/test_docs_repeated_paragraphs.py, standard library only, reading tracked Markdown:

  • It splits each file into paragraphs: blank-line separated, outside code fences, with whitespace folded so a re-wrapped copy still counts.
  • It flags a paragraph of 80 or more characters that occurs twice in the same file. Table rows (test_docs_table_rows.py's job) and headings are left out, since a heading may repeat under different parents (### Layout in docs/textures_arrays.md).
  • The 30 repeats already on main (in animation.md, design.md, gbuffer.md, models.md, shader_validation.md and testing.md) are listed in KNOWN, each next to the open PR that removes it. So the test fails only on a new repeat.
  • A KNOWN entry whose repeat is gone is not an error, so this PR doesn't conflict with those PRs and they can merge in any order. They may delete their entries, but don't have to.

How the threshold was picked: at 80, 120, 160 and 200 characters, every hit on main lies inside one of the merge-duplicated sections listed above (30, 29, 28 and 25 hits); I found no false positive. CI picks the file up through tests/test_docs_*.py, in the docs-only job as well; test_ci_registration.py passes.

Tested

Windows 11 25H2, Python 3.13.14, main 9ce9a7923:

No GPU needed. No game files.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…wn file

test_docs_repeated_lines.py compares lines within three of each other, so a
section a merge kept twice, dozens of lines apart, gets through: main has 30
such paragraphs in six docs (design.md's two "PAL stage descriptors"
sections, models.md's two effect-record sections, ...).

test_docs_repeated_paragraphs.py splits each tracked Markdown file into
paragraphs (outside code fences, whitespace folded, table rows and headings
left out) and flags one of 80 or more characters that occurs twice. The 30
repeats already on main are listed in KNOWN with the open pull requests that
remove them (ItsNotRexed#5755, ItsNotRexed#6552, ItsNotRexed#5350, ItsNotRexed#5169, ItsNotRexed#5598, ItsNotRexed#4855, ItsNotRexed#6969, ItsNotRexed#5358, ItsNotRexed#5345),
so only a new one fails; an entry whose repeat is gone is not an error, and
those pull requests can merge in any order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested d128012 on Windows 11 (26200.9974), Python 3.13.14, CPU only: pass.

  • python -I tests/test_docs_repeated_paragraphs.py -v: Ran 4 tests, OK.
  • Negative control: appended one 117-character paragraph twice to docs/testing.md in the worktree and reran the file: exactly 1 failure, test_docs_repeat_no_paragraph reporting docs/testing.md:664,666. Restored the file and reran: 4/4 OK. So the whole-tree test does exercise the new guard, not just the synthetic unit cases.
  • Code read: paragraphs() folds whitespace, excludes fenced code, table rows and headings as described, and KNOWN entries are all exactly OPENING characters. One non-blocking observation: repeated_paragraphs() keys its result by the first 50 characters, so two different repeated paragraphs sharing that prefix produce two identical keys. I confirmed this with a synthetic pair; since KNOWN is a set of (path, opening), a genuinely new repeat could be absorbed by a still-present KNOWN entry with the same opening. Worth considering a longer key or including a hash, but it does not affect any current doc.
  • python -I -m compileall -q tests/test_docs_repeated_paragraphs.py, python -I scripts/check_no_game_data.py tests/test_docs_repeated_paragraphs.py, git diff --check: pass.

Synthetic inputs only; no game data.

AI-assisted.

@azterixx

Copy link
Copy Markdown

checked: #7813 | with: python -I -m unittest discover -s tests -p test_docs_repeated_paragraphs.py | on: macOS 27.2.1, Apple M1 Pro, CPython 3.15.2, head d128012, CPU only | result: pass (4 tests; main@dde82f27e has 0 (test file not on main))

@airp1ane

Copy link
Copy Markdown
Contributor

Tested d128012 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_docs_repeated_paragraphs.py - all exit 0.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants