Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --changed option to "brew tests" dev cmd #13158

Merged
merged 1 commit into from Apr 19, 2022

Conversation

apainintheneck
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This option allows the user to run tests on only the files that have been changed in comparison with the master branch. It slots in between the brew tests and brew tests --only=filename dev commands.

Resolves #13146.

Library/Homebrew/dev-cmd/tests.rb Show resolved Hide resolved
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great work so far!

Library/Homebrew/dev-cmd/tests.rb Show resolved Hide resolved
Library/Homebrew/dev-cmd/tests.rb Outdated Show resolved Hide resolved
Library/Homebrew/dev-cmd/tests.rb Outdated Show resolved Hide resolved
Library/Homebrew/dev-cmd/tests.rb Outdated Show resolved Hide resolved
Comment on lines 142 to 150
raise UsageError, "The --only= argument requires a valid file or folder name!" if args.only

if args.changed?
opoo "Either no files have been changed from the master branch " \
"or no tests are associated with the changed files!"
return
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
raise UsageError, "The --only= argument requires a valid file or folder name!" if args.only
if args.changed?
opoo "Either no files have been changed from the master branch " \
"or no tests are associated with the changed files!"
return
end
if args.only
raise UsageError, "The --only= argument requires a valid file or folder name!"
elsif args.changed?
opoo "Either no files have been changed from the master branch " \
"or no tests are associated with the changed files!"
return
end

Also: does the latter want to maybe be a UsageError too? Wondering if any other cases need handled, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't think of any other use cases. It would also be possible to split that last warning into two messages. If brew tests --changed is called and no files have been changed, for whatever reason, that's probably a usage error. The other case where no tests directly correspond with the changed files isn't really a usage error imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to split those two up into a usage error and a warning. Also, the decision to use a guard clause was in response to the linter.

This option allows the user to run tests on all
files that have been changed from the master
branch.
@MikeMcQuaid MikeMcQuaid merged commit 2d9bfc6 into Homebrew:master Apr 19, 2022
@MikeMcQuaid
Copy link
Member

Thanks again @apainintheneck!

@apainintheneck apainintheneck deleted the tests-changed-switch branch May 3, 2022 07:24
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to only run tests associated with changed files
3 participants