Check local Markdown links in CTest and the Linux job #222
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!222
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/222/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Leyukaka on GitHub · 2026-11-21 18:34 UTC · original
Leyukaka:docs-links→main· +248 −1 · 4 files · 2 commits · merged 2026-11-21 19:14 UTCChange
Independent problem:
docs/non-windows-hosts.mdlists link checks for documentation contributors, but no check existed.tests/docs_links_check.pychecks every inline Markdown link in the tracked.mdfiles against the checkout. It is registered as the CTestdocs_linksand runs in the Linuxpython-linuxjob, whichdocs/non-windows-hosts.mdalready lists as covering link checks. Externalhttp(s)andmailtolinks are skipped and the check makes no network access.For each local link it checks that:
#fragmentnames a heading in the target Markdown file, or in the same file for#fragmentalone.Heading slugs implement the subset of GitHub's rules that the repository's headings use: lower case, punctuation dropped, spaces to
-,-1/-2suffixes for repeated headings and code-span text kept literal. Emphasis markers inside headings (for example_foo_) and HTML-like text are not stripped the way GitHub does; no current heading contains them. Fragments are compared case-sensitively.Not handled:
<a href>and<a name>;The tracked files contain no reference-style definitions or HTML comments. Links in fenced blocks and inline code spans are ignored.
Verification
On
f85723e, Windows 11 build 26300:The check prints
Self-test passed.andChecked 10 Markdown files and 62 links.The full suite passes 117 of 117 tests. In a source tree exported withgit archive HEAD, CTest reportsdocs_linksas skipped.The self-test runs on every invocation. It covers the slug rules, repeated headings, fenced and inline code, a missing file, a case mismatch, a tracked directory and a fragment on a directory.
Negative controls, run by hand and reverted:
[x](docs/experiments.md#no-such-heading)and[y](Docs/experiments.md)toREADME.mdfails withheading does not existandfile is not tracked (check the case of the path).Evidence and follow-up
The tracked-file check uses
git ls-files. Without.gitat the repository root, as in a source archive, the script returns 77 and CTest reports a skip (SKIP_RETURN_CODE 77). Any other Git failure, such as a missinggitor an ownership refusal, fails the test. CTest registers it only whenINTAKE_PYTHONexists. It uses the standard library only.Checklist
AI-assisted.
@R0Y00 on GitHub · 2026-11-21 18:42 UTC · original
The Python-enabled CTest suite now always registers
docs_links, buttracked_filesrunsgit ls-filesunconditionally. A GitHub source ZIP has no.git, so even with Git installed this test raisesCalledProcessError. Please exercise a source tree without Git metadata and either register the tracked-file check only in a checkout or give it an explicit capability skip there. Keep the strict tracked-path and case checks in CI.@Leyukaka on GitHub · 2026-11-21 19:07 UTC · original
Thanks.
docs_linksnow reports a capability skip in a source tree without Git metadata, and the branch is rebased onf85723e.The skip depends only on whether
<repository root>/.gitexists, as a directory or as a worktree file. Without it, the script prints aSkipped:line and returns 77, and CMake registers the test withSKIP_RETURN_CODE 77. Every other Git problem still fails the test, becausegit ls-filesruns withcheck=True. That includes asafe.directoryownership refusal.GIT_DIRandGIT_WORK_TREEare removed from the environment of that call, so an inherited value from a hook cannot point it at another repository. In the Linux job the script runs directly, so a 77 there would fail the step rather than pass silently.Checked on Windows 11 build 26300:
.git: I exported it withgit archive HEADand configured it with the same Python.ctest --preset dev --no-tests=error -R '^docs_links$'reportsTest #63: docs_links ... ***Skipped, and the script exits with 77.Checked 10 Markdown files and 62 links., and the full suite passes 117 of 117 tests.GIT_TEST_ASSUME_DIFFERENT_OWNER=1, the check fails withCalledProcessError, exit status 128, instead of skipping.GIT_DIR: pointingGIT_DIRat a missing directory still checks the 62 links.AI-assisted.