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

tap: run readall when tapping. #396

Merged
merged 2 commits into from
Jul 9, 2016
Merged

tap: run readall when tapping. #396

merged 2 commits into from
Jul 9, 2016

Conversation

MikeMcQuaid
Copy link
Member

@MikeMcQuaid MikeMcQuaid commented Jun 23, 2016

  • 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 tests with your changes locally?

This will prevent tapping an tap with syntax errors from causing issues
for users.

Fixes #58.

@BrewTestBot BrewTestBot added the in progress Maintainers are working on this label Jun 23, 2016
@@ -221,10 +221,11 @@ def install(options = {})

begin
safe_system "git", *args
safe_system "brew", "readall", name
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use HOMEBREW_BREW_FILE

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it doesn't hurt to check the aliases of the to-be-installed tap, too. Thus, I'd suggest:

safe_system HOMEBREW_BREW_FILE, "readall", "--aliases", name

@MikeMcQuaid
Copy link
Member Author

Have addressed feedback.

@UniqMartin
Copy link
Contributor

I guess this is the first time an integration test tries to run a brew subprocess and our test environment isn't really prepared to handle that. I'm afraid this PR is more involved than one would expect.

@MikeMcQuaid
Copy link
Member Author

  • improved error message output on readall/tap failure
  • fixed the integration tests handling

Bundler.with_original_env do
ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew"
ENV["HOMEBREW_BREW_FILE"] = cmd_exec.join " "
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is going to work and, more importantly, I don't think we want to do this. HOMEBREW_BREW_FILE should be a path to the bin/brew script, not a loose collection of arguments to be interpreted by a shell. I think fixing nested brew invocations in integration tests definitely needs some more thought and likely a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does work. Given it's affecting only the integration tests and they pass I personally don't see the problem. Do you have a suggestion for another approach?

Copy link
Member Author

Choose a reason for hiding this comment

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

(note tests are now 💚)

Copy link
Contributor

Choose a reason for hiding this comment

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

One problem is that these instances re-use the same test identifier and thus overwrite each other's coverage data when running with --coverage. There might be more issues, but to be honest, I haven't spent much time thinking about this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Assuming this is what cmd_id_from_args/HOMEBREW_INTEGRATION_TEST are doing: the arguments here will be handled correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

And the coverage looks correct from local inspection.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's what cmd_id_from_args is for. The nested brew readall spawned from brew tap doesn't go through this code again (unless I'm missing something). Thus it re-uses the same ID and gets its result overwritten by the brew tap process that finishes later.

If this worked as it probably should, I'd expect brew tests --coverage --only=integration_cmds/tap to have nonzero coverage for cmd/readall.rb, but that's not something I can observe locally.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see what you mean, will check this out further.

@MikeMcQuaid
Copy link
Member Author

Reworked this so it doesn't run a brew subprocess.


module Readall
class << self
def valid_ruby_syntax?(ruby_files)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind adding a check that ruby_files is a Queue instance or alternatively convert it to a queue if it isn't already one? I think it's not obvious on the call site that a Queue needs to be supplied and if an Array is used, then the code will try to use it (which is not thread-safe), will fortunately fail, but with a rather cryptic error message:

TypeError: no implicit conversion of true into Integer

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

@UniqMartin
Copy link
Contributor

Big 👍 on the readall refactoring. Would you mind splitting the commit into multiple commits? I think this will make the Git history much clearer and should be relatively easy to do. Suggestion:

  1. brew readall refactoring.
  2. Use of the refactored readall in brew tap.

@MikeMcQuaid
Copy link
Member Author

Addressed all commits, split into two commits.

@UniqMartin
Copy link
Contributor

Spotted one minor style issue (didn't notice any others, but maybe RuboCop sees more), thus a final re-run of RuboCop on the modified files before pulling this would be appreciated.

Other than that, it looks good to me. Thanks for addressing everything! 👍 when 🍏.

This will prevent tapping an tap with syntax errors from causing issues
for users.

Fixes #58.
@MikeMcQuaid MikeMcQuaid merged commit 4da9905 into Homebrew:master Jul 9, 2016
@MikeMcQuaid MikeMcQuaid deleted the tap-readall branch July 9, 2016 12:51
@BrewTestBot BrewTestBot removed the in progress Maintainers are working on this label Jul 9, 2016
UniqMartin added a commit that referenced this pull request Jul 16, 2016
On systems prior to 10.9, formulae that use CVS as a download source
check whether the installed Xcode already provides CVS to avoid adding
a dependency on the `cvs` formula. Unfortunately, if no Xcode is
installed the check fails with

  undefined method `<' for nil:NilClass

causing the formula to become unloadable. This in turn causes some taps
to be untappable since #396 added the `readall` check on `tap`.

Closes #508.
souvik1997 pushed a commit to souvik1997/brew that referenced this pull request Jul 25, 2016
* readall: move readall logic to new class.

* tap: run readall when tapping.

This will prevent tapping an tap with syntax errors from causing issues
for users.

Fixes Homebrew#58.
souvik1997 pushed a commit to souvik1997/brew that referenced this pull request Jul 25, 2016
On systems prior to 10.9, formulae that use CVS as a download source
check whether the installed Xcode already provides CVS to avoid adding
a dependency on the `cvs` formula. Unfortunately, if no Xcode is
installed the check fails with

  undefined method `<' for nil:NilClass

causing the formula to become unloadable. This in turn causes some taps
to be untappable since Homebrew#396 added the `readall` check on `tap`.

Closes Homebrew#508.
@Homebrew Homebrew locked and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants