next.js
37f90d15 - Replace VcStorage with real TurboTasks in tests/benches

Commit
3 days ago
Replace VcStorage with real TurboTasks in tests/benches (#93955) `VcStorage` is a partial in-memory implementor of `TurboTasksApi`/`TurboTasksCallApi` in `turbo-tasks-testing`. It gave a handful of tests/benchmarks a way to allocate cells and call functions without spinning up a real backend, at the cost of stubbing roughly half of the trait surface with `unreachable!()`/`unimplemented!()`. This PR migrates the four call sites to construct a real `TurboTasks` over a `noop_backing_storage()`, then deletes `VcStorage` and the test-only `with_turbo_tasks_for_testing`/`current_task_for_testing` helpers it was the sole consumer of. After this PR, `TurboTasks<B>` is the only concrete implementor of `dyn TurboTasksApi`. ### Migrated call sites - **`turbo-tasks-fs` `with_extension` and `file_stem` tests** — direct `tt.run_once(async move { … })` replacement, matching the existing `test_try_from_sys_path` test in the same file. - **`turbopack-ecmascript` `analyzer::tests::fixture`** — the body is now in a `#[turbo_tasks::function(operation, root)] async fn fixture_op(input: RcStr)` invoked via `fixture_op(input).read_strongly_consistent().await`. The synchronous SWC parser+resolver setup is wrapped in `GLOBALS.set(&globals, || …)` returning owned `(eval_context, var_graph)`, after which the async resolve/link work proceeds without GLOBALS — mirroring the production pattern in `analyze_ecmascript_module_internal`. `run_test` is no longer needed. - **`turbopack-ecmascript` `bench_link`** — restructured to mirror `turbo-tasks-backend/benches/overhead.rs`: `iter_custom` with `TurboTasks` constructed per measurement batch (`storage_mode: None`, `dependency_tracking: false`), `Instant::now()` placed after construction so it isn't timed. `BenchInput.var_graph` is now `Arc<VarGraph>` so the future can be `Send + 'static`. Quick run shows no change in performance for `link/typeof`. ### Deleted - `VcStorage` and its trait impls (`turbo-tasks-testing/src/lib.rs` shrinks from 339 lines to 9). - `with_turbo_tasks_for_testing`, `current_task_for_testing`, and the `test_helpers` re-export module — all unused after `VcStorage` is gone. ### Verification - `cargo check --workspace --tests --benches` — clean. - `cargo clippy` on changed crates — clean. - `cargo test -p turbo-tasks-fs --lib` — 110/110 pass. - `cargo test -p turbopack-ecmascript --lib` — 352/352 pass (including all 60 analyzer fixture tests). - `cargo bench -p turbopack-ecmascript --bench analyzer -- "link/typeof" --quick` — runs; no change in performance detected. <!-- NEXT_JS_LLM_PR -->
Author
Parents
Loading