This commit is contained in:
AnastasiaSulyagina 2016-08-18 22:40:05 +03:00
parent e81f4ab7de
commit 092e2797e1
7 changed files with 15 additions and 104 deletions

View File

@ -51,6 +51,9 @@ begin
ENV["PATH"] += "#{File::PATH_SEPARATOR}#{tap_cmd_dir}" ENV["PATH"] += "#{File::PATH_SEPARATOR}#{tap_cmd_dir}"
end end
# Add cask commands to PATH.
ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_LIBRARY}/Homebrew/cask/cmd"
# Add SCM wrappers. # Add SCM wrappers.
ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_SHIMS_PATH}/scm" ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_SHIMS_PATH}/scm"

View File

@ -166,7 +166,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
# where "doctor" is needed is precisely the situation where such # where "doctor" is needed is precisely the situation where such
# things are less dependable. # things are less dependable.
def self.render_install_location 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? if locations.empty?
none_string none_string
else else

View File

@ -361,17 +361,17 @@ module OS::Mac
"~/Library/Widgets", "~/Library/Widgets",
"~/Library/Workflows", "~/Library/Workflows",
] ]
.map { |x| Pathname(x).expand_path } .map { |x| Pathname(x.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path }
.to_set .to_set
.union(SYSTEM_DIRS) .union(SYSTEM_DIRS)
.freeze .freeze
def system_dir?(dir) def system_dir?(dir)
SYSTEM_DIRS.any? { |u| File.identical?(u, dir) } SYSTEM_DIRS.include?(Pathname.new(dir).expand_path)
end end
def undeletable?(dir) def undeletable?(dir)
UNDELETABLE_DIRS.any? { |u| File.identical?(u, dir) } UNDELETABLE_DIRS.include?(Pathname.new(dir).expand_path)
end end
alias release version alias release version

View File

@ -133,7 +133,7 @@ describe Hbc::SystemCommand do
} }
it "returns without deadlocking" do it "returns without deadlocking" do
wait(10).for { wait(15).for {
shutup { described_class.run(command, options) } shutup { described_class.run(command, options) }
}.to be_a_success }.to be_a_success
end end

View File

@ -1,6 +1,7 @@
require "test_helper" require "test_helper"
describe "Cask" do describe "Cask" do
hbc_relative_tap_path = "../../Taps/caskroom/homebrew-cask"
describe "load" do describe "load" do
it "returns an instance of the Cask for the given token" do it "returns an instance of the Cask for the given token" do
c = Hbc.load("adium") c = Hbc.load("adium")
@ -9,14 +10,14 @@ describe "Cask" do
end end
it "returns an instance of the Cask from a specific file location" do 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 = Hbc.load(location)
c.must_be_kind_of(Hbc::Cask) c.must_be_kind_of(Hbc::Cask)
c.token.must_equal("dia") c.token.must_equal("dia")
end end
it "returns an instance of the Cask from a url" do 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 c = shutup do
Hbc.load(url) Hbc.load(url)
end end
@ -26,7 +27,7 @@ describe "Cask" do
it "raises an error when failing to download a Cask from a url" do it "raises an error when failing to download a Cask from a url" do
lambda { lambda {
url = "file://" + File.expand_path("./Casks/notacask.rb") url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb")
shutup do shutup do
Hbc.load(url) Hbc.load(url)
end end
@ -34,7 +35,7 @@ describe "Cask" do
end end
it "returns an instance of the Cask from a relative file location" do 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.must_be_kind_of(Hbc::Cask)
c.token.must_equal("bbedit") c.token.must_equal("bbedit")
end end

View File

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

View File

@ -8,6 +8,7 @@ if ENV["COVERAGE"]
end end
project_root = Pathname.new(File.expand_path("../..", __FILE__)) 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 # add Homebrew to load path
$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew")) $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") 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 # 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 # create cache directory
Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache") Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache")