Repository navigation
test: run the cases in the fast tier and stop pinning the fix counts - #257
Merged
Merged
Conversation
The cases are what pins each lint's behavior, but they ran only in the slow binary, so `make test-fast` never ran them. Move them to `tests/cases.rs`, a binary of its own, so the fast tier runs them. The cases are spread over the cores in chunks, as the corpus tests spread their fixtures, and the failures are collected and each named. `on_every_core` moves to the shared test helpers for this. `make fix-test-output` now runs `--test cases`.
The two loops built a repository for every case, 116 of them at once in the diff loop, and what they check does not depend on which lint wrote the case. Run them on a list of 15 cases in `tests/slow/sample.rs`: a failing case for each lint, one for each section but Markdown, one with an `allow` entry and one whose config deslag refuses. A test checks that each entry exists and that every lint has its `broken` entry, so a new lint or a lost entry fails. The update loop's floor on the number of cases goes with the discovery it counted.
The corpus fix test pinned how many characters fix changes and leaves, and for what reason, so it failed on every corpus or fix change that was correct. Its final sum added up the pinned constant, not what the test counted. Check from what the test counted instead: each file's characters are all fixed or left, so are the corpus's, and neither count is zero. The per-file checks and the second run that changes nothing stay.
A panic in one chunk of the cases test was resumed when the chunk was joined, so the failures the other chunks had collected were lost and the message named no case. Catch the panic where the case runs and report it as a failure that starts with the case name, like the others.
Ten cases of the sample are called broken, so a failure in the update loop said "broken" without the lint. Print the path of the case, as the diff loop does.
The sample test only checked that an entry is a case directory. Check that each broken case exits 1, that the Rust, C++ and TOML cases have their section in the config, that the allow case has an allow entry, that zero_limit is refused with exit 2, and that no entry is listed twice. Each entry is written out. Without this, a sample whose cases all stopped failing would pass the diff and update loops inert.
webern
force-pushed
the
m/deslag-testtier
branch
from
November 2, 2026 16:58
ff32f71 to
ee8ca5b
Compare
webern
marked this pull request as ready for review
November 2, 2026 17:03
Owner
Author
|
CI is green on ee8ca5b (runs 41486636078, 41486636082 and 41486636248), after the rebase onto eb5961f. Decided on the maintainer's behalf: the cases leave the slow binary they were assigned to on 2026-10-24 and run in the fast tier as their own binary. The reason is that every lint's behaviour is pinned by the cases, and an agent iterating on a lint got no signal from them until |
5 tasks done
webern
added a commit
that referenced
this pull request
Nov 2, 2026
…ng the C++ lexer (#260) This builds on #257 and shows only its own diff until #257 merges. This PR resolves neither the golden-file question nor the library-oracle corpus tests. ## AI Summary Three test files were copies of one another, one test measured elapsed time, and a few tests checked things that something else already breaks on. This removes the copies and puts a counter where the clock was. No `.stderr`, `.json`, golden or corpus file changes, and no case is deleted. ### The section tests are one table `tests/rust_section.rs`, `tests/toml_section.rs` and `tests/cpp_section.rs` (45 tests, each file a copy of the others with the language changed) are now `tests/sections.rs`: one written-out table, `ROWS`, with a row per code section, and one test over it per rule. A rule only one language has is its own test: TOML refuses `doc_comment`, C++ reads eight extensions, TOML's fix leaves a string and keeps CRLF. `the_md_section_keeps_any_glob` is kept once. A test that loops over the list it pins passes when an entry goes (#197, #240). So `the_table_has_a_row_for_each_code_section` compares the table's names with the sections the config schema names, minus `md`, in both directions. Each row's expected messages are written out, never formatted from the name. A test picks its row by name (`row("cpp")`), so reordering the table cannot swap languages. ### Tests and assertions deleted, and what still pins each - `a_config_message_replaces_the_advice` (`tests/unit.rs`): the case `tests/cases/max_size_bytes/custom_message`, whose `.stderr` is the whole report and so shows the advice gone. - The one-possessive half of `the_report_names_the_count_the_places_and_the_advice` (`possessive_own.rs`) and the one-negation half of the same-named test in `not_at_all.rs`: the cases `possessive_own/custom_message` and `not_at_all/custom_message`. - `sentence_lengths_by_label` and its helpers (`tests/slow/corpus.rs`): an ignored test that printed a spread and checked nothing. `every_category_is_well_stocked` stays. - `update_md_meets_its_budget` (`tests/instructions.rs`): `make check-deslag` holds `src/instructions/update.md` to the same budget, as it holds every file. - `the_acknowledgements_credit_the_two_designs_the_entry_takes` (`tests/allow.rs`): it grepped the wording of `ACKNOWLEDGEMENTS.md` and checked no behaviour. Nothing pins it now. - `the_hash_is_fnv_1a_64` (`tests/frozen.rs`): `no_frozen_config_is_edited_and_each_has_a_line_in_hashes` fails on any change to `frozen::hash`. - `lints_turned_on_reads_every_section` (`tests/instructions.rs`): `each_lint_section_turns_on_its_lint_alone` and `the_lints_tables_together_are_valid`. This was the only test that used a non-`md` section. The survivors catch an empty set, ignored overrides and ignored section-level lints, but not a reader that looks only at `md`. - `assert_eq!(Tag::ALL.len(), 13)` (`src/tag/types.rs`, an assertion): the type `[Tag; 13]` says it. Kept on purpose: the ten `custom_message` cases and their `.json` files (each lint substitutes its own placeholders in its own code), `tests/emphasis.rs`, `tests/since.rs`, `stamp.rs`, `phrases.rs`, the guide and README tests in `instructions.rs`, `src/lint/mod.rs` and the 88 tests in `src/config/edit/`. ### The C++ lexer's clock is a read counter One test in `src/document/cpp.rs` timed the lexer with `Instant`, so it could fail on a slow machine and prove nothing on a fast one. It now counts reads. `Scanner` holds a `Reader` in its own module, whose bytes are private. Every read goes through `at`, `byte`, `slice`, `has_at` or `find`, which count what they hand out in a test build and do nothing more otherwise. The compiler refuses code that reads the source without the counter, so a rescan written as a direct slice scan cannot hide. The bound is 32 reads per byte, argued from the code in the comment on `MOST_READS_PER_BYTE`, not found by running it. A lexeme start makes at most 11 reads and steps over a byte; each loop in a lexeme makes at most 2 reads per byte; a blank after a backslash costs at most 6 more; a `<` with no `>` costs 2 more. That is under 21. In a raw string, `find` counts each byte once and the check after each `)` reads the delimiter (at most 16 bytes) and the quote, so under 18. A rescan of the file per directive reads the source length per line, far over any such constant. Two tests feed it: 10,000 `#define X R"(a` lines and 10,000 `#define X 1` lines. The first has one directive in effect (the first raw string swallows the file), so the second is the one that sees a per-directive rescan. ### Before and after | | Before | After | |---|---|---| | Fast-tier test binaries | 27 | 25 | | Fast-tier tests | 1,299 | 1,268 | | Section tests | 45 in 3 binaries | 18 in 1 binary | | Run CPU | equal | equal | | Clean-build CPU | unchanged | unchanged | | CPU to rebuild after an edit | | about 2.8 s less (a review of the diff measured it) | The saving is two fewer test binaries to link, not a faster run. CPU per binary is within noise on a loaded machine. ### Decided on the maintainer's behalf 1. The three section files become one table, with the row-per-section test. Why: one rule in three copies drifts, and two fewer binaries build. 2. The ten `custom_message` cases stay, and the three copies of them go. Why: each lint substitutes its own placeholders in its own code, so each case pins other code; the three deleted checks pinned only what a case already shows. 3. `sentence_lengths_by_label` goes and `every_category_is_well_stocked` stays. Why: the first prints and checks nothing; the second keeps the ratio tests from passing on an empty category, and the corpus loads once, so it saves no CPU. 4. Repo-state tests stay except two. Why: each reads a repo file because that file is its subject, and a fixture would test nothing. `update_md_meets_its_budget` is held by `make check-deslag` and the acknowledgements test checked wording only. 5. The clock becomes a read counter, bounded by a constant argued from the code. Why: a rescan per directive is orders of magnitude over any small constant, and a count does not depend on the machine. 6. Three tests of helpers go. Why: each helper's tests elsewhere fail first if it breaks. 7. `src/config/edit/` tests stay. Why: each refusal pins that `deslag update` never writes a config it cannot edit safely. 8. The 600-line size guide for `tests/sections.rs` is lifted: `#[rustfmt::skip]` kept it at 600 lines by leaving 38 lines over 100 columns, the longest 241. The table is formatted by rustfmt and the file is 723 lines. Why: unreadable rows are worse than a longer file. 9. The counter bound is 32 reads per byte. Why: the argued worst cases are under 21 for non-raw text and under 18 for a raw string, and the worst measured were 7.0 and 17.98, so 32 leaves room without letting a rescan through. ### Tests Each mutation was made in a scratch copy and not committed. - The `cpp` row dropped: `the_table_has_a_row_for_each_code_section` fails, left `["rust","toml"]`, right `["cpp","rust","toml"]`. - "selects it" reworded in `src/config/mod.rs`: `a_file_that_two_sections_select_is_an_error_that_names_both` fails and names the row. - `max_size_bytes.rs` and then `possessive_own.rs` stop replacing `{path}`: `tests/cases.rs` fails on each `custom_message` case. - An unterminated raw string made to give up, so each opening searches to the end: the counter fails at 750,565,002 reads of 150,000 bytes. - `directive` reads the rest of the file again through `at`: `many_plain_directives_are_read_in_linear_time` fails at 600,570,002 reads of 120,000 bytes, while the raw-string test passes. - `directive` scans the rest of the file with a direct slice, `self.bytes[after_hash..]`, counting newlines. This passed both tests before the `Reader`. It no longer compiles, because the bytes are private. The same scan through the reader's `slice` fails `many_plain_directives_are_read_in_linear_time` at 600,590,005 reads of 120,000 bytes. - `frozen::hash` with another multiplier: `no_frozen_config_is_edited_and_each_has_a_line_in_hashes` fails. - `lints_turned_on` returns an empty set: `each_lint_section_turns_on_its_lint_alone` and `the_lints_tables_together_are_valid` fail. - `update.md` grown past its budget: `make check-deslag` exits 2 with "src/instructions/update.md is 1884, which is larger than 1585 bytes". The schema-fit test checks, for every row, `surfaces = ["doc_comment", "comment"]` (`["comment"]` for `toml`), a `banned_chars` groups table and an override, as the three replaced tests did, and an unknown surface is refused. ## Testing - [x] `make ci-fast`: exit 0 - [x] `make test`: exit 0 - [x] `make test-tools`: exit 0 - [x] `make check-deslag`: exit 0 - [x] `make check-fmt`: exit 0 ## References - Builds on #257.
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.
AI Summary
The 127 case directories under
tests/cases/ran only in the slow binary, somake test-fastnever ran them, though they are where every lint's behaviour is pinned. This moves them into the fast tier and removes two costs that did not need to be there.tests/slow/cases.rsis nowtests/cases.rs, its own test binary. Its three tests moved with it unchanged. It is one test that spreads the cases over the cores in chunks (on_every_core, now shared intests/common/mod.rs), collects every failure and names each case. A panic in a case is caught where the case runs and reported as a failure that names it, so it does not hide what the other cases found.make fix-test-outputruns--test cases.tests/slow/sample.rs. The rule for the list is in its doc comment: a failing case for each lint, because--diffnarrows a report per kind of finding; one case for each section but Markdown (Rust, C++, TOML); one case with anallowentry; one case whose config deslag refuses (exit 2). A test checks that every entry exists, that every lint has its<lint>/brokenentry, that eachbrokenentry exits 1, that the Rust, C++ and TOML entries have their section in the config, that theallowentry has anallow, that the refusal exits 2, and that no entry is listed twice. A new lint, or a lost or changed entry, fails it. The update loop's>= 40floor and the diff loop's> 20floor are gone. A failure in the update loop names the case as<lint>/<case>, as the diff loop does.FIXED,FIXED_WHOLEandLEFT_BY_REASON, which every correct change to the corpus or tofixmoved, and whose assert summed the constants and not what was counted. It keeps its per-file checks and the second-run idempotence, checks per file and in total that what was fixed plus what was left equals what was banned, from what the run counted, and floors both counts above zero so it cannot pass inert. The tally still prints.tests/AGENTS.md, the comment on theslowbinary inCargo.toml, the doc comment oftests/slow/main.rs, and the comment onfix-test-output.Nothing else changed. No
.stderr,.json, golden or corpus file moved. The test-doctrine skill is unchanged. This PR resolves neither the golden-file question nor the library-oracle corpus tests.Decided on the maintainer's behalf
ci-fast. This reverses the cases part of the earlier split that putcases,corpus,diffandupdatein one slow binary.tests/golden.rs(7 s) andtests/allow.rs(11 s) are not touched.Timings
CPU seconds (user+sys,
/usr/bin/time -l, children included),fastprofile, builds warm. Other builds were running on the machine, so sys time is inflated and noisy; wall time is not comparable and is not given. Two measurements: the first at load 60 to 90, the second at load 14 to 75.The fix test's difference is load, not code: the test costs the same, since unpinning its counts saves none of its work. The cases test costs more than it did serially because threads add sys time; a quiet-machine run of the fast tier gained about 5 s.
Mutation checks
Each run in a scratch copy, never committed.
tests/cases/density/broken.stderrchanged:make test-fastexit 2,density/broken: stderr differs from line 1.src/lint/density.rs:make test-fastexit 2, six density cases named.verbs_nothing/brokendropped from the sample list: the list's test fails,verbs_nothing has no entry in the sample ... Add verbs_nothing/broken.fixskips counting one left character: the fix test fails at the per-file sum, namingllm/mabel-dev--opteryx/IMPLEMENTATION_SUMMARY.md.fixthat edits a file: the fix test fails,a second fix changed a file.From a review of the diff:
density/zero_limitrenamed: the list's test fails and names it.max_emphasis/brokenswapped formax_emphasis/clean: fails,max_emphasis has no entry in the sample.a second fix changed a file.fix fixed nothing in the corpus(the floor).verbs_nothing/brokenwith a stalebanned_chars/broken.stderr: before, onlyboom-lastprinted and the stderr difference was lost; after, bothbanned_chars/broken: stderr differsandverbs_nothing/broken: panicked: boom-lastprint.verbs_nothing/brokencase replaced by the contents of a passing case: the sample test fails,verbs_nothing/brokenexits 0 where 1 is expected.Testing
make ci-fast: exit 0make test: exit 0make test-tools: exit 0tests/slow/corpus.rs, where the fix test's pinned counts (moved on main by the frontmatter fixes) are deleted as before;make ci-fastandmake testpass again, and the sample test, the diff loop and the update loop pass against the new cases.References
None.