From 092e2797e156a36acd750d2783a18b47305a9747 Mon Sep 17 00:00:00 2001 From: AnastasiaSulyagina Date: Thu, 18 Aug 2016 22:40:05 +0300 Subject: [PATCH] edits --- Library/Homebrew/brew.rb | 3 + Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 2 +- Library/Homebrew/cask/lib/hbc/macos.rb | 6 +- .../cask/spec/cask/system_command_spec.rb | 2 +- Library/Homebrew/cask/test/cask_test.rb | 9 +- Library/Homebrew/cask/test/layout_test.rb | 94 ------------------- Library/Homebrew/cask/test/test_helper.rb | 3 +- 7 files changed, 15 insertions(+), 104 deletions(-) delete mode 100644 Library/Homebrew/cask/test/layout_test.rb diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 15c1ee4ffb..d4e348c3f0 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -51,6 +51,9 @@ begin ENV["PATH"] += "#{File::PATH_SEPARATOR}#{tap_cmd_dir}" end + # Add cask commands to PATH. + ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_LIBRARY}/Homebrew/cask/cmd" + # Add SCM wrappers. ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_SHIMS_PATH}/scm" diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index d2feb1e06b..7ee861508d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -166,7 +166,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base # where "doctor" is needed is precisely the situation where such # things are less dependable. def self.render_install_location - locations = Dir.glob(homebrew_cellar.join("brew-cask", "*")).reverse + locations = Dir.glob(Pathname.new(homebrew_cellar).join("brew-cask", "*")).reverse if locations.empty? none_string else diff --git a/Library/Homebrew/cask/lib/hbc/macos.rb b/Library/Homebrew/cask/lib/hbc/macos.rb index 46047f4138..5e25c657ed 100644 --- a/Library/Homebrew/cask/lib/hbc/macos.rb +++ b/Library/Homebrew/cask/lib/hbc/macos.rb @@ -361,17 +361,17 @@ module OS::Mac "~/Library/Widgets", "~/Library/Workflows", ] - .map { |x| Pathname(x).expand_path } + .map { |x| Pathname(x.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path } .to_set .union(SYSTEM_DIRS) .freeze def system_dir?(dir) - SYSTEM_DIRS.any? { |u| File.identical?(u, dir) } + SYSTEM_DIRS.include?(Pathname.new(dir).expand_path) end def undeletable?(dir) - UNDELETABLE_DIRS.any? { |u| File.identical?(u, dir) } + UNDELETABLE_DIRS.include?(Pathname.new(dir).expand_path) end alias release version diff --git a/Library/Homebrew/cask/spec/cask/system_command_spec.rb b/Library/Homebrew/cask/spec/cask/system_command_spec.rb index e85a1976a4..c291023057 100644 --- a/Library/Homebrew/cask/spec/cask/system_command_spec.rb +++ b/Library/Homebrew/cask/spec/cask/system_command_spec.rb @@ -133,7 +133,7 @@ describe Hbc::SystemCommand do } it "returns without deadlocking" do - wait(10).for { + wait(15).for { shutup { described_class.run(command, options) } }.to be_a_success end diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb index 05bdb6eff3..64fc219655 100644 --- a/Library/Homebrew/cask/test/cask_test.rb +++ b/Library/Homebrew/cask/test/cask_test.rb @@ -1,6 +1,7 @@ require "test_helper" describe "Cask" do + hbc_relative_tap_path = "../../Taps/caskroom/homebrew-cask" describe "load" do it "returns an instance of the Cask for the given token" do c = Hbc.load("adium") @@ -9,14 +10,14 @@ describe "Cask" do end it "returns an instance of the Cask from a specific file location" do - location = File.expand_path("./Casks/dia.rb") + location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") c = Hbc.load(location) c.must_be_kind_of(Hbc::Cask) c.token.must_equal("dia") end it "returns an instance of the Cask from a url" do - url = "file://" + File.expand_path("./Casks/dia.rb") + url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") c = shutup do Hbc.load(url) end @@ -26,7 +27,7 @@ describe "Cask" do it "raises an error when failing to download a Cask from a url" do lambda { - url = "file://" + File.expand_path("./Casks/notacask.rb") + url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb") shutup do Hbc.load(url) end @@ -34,7 +35,7 @@ describe "Cask" do end it "returns an instance of the Cask from a relative file location" do - c = Hbc.load("./Casks/bbedit.rb") + c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb") c.must_be_kind_of(Hbc::Cask) c.token.must_equal("bbedit") end diff --git a/Library/Homebrew/cask/test/layout_test.rb b/Library/Homebrew/cask/test/layout_test.rb deleted file mode 100644 index 110725f314..0000000000 --- a/Library/Homebrew/cask/test/layout_test.rb +++ /dev/null @@ -1,94 +0,0 @@ -require "test_helper" - -describe "Repo layout" do - project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../")) - - # TODO: a more clever way to do this would be to dispense with - # the imperfect IGNORE lists and read the actual repo - # contents by reading the output of "git ls-files" - - # dot dirs are always a project of Dir.entries - # other files are items that the developer hopefully has gitignored - IGNORE_FILES = %w[ - . - .. - .DS_Store - .bundle - .rubocop.yml - .rubocop_todo.yml - .ruby-version - coverage - vendor - ].freeze - - # the developer has hopefully gitignored these - IGNORE_REGEXPS = [ - %r{~$}, # emacs - %r{.sublime-\w+}, # Sublime Text - ].freeze - - TOPLEVEL_DIRS = %w[ - .git - .github - Casks - Formula - ci - cmd - developer - doc - lib - man - spec - test - ].freeze - - TOPLEVEL_FILES = %w[ - .editorconfig - .gitattributes - .gitignore - .rspec - .rubocop.yml - .simplecov - .travis.yml - CONDUCT.md - CONTRIBUTING.md - Gemfile - Gemfile.lock - LICENSE - README.md - Rakefile - tap_migrations.json - USAGE.md - ].freeze - - describe "toplevel dir" do - it "finds some files at the top level" do - entries = Dir.entries(project_root) - entries.length.must_be :>, 0 - end - - it "only finds expected files at the top level" do - entries = Dir.entries(project_root) - IGNORE_FILES - TOPLEVEL_DIRS - TOPLEVEL_FILES - IGNORE_REGEXPS.each do |regexp| - entries.reject! { |elt| elt.match(regexp) } - end - entries.must_equal [] - end - end - - describe "Casks dir" do - it "finds some files in the Casks dir" do - entries = Dir.entries(project_root.join("Casks")) - entries.length.must_be :>, 0 - end - - it "only finds .rb files in the Casks dir" do - entries = Dir.entries(project_root.join("Casks")) - IGNORE_FILES - IGNORE_REGEXPS.each do |regexp| - entries.reject! { |elt| elt.match(regexp) } - end - entries.reject! { |elt| elt.match(%r{\.rb$}) } - entries.must_equal [] - end - end -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index dfe2484ed1..528ca69cf8 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -8,6 +8,7 @@ if ENV["COVERAGE"] end project_root = Pathname.new(File.expand_path("../..", __FILE__)) +tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask") # add Homebrew to load path $LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew")) @@ -78,7 +79,7 @@ Hbc.default_tap = Tap.fetch("caskroom", "testcasks") FileUtils.ln_s project_root.join("test", "support"), Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-testcasks") # pretend that the caskroom/cask Tap is installed -FileUtils.ln_s project_root, Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-cask") +FileUtils.ln_s tap_root, Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-cask") # create cache directory Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache")