Skip to content

dev-cmd/tests: find changed tests when split inside directory - #24494

Merged
cho-m merged 1 commit into
mainfrom
changed-tests-split
Nov 5, 2026
Merged

cho-m merged 1 commit into
mainfrom
changed-tests-split

Conversation

@cho-m

@cho-m cho-m commented Nov 5, 2026

Copy link
Copy Markdown
Member

Mainly needed for RuboCop tests which still have multiple classes inside files so brew lgtm ends up skipping tests.

e.g. https://github.com/Homebrew/brew/tree/main/Library/Homebrew/test/rubocops/lines

Later on, we could move cop classes to separate files.


  • 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.

Mainly needed for RuboCop tests which still have multiple classes inside
files so `brew lgtm` ends up skipping tests.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Updated changed-test detection to find specifications nested in a file-specific test directory when no matching top-level specification exists. Existing handling of changed files within the test directory remains unchanged. This helps the development command associate modified files with their relevant tests in more cases.

For changed Ruby files outside test/, changed_test_files now uses the associated spec when it exists. Otherwise, it selects specs from the matching test subdirectory.

Changes: Test file selection

Layer / File(s) Summary
Associated spec lookup
Library/Homebrew/dev-cmd/tests.rb
changed_test_files checks whether the associated spec exists. If it does not, the method selects specs from the matching test subdirectory.
Merge Risk: Minimal · up to b9c20

No merge-blocking runtime risk is established; add the focused regression test to prevent this behavior from regressing.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: finding changed tests that are split within a directory.
Description check Passed The description explains the skipped RuboCop tests, the reason for the change, and the reported validation step. It is directly related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot 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.

Nitpick comments: 1

Library/Homebrew/dev-cmd/tests.rb: 1

325-329: Trivial · Maintainability & Code Quality · Quick win

Add a regression example for the split-spec fallback in changed_test_files.

The new Pathname.glob("test/#{filestub}/*_spec.rb") branch at Library/Homebrew/dev-cmd/tests.rb:329-330 has no example in Library/Homebrew/test/dev-cmd/tests_spec.rb:314-371. Reverting it to the unconditional associated-spec path would still pass every current example. A later change could then drop split specs silently and reintroduce the skipped RuboCop tests this PR fixes.

Add a context to that describe block. It should stub Utils::Git.changed_files with a source file that has no associated spec but has specs under test/<filestub>/, such as Library/Homebrew/rubocops/bottle.rb. It should then assert that the returned list includes the split spec files, for example test/rubocops/bottle/bottle_format_spec.rb.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f4e3044-d5e5-4c1f-9931-6ae320d76eb5
Commits

Reviewing files that changed from the base of the PR and between d4824f1 and b9c204c.

Files selected for processing: 1

  • Library/Homebrew/dev-cmd/tests.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@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.

Good idea! Yes, I'd be in favour I think of one class per file.

@cho-m
cho-m added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 0f4d92d Nov 5, 2026
56 checks passed
@cho-m
cho-m deleted the changed-tests-split branch November 5, 2026 19:12
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

⌂ 换网址