Repository navigation
feat(rust): move string_wizard to the repo - #2572
Merged
Merged
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ Deploy Preview for rolldown-rs canceled.
|
hyfdev
marked this pull request as ready for review
November 3, 2024 13:45
hyfdev
force-pushed
the
11-03-feat_rust_move_string_wizard_to_the_repo
branch
from
November 3, 2024 13:49
8297982 to
f8ad1f2
Compare
Member
|
I remember that you said that #1364 (comment), maybe we should discuss it in the meeting. |
Contributor
Benchmarks Rust |
Member
Author
Feel free to add this in discussion section. |
Member
Author
Merge activity
|
IWANABETHATGUY
approved these changes
Nov 4, 2024
hyfdev
force-pushed
the
11-03-feat_rust_move_string_wizard_to_the_repo
branch
from
November 4, 2024 04:20
f8ad1f2 to
b3c1906
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Oct 15, 2026
<!-- 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
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.

Description
To have a quick development loop, it's better to move the
string_wizardin the repo so we could modify it in time.