mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
docs(formatter_core): clarify idempotency test infra (#26069)
This commit is contained in:
1 parent
0e969e8520
commit
fc175b09d3
2 files changed
+8
-7
No files matched your search
@@ -186,11 +186,7 @@ fn test() {
|
||||
|
||||
#### oxc_formatter (and other `oxc_formatter_*` language crates)
|
||||
|
||||
- **Fixture tests** (`tests/fixtures/`) and **Prettier conformance** (`tests/conformance.rs`), both part of `cargo test`
|
||||
- **Command**: `cargo test -p <crate>` (conformance only: `--test conformance`)
|
||||
- **Debug**: `PRETTIER_FILTER=<name> cargo test -p <crate> --test conformance -- --nocapture`
|
||||
- Conformance compares output with Prettier's snapshots (suite self-provisioned by `oxc_formatter_tests`); reports are pinned with `insta`
|
||||
- Both harnesses re-format every output and record idempotency violations in the snapshots/reports (tracked, not asserted); adding a fixture automatically covers idempotency
|
||||
- Read the target crate's `AGENTS.md`; it includes the shared formatter policy plus language-specific rules and verification commands
|
||||
|
||||
#### oxc_minifier
|
||||
|
||||
@@ -273,7 +269,6 @@ These test suites are pre-cloned and ready to search:
|
||||
- **Test262** (`tasks/coverage/test262/`) - ECMAScript spec compliance
|
||||
- **Babel** (`tasks/coverage/babel/`) - Parsing and transformation edge cases
|
||||
- **TypeScript** (`tasks/coverage/typescript/`) - TypeScript syntax and semantics
|
||||
- **Prettier** (`crates/oxc_formatter_tests/prettier/`) - Formatting expectations (self-provisioned on first conformance run)
|
||||
|
||||
NOTE: These suites are script-cloned and fully gitignored. ripgrep respects `.gitignore`, so a plain `rg` inside them silently returns nothing.
|
||||
Use `rg --no-ignore` (or `-u`) when searching them.
|
||||
|
||||
@@ -110,6 +110,8 @@ node apps/oxfmt/node_modules/prettier/bin/prettier.cjs --parser <parser> --print
|
||||
|
||||
NOTE: Prettier's default `printWidth` is `80`, but Oxfmt is `100`.
|
||||
|
||||
Fixture tests and Prettier conformance re-format every output and record idempotency violations in their snapshots/reports.
|
||||
|
||||
### Fixture tests
|
||||
|
||||
Snapshot tests driven by fixture files under `tests/fixtures/`; they cover what the Prettier conformance suite does not (suppression, divergence pins, embedded shapes, ...).
|
||||
@@ -135,10 +137,14 @@ cargo test -p <crate> --test conformance
|
||||
PRETTIER_FILTER=<path> cargo test -p <crate> --test conformance -- --nocapture
|
||||
```
|
||||
|
||||
The Prettier suite lives under `crates/oxc_formatter_tests/prettier/` and is self-provisioned on the first conformance run. It is gitignored, so use `rg --no-ignore` (or `-u`) when searching it.
|
||||
|
||||
JSDoc formatting is covered by plain fixture-pair tests in `oxc_formatter` (`--test jsdoc`, committed input/expected pairs — a mismatch is a failing test, not a tracked report entry).
|
||||
|
||||
Failures must be either fixed or classified under "Known divergences".
|
||||
|
||||
### Embedded conformance (`apps/oxfmt`)
|
||||
### E2E conformance (`apps/oxfmt`)
|
||||
|
||||
The embedded-language features (e.g. xxx-in-js / js-in-xxx) are validated end-to-end through Oxfmt. Requires a dev build first.
|
||||
|
||||
There are also conformance tests for each language that use real-world repositories.
|
||||
Reference in new issue
Block a user