Repository navigation
test: add a corpus test that formats real files repeatedly - #834
Merged
Merged
Conversation
The specs are small, so they don't catch formatting that changes when formatted again on larger real code. The corpus test formats every JS/TS file in the directories in `DPRINT_TS_CORPUS` twice and reports the files that change, whose formatted text doesn't parse, or that panic. It only fails for files that aren't in the baseline passed with `--baseline`, and adds a baseline for the deno repo.
…a reducer Formatting that changes when formatted again, but stops changing after a few formats, is now only counted, and the files with problems are the ones still changing after 10 formats. `--reduce <dir>` reduces those files to small snippets that still keep changing, by removing statements and list items and replacing expressions, and writes them along with how each formats.
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.
The specs are small, so they don't catch problems that only show up on larger real code. This adds a corpus test that formats every JS/TS file in a set of directories and reports:
Files that change when formatted again but stop changing within 10 formats are only counted, since they settle.
It's skipped unless
DPRINT_TS_CORPUSis set to the corpus directories, so it doesn't changecargo test. In a git repository it only checks the files git tracks (including in submodules), so local files don't change the results. Files that don't parse are skipped.DPRINT_TS_CORPUS=../deno cargo test --release --test corpus -- --baseline tests/corpus_baselines/deno.txt--baseline <file>only fails for the files that aren't in the baseline, and lists the ones that no longer have problems.--write-baseline <file>writes the baseline.--write-hashes <file>writes a hash of each file's formatted text, for comparing two versions to find the files whose formatting changed.--reduce <dir>reduces each file that keeps changing to a small snippet that still does, by removing statements and list items and replacing expressions with an identifier (largest first, up to two minutes per file), and writes the distinct snippets along with asummary.mdof how each formats.Results for deno
This adds a baseline for deno at 87c5ddbdc92ed65385dc0800dc66645620331080 with its submodules (91,295 files, about 45 seconds in a release build on my machine):
await), which swc parses anyway.Running it in CI would need a checkout of deno and its submodules, so that's left for later.