Repository navigation
test: pin each report with a case and its stderr - #20
Merged
Merged
Conversation
webern
force-pushed
the
m/test-cases
branch
2 times, most recently
from
September 24, 2026 12:51
4d36bf2 to
b2ccaf6
Compare
A case is a small repo under tests/cases/<lint>/, written to show one behavior, with the exact stderr deslag must print there in a .stderr file beside it. An empty .stderr means the run must pass. tests/cases.rs runs each case in a temp copy and compares. make fix-test-output rewrites the .stderr files, and make fix runs it. The report tests in tests/layout.rs move into eight cases. They now pin the whole report instead of pieces of it, including the wording of every kind of problem, and add the missing-block and clean runs.
webern
force-pushed
the
m/test-cases
branch
from
September 24, 2026 14:18
b2ccaf6 to
cd29f00
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a second kind of test data next to the corpus: cases, written for one lint and shipped with whatever they need on disk.
The corpus can't do this job. Its fixtures are quoted from other repos and never edited, and the repos they describe aren't there. A lint like
repo_layoutneeds a directory tree to check paths against, and its report is only worth pinning on a document written to break it in known ways.A case is a directory under
tests/cases/<lint>/that is a whole repo root: the Markdown, adeslag.toml, and any files the lint looks for. Beside it,<case>.stderrholds exactly whatdeslag checkprints there:tests/cases.rscopies each case to a temp directory, runs the binary there, and compares its stderr with the file. Some other details:.stderrmeans the run must exit 0, and any other means exit 1. That is the contract the binary already has.[ROOT]..stderrfile with no case beside it, or any other stray file, fails the test, so renaming a case can't leave a stale file behind.Accepting new output is
make fix-test-output, which runs the test withDESLAG_FIX_TEST_OUTPUT=1. It is part ofmake fix, and the build doctrine's definition offixnow says so. It accepts whatever deslag prints, so the diff has to be read.The first cases replace the tests in
tests/layout.rsthat ran the binary. Those tests checked pieces of the report withcontains, while the cases pin all of it:broken: one layout with every kind of problem, so every message's wording is pinned. It setsmax_width = 80, so the advice and the width problem must both show the configured width.clean: a good layout passes on the default limitsno_section,no_block: the short report, and a heading with no code block (not covered before)custom_message: a configmessagereplaces the advice, with every placeholder filled innested: paths are relative tosrc/AGENTS.md, not the repo rootmin_over_max,min_over_default_max: the two ways the limits can contradict each otherThe tests of
readandcheckstay intests/layout.rs.tests/cases/isn't excluded from the spell check: cases are ours, unlike the corpus. The self-lint globs are anchored, so the cases'AGENTS.mdfiles aren't linted as this repo's own.A case can't hold a
.gitdirectory, or a.gitignorethat ignores its own files, because git would apply it to this repo too. The harness's doc comment says so.AGENTS.mdand the as-built doc are updated.Testing
make ci: exit 0.stderrexisted: every case reported its file as missing. Then ranmake fix-test-outputand checked each.stderrline by line against its source: line numbers, columns, entry counts and file counts.nested.stderrand added a strayorphan.stderr: the test failed on both, naming line 10 as the first difference. Restored both.References
repo_layoutlint it adds.