Skip to content

test/cmd/which-formula_spec: avoid modifications outside test dir - #23626

Merged
MikeMcQuaid merged 1 commit into
mainfrom
which-formula_spec-test-dir
Aug 23, 2026
Merged

test/cmd/which-formula_spec: avoid modifications outside test dir#23626
MikeMcQuaid merged 1 commit into
mainfrom
which-formula_spec-test-dir

Conversation

@cho-m

@cho-m cho-m commented Aug 23, 2026

Copy link
Copy Markdown
Member

HOMEBREW_LIBRARY_PATH is the non-mocked path so setting shell_cellar based on this means modifications are done outside of test environment and instead in user's installation.

Can see this happen by adding a sleep 10 in test case and then checking cellar path.

  • Before test
    /bin/ls /opt/homebrew/Cellar/foo
    ls: /opt/homebrew/Cellar/foo: No such file or directory
  • During test
    /bin/ls /opt/homebrew/Cellar/foo
    1.0.0

Not sure why this isn't sandboxed. Maybe to avoid nested usage or some particular integration scenarios?

Instead, HOMEBREW_CELLAR is within our temporary test path.


  • 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 brew benchmark results.
  • 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?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Copilot AI lite review requested due to automatic review settings August 23, 2026 04:57

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

This PR fixes which-formula’s command spec to avoid creating/removing directories in a user’s real Homebrew installation during test runs by ensuring the test always uses the test-scoped HOMEBREW_CELLAR path.

Changes:

  • Simplifies shell_cellar selection to always use HOMEBREW_CELLAR, preventing writes under a real .../Cellar when present.
  • Keeps the Bash-command execution environment aligned with the test sandbox by consistently exporting HOMEBREW_CELLAR from the same temporary location.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 23, 2026
Merged via the queue into main with commit 7cf2ce3 Aug 23, 2026
51 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the which-formula_spec-test-dir branch August 23, 2026 08:51
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.

3 participants