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

Move Cask core code to Homebrew #725

Merged
merged 2 commits into from
Aug 19, 2016

Conversation

AnastasiaSulyagina
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 successfully run brew tests with your changes locally?

Moving Cask core code to Homebrew as part of #14384.

Change is splitted in 2 commits to be easier to review. Any advice on better splitting or anything else welcome.

cc @MikeMcQuaid @vitorgalvao @jawshooah @adidalal (bring other cask maintainers please)

@jawshooah
Copy link
Contributor

jawshooah commented Aug 16, 2016

Pinging @reitermarkus, @mwean, @fanquake, @victorpopkov, @alebcay, @claui, and @phinze for visibility.

@MikeMcQuaid
Copy link
Member

CC @Homebrew/maintainers as this is a big one.

@MikeMcQuaid
Copy link
Member

I've opened #727 to fix the test failures here as they are in our code making assumptions about Cask code that we need to decide if they are valid.

@MikeMcQuaid
Copy link
Member

@MikeMcQuaid
Copy link
Member

You can probably remove all the "under Ruby 2.1" tests and may need some test fixtures to not assume Caskroom/homebrew-cask is tapped (although we could compromise that and just tap it before the test). It's probably worth doing these in a separate PR before merging this or the respective Cask PR.

@AnastasiaSulyagina
Copy link
Contributor Author

Seems that cask tap's path for test-bot is not HOMEBREW_LIBRARY.join("Taps", "caskroom", "homebrew-cask"). Will take a look

@MikeMcQuaid
Copy link
Member

Seems that cask tap's path for test-bot is not HOMEBREW_LIBRARY.join("Taps", "caskroom", "homebrew-cask"). Will take a look

@AnastasiaSulyagina on the test-bot: it's not even tapped 😀. This is something we could address at a later point, though.

@MikeMcQuaid
Copy link
Member

This is something we could address at a later point, though.

Although let me know which you'd rather do.

@AnastasiaSulyagina
Copy link
Contributor Author

I'd rather tap it before tests.
Why to address it at later point and not now?

@MikeMcQuaid
Copy link
Member

I'd rather tap it before tests.

🆒 I can open a PR for that.

Why to address it at later point and not now?

Basically because at some point we're going to need to remove that reliance on having the tap tapped in favour of making tests create the Casks they expect and I figure that doesn't need to necessarily block this PR being merged.

@AnastasiaSulyagina
Copy link
Contributor Author

AnastasiaSulyagina commented Aug 17, 2016

I can open a PR for that.

That would be nice :)

Basically because at some point we're going to need to remove that reliance on having the tap tapped in favour of making tests create the Casks they expect and I figure that doesn't need to necessarily block this PR being merged.

Thanks, got it.

@reitermarkus
Copy link
Member

reitermarkus commented Aug 17, 2016

Speaking of Taps, If possible, you might want to merge in the last two commits in Homebrew/homebrew-cask#23821. The only thing I'm missing is an elegant way to redefine Tap::TAP_DIRECTORY for our tests.

@MikeMcQuaid
Copy link
Member

@reitermarkus I think you could merge that in for now as there's already conflicts there until there's a 👍 on holding off merging core PRs.

@reitermarkus
Copy link
Member

Ok, merged the three remaining core PRs. Holding off now until this move is complete.

@DomT4
Copy link
Member

DomT4 commented Aug 17, 2016

Do we need stuff like the GitHub templates, CoC & other dotfiles from Cask here? Are they not remaining with the Cask tap?

@MikeMcQuaid
Copy link
Member

Do we need stuff like the GitHub templates, CoC & other dotfiles from Cask here? Are they not remaining with the Cask tap?

@DomT4 I'm in favour of moving basically everything for now and then removing them once they are over; it's too hard to review the diff for now.

@DomT4
Copy link
Member

DomT4 commented Aug 17, 2016

Cool. That was exactly my thought, that removing the unnecessary text files might make the diff actually reviewable, heh, but whether that's done in pre or post doesn't matter much.

@AnastasiaSulyagina
Copy link
Contributor Author

AnastasiaSulyagina commented Aug 17, 2016

@jawshooah, are these tests needed? If yes, why should directories be undeletable and should I edit the paths somehow to fix it?

rspec ./spec/cask/macos_spec.rb:43 # OS::Mac says the user library directory is undeletable
rspec ./spec/cask/macos_spec.rb:31 # OS::Mac says the home directory is undeletable

@jawshooah
Copy link
Contributor

