test(allocator): copy Bump tests from bumpalo#21270
Conversation
Oxc's `Bump` uses a 16 KiB default chunk (`FIRST_ALLOCATION_GOAL`) vs bumpalo's 512 bytes. Adjust the two affected tests: - `change_allocation_limit_with_live_allocations`: Use `with_capacity(448)` for a small initial chunk that fits under the 512-byte limit, and raise the second limit to 32768 to accommodate the larger minimum new chunk size. - `reset_updates_allocated_bytes`: Use `with_capacity(512)` so both 512-byte allocations don't fit in a single chunk, ensuring `reset` actually reduces `allocated_bytes`.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR ports the upstream bumpalo test suite covering Bump into crates/oxc_allocator, with minimal adjustments needed for oxc’s allocator defaults (notably chunk sizing) and to keep the tests runnable under this workspace’s linting/CI setup.
Changes:
- Added a dedicated integration-test suite under
crates/oxc_allocator/tests/bump/covering allocation APIs, limits, reset behavior, and chunk iteration. - Added a custom-harness integration test (
bump_try_alloc) that simulates global allocation failures to validatetry_*APIs. - Added
quickcheck/randas workspace + dev-dependencies to support property tests.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_allocator/tests/bump/try_alloc_with.rs | Adds try_alloc_with large-object tests (ignored under debug assertions). |
| crates/oxc_allocator/tests/bump/try_alloc_try_with.rs | Adds try_alloc_try_with success/failure tests for large objects. |
| crates/oxc_allocator/tests/bump/tests.rs | Adds core Bump behavioral tests (chunk iteration, alignment, reset, OOM overflow guard). |
| crates/oxc_allocator/tests/bump/quickchecks.rs | Adds property-based tests for overlap/containment/alignment and allocation accounting. |
| crates/oxc_allocator/tests/bump/quickcheck.rs | Adds a wrapper quickcheck! macro to cap iterations under Miri. |
| crates/oxc_allocator/tests/bump/main.rs | Test-crate entry wiring for the multi-module bump integration test. |
| crates/oxc_allocator/tests/bump/capacity.rs | Adds capacity edge-case test for try_with_capacity. |
| crates/oxc_allocator/tests/bump/allocation_limit.rs | Adds allocation limit tests; adjusts capacities to match oxc’s chunk sizing. |
| crates/oxc_allocator/tests/bump/alloc_with.rs | Adds alloc_with large-object tests (ignored under debug assertions). |
| crates/oxc_allocator/tests/bump/alloc_try_with.rs | Adds alloc_try_with and slice try_fill_* large-length failure tests. |
| crates/oxc_allocator/tests/bump/alloc_fill.rs | Adds slice fill/copy/clone/default tests, including overflow panic expectation. |
| crates/oxc_allocator/tests/bump_try_alloc.rs | Adds custom serial test runner to validate try_* APIs under forced allocator failure. |
| crates/oxc_allocator/Cargo.toml | Registers bump_try_alloc as harness = false and adds dev-deps needed by new tests. |
| Cargo.toml | Adds workspace dependency versions for quickcheck and rand. |
| Cargo.lock | Locks new dependency graph for quickcheck/rand (and transitive deps). |

#20963 copied
bumpalo's code intooxc_allocatorcrate, but I neglected to copy across the tests.This PR copies all
bumpalo's test files that relate toBump, and makes only in the minimum required changes to make them compile and the tests pass.2 tests required modification to pass:
change_allocation_limit_with_live_allocationsreset_updates_allocated_bytesBoth failed because oxc's
Bumpuses a 16 KiB default chunk size (vsbumpalo's 512 bytes). The fix is to create theBumpwithwith_capacity(448)/with_capacity(512)respectively, so the initial chunk is small enough for the test logic to work as intended (limit not already exceeded, and two allocations spanning multiple chunks).That apart, the tests are unaltered except for import paths and other cosmetic changes, the changes that are made are split into multiple small commits for ease of review. I'm going to manually merge this PR, so that we have a "paper trail" of what changes were made to the tests in GitHub (not merging with Graphite which would squash all the commits).