Skip to content

Speed up tests#22852

Open
MikeMcQuaid wants to merge 1 commit into
mainfrom
speed_up_tests
Open

Speed up tests#22852
MikeMcQuaid wants to merge 1 commit into
mainfrom
speed_up_tests

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member
  • trim slow profiled spec outliers in test setup.
  • keep one integration path for important command flows.
  • setup work dominated profile time, not the behaviour.
  • replace repeated command installs with fixture state where safe.
  • move invalid API tap checks out of API fixture setup.
  • shorten the SIGINT sleep while keeping the interruption proof.
  • make nested sandbox skips explicit in dev-cmd/test_spec.rb.
  • tradeoff: tests are less end-to-end where setup was not core.

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

OpenAI Codex 5.5 xhigh with local review, testing and tweaking.


- What: trims setup-heavy profiled test outliers.
- What: keeps command integrations to happy paths.
- Why: coverage profiling was spending time in setup.
- Why: a fast suite makes repeated profile runs practical.
- How: create fixture state directly for non-core setup.
- How: avoid cask archive extraction in artifact link specs.
- How: keep `brew test` fixture executable with a tiny script.
- How: shorten fixed sleeps and avoid redundant subprocesses.
- When: apply this to profiled examples where setup dominates.
- Pros: preserves important command smoke coverage with less wall time.
- Pros: removes several multi-second coverage outliers.
- Cons: some setup details are no longer end-to-end here.
- Tradeoff: negative paths rely more on focused in-process coverage.
- Tradeoff: `cmd/upgrade` stays broad because formula+cask is core.
- Tradeoff: `cmd/migrate` is unchanged because it failed locally first.
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review June 22, 2026 18:00
Copilot AI review requested due to automatic review settings June 22, 2026 18:00
@MikeMcQuaid

MikeMcQuaid commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

Seems to speed macOS tests up from ~17m -> ~13m.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

Library/Homebrew/test/cmd/tab_spec.rb:28

  • The formula-path coverage for brew tab --no-installed-on-request was removed, so this spec no longer exercises the “unmark” behavior for formulae (only for casks). That leaves the --no-installed-on-request formula path untested in integration specs.
  it "marks a formula as installed on request", :integration_test do
    setup_test_formula "foo",
                       tab_attributes: { "installed_on_request" => false }
    foo = Formula["foo"]

    expect { brew "tab", "--installed-on-request", "foo" }

Comment on lines +263 to +271
external_patch = formula do
patch :p1 do
url "file://#{tarball_fixture("testball-0.1-patches.tgz")}"
sha256 tarball_fixture_sha256("testball-0.1-patches.tgz")
apply "noop-a.diff"
end
end.stable.patches.last

expect(external_patch).to have_attributes(strip: :p1, patch_files: ["noop-a.diff"])
Comment on lines +19 to +20
formula_prefix = HOMEBREW_CELLAR/"testball/0.1"
(formula_prefix/"bin").mkpath
Comment on lines +11 to +13
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
formula_prefix = HOMEBREW_CELLAR/"testball/0.1"
(formula_prefix/"bin").mkpath
Comment on lines 76 to 80
it "downloads Formula and Cask URLs concurrently", :cask, :integration_test do
setup_test_formula "testball1"
setup_test_formula "testball2"

expect { brew "fetch", "testball1", "testball2", "local-caffeine" }.to be_a_success
expect { brew "fetch", "testball1", "local-caffeine" }.to be_a_success

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.

2 participants