jawshooah commented Aug 17, 2016

Undeletable directories include system and user directories that should never be included in uninstall :delete or zap :delete. Those tests ensure that, were a Cask author to mistakenly include, for example, ~/Library in uninstall :delete, we would not actually delete that directory.

@AnastasiaSulyagina
Copy link
Contributor Author

As I understood /Users/brew/Jenkins/pr-brew/version/el_capitan/home/ is Dir.home for test-bot. In macos.rb there is ~ string which actually should equal Dir.home. Am I wrong?

@reitermarkus
Copy link
Member

This would mean we have need to call sub(%r{^~(?=(/|$))}, Dir.home) everywhere we expect to receive a relative path instead of (or in addition to) expand_path.

@AnastasiaSulyagina
Copy link
Contributor Author

AnastasiaSulyagina commented Aug 18, 2016

Hm. I thought that as it never was an issue before and appeared now in tests only, I can just replace ~ with Dir.home in Undeletables list. If it's unacceptable I'll fix it

@AnastasiaSulyagina
Copy link
Contributor Author

Why can build pass in travis-ci/pr and fail in default?

@MikeMcQuaid
Copy link
Member

@AnastasiaSulyagina The filesystems may have different permissions.

@reitermarkus
Copy link
Member

@AnastasiaSulyagina, could you rather cange https://github.com/AnastasiaSulyagina/brew/blob/move-cask/Library/Homebrew/cask/lib/hbc/macos.rb#L364 to .map { |x| Pathname(x.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path } instead of changing the whole list, to keep it at little more readable?

@MikeMcQuaid
Copy link
Member

Mentioned to @AnastasiaSulyagina in Slack:

ENV["HOMEBREW_HOME"] = ENV["HOME"] = "#{Dir.pwd}/home"
mkdir_p ENV["HOME"]
is the issue; the test-bot overrides the $HOME variable to stop things being dumped in ~ and I'm guessing it's not getting expanded consistently as a result.

@reitermarkus
Copy link
Member

@MikeMcQuaid, might be worth knowing what File.expand_path is using internally then to see if we can also override it globally in tests.

@reitermarkus
Copy link
Member

Ok, seem's like it is using $HOME internally as well: https://github.com/ruby/ruby/blob/7a4aea47e281402a178b69b5f90d6ed330122e67/file.c#L3209

@AnastasiaSulyagina
Copy link
Contributor Author

Rebased both PRs, fixed macos.rb

@reitermarkus
Copy link
Member

reitermarkus commented Aug 19, 2016

I might have found the reason why some of the undeletable? tests are still failing.

irb> File.identical?('does-not-exist', 'does-not-exist')
=> false
irb> File.identical?('exists', 'exists')
=> true

Seems like File.identical? doesn't work on nonexistent paths.

@AnastasiaSulyagina, could you try changing https://github.com/AnastasiaSulyagina/brew/blob/move-cask/Library/Homebrew/cask/lib/hbc/macos.rb#L369-L375 to the following?

  def system_dir?(dir)
    SYSTEM_DIRS.include?(Pathname.new(dir).expand_path)
  end

  def undeletable?(dir)
    UNDELETABLE_DIRS.include?(Pathname.new(dir).expand_path)
  end

@AnastasiaSulyagina
Copy link
Contributor Author

AnastasiaSulyagina commented Aug 19, 2016

1) Hbc::SystemCommand with a very long STDERR output returns without deadlocking
     Failure/Error: wait(10).for {
       RSpec::Wait::TimeoutError
     # ./spec/cask/system_command_spec.rb:136:in `block (3 levels) in <top (required)>'

It is not related to the PR, is it?

@reitermarkus
Copy link
Member

reitermarkus commented Aug 19, 2016

@AnastasiaSulyagina, could you bump https://github.com/AnastasiaSulyagina/brew/blob/move-cask/Library/Homebrew/cask/spec/cask/system_command_spec.rb#L136 to 15 seconds? I don't think there's actually a deadlock, as this only times out occasionally.

@reitermarkus
Copy link
Member

Finally! 🎉

@MikeMcQuaid
Copy link
Member

Merging this and Homebrew/homebrew-cask#23852 should follow soon afterwards 🎉. Great work, @AnastasiaSulyagina!

@MikeMcQuaid MikeMcQuaid merged commit bd1ded9 into Homebrew:master Aug 19, 2016
@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
gsoc-outreachy Google Summer of Code or Outreachy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants