Skip to content

Commit fa26c70

Browse files
Add deterministic Tailwind parity checks (#144)
* Add deterministic Tailwind parity checks Compare RustyWind with pinned real-world TSX, Svelte, and Astro corpora through xtask. Lock formatter inputs and corpus fingerprints so large parser changes can be checked reproducibly. Treat shared-order and extraction differences as failures while reporting custom utilities separately. * Harden Tailwind parity checks Resolve the release binary from Cargo's artifact output so custom target directories are honored. Classify every Tailwind token, bound child processes, and scrub configured paths from errors.
1 parent 150ac6f commit fa26c70

13 files changed

Lines changed: 2906 additions & 2 deletions

File tree

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ fmt:
66
clippy:
77
cargo clippy -- -D warnings
88

9+
compare-tailwind *args:
10+
cargo xtask compare run {{args}}
11+
912
update:
1013
cargo update --workspace
1114

tests/tailwind-compare/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Tailwind comparison engine
2+
3+
This package compares RustyWind's ordering of static quoted class attributes
4+
with Prettier's Tailwind CSS plugin across a pinned external corpus. It supports
5+
TSX, Svelte, and Astro sources. The engine reverses eligible class lists in
6+
memory before invoking either formatter, so already-sorted source does not
7+
produce false agreement.
8+
9+
Install the exact toolchain and run the focused unit tests with:
10+
11+
```bash
12+
cd tests/tailwind-compare
13+
npm ci
14+
npm test
15+
```
16+
17+
The repository's `xtask` command is the intended orchestration layer. It checks
18+
out the corpus and supplies every input explicitly:
19+
20+
```bash
21+
node compare.mjs \
22+
--corpus example/project \
23+
--repo /path/to/project \
24+
--revision 0123456789abcdef0123456789abcdef01234567 \
25+
--scope src \
26+
--kind tsx \
27+
--limit 30 \
28+
--rustywind ../../target/release/rustywind \
29+
--stylesheet tailwind.css \
30+
--output /path/to/report.json
31+
```
32+
33+
Candidates are ranked by descending static attribute count, then by bytewise
34+
UTF-8 relative path. The report fingerprint is SHA-256 over those ordered
35+
selected records: relative path, NUL, scrambled source, NUL. Reports contain
36+
only logical corpus paths, not checkout or executable paths.
37+
38+
The process exits nonzero for invalid arguments, missing inputs, and a failed
39+
Tailwind classification probe. Source parse errors and RustyWind failures are
40+
recorded in the report for the caller to interpret alongside ordering and
41+
extraction findings.
42+
43+
Only quoted `class` and `className` literals without template delimiters are in
44+
scope. Dynamic expressions, `class:list`, helper calls such as `cn` and `cva`,
45+
and project-specific Tailwind configuration are outside this comparison. A
46+
token is Tailwind-known when the pinned Prettier plugin moves it past two
47+
unknown sentinels using the supplied minimal Tailwind 4 stylesheet. Differences
48+
that preserve the order of known tokens are reported separately as
49+
`custom-only`.

0 commit comments

Comments
 (0)