Check local Markdown links in CTest and the Linux job #219

Merged
Leyukaka merged 2 commits from upstream-pr/222 into main 2026-11-21 19:14:01 +00:00
Leyukaka commented 2026-11-21 18:34:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T18:34:26Z.


Change

Independent problem: docs/non-windows-hosts.md lists link checks for documentation contributors, but no check existed. tests/docs_links_check.py checks every inline Markdown link in the tracked .md files against the checkout. It is registered as the CTest docs_links and runs in the Linux python-linux job, which docs/non-windows-hosts.md already lists as covering link checks. External http(s) and mailto links are skipped and the check makes no network access.

For each local link it checks that:

  • the target stays inside the repository;
  • the target is a file Git tracks, compared with exact case, so a link that only resolves on a case-insensitive file system fails. A tracked directory is accepted, but not with a fragment;
  • a #fragment names a heading in the target Markdown file, or in the same file for #fragment alone.

Heading slugs implement the subset of GitHub's rules that the repository's headings use: lower case, punctuation dropped, spaces to -, -1/-2 suffixes 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:

  • reference-style links;
  • HTML <a href> and <a name>;
  • links inside indented code or HTML comments.

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:

ctest --preset dev --no-tests=error -R '^docs_links$' -V

The check prints Self-test passed. and Checked 10 Markdown files and 62 links. The full suite passes 117 of 117 tests. In a source tree exported with git archive HEAD, CTest reports docs_links as 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:

  • Appending [x](docs/experiments.md#no-such-heading) and [y](Docs/experiments.md) to README.md fails with heading does not exist and file is not tracked (check the case of the path).
  • Removing the duplicate-suffix loop fails the self-test.
  • Accepting a fragment on a directory fails the self-test.

Evidence and follow-up

The tracked-file check uses git ls-files. Without .git at 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 missing git or an ownership refusal, fails the test. CTest registers it only when INTAKE_PYTHON exists. It uses the standard library only.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532806690 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/222). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T18:34:26Z. --- ## Change Independent problem: `docs/non-windows-hosts.md` lists link checks for documentation contributors, but no check existed. `tests/docs_links_check.py` checks every inline Markdown link in the tracked `.md` files against the checkout. It is registered as the CTest `docs_links` and runs in the Linux `python-linux` job, which `docs/non-windows-hosts.md` already lists as covering link checks. External `http(s)` and `mailto` links are skipped and the check makes no network access. For each local link it checks that: - the target stays inside the repository; - the target is a file Git tracks, compared with exact case, so a link that only resolves on a case-insensitive file system fails. A tracked directory is accepted, but not with a fragment; - a `#fragment` names a heading in the target Markdown file, or in the same file for `#fragment` alone. Heading slugs implement the subset of GitHub's rules that the repository's headings use: lower case, punctuation dropped, spaces to `-`, `-1`/`-2` suffixes 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: - reference-style links; - HTML `<a href>` and `<a name>`; - links inside indented code or HTML comments. 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: ```powershell ctest --preset dev --no-tests=error -R '^docs_links$' -V ``` The check prints `Self-test passed.` and `Checked 10 Markdown files and 62 links.` The full suite passes 117 of 117 tests. In a source tree exported with `git archive HEAD`, CTest reports `docs_links` as 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: - Appending `[x](docs/experiments.md#no-such-heading)` and `[y](Docs/experiments.md)` to `README.md` fails with `heading does not exist` and `file is not tracked (check the case of the path)`. - Removing the duplicate-suffix loop fails the self-test. - Accepting a fragment on a directory fails the self-test. ## Evidence and follow-up The tracked-file check uses `git ls-files`. Without `.git` at 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 missing `git` or an ownership refusal, fails the test. CTest registers it only when `INTAKE_PYTHON` exists. It uses the standard library only. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:41:53 +00:00
R0Y00 commented 2026-11-24 06:47:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:42:44Z.


The Python-enabled CTest suite now always registers docs_links, but tracked_files runs git ls-files unconditionally. A GitHub source ZIP has no .git, so even with Git installed this test raises CalledProcessError. 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067455533 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/222#issuecomment-7067455533). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T18:42:44Z. --- The Python-enabled CTest suite now always registers `docs_links`, but `tracked_files` runs `git ls-files` unconditionally. A GitHub source ZIP has no `.git`, so even with Git installed this test raises `CalledProcessError`. 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 commented 2026-11-24 06:47:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T19:07:13Z.


Thanks. docs_links now reports a capability skip in a source tree without Git metadata, and the branch is rebased on f85723e.

The skip depends only on whether <repository root>/.git exists, as a directory or as a worktree file. Without it, the script prints a Skipped: line and returns 77, and CMake registers the test with SKIP_RETURN_CODE 77. Every other Git problem still fails the test, because git ls-files runs with check=True. That includes a safe.directory ownership refusal. GIT_DIR and GIT_WORK_TREE are 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:

  • Source tree without .git: I exported it with git archive HEAD and configured it with the same Python. ctest --preset dev --no-tests=error -R '^docs_links$' reports Test #63: docs_links ... ***Skipped, and the script exits with 77.
  • Checkout: Checked 10 Markdown files and 62 links., and the full suite passes 117 of 117 tests.
  • Ownership refusal: with GIT_TEST_ASSUME_DIFFERENT_OWNER=1, the check fails with CalledProcessError, exit status 128, instead of skipping.
  • Inherited GIT_DIR: pointing GIT_DIR at a missing directory still checks the 62 links.
  • Mutation: if the detection always reports a checkout, the self-test fails.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067775917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/222#issuecomment-7067775917). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T19:07:13Z. --- Thanks. `docs_links` now reports a capability skip in a source tree without Git metadata, and the branch is rebased on `f85723e`. The skip depends only on whether `<repository root>/.git` exists, as a directory or as a worktree file. Without it, the script prints a `Skipped:` line and returns 77, and CMake registers the test with `SKIP_RETURN_CODE 77`. Every other Git problem still fails the test, because `git ls-files` runs with `check=True`. That includes a `safe.directory` ownership refusal. `GIT_DIR` and `GIT_WORK_TREE` are 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: - **Source tree without `.git`:** I exported it with `git archive HEAD` and configured it with the same Python. `ctest --preset dev --no-tests=error -R '^docs_links$'` reports `Test #63: docs_links ... ***Skipped`, and the script exits with 77. - **Checkout:** `Checked 10 Markdown files and 62 links.`, and the full suite passes 117 of 117 tests. - **Ownership refusal:** with `GIT_TEST_ASSUME_DIFFERENT_OWNER=1`, the check fails with `CalledProcessError`, exit status 128, instead of skipping. - **Inherited `GIT_DIR`:** pointing `GIT_DIR` at a missing directory still checks the 62 links. - **Mutation:** if the detection always reports a checkout, the self-test fails. _AI-assisted._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!219
No description provided.