Repository navigation
test: fold hand-unrolled Rust test tables - #11212
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
✅ Deploy Preview for rolldown-rs canceled.
|
Merging this PR will not alter performance
|
sapphi-red
left a comment
There was a problem hiding this comment.
I think the tests in
- crates/rolldown_ecmascript_utils/src/source_utils.rs
- crates/rolldown_utils/src/light_guess.rs
can be kept as it describes those cases are handled.
Merge activity
|
<!-- claude-projects-attribution: {"github_login":"Brooooooklyn"} -->
_Requested by **Brooklyn** · [project thread](https://claude.ai/code/project/chan_018s9RxRdtH424j2EhXdzV3N?thread=cmsg_018s9RxRdtH424j2EhXdzV3NQxbeR8Pt7qaqSQwoq9rEFo)_
<!-- routine:prune-tests:fold-rust-table-tests -->
Before: two Rust test modules were hand-unrolled lookup tables: 19 copy-pasted `dynamic_import_to_glob` tests, and three `relocate` tests that differed only in the target.
After: both are table-driven tests. Every row, comment and old test name is kept; the old name is the row label in the assertion message. Test code only: every hunk is inside a `#[cfg(test)] mod tests` block or under `tests/`.
Update after review: the two subset tests this PR first deleted (`source_utils` `test_contains_script_closing_tag_in_tagged_template` and `light_guess` `unknown_extensions`) are restored unchanged in e16c035, because they document that those cases are handled. The PR now only folds tables.
How: each row was defended by mutating product code with the most realistic regression only that row would catch, rebuilding, running, and reverting. Every row is the only guard for at least one mutation, so none was dropped, and evidence comments record that.
### Totals
| | Before | After |
|---|---|---|
| Files touched | – | 2 |
| Cases in the 2 touched test binaries | 67 | 48 |
| Cases deleted outright | – | 0 |
| Cases removed by folding (19 → 2 and 3 → 1, every row kept) | – | 19 |
| Net lines | – | −87 (+93 / −180) |
| Runtime saved (removed cases' summed duration) | – | ~0 s (every removed case reported `<0.000s>`) |
Whole suite at the merge-base could not be collected here (that needs the full workspace plus the NAPI binding). Counted instead: 522 `#[test]` / `#[tokio::test]` functions under `crates/`, plus fixture cases from 2,164 `_config.json` files (67 dot-prefixed, skipped); test262 and Vitest not counted.
### Per file
1. **`crates/rolldown_plugin_vite_dynamic_import_vars/src/dynamic_import_to_glob.rs`** (hand-unrolled lookup table, 19 → 2)
- All 19 bodies were the same parse → `to_glob_pattern` → assert sequence (a port of `@rollup/plugin-dynamic-import-vars`). They become `converts_dynamic_import_expressions_to_globs` (16 rows) and `rejects_unsupported_dynamic_import_expressions` (3 rows).
- M10–M13 each failed exactly one original test; after the fold the same mutations fail the folded test, and the message names the row.
2. **`crates/string_wizard/tests/magic_string.rs` › `relocate::refuses_to_move_a_selection_to_inside_itself{,2,3}`** (hand-unrolled lookup table, 3 → 1)
- One loop over targets `[3, 4, 6]`. Each target alone guards one edge of `to >= start && to <= end` (M7, M8, M9), so all three are kept with an evidence comment. After the fold, M7, M8 and M9 all fail it.
### Kept after defense — do not re-nominate
- Every row of both `dynamic_import_to_glob` tables (M10 → `escapes_square_brackets`, M11 → `data_uri`, M12 → `throws_…non_add_operator`, M13 → `throws_…file_extension`).
- All three `refuses_to_move…` targets (3, 4, 6).
- `source_utils` `test_contains_script_closing_tag_in_tagged_template` and `_multiple_occurrences`, and `light_guess` `unknown_extensions` (kept on review: they document handled cases).
### Case counts
| File | Before | After | Delta | Expected delta |
|---|---|---|---|---|
| `dynamic_import_to_glob.rs` (crate lib binary) | 19 | 2 | −17 | −17 |
| `string_wizard/tests/magic_string.rs` | 48 | 46 | −2 | −2 |
| **Total** | **67** | **48** | **−19** | **−19** |
`rolldown_utils` (68) and `rolldown_ecmascript_utils` (18) lib binaries are back to their merge-base counts and pass. **0 new failures**, no pre-existing failures.
### Mutations
Each was applied alone, rebuilt, run, then reverted (`git status` clean afterwards).
| # | Location | Change | Failed before | Failed after |
|---|---|---|---|---|
| M7 | `crates/string_wizard/src/magic_string/movement.rs:35` | `to >= start` → `to > start` | `refuses…itself`, `zero_width_relocate_to_its_own_position_still_errors` | folded test, `zero_width…` |
| M8 | `movement.rs:35` | `to <= end` → `to < end` | `refuses…itself3`, `zero_width…` | folded test, `zero_width…` |
| M9 | `movement.rs:35` | `to == start \|\| to == end` | `refuses…itself2` | folded test |
| M10 | `dynamic_import_to_glob.rs:42` | stop escaping `[` and `]` | `escapes_square_brackets` | `converts_…` |
| M11 | `dynamic_import_to_glob.rs:9` | drop `data:` from `IGNORED_PROTOCOLS` | `data_uri` | `converts_…` |
| M12 | `dynamic_import_to_glob.rs:107` | accept any binary operator | `throws_…non_add_operator` | `rejects_…` |
| M13 | `dynamic_import_to_glob.rs:32` | drop the extension check | `throws_…file_extension` | `rejects_…` |
| M14 | `dynamic_import_to_glob.rs:89` | `arguments.is_empty()` → `len() < 2` | nothing (pre-existing gap, not touched here) | – |
M14 shows single-argument `.concat()` (e.g. `'./foo/'.concat(bar)`) is untested; this PR does not change that.
### What ran and what did not
- Ran, at origin/main (c9a8cda) and after: `cargo test --locked` for `rolldown_plugin_vite_dynamic_import_vars`, `string_wizard`, `rolldown_utils` and `rolldown_ecmascript_utils` (per-test durations via `--report-time`); `cargo clippy --locked -p <those crates> --all-targets -- --deny warnings`; `cargo fmt --all --check`; `git diff --check`. All clean, including after the restore commit.
- Not run: the full `just test-rust` (bundler fixtures and test262), the Node/Vitest suites (`just test-node`, needs the binding), `just lint-repo` / `just lint-node` (no non-Rust files changed).
### Excluded pull requests
All 162 open PRs on 2026-10-14 were fetched and every file they touch (1,889 files) was skipped; neither file here is touched by any of them.
### Age check (cutoff: 30 days, 2026-09-14)
| Test(s) | First added |
|---|---|
| `dynamic_import_to_glob` tests | 2024-08-01 (`40cf58b9b`, #1732; moved in `9cb5be8a4`, #7068) |
| `refuses_to_move…` tests | 2024-11-04 (`2ace0ebac`, #2572) |
None is in a permission, security or entitlement suite, and neither was added for a bug.
To revert: `git revert e16c035 6a233d9`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01PxVsmvB9xfZKfVnUonY8kf
e16c035 to
d226543
Compare
## [1.2.15] - 2026-10-21 ### 🚀 Features - rolldown_plugin_vite_resolve: add `isBundled` to pick the browser-external stub format (#11260) by @h-a-n-a - dev: mark entry modules in the HMR module graph (#11252) by @h-a-n-a - mark module starts with `// <id>` comments instead of `#region` pairs (#11235) by @IWANABETHATGUY ### 🐛 Bug Fixes - plugin: stop `this.resolve` recursion between plugins with `skipSelf: true` (#11181) by @anzal1 - rolldown_plugin_vite_resolve: handle external `require` for `ssr.target: 'webworker'` (#11205) by @sapphi-red - rolldown_plugin_vite_build_import_analysis: only wrap dynamic imports with static specifiers in __vitePreload (#10879) by @smeng9 - strict-execution-order: wrap eager modules that forward wrapped definers (#11186) by @hyfdev - chunk-import-map: keep common chunk keys unique when enabling inline common chunks (#11230) by @hyfdev - only register signal-exit handler when a trace subscriber is active (#11208) by @DaniilIsupov ### 🧪 Testing - fold hand-unrolled Rust test tables (#11212) by @Brooooooklyn ### ⚙️ Miscellaneous Tasks - deps: upgrade oxc to 0.155.0 (#11228) by @Dunqing - rollup-tests: retriage failed tests (#11251) by @sapphi-red - deps: update rollup submodule for tests to v4.64.12 (#11249) by @rolldown-guard[bot] - deps: update test262 submodule for tests (#11242) by @rolldown-guard[bot] ### ❤️ New Contributors * @anzal1 made their first contribution in [#11181](#11181) * @smeng9 made their first contribution in [#10879](#10879) * @DaniilIsupov made their first contribution in [#11208](#11208) Co-authored-by: shulaoda <[email protected]>
Requested by Brooklyn · project thread
Before: two Rust test modules were hand-unrolled lookup tables: 19 copy-pasted
dynamic_import_to_globtests, and threerelocatetests that differed only in the target.After: both are table-driven tests. Every row, comment and old test name is kept; the old name is the row label in the assertion message. Test code only: every hunk is inside a
#[cfg(test)] mod testsblock or undertests/.Update after review: the two subset tests this PR first deleted (
source_utilstest_contains_script_closing_tag_in_tagged_templateandlight_guessunknown_extensions) are restored unchanged in e16c035, because they document that those cases are handled. The PR now only folds tables.How: each row was defended by mutating product code with the most realistic regression only that row would catch, rebuilding, running, and reverting. Every row is the only guard for at least one mutation, so none was dropped, and evidence comments record that.
Totals
<0.000s>)Whole suite at the merge-base could not be collected here (that needs the full workspace plus the NAPI binding). Counted instead: 522
#[test]/#[tokio::test]functions undercrates/, plus fixture cases from 2,164_config.jsonfiles (67 dot-prefixed, skipped); test262 and Vitest not counted.Per file
crates/rolldown_plugin_vite_dynamic_import_vars/src/dynamic_import_to_glob.rs(hand-unrolled lookup table, 19 → 2)to_glob_pattern→ assert sequence (a port of@rollup/plugin-dynamic-import-vars). They becomeconverts_dynamic_import_expressions_to_globs(16 rows) andrejects_unsupported_dynamic_import_expressions(3 rows).crates/string_wizard/tests/magic_string.rs›relocate::refuses_to_move_a_selection_to_inside_itself{,2,3}(hand-unrolled lookup table, 3 → 1)[3, 4, 6]. Each target alone guards one edge ofto >= start && to <= end(M7, M8, M9), so all three are kept with an evidence comment. After the fold, M7, M8 and M9 all fail it.Kept after defense — do not re-nominate
dynamic_import_to_globtables (M10 →escapes_square_brackets, M11 →data_uri, M12 →throws_…non_add_operator, M13 →throws_…file_extension).refuses_to_move…targets (3, 4, 6).source_utilstest_contains_script_closing_tag_in_tagged_templateand_multiple_occurrences, andlight_guessunknown_extensions(kept on review: they document handled cases).Case counts
dynamic_import_to_glob.rs(crate lib binary)string_wizard/tests/magic_string.rsrolldown_utils(68) androlldown_ecmascript_utils(18) lib binaries are back to their merge-base counts and pass. 0 new failures, no pre-existing failures.Mutations
Each was applied alone, rebuilt, run, then reverted (
git statusclean afterwards).crates/string_wizard/src/magic_string/movement.rs:35to >= start→to > startrefuses…itself,zero_width_relocate_to_its_own_position_still_errorszero_width…movement.rs:35to <= end→to < endrefuses…itself3,zero_width…zero_width…movement.rs:35to == start || to == endrefuses…itself2dynamic_import_to_glob.rs:42[and]escapes_square_bracketsconverts_…dynamic_import_to_glob.rs:9data:fromIGNORED_PROTOCOLSdata_uriconverts_…dynamic_import_to_glob.rs:107throws_…non_add_operatorrejects_…dynamic_import_to_glob.rs:32throws_…file_extensionrejects_…dynamic_import_to_glob.rs:89arguments.is_empty()→len() < 2M14 shows single-argument
.concat()(e.g.'./foo/'.concat(bar)) is untested; this PR does not change that.What ran and what did not
cargo test --lockedforrolldown_plugin_vite_dynamic_import_vars,string_wizard,rolldown_utilsandrolldown_ecmascript_utils(per-test durations via--report-time);cargo clippy --locked -p <those crates> --all-targets -- --deny warnings;cargo fmt --all --check;git diff --check. All clean, including after the restore commit.just test-rust(bundler fixtures and test262), the Node/Vitest suites (just test-node, needs the binding),just lint-repo/just lint-node(no non-Rust files changed).Excluded pull requests
All 162 open PRs on 2026-10-14 were fetched and every file they touch (1,889 files) was skipped; neither file here is touched by any of them.
Age check (cutoff: 30 days, 2026-09-14)
dynamic_import_to_globtests40cf58b9b, #1732; moved in9cb5be8a4, #7068)refuses_to_move…tests2ace0ebac, #2572)None is in a permission, security or entitlement suite, and neither was added for a bug.
To revert:
git revert e16c03518 6a233d9da.🤖 Generated with Claude Code
https://claude.ai/code/session_01PxVsmvB9xfZKfVnUonY8kf