Skip to content

Conversation

@pfgithub
Copy link
Collaborator

Fixes #23066

Reverts the breaking change to this order made in #22534

@robobun
Copy link
Collaborator

robobun commented Sep 29, 2025

Updated 9:41 PM PT - Sep 30th, 2025

@pfgithub, your commit 1e1b542 has 5 failures in Build #27694 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 23113

That installs a local version of the PR into your bun-23113 executable, so you can run:

bun-23113 --bun

@pfgithub pfgithub marked this pull request as ready for review September 30, 2025 21:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Store test Config on Order and remove cfg parameters from multiple Order methods. Propagate a new FirstLast (first/last) flag through BunTest and TestCommand to control global hooks across multi-file runs. Add multi-file scheduling tests and update a regression snapshot.

Changes

Cohort / File(s) Summary
Order struct and API refactor
src/bun.js/test/Order.zig
Add cfg: Config field; change init to accept cfg; remove cfg parameters from generateOrderSub, generateAllOrder, generateOrderDescribe, and generateOrderTest; switch internal uses to this.cfg and update call sites.
Bun test runner FirstLast propagation
src/bun.js/test/bun_test.zig
Add BunTestRoot.FirstLast { first, last }; extend BunTestRoot.enterFile(...) and BunTest.init(...) to accept/store FirstLast; use first/last to gate beforeAll/afterAll ordering and adjust init/deinit ordering.
CLI TestCommand API change
src/cli/test_command.zig
Change TestCommand.run(...) signature to accept first_last: bun_test.BunTestRoot.FirstLast (replacing previous allocator parameter) and update call sites to pass first/last flags for multi-file runs.
Multi-file scheduling tests and fixtures
test/js/bun/test/bun_test.test.ts, test/js/bun/test/scheduling/multi-file/*
Add multi-file test that spawns bun test with two fixture files and a preload; add preload.ts registering beforeAll/beforeEach/afterEach/afterAll, plus test1.fixture.ts and test2.fixture.ts that log test names.
Regression snapshot update
test/regression/issue/12782.test.ts
Replace failing environment-variable preload content so bar fixture tests pass; update inline snapshot to reflect new outcomes (total tests and pass/fail counts updated); exit code remains 1.

Possibly related PRs

Suggested reviewers

  • nektro
  • dylan-conway

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request includes a refactor of the Order struct’s configuration handling, adding a cfg field and updating multiple signatures unrelated to the specific objective of fixing global hook execution ordering described in issue #23066. Consider extracting the configuration refactor into a separate pull request or otherwise justifying its relevance to the beforeAll/afterAll ordering fix in this PR.
Description Check ⚠️ Warning The Pull Request description does not follow the repository’s template since it lacks the required “What does this PR do?” and “How did you verify your code works?” sections and provides only a brief note about the issue and revert, making it incomplete. Please update the description to include clear sections for “What does this PR do?” and “How did you verify your code works?” and provide details on implementation and testing steps.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “run beforeAll before the first file and afterAll after the last file” succinctly and accurately describes the primary change of adjusting when global hooks execute, making it clear that beforeAll now runs before the first test file and afterAll after the last file. It is concise, specific, and directly reflects the core update without extraneous details.
Linked Issues Check ✅ Passed The changes introduce a FirstLast mechanism that gates global beforeAll and afterAll hooks to run only once across the entire test run, update the command-line invocation to derive the first and last file flags correctly, and add tests to validate this behavior, thereby satisfying the requirements of linked issue #23066.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pfg/describe-4

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 437d935 and 1e1b542.

📒 Files selected for processing (3)
  • src/bun.js/test/Order.zig (5 hunks)
  • src/bun.js/test/bun_test.zig (6 hunks)
  • test/js/bun/test/bun_test.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/js/bun/test/bun_test.test.ts
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

Implement debug logs in Zig using const log = bun.Output.scoped(.${SCOPE}, false); and invoking log("...", .{})

Files:

  • src/bun.js/test/Order.zig
  • src/bun.js/test/bun_test.zig
**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/javascriptcore-class.mdc)

**/*.zig: Declare the extern C symbol in Zig and export a Zig-friendly alias for use
Wrap the Bun____toJS extern in a Zig method that takes a JSGlobalObject and returns JSC.JSValue

**/*.zig: Format Zig files with zig-format (bun run zig-format)
In Zig, manage memory carefully with allocators and use defer for cleanup

Files:

  • src/bun.js/test/Order.zig
  • src/bun.js/test/bun_test.zig
src/bun.js/**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)

src/bun.js/**/*.zig: In Zig binding structs, expose generated bindings via pub const js = JSC.Codegen.JS and re-export toJS/fromJS/fromJSDirect
Constructors and prototype methods should return bun.JSError!JSC.JSValue to integrate Zig error handling with JS exceptions
Use parameter name globalObject (not ctx) and accept (*JSC.JSGlobalObject, *JSC.CallFrame) in binding methods/constructors
Implement getters as get(this, globalObject) returning JSC.JSValue and matching the .classes.ts interface
Provide deinit() for resource cleanup and finalize() that calls deinit(); use bun.destroy(this) or appropriate destroy pattern
Access JS call data via CallFrame (argument(i), argumentCount(), thisValue()) and throw errors with globalObject.throw(...)
For properties marked cache: true, use the generated Zig accessors (NameSetCached/GetCached) to work with GC-owned values
In finalize() for objects holding JS references, release them using .deref() before destroy

Files:

  • src/bun.js/test/Order.zig
  • src/bun.js/test/bun_test.zig
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Format
🔇 Additional comments (2)
src/bun.js/test/bun_test.zig (1)

566-574: Global hook gating looks correct.

These First/Last checks finally keep preload beforeAll/afterAll from firing per file while still scheduling them exactly once at the run boundaries. Nice work.

src/bun.js/test/Order.zig (1)

3-26: Consolidating cfg on the Order instance is a solid cleanup.

Passing the config once at init and reading it inside the helpers trims the call surface without changing scheduling semantics. Looks great.

Also applies to: 60-83


Comment @coderabbitai help to get the list of available commands and usage tips.

@pfgithub pfgithub merged commit 613aea1 into main Oct 1, 2025
57 of 60 checks passed
@pfgithub pfgithub deleted the pfg/describe-4 branch October 1, 2025 04:47
This was referenced Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bun v1.2.23, global beforeAll/afterAll is called once per test file, rather than only once for all tests.

3 participants