Skip to content

test(allocator): copy Bump tests from bumpalo#21270

Merged
overlookmotel merged 17 commits intomainfrom
om/04-09-test_allocator_copy_bump_tests_from_bumpalo_
Apr 9, 2026
Merged

test(allocator): copy Bump tests from bumpalo#21270
overlookmotel merged 17 commits intomainfrom
om/04-09-test_allocator_copy_bump_tests_from_bumpalo_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 9, 2026

#20963 copied bumpalo's code into oxc_allocator crate, but I neglected to copy across the tests.

This PR copies all bumpalo's test files that relate to Bump, and makes only in the minimum required changes to make them compile and the tests pass.

2 tests required modification to pass:

  1. change_allocation_limit_with_live_allocations
  2. reset_updates_allocated_bytes

Both failed because oxc's Bump uses a 16 KiB default chunk size (vs bumpalo's 512 bytes). The fix is to create the Bump with with_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).

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`.
Copy link
Copy Markdown
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@github-actions github-actions Bot added A-allocator Area - Allocator C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Apr 9, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 9, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-09-test_allocator_copy_bump_tests_from_bumpalo_ (c87d93a) with main (f5e1845)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@overlookmotel overlookmotel marked this pull request as ready for review April 9, 2026 18:26
Copilot AI review requested due to automatic review settings April 9, 2026 18:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 validate try_* APIs.
  • Added quickcheck/rand as 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).

Comment thread crates/oxc_allocator/tests/bump/alloc_fill.rs
Comment thread crates/oxc_allocator/tests/bump/tests.rs
@overlookmotel overlookmotel merged commit e005557 into main Apr 9, 2026
36 checks passed
@overlookmotel overlookmotel deleted the om/04-09-test_allocator_copy_bump_tests_from_bumpalo_ branch April 9, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants