From 3c566399cf8dab3aff8c54381e7b83b0e6ef3995 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Fri, 23 Dec 2016 11:29:31 +0000 Subject: Added check for insecure mirror URLs --- Library/Homebrew/dev-cmd/audit.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index e83fb2bd0..fffe14b47 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -623,11 +623,11 @@ class FormulaAuditor %w[Stable Devel HEAD].each do |name| next unless spec = formula.send(name.downcase) - ra = ResourceAuditor.new(spec).audit + ra = ResourceAuditor.new(spec, online: @online).audit problems.concat ra.problems.map { |problem| "#{name}: #{problem}" } spec.resources.each_value do |resource| - ra = ResourceAuditor.new(resource).audit + ra = ResourceAuditor.new(resource, online: @online).audit problems.concat ra.problems.map { |problem| "#{name} resource #{resource.name.inspect}: #{problem}" } @@ -1127,7 +1127,7 @@ class ResourceAuditor attr_reader :problems attr_reader :version, :checksum, :using, :specs, :url, :mirrors, :name - def initialize(resource) + def initialize(resource, options = {}) @name = resource.name @version = resource.version @checksum = resource.checksum @@ -1135,6 +1135,7 @@ class ResourceAuditor @mirrors = resource.mirrors @using = resource.using @specs = resource.specs + @online = options[:online] @problems = [] end @@ -1390,6 +1391,20 @@ class ResourceAuditor next unless u =~ %r{https?://(?:central|repo\d+)\.maven\.org/maven2/(.+)$} problem "#{u} should be `https://search.maven.org/remotecontent?filepath=#{$1}`" end + + return unless @online + urls.each do |url| + next unless url.start_with? "http:" + # Check for insecure mirrors + status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ + "--write-out", "%{http_code}", url + secure_url = url.sub "http", "https" + secure_status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ + "--write-out", "%{http_code}", secure_url + if status_code.start_with?("20") && secure_status_code.start_with?("20") + problem "The URL #{url} could use HTTPS rather than HTTP" + end + end end def problem(text) -- cgit v1.2.3 From 6d318761d21e43ef8785ae4da24b8f6fdbd52db8 Mon Sep 17 00:00:00 2001 From: Nathan Toone Date: Wed, 28 Dec 2016 10:56:03 -0700 Subject: Delete pkgutil directories that are really files. Sometimes, pkgutil will return actual files (usually .nib files) as if they were part of the directory. Microsoft Office is an example of this: in a recent update the file `/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/SharedSupport/Microsoft Error Reporting.app/Contents/Resources/en.lproj/MainWindowAlt.nib` was returning from `/usr/sbin/pkgutil --only-dirs --files com.microsoft.package.component` even though it should have been a file instead of a directory. This caused the `rmdir` command to fail. This patch will check if we are trying to delete a “directory” that is really a “file” - and if we are, we just delete the file instead. This will allow packages that get in this state to be uninstalled. A unit test which can be run using `brew cask-tests` is also included. --- Library/Homebrew/cask/lib/hbc/pkg.rb | 8 ++++++++ Library/Homebrew/cask/test/cask/pkg_test.rb | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb index 2fb634f24..497a7b6dd 100644 --- a/Library/Homebrew/cask/lib/hbc/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/pkg.rb @@ -26,6 +26,7 @@ module Hbc _deepest_path_first(pkgutil_bom_dirs).each do |dir| next unless dir.exist? && !MacOS.undeletable?(dir) _with_full_permissions(dir) do + _delete_broken_file_dir(dir) && next _clean_broken_symlinks(dir) _clean_ds_store(dir) _rmdir(dir) @@ -97,6 +98,13 @@ module Hbc end end + # Some pkgs (microsoft office for one) leave files (generally nibs) but + # report them as directories. We remove these as files instead. + def _delete_broken_file_dir(path) + return unless path.file? && !path.symlink? + @command.run!("/bin/rm", args: ["-f", "--", path], sudo: true) + end + # Some pkgs leave broken symlinks hanging around; we clean them out before # attempting to rmdir to prevent extra cruft from lying around after # uninstall diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb index 85a42356e..b99d49ddd 100644 --- a/Library/Homebrew/cask/test/cask/pkg_test.rb +++ b/Library/Homebrew/cask/test/cask/pkg_test.rb @@ -68,6 +68,23 @@ describe Hbc::Pkg do fake_dir.must_be :exist? end + it "chokes on directories that are really files" do + pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) + + fake_dir = Pathname(Dir.mktmpdir) + fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } + + pkg.stubs(:pkgutil_bom_specials).returns([]) + pkg.stubs(:pkgutil_bom_files).returns([]) + pkg.stubs(:pkgutil_bom_dirs).returns([fake_file, fake_dir]) + pkg.stubs(:forget) + + pkg.uninstall + + fake_file.wont_be :exist? + fake_dir.wont_be :exist? + end + it "snags permissions on ornery dirs, but returns them afterwords" do pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) -- cgit v1.2.3 From fe117bf79b244c42b7e4049d353c3c003eae4880 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 22:44:01 +0000 Subject: requirement: get formula from satisfy. If satisfy returns a `Pathname` from `which` then we can use that to infer a formula dependency from that `Requirement`. --- Library/Homebrew/requirement.rb | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index fe1a3c020..49108ca75 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -15,6 +15,7 @@ class Requirement @default_formula = self.class.default_formula @cask ||= self.class.cask @download ||= self.class.download + @formula = nil tags.each do |tag| next unless tag.is_a? Hash @cask ||= tag[:cask] @@ -56,7 +57,14 @@ class Requirement def satisfied? result = self.class.satisfy.yielder { |p| instance_eval(&p) } @satisfied_result = result - result ? true : false + return false unless result + + if parent = satisfied_result_parent + parent.to_s =~ %r{(#{Regexp.escape(HOMEBREW_CELLAR)}|#{Regexp.escape(HOMEBREW_PREFIX)}/opt)/([\w+-.@]+)} + @formula = $2 + end + + true end # Overriding #fatal? is deprecated. @@ -69,6 +77,11 @@ class Requirement self.class.default_formula || false end + def satisfied_result_parent + return unless @satisfied_result.is_a?(Pathname) + @satisfied_result.resolved_path.parent + end + # Overriding #modify_build_environment is deprecated. # Pass a block to the env DSL method instead. # Note: #satisfied? should be called before invoking this method @@ -81,11 +94,8 @@ class Requirement # satisfy { which("executable") } # work, even under superenv where "executable" wouldn't normally be on the # PATH. - # This is undocumented magic and it should be removed, but we need to add - # a way to declare path-based requirements that work with superenv first. - return unless @satisfied_result.is_a?(Pathname) - parent = @satisfied_result.parent - + parent = satisfied_result_parent + return unless parent return if ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s) ENV.append_path("PATH", parent) end @@ -111,13 +121,15 @@ class Requirement "#<#{self.class.name}: #{name.inspect} #{tags.inspect}>" end + def formula + @formula || self.class.default_formula + end + def to_dependency - f = self.class.default_formula - raise "No default formula defined for #{inspect}" if f.nil? - if f =~ HOMEBREW_TAP_FORMULA_REGEX - TapDependency.new(f, tags, method(:modify_build_environment), name) - else - Dependency.new(f, tags, method(:modify_build_environment), name) + if formula =~ HOMEBREW_TAP_FORMULA_REGEX + TapDependency.new(formula, tags, method(:modify_build_environment), name) + elsif formula + Dependency.new(formula, tags, method(:modify_build_environment), name) end end -- cgit v1.2.3 From 0158cc2e23f228715182a946ddfd6268bd6fc2d8 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 22:44:33 +0000 Subject: build: don't assume requirement dependency is default formula. --- Library/Homebrew/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index c4e903642..c0f15158d 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -48,7 +48,7 @@ class Build Requirement.prune elsif req.build? && dependent != formula Requirement.prune - elsif req.satisfied? && req.default_formula? && (dep = req.to_dependency).installed? + elsif req.satisfied? && (dep = req.to_dependency) && dep.installed? deps << dep Requirement.prune end -- cgit v1.2.3 From 5821572b9b14b682feaec3f0c42afdba61a821b2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 22:44:47 +0000 Subject: formula_installer: don't assume requirement dependency is default formula. --- Library/Homebrew/formula_installer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 24c068460..66bd60c37 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -370,8 +370,8 @@ class FormulaInstaller raise UnsatisfiedRequirements, fatals end - def install_requirement_default_formula?(req, dependent, build) - return false unless req.default_formula? + def install_requirement_formula?(req, dependent, build) + return false unless req.to_dependency return true unless req.satisfied? return false if req.run? install_bottle_for?(dependent, build) || build_bottle? @@ -390,7 +390,7 @@ class FormulaInstaller Requirement.prune elsif req.build? && install_bottle_for?(dependent, build) Requirement.prune - elsif install_requirement_default_formula?(req, dependent, build) + elsif install_requirement_formula?(req, dependent, build) dep = req.to_dependency deps.unshift(dep) formulae.unshift(dep.to_formula) -- cgit v1.2.3 From f4496e85e515180f96e0863af3047bf3f4a94e81 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 15 Jan 2017 02:31:11 -0800 Subject: audit: don't allow universal for new formulae. We're frowning on these now so may as well turn that into code. --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 744aa6fbe..f2306debf 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -481,6 +481,10 @@ class FormulaAuditor next unless @strict + if o.name == "universal" + problem "macOS has been 64-bit only since 10.6 so universal options are deprecated." + end + if o.name !~ /with(out)?-/ && o.name != "c++11" && o.name != "universal" problem "Options should begin with with/without. Migrate '--#{o.name}' with `deprecated_option`." end -- cgit v1.2.3 From 0d9020838fd19c5f4b677c4576159e561bfe7de1 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 15 Jan 2017 19:50:07 +0000 Subject: tests: test Formula#recursive_requirements --- Library/Homebrew/test/formula_test.rb | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 81022d220..e295875e7 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -689,6 +689,44 @@ class FormulaTests < Homebrew::TestCase assert_equal %w[foo/bar/f1 baz/qux/f2], f3.runtime_dependencies.map(&:name) end + def test_requirements + f1 = formula("f1") do + url "f1-1" + + depends_on :python + depends_on :x11 => :recommended + depends_on :xcode => ['1.0', :optional] + end + stub_formula_loader f1 + + python = PythonRequirement.new + x11 = X11Requirement.new("x11", [:recommended]) + xcode = XcodeRequirement.new(["1.0", :optional]) + + # Default block should filter out deps that aren't being used + assert_equal Set[python, x11], Set.new(f1.recursive_requirements) + + f1.build = BuildOptions.new(["--with-xcode", "--without-x11"], f1.options) + assert_equal Set[python, xcode], Set.new(f1.recursive_requirements) + f1.build = f1.stable.build + + f2 = formula("f2") do + url "f2-1" + depends_on "f1" + end + + assert_equal Set[python, x11], Set.new(f2.recursive_requirements) + + # Empty block should allow all requirements + assert_equal Set[python, x11, xcode], Set.new(f2.recursive_requirements {}) + + # Requirements can be pruned + requirements = f2.recursive_requirements do |dependent, requirement| + Requirement.prune if requirement.is_a?(PythonRequirement) + end + assert_equal Set[x11, xcode], Set.new(requirements) + end + def test_to_hash f1 = formula("foo") do url "foo-1.0" -- cgit v1.2.3 From 02b7ffd89df401ffd142016d10ff6bb2f64c2149 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 15 Jan 2017 21:04:59 +0000 Subject: formula: runtime_dependencies contains requirement formulae. When a Requirement is converted to a Formula it should be listed under the runtime dependencies. --- Library/Homebrew/formula.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 91a3e8150..1ced5030f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1519,10 +1519,15 @@ class Formula # Returns a list of Dependency objects that are required at runtime. # @private def runtime_dependencies - recursive_dependencies do |_dependent, dependency| + runtime_dependencies = recursive_dependencies do |_, dependency| Dependency.prune if dependency.build? Dependency.prune if !dependency.required? && build.without?(dependency) end + runtime_requirement_deps = recursive_requirements do |_, requirement| + Requirement.prune if requirement.build? + Requirement.prune if !requirement.required? && build.without?(requirement) + end.map(&:to_dependency).compact + runtime_dependencies + runtime_requirement_deps end # Returns a list of formulae depended on by this formula that aren't -- cgit v1.2.3 From feea90c0ddee280193182d8cce2ce56bc8e4aa6f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 16 Jan 2017 20:15:20 +0000 Subject: create: handle null versions. Fixes #1821 --- Library/Homebrew/dev-cmd/create.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index 07dd1b322..b4cda0fad 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -142,12 +142,10 @@ class FormulaCreator def generate! raise "#{path} already exists" if path.exist? - if version.nil? + if version.nil? || version.null? opoo "Version cannot be determined from URL." puts "You'll need to add an explicit 'version' to the formula." - end - - if fetch? && version + elsif fetch? r = Resource.new r.url(url) r.version(version) -- cgit v1.2.3 From 6040456ea91add1d9f20820f6e23a47eb92bb4af Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 16 Jan 2017 20:35:56 +0000 Subject: Unset GREP_OPTIONS. Users may have this set, breaking grep's output. Fixes #1430. --- Library/Homebrew/brew.sh | 3 +++ Library/Homebrew/extend/ENV/shared.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 92953001d..81a52f474 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -82,6 +82,9 @@ unset GEM_PATH # bash processes inside builds unset BASH_ENV +# Users may have this set, breaking grep's output. +unset GREP_OPTIONS + HOMEBREW_SYSTEM="$(uname -s)" case "$HOMEBREW_SYSTEM" in Darwin) HOMEBREW_MACOS="1" ;; diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index a93c1ee1f..7b468574a 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -17,7 +17,7 @@ module SharedEnvExtension FC_FLAG_VARS = %w[FCFLAGS FFLAGS].freeze # @private SANITIZED_VARS = %w[ - CDPATH GREP_OPTIONS CLICOLOR_FORCE + CDPATH CLICOLOR_FORCE CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH CC CXX OBJC OBJCXX CPP MAKE LD LDSHARED CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS -- cgit v1.2.3 From 33b955a3f24d835f45d439f97ecabb7d6d51b7ad Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 16 Jan 2017 21:58:57 +0000 Subject: tests: fix style of recursive_requirements tests --- Library/Homebrew/test/formula_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index e295875e7..2d2136a05 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -694,8 +694,8 @@ class FormulaTests < Homebrew::TestCase url "f1-1" depends_on :python - depends_on :x11 => :recommended - depends_on :xcode => ['1.0', :optional] + depends_on x11: :recommended + depends_on xcode: ["1.0", :optional] end stub_formula_loader f1 @@ -721,7 +721,7 @@ class FormulaTests < Homebrew::TestCase assert_equal Set[python, x11, xcode], Set.new(f2.recursive_requirements {}) # Requirements can be pruned - requirements = f2.recursive_requirements do |dependent, requirement| + requirements = f2.recursive_requirements do |_dependent, requirement| Requirement.prune if requirement.is_a?(PythonRequirement) end assert_equal Set[x11, xcode], Set.new(requirements) -- cgit v1.2.3 From 36c1c8e9b0e5919a5165ffb5eaeddb54db1238b0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 16 Jan 2017 22:41:37 +0000 Subject: uses: fix recursive requirement resolution Fixes #1848 by sharing recursive dependency resolution between dependencies and requirements. Coincidentally, this also fixes the errors introduced by #1784 that necessitated it being reverted in #1797. --- Library/Homebrew/cmd/uses.rb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index fb11a31a7..e5e140d36 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -58,15 +58,29 @@ module Homebrew Dependency.prune unless includes.include?("build?") end end - reqs = f.recursive_requirements do |dependent, req| + + dep_formulae = deps.map do |dep| + begin + dep.to_formula + rescue + end + end.compact + + reqs_by_formula = ([f] + dep_formulae).flat_map do |formula| + formula.requirements.map { |req| [formula, req] } + end + + reqs_by_formula.reject! do |dependent, req| if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + ignores.include?("recommended?") || dependent.build.without?(req) elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + !includes.include?("optional?") && !dependent.build.with?(req) elsif req.build? - Requirement.prune unless includes.include?("build?") + !includes.include?("build?") end end + + reqs = reqs_by_formula.map(&:last) else deps = f.deps.reject do |dep| ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } -- cgit v1.2.3 From 0b216798bb33e63e7b9da795925f610f93cc1e33 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 15 Jan 2017 17:40:51 +0000 Subject: Revert "Revert "uses: properly handle untapped fo… …rmulae in recursive dependency expansion"" This reverts commit dc9819b86c60b5c6fd10373ff318d8ef60f97d52. --- Library/Homebrew/cmd/uses.rb | 73 ++++++++++++++++---------------- Library/Homebrew/dependency.rb | 2 +- Library/Homebrew/test/dependency_test.rb | 5 +++ 3 files changed, 43 insertions(+), 37 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index fb11a31a7..f9af36754 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -47,48 +47,49 @@ module Homebrew uses = formulae.select do |f| used_formulae.all? do |ff| - begin - if recursive - deps = f.recursive_dependencies do |dependent, dep| - if dep.recommended? - Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? - Dependency.prune unless includes.include?("build?") - end + if recursive + deps = f.recursive_dependencies do |dependent, dep| + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") end - reqs = f.recursive_requirements do |dependent, req| - if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) - elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) - elsif req.build? - Requirement.prune unless includes.include?("build?") - end - end - else - deps = f.deps.reject do |dep| - ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } - end - reqs = f.requirements.reject do |req| - ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } + + # If a tap isn't installed, we can't find the dependencies of one + # its formulae, and an exception will be thrown if we try. + if dep.is_a?(TapDependency) && !dep.tap.installed? + Dependency.keep_but_prune_recursive_deps end end - next true if deps.any? do |dep| - begin - dep.to_formula.full_name == ff.full_name - rescue - dep.name == ff.name + reqs = f.recursive_requirements do |dependent, req| + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") end end - - reqs.any? do |req| - req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + else + deps = f.deps.reject do |dep| + ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } + end + reqs = f.requirements.reject do |req| + ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } end - rescue FormulaUnavailableError - # Silently ignore this case as we don't care about things used in - # taps that aren't currently tapped. + end + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name + end + end + + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) end end end diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 253ba4bee..4a452440a 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -175,7 +175,7 @@ class TapDependency < Dependency attr_reader :tap def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last]) - @tap = name.rpartition("/").first + @tap = Tap.fetch(name.rpartition("/").first) super(name, tags, env_proc, option_names) end diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb index 65255995e..134e91d13 100644 --- a/Library/Homebrew/test/dependency_test.rb +++ b/Library/Homebrew/test/dependency_test.rb @@ -118,6 +118,11 @@ class DependencyTests < Homebrew::TestCase end class TapDependencyTests < Homebrew::TestCase + def test_tap + dep = TapDependency.new("foo/bar/dog") + assert_equal Tap.new("foo", "bar"), dep.tap + end + def test_option_names dep = TapDependency.new("foo/bar/dog") assert_equal %w[dog], dep.option_names -- cgit v1.2.3 From 9475622c070d941b044f94eafef0d46aa29568bc Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 16 Jan 2017 23:23:09 +0000 Subject: uses: restore formula-level exception handler This is a temporary measure until: - #1862 is merged - I can a test on `brew uses` against every formula in the official taps to verify that exceptions are no longer raised. --- Library/Homebrew/cmd/uses.rb | 79 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 37 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index f9af36754..20fc146bf 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -47,49 +47,54 @@ module Homebrew uses = formulae.select do |f| used_formulae.all? do |ff| - if recursive - deps = f.recursive_dependencies do |dependent, dep| - if dep.recommended? - Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? - Dependency.prune unless includes.include?("build?") - end + begin + if recursive + deps = f.recursive_dependencies do |dependent, dep| + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end - # If a tap isn't installed, we can't find the dependencies of one - # its formulae, and an exception will be thrown if we try. - if dep.is_a?(TapDependency) && !dep.tap.installed? - Dependency.keep_but_prune_recursive_deps + # If a tap isn't installed, we can't find the dependencies of one + # its formulae, and an exception will be thrown if we try. + if dep.is_a?(TapDependency) && !dep.tap.installed? + Dependency.keep_but_prune_recursive_deps + end end - end - reqs = f.recursive_requirements do |dependent, req| - if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) - elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) - elsif req.build? - Requirement.prune unless includes.include?("build?") + reqs = f.recursive_requirements do |dependent, req| + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end + end + else + deps = f.deps.reject do |dep| + ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } + end + reqs = f.requirements.reject do |req| + ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } end end - else - deps = f.deps.reject do |dep| - ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } - end - reqs = f.requirements.reject do |req| - ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } - end - end - next true if deps.any? do |dep| - begin - dep.to_formula.full_name == ff.full_name - rescue - dep.name == ff.name + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name + end end - end - reqs.any? do |req| - req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + end + rescue FormulaUnavailableError + # Silently ignore this case as we don't care about things used in + # taps that aren't currently tapped. end end end -- cgit v1.2.3 From dac66c4ada178c09b3b9b77feb2eaa7442b7443e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jan 2017 10:43:43 +0000 Subject: Add `keg_only :versioned_formula`. This is used to indicate a formula is a version of another formula. This will be used to provide a consistent interface for older formulae versions and replaces the use of `conflicts_with`. --- Library/Homebrew/dev-cmd/audit.rb | 10 +++++++- Library/Homebrew/formula.rb | 5 ++++ Library/Homebrew/formula_support.rb | 47 ++++++++++++++++++++----------------- 3 files changed, 40 insertions(+), 22 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 394e0e763..281839621 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -459,6 +459,14 @@ class FormulaAuditor end def audit_conflicts + if formula.versioned_formula? + problem <<-EOS + Versioned formulae should not use `conflicts_with`. + Use `keg_only :versioned_formula` instead. + EOS + return + end + formula.conflicts.each do |c| begin Formulary.factory(c.name) @@ -497,7 +505,7 @@ class FormulaAuditor return unless @new_formula return if formula.deprecated_options.empty? - return if formula.name.include?("@") + return if formula.versioned_formula? problem "New formulae should not use `deprecated_option`." end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1ced5030f..77688840c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -382,6 +382,11 @@ class Formula PkgVersion.new(version, revision) end + # If this is a `@`-versioned formula. + def versioned_formula? + name.include?("@") + end + # A named Resource for the currently active {SoftwareSpec}. # Additional downloads can be defined as {#resource}s. # {Resource#stage} will create a temporary directory and yield to a block. diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index e4f800364..dcb995a6b 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -29,27 +29,32 @@ class KegOnlyReason def to_s return @explanation unless @explanation.empty? case @reason - when :provided_by_macos, :provided_by_osx then <<-EOS -macOS already provides this software and installing another version in -parallel can cause all kinds of trouble. -EOS - when :shadowed_by_macos, :shadowed_by_osx then <<-EOS -macOS provides similar software and installing this software in -parallel can cause all kinds of trouble. -EOS - when :provided_pre_mountain_lion then <<-EOS -macOS already provides this software in versions before Mountain Lion. -EOS - when :provided_pre_mavericks then <<-EOS -macOS already provides this software in versions before Mavericks. -EOS - when :provided_pre_el_capitan then <<-EOS -macOS already provides this software in versions before El Capitan. -EOS - when :provided_until_xcode43 - "Xcode provides this software prior to version 4.3." - when :provided_until_xcode5 - "Xcode provides this software prior to version 5." + when :versioned_formula then <<-EOS.undent + This is an alternate version of another formula. + EOS + when :provided_by_macos, :provided_by_osx then <<-EOS.undent + macOS already provides this software and installing another version in + parallel can cause all kinds of trouble. + EOS + when :shadowed_by_macos, :shadowed_by_osx then <<-EOS.undent + macOS provides similar software and installing this software in + parallel can cause all kinds of trouble. + EOS + when :provided_pre_mountain_lion then <<-EOS.undent + macOS already provides this software in versions before Mountain Lion. + EOS + when :provided_pre_mavericks then <<-EOS.undent + macOS already provides this software in versions before Mavericks. + EOS + when :provided_pre_el_capitan then <<-EOS.undent + macOS already provides this software in versions before El Capitan. + EOS + when :provided_until_xcode43 then <<-EOS.undent + Xcode provides this software prior to version 4.3. + EOS + when :provided_until_xcode5 then <<-EOS.undent + Xcode provides this software prior to version 5. + EOS else @reason end.strip -- cgit v1.2.3 From fa3d459f5bb8a5de8c55febfdff6854b27743657 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jan 2017 11:17:55 +0000 Subject: suite_test: skip flaky test. --- Library/Homebrew/cask/test/cask/artifact/suite_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb index b2949950e..ed151e45c 100644 --- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb @@ -13,6 +13,8 @@ describe Hbc::Artifact::Suite do end it "moves the suite to the proper directory" do + skip("flaky test") + shutup do install_phase.call end -- cgit v1.2.3 From 42486c1181bdf4ed85f334ccb1edbb6632cfc4b2 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 17 Jan 2017 10:16:35 -0500 Subject: bottle: add: improve regexp to recognize comments This would have eliminated the need for Homebrew/homebrew-core#9000, for instance. --- Library/Homebrew/dev-cmd/bottle.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 9618cf412..75078cffd 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -435,6 +435,7 @@ module Homebrew else string = s.sub!( /( + (\ {2}\#[^\n]*\n)* # comments \ {2}( # two spaces at the beginning (url|head)\ ['"][\S\ ]+['"] # url or head with a string ( -- cgit v1.2.3 From 4f0505f759d355d6a514485733c0ea3349711655 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jan 2017 19:09:41 +0000 Subject: audit: only warn on versioned conflicts_with. Rather than all versioned formulae regardless. Oops. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 281839621..594555695 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -459,7 +459,7 @@ class FormulaAuditor end def audit_conflicts - if formula.versioned_formula? + if formula.conflicts.any? && formula.versioned_formula? problem <<-EOS Versioned formulae should not use `conflicts_with`. Use `keg_only :versioned_formula` instead. -- cgit v1.2.3 From f0e5ebce06e8c2d7335fb3fbbc4314ee53c05e82 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 17 Jan 2017 14:55:00 -0500 Subject: rubocop_todo: bump max module length to 400 --- Library/Homebrew/.rubocop_todo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index c1b2ba6e7..99080b546 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -66,7 +66,7 @@ Metrics/BlockNesting: # Offense count: 19 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 363 + Max: 400 # Offense count: 1 # Configuration parameters: CountKeywordArgs. -- cgit v1.2.3 From 4d2201b8beabf99a1f4bf062a5aef12b19475caa Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 18 Jan 2017 08:36:36 +0000 Subject: integration_command_test_case: improve fail output Instead of `puts`ing when the failure occurs save it until the error message and print a prose description of what the failure was and the output from the command. This makes the output from failing tests significantly easier to read. --- .../test/support/helper/integration_command_test_case.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index b79fdd6e0..6879f2f81 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -106,16 +106,20 @@ class IntegrationCommandTestCase < Homebrew::TestCase def cmd(*args) output = cmd_output(*args) status = $?.exitstatus - puts "\n'brew #{args.join " "}' output: #{output}" if status.nonzero? - assert_equal 0, status + assert_equal 0, status, <<-EOS.undent + `brew #{args.join " "}` exited with non-zero status! + #{output} + EOS output end def cmd_fail(*args) output = cmd_output(*args) status = $?.exitstatus - $stderr.puts "\n'brew #{args.join " "}'" if status.zero? - refute_equal 0, status + refute_equal 0, status, <<-EOS.undent + `brew #{args.join " "}` exited with zero status! + #{output} + EOS output end -- cgit v1.2.3 From 483c40fb03b83d109795ece1351dcc1ca318a143 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Wed, 18 Jan 2017 15:54:47 +0530 Subject: Add custom cop to refactor revision to rebuild in bottle block --- Library/.rubocop.yml | 6 +++ Library/Homebrew/rubocops/bottle_block_cop.rb | 54 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Library/Homebrew/rubocops/bottle_block_cop.rb (limited to 'Library') diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 097eff995..012fcd609 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -6,6 +6,12 @@ AllCops: - '**/Casks/**/*' - '**/vendor/**/*' +require: + - ./Homebrew/rubocops/bottle_block_cop.rb + +CustomCops/CorrectBottleBlock: + Enabled: true + Metrics/AbcSize: Enabled: false diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb new file mode 100644 index 000000000..7cb97ea89 --- /dev/null +++ b/Library/Homebrew/rubocops/bottle_block_cop.rb @@ -0,0 +1,54 @@ +module RuboCop + module Cop + module CustomCops + class CorrectBottleBlock < Cop + MSG = 'Use rebuild instead of revision in bottle block'.freeze + + def on_block(node) + return if block_length(node).zero? + method, _args, _body = *node + + keyword, method_name = *method + + if method_name.equal?(:bottle) and has_revision?(_body) + add_offense(node, :expression) + end + end + + private + + def autocorrect(node) + ->(corrector) do + # Check for revision + method, _args, _body = *node + if has_revision?(_body) + replace_revision(corrector, node) + end + end + end + + def has_revision?(body) + body.children.each do |method_call_node| + _receiver, _method_name, *args = *method_call_node + if _method_name == :revision + return true + end + end + false + end + + def replace_revision(corrector, node) + new_source = String.new + node.source.each_line do |line| + if line =~ /\A\s*revision/ + line = line.sub('revision','rebuild') + end + new_source << line + end + corrector.insert_before(node.source_range, new_source) + corrector.remove(node.source_range) + end + end + end + end +end -- cgit v1.2.3 From b99fb562753b45e7efec13366b32ddd2f58194f9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:05:27 +0000 Subject: tab: store installed_{as_dependency,on_request}. These are used to determine whether or not a formula’s install was specifically requested by a user and/or pulled in as a dependency. --- Library/Homebrew/tab.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 746c3dd92..fd59539df 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -25,6 +25,8 @@ class Tab < OpenStruct "unused_options" => build.unused_options.as_flags, "tabfile" => formula.prefix.join(FILENAME), "built_as_bottle" => build.bottle?, + "installed_as_dependency" => false, + "installed_on_request" => true, "poured_from_bottle" => false, "time" => Time.now.to_i, "source_modified_time" => formula.source_modified_time.to_i, @@ -172,6 +174,8 @@ class Tab < OpenStruct "used_options" => [], "unused_options" => [], "built_as_bottle" => false, + "installed_as_dependency" => false, + "installed_on_request" => true, "poured_from_bottle" => false, "time" => nil, "source_modified_time" => 0, @@ -313,6 +317,8 @@ class Tab < OpenStruct "unused_options" => unused_options.as_flags, "built_as_bottle" => built_as_bottle, "poured_from_bottle" => poured_from_bottle, + "installed_as_dependency" => installed_as_dependency, + "installed_on_request" => installed_on_request, "changed_files" => changed_files && changed_files.map(&:to_s), "time" => time, "source_modified_time" => source_modified_time.to_i, -- cgit v1.2.3 From 44f1c9752a1f55f09475cab79ab85fdaf39cef84 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:06:38 +0000 Subject: formula: installed_{as_dependency,on_request} hash Which, in turn, provides them for `brew info --json=v1` so other tools such as e.g. `brew bundle` can make use of this information. --- Library/Homebrew/formula.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 77688840c..6df1eb4de 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1629,6 +1629,8 @@ class Formula "built_as_bottle" => tab.built_as_bottle, "poured_from_bottle" => tab.poured_from_bottle, "runtime_dependencies" => tab.runtime_dependencies, + "installed_as_dependency" => tab.installed_as_dependency, + "installed_on_request" => tab.installed_on_request, } end -- cgit v1.2.3 From 16293c0a68622dee1497b36be8aef9d8a6dc064f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:07:55 +0000 Subject: formula_installer: use installed_* variables. Also, report formulae installed on request. This is useful in differentiating between those formulae that are popular because they are widely requested and those that are popular because they are widely depended on. --- Library/Homebrew/formula_installer.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 55e983264..d9127f654 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -36,6 +36,7 @@ class FormulaInstaller mode_attr_accessor :build_from_source, :force_bottle mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git mode_attr_accessor :verbose, :debug, :quieter + mode_attr_accessor :installed_as_dependency, :installed_on_request def initialize(formula) @formula = formula @@ -50,6 +51,8 @@ class FormulaInstaller @verbose = false @quieter = false @debug = false + @installed_as_dependency = false + @installed_on_request = true @options = Options.new @invalid_option_names = [] @requirement_messages = [] @@ -250,6 +253,12 @@ class FormulaInstaller category = "install" action = ([formula.full_name] + options).join(" ") Utils::Analytics.report_event(category, action) + + if installed_on_request + category = "install_on_request" + action = ([formula.full_name] + options).join(" ") + Utils::Analytics.report_event(category, action) + end end @@attempted << formula @@ -287,6 +296,12 @@ class FormulaInstaller brew_prefix = formula.prefix/".brew" brew_prefix.mkdir Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s) + + keg = Keg.new(formula.prefix) + tab = Tab.for_keg(keg) + tab.installed_as_dependency = installed_as_dependency + tab.installed_on_request = installed_on_request + tab.write end build_bottle_postinstall if build_bottle? @@ -483,6 +498,8 @@ class FormulaInstaller fi.build_from_source = ARGV.build_formula_from_source?(df) fi.verbose = verbose? && !quieter? fi.debug = debug? + fi.installed_as_dependency = true + fi.installed_on_request = false fi.prelude oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}" fi.install @@ -809,6 +826,8 @@ class FormulaInstaller tab.time = Time.now.to_i tab.head = HOMEBREW_REPOSITORY.git_head tab.source["path"] = formula.specified_path.to_s + tab.installed_as_dependency = installed_as_dependency + tab.installed_on_request = installed_on_request tab.write end -- cgit v1.2.3 From ee43c09f7acfa57b6ea4b6238d7c3b0aa088031e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:09:31 +0000 Subject: install: set installed_{as_dependency,on_request}. --- Library/Homebrew/cmd/install.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index fbfe46e71..5a3aeb7b3 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -184,6 +184,14 @@ module Homebrew # FormulaInstaller will handle this case. formulae << f end + + # Even if we don't install this formula mark it as no longer just + # installed as a dependency. + next unless f.opt_prefix.directory? + keg = Keg.new(f.opt_prefix.resolved_path) + tab = Tab.for_keg(keg) + tab.installed_on_request = true + tab.write end perform_preinstall_checks -- cgit v1.2.3 From 89d8864b6b26373f8e35be20ddb76644b186c705 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:09:46 +0000 Subject: upgrade: tab installed_{as_dependency,on_request} --- Library/Homebrew/cmd/upgrade.rb | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 5b49a9f65..ce892f85c 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -94,14 +94,24 @@ module Homebrew .select(&:directory?) .map { |k| Keg.new(k.resolved_path) } + if f.opt_prefix.directory? + keg = Keg.new(f.opt_prefix.resolved_path) + tab = Tab.for_keg(keg) + end + fi = FormulaInstaller.new(f) - fi.options = f.build.used_options - fi.options &= f.options - fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) - fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? - fi.verbose = ARGV.verbose? - fi.quieter = ARGV.quieter? - fi.debug = ARGV.debug? + fi.options = f.build.used_options + fi.options &= f.options + fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) + fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? + fi.verbose = ARGV.verbose? + fi.quieter = ARGV.quieter? + fi.debug = ARGV.debug? + fi.installed_on_request = !ARGV.named.empty? + if tab + fi.installed_as_dependency = tab.installed_as_dependency + fi.installed_on_request ||= tab.installed_on_request + end fi.prelude oh1 "Upgrading #{f.full_specified_name} #{fi.options.to_a.join " "}" -- cgit v1.2.3 From 5424db12637917c159aca231d7e18ecfdcc8315b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 18 Jan 2017 15:25:17 +0000 Subject: upgrade: temporarily comment out for fix. --- Library/Homebrew/cmd/upgrade.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index ce892f85c..d3b9784b1 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -110,7 +110,7 @@ module Homebrew fi.installed_on_request = !ARGV.named.empty? if tab fi.installed_as_dependency = tab.installed_as_dependency - fi.installed_on_request ||= tab.installed_on_request + #fi.installed_on_request ||= tab.installed_on_request end fi.prelude -- cgit v1.2.3 From f0249643d47f1dee4a0d08c440eb3afd6da3558a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 18 Jan 2017 16:10:28 +0000 Subject: formula_installer: use attr_accessor for installed_* --- Library/Homebrew/cmd/upgrade.rb | 2 +- Library/Homebrew/formula_installer.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index d3b9784b1..ce892f85c 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -110,7 +110,7 @@ module Homebrew fi.installed_on_request = !ARGV.named.empty? if tab fi.installed_as_dependency = tab.installed_as_dependency - #fi.installed_on_request ||= tab.installed_on_request + fi.installed_on_request ||= tab.installed_on_request end fi.prelude diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index d9127f654..e8f0e4bf8 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -32,11 +32,11 @@ class FormulaInstaller attr_reader :formula attr_accessor :options, :build_bottle, :invalid_option_names + attr_accessor :installed_as_dependency, :installed_on_request mode_attr_accessor :show_summary_heading, :show_header mode_attr_accessor :build_from_source, :force_bottle mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git mode_attr_accessor :verbose, :debug, :quieter - mode_attr_accessor :installed_as_dependency, :installed_on_request def initialize(formula) @formula = formula -- cgit v1.2.3 From 0b3d9031e26b47d0ebf48276616c1c4da01ce336 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Wed, 18 Jan 2017 15:55:32 +0530 Subject: Add --fix option to brew audit command --- Library/Homebrew/dev-cmd/audit.rb | 10 ++++++--- Library/Homebrew/rubocops/bottle_block_cop.rb | 30 +++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 88d9a535c..c2d6aeaed 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1,11 +1,14 @@ -#: * `audit` [`--strict`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] []: +#: * `audit` [`--strict`] [`--fix`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] []: #: Check for Homebrew coding style violations. This should be #: run before submitting a new formula. #: #: If no are provided, all of them are checked. #: #: If `--strict` is passed, additional checks are run, including RuboCop -#: style checks. +#: style checks and custom cop checks. +#: +#: If `--fix` is passed, style violations and custom cop violations will be +#: automatically fixed using RuboCop's `--auto-correct` feature. #: #: If `--online` is passed, additional slower checks that require a network #: connection are run. @@ -62,8 +65,9 @@ module Homebrew end if strict + options = { fix: ARGV.flag?("--fix"), realpath: true } # Check style in a single batch run up front for performance - style_results = check_style_json(files, realpath: true) + style_results = check_style_json(files, options) end ff.each do |f| diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb index 7cb97ea89..6b699ab5e 100644 --- a/Library/Homebrew/rubocops/bottle_block_cop.rb +++ b/Library/Homebrew/rubocops/bottle_block_cop.rb @@ -1,36 +1,34 @@ module RuboCop module Cop - module CustomCops + module CustomCops class CorrectBottleBlock < Cop - MSG = 'Use rebuild instead of revision in bottle block'.freeze + MSG = "Use rebuild instead of revision in bottle block".freeze def on_block(node) return if block_length(node).zero? - method, _args, _body = *node + method, _args, body = *node + _keyword, method_name = *method - keyword, method_name = *method - - if method_name.equal?(:bottle) and has_revision?(_body) - add_offense(node, :expression) - end + return unless method_name.equal?(:bottle) && revision?(body) + add_offense(node, :expression) end private def autocorrect(node) - ->(corrector) do + lambda do |corrector| # Check for revision - method, _args, _body = *node - if has_revision?(_body) + _method, _args, body = *node + if revision?(body) replace_revision(corrector, node) end end end - def has_revision?(body) + def revision?(body) body.children.each do |method_call_node| - _receiver, _method_name, *args = *method_call_node - if _method_name == :revision + _receiver, method_name, _args = *method_call_node + if method_name == :revision return true end end @@ -38,10 +36,10 @@ module RuboCop end def replace_revision(corrector, node) - new_source = String.new + new_source = "" node.source.each_line do |line| if line =~ /\A\s*revision/ - line = line.sub('revision','rebuild') + line = line.sub("revision", "rebuild") end new_source << line end -- cgit v1.2.3 From 6fc1747e0550545b4fe80f5a1854d16dd2b08afe Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 19 Jan 2017 13:16:08 +0000 Subject: tests: add a missing Tab cache clear This was responsible for the sporadic failures I encountered in #1878. --- Library/Homebrew/test/formulary_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library') diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index 3d88c8407..a306c43df 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -110,6 +110,7 @@ class FormularyFactoryTest < Homebrew::TestCase keg.uninstall formula.clear_cache formula.bottle.clear_cache + Tab.clear_cache end def test_load_from_contents -- cgit v1.2.3 From 366ee0b267dbf54d6dfda7210036e388bd2fd1ff Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 19 Jan 2017 13:19:59 +0000 Subject: tests: revert modification to ARGV at end of test Similar to 6fc1747e0550545b4fe80f5a1854d16dd2b08afe. I hadn't seen any test failures caused by this, but I noticed it in the process of trackign that down and it's an accident waiting to happen. --- Library/Homebrew/test/formula_installer_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb index 652548bd7..f86ae1488 100644 --- a/Library/Homebrew/test/formula_installer_test.rb +++ b/Library/Homebrew/test/formula_installer_test.rb @@ -61,6 +61,8 @@ class InstallTests < Homebrew::TestCase assert_equal 3, bin.children.length assert_predicate f.prefix/".brew/testball.rb", :readable? end + ensure + ARGV.reject! { |a| a == "--with-invalid_flag" } end def test_bottle_unneeded_formula_install -- cgit v1.2.3 From 34e13fc52750f1f13df96809034d59ce01af827f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 18 Jan 2017 22:20:44 +0000 Subject: keg: don't conditionally switch alias target This seems to be a remnant of Ruby 1.8. --- Library/Homebrew/keg.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 14eb0e3f3..4c869b048 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -192,11 +192,7 @@ class Keg path.parent end - if Pathname.method_defined?(:to_path) - alias to_path to_s - else - alias to_str to_s - end + alias to_path to_s def inspect "#<#{self.class.name}:#{path}>" -- cgit v1.2.3 From 245944d359f366aaf511f133e11c98ec14cd50b1 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 18 Jan 2017 22:21:22 +0000 Subject: keg: use Forwardable to methods delegated to #path --- Library/Homebrew/keg.rb | 50 ++++++------------------------------------------- 1 file changed, 6 insertions(+), 44 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 4c869b048..837968615 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -174,6 +174,12 @@ class Keg attr_reader :path, :name, :linked_keg_record, :opt_record protected :path + extend Forwardable + + def_delegators :path, + :to_s, :hash, :abv, :disk_usage, :file_count, :directory?, :exist?, :/, + :join, :rename, :find + def initialize(path) path = path.resolved_path if path.to_s.start_with?("#{HOMEBREW_PREFIX}/opt/") raise "#{path} is not a valid keg" unless path.parent.parent.realpath == HOMEBREW_CELLAR.realpath @@ -184,10 +190,6 @@ class Keg @opt_record = HOMEBREW_PREFIX/"opt/#{name}" end - def to_s - path.to_s - end - def rack path.parent end @@ -203,30 +205,6 @@ class Keg end alias eql? == - def hash - path.hash - end - - def abv - path.abv - end - - def disk_usage - path.disk_usage - end - - def file_count - path.file_count - end - - def directory? - path.directory? - end - - def exist? - path.exist? - end - def empty_installation? Pathname.glob("#{path}/**/*") do |file| next if file.directory? @@ -239,18 +217,6 @@ class Keg true end - def /(other) - path / other - end - - def join(*args) - path.join(*args) - end - - def rename(*args) - path.rename(*args) - end - def linked? linked_keg_record.symlink? && linked_keg_record.directory? && @@ -396,10 +362,6 @@ class Keg end end - def find(*args, &block) - path.find(*args, &block) - end - def oldname_opt_record @oldname_opt_record ||= if (opt_dir = HOMEBREW_PREFIX/"opt").directory? opt_dir.subdirs.detect do |dir| -- cgit v1.2.3 From cebe137499cc5e74dd0b34e54226a1ade7a4bf60 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 18 Jan 2017 11:03:36 -0800 Subject: audit: exempt wine's deps from the universal deprecation This can be reverted when wine's dependencies are all vendored. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 594555695..5b0102130 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -489,7 +489,7 @@ class FormulaAuditor next unless @strict - if o.name == "universal" + if o.name == "universal" && !Formula["wine"].recursive_dependencies.map(&:name).include?(formula.name) problem "macOS has been 64-bit only since 10.6 so universal options are deprecated." end -- cgit v1.2.3 From 70a381a00ff1e354e059aa07d55ebab90c5f874a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 11:21:30 +0000 Subject: tests: enforce `super` in lifecycle hooks This will allow us to have global setup and teardown for tests. For example, we can automatically clear caches after each test, to avoid annoying intermittent failures like #1879 and #1886. --- Library/Homebrew/test/ARGV_test.rb | 1 + Library/Homebrew/test/ENV_test.rb | 1 + Library/Homebrew/test/audit_test.rb | 4 ++++ Library/Homebrew/test/bottle_collector_test.rb | 1 + Library/Homebrew/test/bottle_hooks_test.rb | 2 ++ Library/Homebrew/test/build_environment_test.rb | 1 + Library/Homebrew/test/build_options_test.rb | 1 + Library/Homebrew/test/caveats_test.rb | 1 + .../Homebrew/test/checksum_verification_test.rb | 1 + Library/Homebrew/test/cleaner_test.rb | 2 ++ Library/Homebrew/test/cleanup_test.rb | 2 ++ Library/Homebrew/test/commands_test.rb | 2 ++ Library/Homebrew/test/compiler_selector_test.rb | 1 + Library/Homebrew/test/dependencies_test.rb | 2 ++ Library/Homebrew/test/dependency_collector_test.rb | 2 ++ Library/Homebrew/test/dependency_expansion_test.rb | 1 + Library/Homebrew/test/dependency_test.rb | 1 + Library/Homebrew/test/descriptions_test.rb | 3 +++ Library/Homebrew/test/diagnostic_test.rb | 2 ++ Library/Homebrew/test/download_strategies_test.rb | 6 ++++++ Library/Homebrew/test/formula_lock_test.rb | 2 ++ Library/Homebrew/test/formula_pin_test.rb | 2 ++ Library/Homebrew/test/formula_test.rb | 5 +++++ Library/Homebrew/test/formulary_test.rb | 6 ++++++ Library/Homebrew/test/gpg2_requirement_test.rb | 2 ++ Library/Homebrew/test/gpg_test.rb | 1 + Library/Homebrew/test/keg_test.rb | 4 ++++ Library/Homebrew/test/language_python_test.rb | 2 ++ Library/Homebrew/test/migrator_test.rb | 5 +++++ Library/Homebrew/test/options_test.rb | 3 +++ .../Homebrew/test/os/mac/bottle_collector_test.rb | 1 + .../test/os/mac/dependency_collector_test.rb | 2 ++ Library/Homebrew/test/os/mac/diagnostic_test.rb | 2 ++ Library/Homebrew/test/os/mac/keg_test.rb | 4 ++++ Library/Homebrew/test/os/mac/mach_test.rb | 3 +++ Library/Homebrew/test/os/mac/version_test.rb | 1 + Library/Homebrew/test/patch_test.rb | 1 + Library/Homebrew/test/patching_test.rb | 1 + Library/Homebrew/test/pathname_test.rb | 2 ++ Library/Homebrew/test/resource_test.rb | 1 + Library/Homebrew/test/sandbox_test.rb | 2 ++ Library/Homebrew/test/software_spec_test.rb | 3 +++ Library/Homebrew/test/stdlib_test.rb | 1 + .../helper/integration_command_test_case.rb | 2 ++ .../test/support/helper/lifecycle_enforcer.rb | 22 ++++++++++++++++++++++ Library/Homebrew/test/support/helper/test_case.rb | 2 ++ Library/Homebrew/test/tab_test.rb | 4 ++++ Library/Homebrew/test/tap_test.rb | 3 +++ Library/Homebrew/test/uninstall_test.rb | 3 +++ Library/Homebrew/test/update_report_test.rb | 1 + Library/Homebrew/test/utils_test.rb | 2 ++ 51 files changed, 132 insertions(+) create mode 100644 Library/Homebrew/test/support/helper/lifecycle_enforcer.rb (limited to 'Library') diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb index 6805e0c62..06660defc 100644 --- a/Library/Homebrew/test/ARGV_test.rb +++ b/Library/Homebrew/test/ARGV_test.rb @@ -3,6 +3,7 @@ require "extend/ARGV" class ArgvExtensionTests < Homebrew::TestCase def setup + super @argv = [].extend(HomebrewArgvExtension) end diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb index dd6025084..cbfd01e25 100644 --- a/Library/Homebrew/test/ENV_test.rb +++ b/Library/Homebrew/test/ENV_test.rb @@ -31,6 +31,7 @@ end module SharedEnvTests def setup + super @env = {}.extend(EnvActivation) end diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index dace4dc2b..0b13d3c2b 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -6,11 +6,13 @@ require "dev-cmd/audit" class FormulaTextTests < Homebrew::TestCase def setup + super @dir = mktmpdir end def teardown FileUtils.rm_rf @dir + super end def formula_text(name, body = nil, options = {}) @@ -58,11 +60,13 @@ end class FormulaAuditorTests < Homebrew::TestCase def setup + super @dir = mktmpdir end def teardown FileUtils.rm_rf @dir + super end def formula_auditor(name, text, options = {}) diff --git a/Library/Homebrew/test/bottle_collector_test.rb b/Library/Homebrew/test/bottle_collector_test.rb index d75e29ec8..5879da92c 100644 --- a/Library/Homebrew/test/bottle_collector_test.rb +++ b/Library/Homebrew/test/bottle_collector_test.rb @@ -3,6 +3,7 @@ require "utils/bottles" class BottleCollectorTests < Homebrew::TestCase def setup + super @collector = Utils::Bottles::Collector.new end diff --git a/Library/Homebrew/test/bottle_hooks_test.rb b/Library/Homebrew/test/bottle_hooks_test.rb index 3535d80ef..fd890192f 100644 --- a/Library/Homebrew/test/bottle_hooks_test.rb +++ b/Library/Homebrew/test/bottle_hooks_test.rb @@ -17,6 +17,7 @@ class BottleHookTests < Homebrew::TestCase end def setup + super @fi = FormulaInstaller.new FormulaDouble.new end @@ -43,5 +44,6 @@ class BottleHookTests < Homebrew::TestCase def teardown Homebrew::Hooks::Bottles.reset_hooks + super end end diff --git a/Library/Homebrew/test/build_environment_test.rb b/Library/Homebrew/test/build_environment_test.rb index 73a1c95f7..54b9cb2b1 100644 --- a/Library/Homebrew/test/build_environment_test.rb +++ b/Library/Homebrew/test/build_environment_test.rb @@ -3,6 +3,7 @@ require "build_environment" class BuildEnvironmentTests < Homebrew::TestCase def setup + super @env = BuildEnvironment.new end diff --git a/Library/Homebrew/test/build_options_test.rb b/Library/Homebrew/test/build_options_test.rb index e460d25cc..05e7ccd94 100644 --- a/Library/Homebrew/test/build_options_test.rb +++ b/Library/Homebrew/test/build_options_test.rb @@ -4,6 +4,7 @@ require "options" class BuildOptionsTests < Homebrew::TestCase def setup + super args = Options.create(%w[--with-foo --with-bar --without-qux]) opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux]) @build = BuildOptions.new(args, opts) diff --git a/Library/Homebrew/test/caveats_test.rb b/Library/Homebrew/test/caveats_test.rb index 9eaac5792..3a582b907 100644 --- a/Library/Homebrew/test/caveats_test.rb +++ b/Library/Homebrew/test/caveats_test.rb @@ -4,6 +4,7 @@ require "caveats" class CaveatsTests < Homebrew::TestCase def setup + super @f = formula { url "foo-1.0" } @c = Caveats.new @f end diff --git a/Library/Homebrew/test/checksum_verification_test.rb b/Library/Homebrew/test/checksum_verification_test.rb index 9017b528d..ad7dfb462 100644 --- a/Library/Homebrew/test/checksum_verification_test.rb +++ b/Library/Homebrew/test/checksum_verification_test.rb @@ -19,6 +19,7 @@ class ChecksumVerificationTests < Homebrew::TestCase def teardown @_f.clear_cache + super end def test_good_sha256 diff --git a/Library/Homebrew/test/cleaner_test.rb b/Library/Homebrew/test/cleaner_test.rb index ac108421c..413925dfa 100644 --- a/Library/Homebrew/test/cleaner_test.rb +++ b/Library/Homebrew/test/cleaner_test.rb @@ -6,12 +6,14 @@ class CleanerTests < Homebrew::TestCase include FileUtils def setup + super @f = formula("cleaner_test") { url "foo-1.0" } @f.prefix.mkpath end def teardown @f.rack.rmtree if @f.rack.exist? + super end def test_clean_file diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index bb8e1cdc6..e27439e07 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -14,6 +14,7 @@ end class CleanupTests < Homebrew::TestCase def setup + super @ds_store = Pathname.new "#{HOMEBREW_PREFIX}/Library/.DS_Store" FileUtils.touch @ds_store end @@ -22,6 +23,7 @@ class CleanupTests < Homebrew::TestCase FileUtils.rm_f @ds_store ARGV.delete "--dry-run" ARGV.delete "--prune=all" + super end def test_cleanup diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb index d44d2da0e..3d7c16e58 100644 --- a/Library/Homebrew/test/commands_test.rb +++ b/Library/Homebrew/test/commands_test.rb @@ -13,6 +13,7 @@ end class CommandsTests < Homebrew::TestCase def setup + super @cmds = [ # internal commands HOMEBREW_LIBRARY_PATH/"cmd/rbcmd.rb", @@ -28,6 +29,7 @@ class CommandsTests < Homebrew::TestCase def teardown @cmds.each(&:unlink) + super end def test_internal_commands diff --git a/Library/Homebrew/test/compiler_selector_test.rb b/Library/Homebrew/test/compiler_selector_test.rb index b1591bdbe..aa1a6f97e 100644 --- a/Library/Homebrew/test/compiler_selector_test.rb +++ b/Library/Homebrew/test/compiler_selector_test.rb @@ -31,6 +31,7 @@ class CompilerSelectorTests < Homebrew::TestCase end def setup + super @f = Double.new @cc = :clang @versions = CompilerVersions.new diff --git a/Library/Homebrew/test/dependencies_test.rb b/Library/Homebrew/test/dependencies_test.rb index db3b78226..c5444fcbc 100644 --- a/Library/Homebrew/test/dependencies_test.rb +++ b/Library/Homebrew/test/dependencies_test.rb @@ -5,6 +5,7 @@ require "requirements" class DependenciesTests < Homebrew::TestCase def setup + super @deps = Dependencies.new end @@ -89,6 +90,7 @@ end class RequirementsTests < Homebrew::TestCase def setup + super @reqs = Requirements.new end diff --git a/Library/Homebrew/test/dependency_collector_test.rb b/Library/Homebrew/test/dependency_collector_test.rb index 1c7f70118..c63d04637 100644 --- a/Library/Homebrew/test/dependency_collector_test.rb +++ b/Library/Homebrew/test/dependency_collector_test.rb @@ -11,11 +11,13 @@ class DependencyCollectorTests < Homebrew::TestCase end def setup + super @d = DependencyCollector.new end def teardown DependencyCollector.clear_cache + super end def test_dependency_creation diff --git a/Library/Homebrew/test/dependency_expansion_test.rb b/Library/Homebrew/test/dependency_expansion_test.rb index 9d6de35e2..de743ce03 100644 --- a/Library/Homebrew/test/dependency_expansion_test.rb +++ b/Library/Homebrew/test/dependency_expansion_test.rb @@ -9,6 +9,7 @@ class DependencyExpansionTests < Homebrew::TestCase end def setup + super @foo = build_dep(:foo) @bar = build_dep(:bar) @baz = build_dep(:baz) diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb index 134e91d13..404f26d79 100644 --- a/Library/Homebrew/test/dependency_test.rb +++ b/Library/Homebrew/test/dependency_test.rb @@ -3,6 +3,7 @@ require "dependency" class DependableTests < Homebrew::TestCase def setup + super @tags = ["foo", "bar", :build] @dep = Struct.new(:tags).new(@tags).extend(Dependable) end diff --git a/Library/Homebrew/test/descriptions_test.rb b/Library/Homebrew/test/descriptions_test.rb index de38fdbd1..baeeb7b19 100644 --- a/Library/Homebrew/test/descriptions_test.rb +++ b/Library/Homebrew/test/descriptions_test.rb @@ -3,6 +3,8 @@ require "descriptions" class DescriptionsTest < Homebrew::TestCase def setup + super + @descriptions_hash = {} @descriptions = Descriptions.new(@descriptions_hash) @@ -12,6 +14,7 @@ class DescriptionsTest < Homebrew::TestCase def teardown $stdout = @old_stdout + super end def test_single_core_formula diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index c9bb524b0..608dda099 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -5,12 +5,14 @@ require "diagnostic" class DiagnosticChecksTest < Homebrew::TestCase def setup + super @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end def teardown ENV.replace(@env) + super end def test_inject_file_list diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 2b64abbf9..fa69ec64e 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -15,6 +15,7 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase include FileUtils def setup + super @name = "foo" @resource = ResourceDouble.new @strategy = AbstractDownloadStrategy.new(@name, @resource) @@ -63,6 +64,7 @@ end class GitHubPrivateRepositoryDownloadStrategyTests < Homebrew::TestCase def setup + super resource = ResourceDouble.new("https://github.com/owner/repo/archive/1.1.5.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" GitHub.stubs(:repository).returns {} @@ -87,6 +89,7 @@ end class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase def setup + super resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" GitHub.stubs(:repository).returns {} @@ -138,6 +141,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase include FileUtils def setup + super resource = ResourceDouble.new("https://github.com/homebrew/foo") @commit_id = 1 @strategy = GitDownloadStrategy.new("baz", resource) @@ -147,6 +151,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase def teardown rmtree @cached_location + super end def git_commit_all @@ -236,6 +241,7 @@ end class DownloadStrategyDetectorTests < Homebrew::TestCase def setup + super @d = DownloadStrategyDetector.new end diff --git a/Library/Homebrew/test/formula_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb index 80ee9dd25..d5bd0d07c 100644 --- a/Library/Homebrew/test/formula_lock_test.rb +++ b/Library/Homebrew/test/formula_lock_test.rb @@ -3,6 +3,7 @@ require "formula_lock" class FormulaLockTests < Homebrew::TestCase def setup + super @lock = FormulaLock.new("foo") @lock.lock end @@ -10,6 +11,7 @@ class FormulaLockTests < Homebrew::TestCase def teardown @lock.unlock HOMEBREW_LOCK_DIR.children.each(&:unlink) + super end def test_locking_file_with_existing_lock_raises_error diff --git a/Library/Homebrew/test/formula_pin_test.rb b/Library/Homebrew/test/formula_pin_test.rb index 297d7703e..5dd2bd29e 100644 --- a/Library/Homebrew/test/formula_pin_test.rb +++ b/Library/Homebrew/test/formula_pin_test.rb @@ -21,6 +21,7 @@ class FormulaPinTests < Homebrew::TestCase end def setup + super @f = FormulaDouble.new @pin = FormulaPin.new(@f) @f.rack.mkpath @@ -50,5 +51,6 @@ class FormulaPinTests < Homebrew::TestCase def teardown @f.rack.rmtree + super end end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 2d2136a05..8293768fe 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -874,6 +874,8 @@ class AliasChangeTests < Homebrew::TestCase end def setup + super + alias_name = "bar" @alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}" @@ -942,6 +944,8 @@ class OutdatedVersionsTests < Homebrew::TestCase attr_reader :f, :old_formula, :new_formula def setup + super + @f = formula do url "foo" version "1.20" @@ -960,6 +964,7 @@ class OutdatedVersionsTests < Homebrew::TestCase def teardown formulae = [@f, @old_formula, @new_formula] formulae.map(&:rack).select(&:exist?).each(&:rmtree) + super end def alias_path diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index a306c43df..360c44a0d 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -16,6 +16,7 @@ end class FormularyFactoryTest < Homebrew::TestCase def setup + super @name = "testball_bottle" @path = CoreTap.new.formula_dir/"#{@name}.rb" @bottle_dir = Pathname.new("#{TEST_FIXTURE_DIR}/bottles") @@ -41,6 +42,7 @@ class FormularyFactoryTest < Homebrew::TestCase def teardown @path.unlink + super end def test_factory @@ -129,6 +131,7 @@ end class FormularyTapFactoryTest < Homebrew::TestCase def setup + super @name = "foo" @tap = Tap.new "homebrew", "foo" @path = @tap.path/"#{@name}.rb" @@ -142,6 +145,7 @@ class FormularyTapFactoryTest < Homebrew::TestCase def teardown @tap.path.rmtree + super end def test_factory_tap_formula @@ -174,6 +178,7 @@ end class FormularyTapPriorityTest < Homebrew::TestCase def setup + super @name = "foo" @core_path = CoreTap.new.formula_dir/"#{@name}.rb" @tap = Tap.new "homebrew", "foo" @@ -190,6 +195,7 @@ class FormularyTapPriorityTest < Homebrew::TestCase def teardown @core_path.unlink @tap.path.rmtree + super end def test_find_with_priority_core_formula diff --git a/Library/Homebrew/test/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb index fa7fc9ea4..b45798b42 100644 --- a/Library/Homebrew/test/gpg2_requirement_test.rb +++ b/Library/Homebrew/test/gpg2_requirement_test.rb @@ -4,6 +4,7 @@ require "fileutils" class GPG2RequirementTests < Homebrew::TestCase def setup + super @dir = Pathname.new(mktmpdir) (@dir/"bin/gpg").write <<-EOS.undent #!/bin/bash @@ -14,6 +15,7 @@ class GPG2RequirementTests < Homebrew::TestCase def teardown FileUtils.rm_rf @dir + super end def test_satisfied diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb index 0374bdab4..881468ad2 100644 --- a/Library/Homebrew/test/gpg_test.rb +++ b/Library/Homebrew/test/gpg_test.rb @@ -3,6 +3,7 @@ require "gpg" class GpgTest < Homebrew::TestCase def setup + super skip "GPG Unavailable" unless Gpg.available? @dir = Pathname.new(mktmpdir) end diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 40b47b5e9..08bda4699 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -20,6 +20,8 @@ class LinkTestCase < Homebrew::TestCase end def setup + super + @keg = setup_test_keg("foo", "1.0") @dst = HOMEBREW_PREFIX.join("bin", "helloworld") @nonexistent = Pathname.new("/some/nonexistent/path") @@ -43,6 +45,8 @@ class LinkTestCase < Homebrew::TestCase rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" + + super end end diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb index d1e3867f7..0a6d1eeaa 100644 --- a/Library/Homebrew/test/language_python_test.rb +++ b/Library/Homebrew/test/language_python_test.rb @@ -4,6 +4,7 @@ require "resource" class LanguagePythonTests < Homebrew::TestCase def setup + super @dir = Pathname.new(mktmpdir) resource = stub("resource", stage: true) formula_bin = @dir/"formula_bin" @@ -16,6 +17,7 @@ class LanguagePythonTests < Homebrew::TestCase def teardown FileUtils.rm_rf @dir + super end def test_virtualenv_creation diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb index 8a2b6ad63..53151f3e3 100644 --- a/Library/Homebrew/test/migrator_test.rb +++ b/Library/Homebrew/test/migrator_test.rb @@ -10,6 +10,7 @@ end class MigratorErrorsTests < Homebrew::TestCase def setup + super @new_f = Testball.new("newname") @new_f.oldname = "oldname" @old_f = Testball.new("oldname") @@ -40,6 +41,8 @@ class MigratorTests < Homebrew::TestCase include FileUtils def setup + super + @new_f = Testball.new("newname") @new_f.oldname = "oldname" @@ -93,6 +96,8 @@ class MigratorTests < Homebrew::TestCase @new_f.unpin HOMEBREW_LOCK_DIR.children.each(&:unlink) + + super end def test_move_cellar diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb index e7189a604..f38ec4415 100644 --- a/Library/Homebrew/test/options_test.rb +++ b/Library/Homebrew/test/options_test.rb @@ -15,6 +15,7 @@ end class OptionTests < Homebrew::TestCase def setup + super @option = Option.new("foo") end @@ -43,6 +44,7 @@ end class DeprecatedOptionTests < Homebrew::TestCase def setup + super @deprecated_option = DeprecatedOption.new("foo", "bar") end @@ -68,6 +70,7 @@ end class OptionsTests < Homebrew::TestCase def setup + super @options = Options.new end diff --git a/Library/Homebrew/test/os/mac/bottle_collector_test.rb b/Library/Homebrew/test/os/mac/bottle_collector_test.rb index 2f88050ae..e9ae9b753 100644 --- a/Library/Homebrew/test/os/mac/bottle_collector_test.rb +++ b/Library/Homebrew/test/os/mac/bottle_collector_test.rb @@ -3,6 +3,7 @@ require "utils/bottles" class OSMacBottleCollectorTests < Homebrew::TestCase def setup + super @collector = Utils::Bottles::Collector.new end diff --git a/Library/Homebrew/test/os/mac/dependency_collector_test.rb b/Library/Homebrew/test/os/mac/dependency_collector_test.rb index 4fdf3ebe4..1033df9ab 100644 --- a/Library/Homebrew/test/os/mac/dependency_collector_test.rb +++ b/Library/Homebrew/test/os/mac/dependency_collector_test.rb @@ -7,11 +7,13 @@ class OSMacDependencyCollectorTests < Homebrew::TestCase end def setup + super @d = DependencyCollector.new end def teardown DependencyCollector.clear_cache + super end def test_tar_needs_xz_dependency diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 655aa1d46..284d293ca 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -5,12 +5,14 @@ require "diagnostic" class OSMacDiagnosticChecksTest < Homebrew::TestCase def setup + super @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end def teardown ENV.replace(@env) + super end def test_check_for_other_package_managers diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb index e79cbc921..5f215bd06 100644 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ b/Library/Homebrew/test/os/mac/keg_test.rb @@ -6,6 +6,8 @@ class OSMacLinkTests < Homebrew::TestCase include FileUtils def setup + super + keg = HOMEBREW_CELLAR.join("foo", "1.0") keg.join("bin").mkpath @@ -34,6 +36,8 @@ class OSMacLinkTests < Homebrew::TestCase rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" + + super end def test_mach_o_files_skips_hardlinks diff --git a/Library/Homebrew/test/os/mac/mach_test.rb b/Library/Homebrew/test/os/mac/mach_test.rb index a42f7316b..ed0424be6 100644 --- a/Library/Homebrew/test/os/mac/mach_test.rb +++ b/Library/Homebrew/test/os/mac/mach_test.rb @@ -109,6 +109,7 @@ end class ArchitectureListExtensionTests < MachOPathnameTests def setup + super @archs = [:i386, :x86_64, :ppc7400, :ppc64].extend(ArchitectureListExtension) end @@ -157,11 +158,13 @@ class TextExecutableTests < Homebrew::TestCase attr_reader :pn def setup + super @pn = HOMEBREW_PREFIX.join("an_executable") end def teardown HOMEBREW_PREFIX.join("an_executable").unlink + super end def test_simple_shebang diff --git a/Library/Homebrew/test/os/mac/version_test.rb b/Library/Homebrew/test/os/mac/version_test.rb index f702c7097..ba4217691 100644 --- a/Library/Homebrew/test/os/mac/version_test.rb +++ b/Library/Homebrew/test/os/mac/version_test.rb @@ -4,6 +4,7 @@ require "os/mac/version" class OSMacVersionTests < Homebrew::TestCase def setup + super @v = MacOS::Version.new("10.7") end diff --git a/Library/Homebrew/test/patch_test.rb b/Library/Homebrew/test/patch_test.rb index 62624720e..f5a61398a 100644 --- a/Library/Homebrew/test/patch_test.rb +++ b/Library/Homebrew/test/patch_test.rb @@ -111,6 +111,7 @@ end class ExternalPatchTests < Homebrew::TestCase def setup + super @p = ExternalPatch.new(:p1) { url "file:///my.patch" } end diff --git a/Library/Homebrew/test/patching_test.rb b/Library/Homebrew/test/patching_test.rb index ac14c8e1e..eadab15dc 100644 --- a/Library/Homebrew/test/patching_test.rb +++ b/Library/Homebrew/test/patching_test.rb @@ -23,6 +23,7 @@ class PatchingTests < Homebrew::TestCase def teardown @_f.clear_cache @_f.patchlist.each { |p| p.clear_cache if p.external? } + super end def assert_patched(formula) diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb index 2f6360719..2f4002b00 100644 --- a/Library/Homebrew/test/pathname_test.rb +++ b/Library/Homebrew/test/pathname_test.rb @@ -7,6 +7,7 @@ module PathnameTestExtension include FileUtils def setup + super @src = Pathname.new(mktmpdir) @dst = Pathname.new(mktmpdir) @file = @src/"foo" @@ -16,6 +17,7 @@ module PathnameTestExtension def teardown rmtree(@src) rmtree(@dst) + super end end diff --git a/Library/Homebrew/test/resource_test.rb b/Library/Homebrew/test/resource_test.rb index c1b526cb2..d982a7c33 100644 --- a/Library/Homebrew/test/resource_test.rb +++ b/Library/Homebrew/test/resource_test.rb @@ -3,6 +3,7 @@ require "resource" class ResourceTests < Homebrew::TestCase def setup + super @resource = Resource.new("test") end diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 2a062cb10..96558afa4 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -3,6 +3,7 @@ require "sandbox" class SandboxTest < Homebrew::TestCase def setup + super skip "sandbox not implemented" unless Sandbox.available? @sandbox = Sandbox.new @dir = Pathname.new(mktmpdir) @@ -11,6 +12,7 @@ class SandboxTest < Homebrew::TestCase def teardown @dir.rmtree + super end def test_formula? diff --git a/Library/Homebrew/test/software_spec_test.rb b/Library/Homebrew/test/software_spec_test.rb index d9226f8c3..026265a4a 100644 --- a/Library/Homebrew/test/software_spec_test.rb +++ b/Library/Homebrew/test/software_spec_test.rb @@ -3,6 +3,7 @@ require "software_spec" class SoftwareSpecTests < Homebrew::TestCase def setup + super @spec = SoftwareSpec.new end @@ -136,6 +137,7 @@ end class HeadSoftwareSpecTests < Homebrew::TestCase def setup + super @spec = HeadSoftwareSpec.new end @@ -150,6 +152,7 @@ end class BottleSpecificationTests < Homebrew::TestCase def setup + super @spec = BottleSpecification.new end diff --git a/Library/Homebrew/test/stdlib_test.rb b/Library/Homebrew/test/stdlib_test.rb index 3babfd58a..f193ae71e 100644 --- a/Library/Homebrew/test/stdlib_test.rb +++ b/Library/Homebrew/test/stdlib_test.rb @@ -4,6 +4,7 @@ require "cxxstdlib" class CxxStdlibTests < Homebrew::TestCase def setup + super @clang = CxxStdlib.create(:libstdcxx, :clang) @gcc = CxxStdlib.create(:libstdcxx, :gcc) @gcc40 = CxxStdlib.create(:libstdcxx, :gcc_4_0) diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index 6879f2f81..86184ac51 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -6,6 +6,7 @@ require "test/support/helper/test_case" class IntegrationCommandTestCase < Homebrew::TestCase def setup + super @cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`. (HOMEBREW_PREFIX/"bin").mkpath FileUtils.touch HOMEBREW_PREFIX/"bin/brew" @@ -38,6 +39,7 @@ class IntegrationCommandTestCase < Homebrew::TestCase coretap.path/"formula_renames.json", ].flatten FileUtils.rm_rf paths_to_delete + super end def needs_test_cmd_taps diff --git a/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb b/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb new file mode 100644 index 000000000..413f8b11e --- /dev/null +++ b/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb @@ -0,0 +1,22 @@ +module Test + module Helper + module LifecycleEnforcer + def setup + @__setup_called = true + super + end + + def teardown + @__teardown_called = true + super + end + + def after_teardown + assert @__setup_called, "Expected setup to call `super` but didn't" + assert @__teardown_called, "Expected teardown to call `super` but didn't" + + super + end + end + end +end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 60c91e7bb..5becfeef1 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -2,10 +2,12 @@ module Homebrew class TestCase < ::Minitest::Test require "test/support/helper/env" require "test/support/helper/fs_leak_logger" + require "test/support/helper/lifecycle_enforcer" require "test/support/helper/shutup" require "test/support/helper/version_assertions" include Test::Helper::Env include Test::Helper::FSLeakLogger + include Test::Helper::LifecycleEnforcer include Test::Helper::Shutup include Test::Helper::VersionAssertions diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index f9824ba2a..5a354a908 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -4,6 +4,8 @@ require "formula" class TabTests < Homebrew::TestCase def setup + super + @used = Options.create(%w[--with-foo --without-bar]) @unused = Options.create(%w[--with-baz --without-qux]) @@ -260,6 +262,7 @@ end class TabLoadingTests < Homebrew::TestCase def setup + super @f = formula { url "foo-1.0" } @f.prefix.mkpath @path = @f.prefix.join(Tab::FILENAME) @@ -268,6 +271,7 @@ class TabLoadingTests < Homebrew::TestCase def teardown @f.rack.rmtree + super end def test_for_keg diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 7114cdf22..4990bc6df 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -34,6 +34,7 @@ class TapTest < Homebrew::TestCase include FileUtils def setup + super @path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" @path.mkpath @tap = Tap.new("Homebrew", "foo") @@ -86,6 +87,7 @@ class TapTest < Homebrew::TestCase def teardown @path.rmtree + super end def test_fetch @@ -285,6 +287,7 @@ class CoreTapTest < Homebrew::TestCase include FileUtils def setup + super @repo = CoreTap.new end diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 597e77e40..4ab2f985e 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -3,6 +3,8 @@ require "cmd/uninstall" class UninstallTests < Homebrew::TestCase def setup + super + @dependency = formula("dependency") { url "f-1" } @dependent = formula("dependent") do url "f-1" @@ -32,6 +34,7 @@ class UninstallTests < Homebrew::TestCase f.installed_kegs.each(&:remove_opt_record) f.rack.rmtree end + super end def handle_unsatisfied_dependents diff --git a/Library/Homebrew/test/update_report_test.rb b/Library/Homebrew/test/update_report_test.rb index 6b6cec6ce..32c3e36d0 100644 --- a/Library/Homebrew/test/update_report_test.rb +++ b/Library/Homebrew/test/update_report_test.rb @@ -24,6 +24,7 @@ class ReportTests < Homebrew::TestCase end def setup + super @tap = CoreTap.new @reporter = ReporterMock.new(@tap) @hub = ReporterHub.new diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index d7c25683d..310bfb135 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -5,6 +5,7 @@ require "utils/shell" class UtilTests < Homebrew::TestCase def setup + super @dir = Pathname.new(mktmpdir) @env = ENV.to_hash end @@ -12,6 +13,7 @@ class UtilTests < Homebrew::TestCase def teardown @dir.rmtree ENV.replace @env + super end def test_ofail -- cgit v1.2.3 From 2d550b50081bfa0d641875f8657fd376afe0c10f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 14:24:19 +0000 Subject: tests: clear tab cache in global teardown --- Library/Homebrew/test/formulary_test.rb | 1 - Library/Homebrew/test/support/helper/test_case.rb | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index 360c44a0d..2ed5cd3f0 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -112,7 +112,6 @@ class FormularyFactoryTest < Homebrew::TestCase keg.uninstall formula.clear_cache formula.bottle.clear_cache - Tab.clear_cache end def test_load_from_contents diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 5becfeef1..170dd4cff 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -14,6 +14,11 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + def teardown + Tab.clear_cache + super + end + def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block) @_f = Class.new(Formula, &block).new(name, path, spec, alias_path: alias_path) end -- cgit v1.2.3 From d86342a2519b6bdc5393302e3e81e5b72aa26e7f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:08:20 +0000 Subject: tests: reset ARGV in teardown --- Library/Homebrew/test/cleanup_test.rb | 2 -- Library/Homebrew/test/formula_installer_test.rb | 13 ++++--------- Library/Homebrew/test/support/helper/test_case.rb | 6 ++++++ Library/Homebrew/test/uninstall_test.rb | 2 -- 4 files changed, 10 insertions(+), 13 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index e27439e07..03ad6871e 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -21,8 +21,6 @@ class CleanupTests < Homebrew::TestCase def teardown FileUtils.rm_f @ds_store - ARGV.delete "--dry-run" - ARGV.delete "--prune=all" super end diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb index f86ae1488..5467be98a 100644 --- a/Library/Homebrew/test/formula_installer_test.rb +++ b/Library/Homebrew/test/formula_installer_test.rb @@ -61,8 +61,6 @@ class InstallTests < Homebrew::TestCase assert_equal 3, bin.children.length assert_predicate f.prefix/".brew/testball.rb", :readable? end - ensure - ARGV.reject! { |a| a == "--with-invalid_flag" } end def test_bottle_unneeded_formula_install @@ -86,13 +84,10 @@ class InstallTests < Homebrew::TestCase cc_arg = "--cc=clang" ARGV << cc_arg - begin - temporary_install(TestballBottle.new) do |f| - tab = Tab.for_formula(f) - assert_equal "clang", tab.compiler - end - ensure - ARGV.delete_if { |x| x == cc_arg } + + temporary_install(TestballBottle.new) do |f| + tab = Tab.for_formula(f) + assert_equal "clang", tab.compiler end end end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 170dd4cff..ebe5d3d22 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -14,8 +14,14 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + def setup + super + @__argv = ARGV.dup + end + def teardown Tab.clear_cache + ARGV.replace(@__argv) super end diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 4ab2f985e..b517836e8 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -62,8 +62,6 @@ class UninstallTests < Homebrew::TestCase assert_empty handle_unsatisfied_dependents refute_predicate Homebrew, :failed? end - ensure - ARGV.delete("--ignore-dependencies") end end -- cgit v1.2.3 From d7b8420aaadf93b455a5c268777c3013f8ac2296 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:39:17 +0000 Subject: tests: clean up file system for all tests (No longer just integration tests.) --- .../Homebrew/test/checksum_verification_test.rb | 5 ---- Library/Homebrew/test/cleaner_test.rb | 5 ---- Library/Homebrew/test/download_strategies_test.rb | 5 ---- Library/Homebrew/test/formula_lock_test.rb | 1 - Library/Homebrew/test/formula_pin_test.rb | 5 ---- Library/Homebrew/test/formula_test.rb | 6 ----- Library/Homebrew/test/formulary_test.rb | 16 ----------- Library/Homebrew/test/keg_test.rb | 9 +------ Library/Homebrew/test/migrator_test.rb | 18 +------------ Library/Homebrew/test/os/mac/keg_test.rb | 2 -- Library/Homebrew/test/patching_test.rb | 6 ----- .../helper/integration_command_test_case.rb | 30 --------------------- Library/Homebrew/test/support/helper/test_case.rb | 31 +++++++++++++++++++++- Library/Homebrew/test/tab_test.rb | 5 ---- Library/Homebrew/test/tap_test.rb | 5 ---- Library/Homebrew/test/uninstall_test.rb | 4 --- 16 files changed, 32 insertions(+), 121 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/checksum_verification_test.rb b/Library/Homebrew/test/checksum_verification_test.rb index ad7dfb462..4c674edd2 100644 --- a/Library/Homebrew/test/checksum_verification_test.rb +++ b/Library/Homebrew/test/checksum_verification_test.rb @@ -17,11 +17,6 @@ class ChecksumVerificationTests < Homebrew::TestCase end end - def teardown - @_f.clear_cache - super - end - def test_good_sha256 formula do sha256 TESTBALL_SHA256 diff --git a/Library/Homebrew/test/cleaner_test.rb b/Library/Homebrew/test/cleaner_test.rb index 413925dfa..05a91b90b 100644 --- a/Library/Homebrew/test/cleaner_test.rb +++ b/Library/Homebrew/test/cleaner_test.rb @@ -11,11 +11,6 @@ class CleanerTests < Homebrew::TestCase @f.prefix.mkpath end - def teardown - @f.rack.rmtree if @f.rack.exist? - super - end - def test_clean_file @f.bin.mkpath @f.lib.mkpath diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index fa69ec64e..604671b1e 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -149,11 +149,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase mkpath @cached_location end - def teardown - rmtree @cached_location - super - end - def git_commit_all shutup do system "git", "add", "--all" diff --git a/Library/Homebrew/test/formula_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb index d5bd0d07c..13244555d 100644 --- a/Library/Homebrew/test/formula_lock_test.rb +++ b/Library/Homebrew/test/formula_lock_test.rb @@ -10,7 +10,6 @@ class FormulaLockTests < Homebrew::TestCase def teardown @lock.unlock - HOMEBREW_LOCK_DIR.children.each(&:unlink) super end diff --git a/Library/Homebrew/test/formula_pin_test.rb b/Library/Homebrew/test/formula_pin_test.rb index 5dd2bd29e..7e3c7efa0 100644 --- a/Library/Homebrew/test/formula_pin_test.rb +++ b/Library/Homebrew/test/formula_pin_test.rb @@ -48,9 +48,4 @@ class FormulaPinTests < Homebrew::TestCase refute_predicate @pin, :pinned? refute_predicate HOMEBREW_PINNED_KEGS, :directory? end - - def teardown - @f.rack.rmtree - super - end end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 8293768fe..1a1fe562e 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -961,12 +961,6 @@ class OutdatedVersionsTests < Homebrew::TestCase @old_alias_target_prefix = HOMEBREW_CELLAR/"#{old_formula.name}/1.0" end - def teardown - formulae = [@f, @old_formula, @new_formula] - formulae.map(&:rack).select(&:exist?).each(&:rmtree) - super - end - def alias_path "#{@f.tap.alias_dir}/bar" end diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index 2ed5cd3f0..f1fad404c 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -40,11 +40,6 @@ class FormularyFactoryTest < Homebrew::TestCase EOS end - def teardown - @path.unlink - super - end - def test_factory assert_kind_of Formula, Formulary.factory(@name) end @@ -142,11 +137,6 @@ class FormularyTapFactoryTest < Homebrew::TestCase @path.write @code end - def teardown - @tap.path.rmtree - super - end - def test_factory_tap_formula assert_kind_of Formula, Formulary.factory(@name) end @@ -191,12 +181,6 @@ class FormularyTapPriorityTest < Homebrew::TestCase @tap_path.write code end - def teardown - @core_path.unlink - @tap.path.rmtree - super - end - def test_find_with_priority_core_formula formula = Formulary.find_with_priority(@name) assert_kind_of Formula, formula diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 08bda4699..8f4cc44d9 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -36,16 +36,9 @@ class LinkTestCase < Homebrew::TestCase end def teardown - @kegs.each do |keg| - keg.unlink - keg.uninstall - end - + @kegs.each(&:unlink) $stdout = @old_stdout - - rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" - super end end diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb index 53151f3e3..84708a502 100644 --- a/Library/Homebrew/test/migrator_test.rb +++ b/Library/Homebrew/test/migrator_test.rb @@ -72,31 +72,15 @@ class MigratorTests < Homebrew::TestCase end def teardown - @old_pin.unlink if @old_pin.symlink? - - if @old_keg_record.parent.symlink? - @old_keg_record.parent.unlink - elsif @old_keg_record.directory? + if !@old_keg_record.parent.symlink? && @old_keg_record.directory? @keg.unlink - @keg.uninstall end if @new_keg_record.directory? new_keg = Keg.new(@new_keg_record) new_keg.unlink - new_keg.uninstall end - @old_keg_record.parent.rmtree if @old_keg_record.parent.directory? - @new_keg_record.parent.rmtree if @new_keg_record.parent.directory? - - rmtree HOMEBREW_PREFIX/"bin" - rmtree HOMEBREW_PREFIX/"opt" if (HOMEBREW_PREFIX/"opt").directory? - # What to do with pin? - @new_f.unpin - - HOMEBREW_LOCK_DIR.children.each(&:unlink) - super end diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb index 5f215bd06..a2b6b2d50 100644 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ b/Library/Homebrew/test/os/mac/keg_test.rb @@ -30,11 +30,9 @@ class OSMacLinkTests < Homebrew::TestCase def teardown @keg.unlink - @keg.uninstall $stdout = @old_stdout - rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" super diff --git a/Library/Homebrew/test/patching_test.rb b/Library/Homebrew/test/patching_test.rb index eadab15dc..3dacc0818 100644 --- a/Library/Homebrew/test/patching_test.rb +++ b/Library/Homebrew/test/patching_test.rb @@ -20,12 +20,6 @@ class PatchingTests < Homebrew::TestCase end end - def teardown - @_f.clear_cache - @_f.patchlist.each { |p| p.clear_cache if p.external? } - super - end - def assert_patched(formula) shutup do formula.brew do diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index 86184ac51..a36b56691 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -12,36 +12,6 @@ class IntegrationCommandTestCase < Homebrew::TestCase FileUtils.touch HOMEBREW_PREFIX/"bin/brew" end - def teardown - coretap = CoreTap.new - paths_to_delete = [ - HOMEBREW_LINKED_KEGS, - HOMEBREW_PINNED_KEGS, - HOMEBREW_CELLAR.children, - HOMEBREW_CACHE.children, - HOMEBREW_LOCK_DIR.children, - HOMEBREW_LOGS.children, - HOMEBREW_TEMP.children, - HOMEBREW_PREFIX/".git", - HOMEBREW_PREFIX/"bin", - HOMEBREW_PREFIX/"share", - HOMEBREW_PREFIX/"opt", - HOMEBREW_PREFIX/"Caskroom", - HOMEBREW_LIBRARY/"Taps/caskroom", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", - HOMEBREW_REPOSITORY/".git", - coretap.path/".git", - coretap.alias_dir, - coretap.formula_dir.children, - coretap.path/"formula_renames.json", - ].flatten - FileUtils.rm_rf paths_to_delete - super - end - def needs_test_cmd_taps return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set" diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index ebe5d3d22..53d4e7031 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -20,8 +20,37 @@ module Homebrew end def teardown - Tab.clear_cache ARGV.replace(@__argv) + + Tab.clear_cache + + coretap = CoreTap.new + paths_to_delete = [ + HOMEBREW_LINKED_KEGS, + HOMEBREW_PINNED_KEGS, + HOMEBREW_CELLAR.children, + HOMEBREW_CACHE.children, + HOMEBREW_LOCK_DIR.children, + HOMEBREW_LOGS.children, + HOMEBREW_TEMP.children, + HOMEBREW_PREFIX/".git", + HOMEBREW_PREFIX/"bin", + HOMEBREW_PREFIX/"share", + HOMEBREW_PREFIX/"opt", + HOMEBREW_PREFIX/"Caskroom", + HOMEBREW_LIBRARY/"Taps/caskroom", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", + HOMEBREW_REPOSITORY/".git", + coretap.path/".git", + coretap.alias_dir, + coretap.formula_dir.children, + coretap.path/"formula_renames.json", + ].flatten + FileUtils.rm_rf paths_to_delete + super end diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index 5a354a908..f6f55348d 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -269,11 +269,6 @@ class TabLoadingTests < Homebrew::TestCase @path.write TEST_FIXTURE_DIR.join("receipt.json").read end - def teardown - @f.rack.rmtree - super - end - def test_for_keg tab = Tab.for_keg(@f.prefix) assert_equal @path, tab.tabfile diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 4990bc6df..0e07927fc 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -85,11 +85,6 @@ class TapTest < Homebrew::TestCase ENV.replace(env) end - def teardown - @path.rmtree - super - end - def test_fetch assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew") tap = Tap.fetch("Homebrew", "foo") diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index b517836e8..2f8bf4fff 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -30,10 +30,6 @@ class UninstallTests < Homebrew::TestCase def teardown Homebrew.failed = false - [@dependency, @dependent].each do |f| - f.installed_kegs.each(&:remove_opt_record) - f.rack.rmtree - end super end -- cgit v1.2.3 From 1aee7c6945c3cbbbbfa2830bb1cf6bf39d4702be Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:55:42 +0000 Subject: tests: remove explicit tmpdir deletions These are no longer necessary. --- Library/Homebrew/test/audit_test.rb | 10 ---------- Library/Homebrew/test/language_python_test.rb | 5 ----- Library/Homebrew/test/pathname_test.rb | 6 ------ Library/Homebrew/test/sandbox_test.rb | 5 ----- Library/Homebrew/test/utils_test.rb | 1 - 5 files changed, 27 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index 0b13d3c2b..f8d137482 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -10,11 +10,6 @@ class FormulaTextTests < Homebrew::TestCase @dir = mktmpdir end - def teardown - FileUtils.rm_rf @dir - super - end - def formula_text(name, body = nil, options = {}) path = Pathname.new "#{@dir}/#{name}.rb" path.open("w") do |f| @@ -64,11 +59,6 @@ class FormulaAuditorTests < Homebrew::TestCase @dir = mktmpdir end - def teardown - FileUtils.rm_rf @dir - super - end - def formula_auditor(name, text, options = {}) path = Pathname.new "#{@dir}/#{name}.rb" path.open("w") do |f| diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb index 0a6d1eeaa..aa0a7d51d 100644 --- a/Library/Homebrew/test/language_python_test.rb +++ b/Library/Homebrew/test/language_python_test.rb @@ -15,11 +15,6 @@ class LanguagePythonTests < Homebrew::TestCase @venv = Language::Python::Virtualenv::Virtualenv.new(@formula, @dir, "python") end - def teardown - FileUtils.rm_rf @dir - super - end - def test_virtualenv_creation @formula.expects(:resource).with("homebrew-virtualenv").returns( mock("resource", stage: true) diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb index 2f4002b00..b48a26fbd 100644 --- a/Library/Homebrew/test/pathname_test.rb +++ b/Library/Homebrew/test/pathname_test.rb @@ -13,12 +13,6 @@ module PathnameTestExtension @file = @src/"foo" @dir = @src/"bar" end - - def teardown - rmtree(@src) - rmtree(@dst) - super - end end class PathnameTests < Homebrew::TestCase diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 96558afa4..2e97b5d6a 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -10,11 +10,6 @@ class SandboxTest < Homebrew::TestCase @file = @dir/"foo" end - def teardown - @dir.rmtree - super - end - def test_formula? f = formula { url "foo-1.0" } f2 = formula { url "bar-1.0" } diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 310bfb135..7099e332c 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -11,7 +11,6 @@ class UtilTests < Homebrew::TestCase end def teardown - @dir.rmtree ENV.replace @env super end -- cgit v1.2.3 From 6861451f87316ce339af55eaa8e63e5ef8c5021b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 16:15:48 +0000 Subject: tests: remove more per-test file system cleanup These locations are now all automatically cleaned up after every test. --- Library/Homebrew/test/ARGV_test.rb | 2 -- Library/Homebrew/test/cleanup_test.rb | 3 -- Library/Homebrew/test/diagnostic_test.rb | 2 -- Library/Homebrew/test/formula_installer_test.rb | 4 --- Library/Homebrew/test/formula_test.rb | 38 ------------------------- Library/Homebrew/test/formulary_test.rb | 9 ------ Library/Homebrew/test/gpg_test.rb | 2 -- Library/Homebrew/test/install_test.rb | 1 - Library/Homebrew/test/keg_test.rb | 6 ---- Library/Homebrew/test/migrator_test.rb | 2 -- Library/Homebrew/test/os/mac/keg_test.rb | 2 -- Library/Homebrew/test/tap_test.rb | 7 ----- Library/Homebrew/test/versions_test.rb | 2 -- 13 files changed, 80 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb index 06660defc..e93d09c39 100644 --- a/Library/Homebrew/test/ARGV_test.rb +++ b/Library/Homebrew/test/ARGV_test.rb @@ -22,8 +22,6 @@ class ArgvExtensionTests < Homebrew::TestCase keg.mkpath @argv << "mxcl" assert_equal 1, @argv.kegs.length - ensure - keg.parent.rmtree end def test_argv_named diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index 03ad6871e..8a292933a 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -55,9 +55,6 @@ class CleanupTests < Homebrew::TestCase refute_predicate f1, :installed? refute_predicate f2, :installed? assert_predicate f3, :installed? - ensure - [f1, f2, f3].each(&:clear_cache) - f3.rack.rmtree end def test_cleanup_logs diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index 608dda099..2d1286827 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -105,8 +105,6 @@ class DiagnosticChecksTest < Homebrew::TestCase assert_match "/usr/bin occurs before #{HOMEBREW_PREFIX}/bin", @checks.check_user_path_1 - ensure - bin.rmtree end def test_check_user_path_bin diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb index 5467be98a..c99b2de74 100644 --- a/Library/Homebrew/test/formula_installer_test.rb +++ b/Library/Homebrew/test/formula_installer_test.rb @@ -125,11 +125,7 @@ class FormulaInstallerTests < Homebrew::TestCase fi = FormulaInstaller.new(dependent) assert_raises(CannotInstallFormulaError) { fi.check_install_sanity } ensure - dependency.unpin dependency_keg.unlink - dependency_keg.uninstall - dependency.clear_cache - dep_path.unlink Formulary::FORMULAE.delete(dep_path) end end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 1a1fe562e..a04342311 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -176,8 +176,6 @@ class FormulaTests < Homebrew::TestCase prefix.mkpath FileUtils.touch prefix+Tab::FILENAME assert_predicate f, :any_version_installed? - ensure - f.rack.rmtree end def test_migration_needed @@ -203,9 +201,6 @@ class FormulaTests < Homebrew::TestCase newname_prefix.mkpath refute_predicate f, :migration_needed? - ensure - oldname_prefix.parent.rmtree - newname_prefix.parent.rmtree end def test_installed? @@ -240,8 +235,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR+f.name+f.head.version prefix.mkpath assert_equal prefix, f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_devel_installed @@ -255,8 +248,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR+f.name+f.devel.version prefix.mkpath assert_equal prefix, f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_stable_installed @@ -270,8 +261,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR+f.name+f.version prefix.mkpath assert_equal prefix, f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_outdated_stable_head_installed @@ -289,8 +278,6 @@ class FormulaTests < Homebrew::TestCase tab.write assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_outdated_devel_head_installed @@ -311,8 +298,6 @@ class FormulaTests < Homebrew::TestCase tab.write assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_head @@ -358,8 +343,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD-222222_2" assert_equal prefix, f.latest_head_prefix - ensure - f.rack.rmtree end def test_equality @@ -571,7 +554,6 @@ class FormulaTests < Homebrew::TestCase assert_equal Version.create("HEAD-5658946"), f.head.version ensure ENV.replace(initial_env) - cached_location.rmtree end def test_legacy_options @@ -771,9 +753,6 @@ class FormulaTests < Homebrew::TestCase assert_equal f3.installed_kegs.sort_by(&:version)[0..1], f3.eligible_kegs_for_cleanup.sort_by(&:version) - ensure - [f1, f2, f3].each(&:clear_cache) - f3.rack.rmtree end def test_eligible_kegs_for_cleanup_keg_pinned @@ -795,10 +774,6 @@ class FormulaTests < Homebrew::TestCase assert_predicate f3, :installed? assert_equal [Keg.new(f2.prefix)], shutup { f3.eligible_kegs_for_cleanup } - ensure - f1.unpin - [f1, f2, f3].each(&:clear_cache) - f3.rack.rmtree end def test_eligible_kegs_for_cleanup_head_installed @@ -821,8 +796,6 @@ class FormulaTests < Homebrew::TestCase eligible_kegs = f.installed_kegs - [Keg.new(f.prefix("HEAD-111111_1"))] assert_equal eligible_kegs, f.eligible_kegs_for_cleanup - ensure - f.rack.rmtree end def test_pour_bottle @@ -1173,11 +1146,6 @@ class OutdatedVersionsTests < Homebrew::TestCase ensure ENV.replace(initial_env) testball_repo.rmtree if testball_repo.exist? - outdated_stable_prefix.rmtree if outdated_stable_prefix.exist? - head_prefix_b.rmtree if head_prefix.exist? - head_prefix_c.rmtree if head_prefix_c.exist? - FileUtils.rm_rf HOMEBREW_CACHE/"testball--git" - FileUtils.rm_rf HOMEBREW_CELLAR/"testball" end def test_outdated_kegs_version_scheme_changed @@ -1191,8 +1159,6 @@ class OutdatedVersionsTests < Homebrew::TestCase setup_tab_for_prefix(prefix, versions: { "stable" => "0.1" }) refute_predicate f.outdated_kegs, :empty? - ensure - prefix.rmtree end def test_outdated_kegs_mixed_version_schemes @@ -1220,8 +1186,6 @@ class OutdatedVersionsTests < Homebrew::TestCase prefix_d = HOMEBREW_CELLAR.join("testball/20141011") setup_tab_for_prefix(prefix_d, versions: { "stable" => "20141009", "version_scheme" => 3 }) assert_predicate f.outdated_kegs, :empty? - ensure - f.rack.rmtree end def test_outdated_kegs_head_with_version_scheme @@ -1241,7 +1205,5 @@ class OutdatedVersionsTests < Homebrew::TestCase setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 2 }) assert_predicate f.outdated_kegs, :empty? - ensure - head_prefix.rmtree end end diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index f1fad404c..ea7ecf8d0 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -58,8 +58,6 @@ class FormularyFactoryTest < Homebrew::TestCase path.write "class Wrong#{Formulary.class_s(name)} < Formula\nend\n" assert_raises(FormulaClassUnavailableError) { Formulary.factory(name) } - ensure - path.unlink end def test_factory_from_path @@ -87,8 +85,6 @@ class FormularyFactoryTest < Homebrew::TestCase result = Formulary.factory("foo") assert_kind_of Formula, result assert_equal alias_path.to_s, result.alias_path - ensure - alias_dir.rmtree end def test_factory_from_rack_and_from_keg @@ -104,9 +100,6 @@ class FormularyFactoryTest < Homebrew::TestCase assert_kind_of Tab, f.build ensure keg.unlink - keg.uninstall - formula.clear_cache - formula.bottle.clear_cache end def test_load_from_contents @@ -118,8 +111,6 @@ class FormularyFactoryTest < Homebrew::TestCase (HOMEBREW_CELLAR/@name).mkpath assert_equal HOMEBREW_CELLAR/@name, Formulary.to_rack(@name) assert_raises(TapFormulaUnavailableError) { Formulary.to_rack("a/b/#{@name}") } - ensure - FileUtils.rm_rf HOMEBREW_CELLAR/@name end end diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb index 881468ad2..d3a637297 100644 --- a/Library/Homebrew/test/gpg_test.rb +++ b/Library/Homebrew/test/gpg_test.rb @@ -15,7 +15,5 @@ class GpgTest < Homebrew::TestCase assert_predicate @dir/".gnupg/secring.gpg", :exist? end end - ensure - @dir.rmtree end end diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index e047c0030..fa0ef5ffe 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -113,7 +113,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase ensure ENV.replace(initial_env) - repo_path.rmtree end def test_install_with_invalid_option diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 8f4cc44d9..bd4232038 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -298,8 +298,6 @@ class LinkTests < LinkTestCase assert_equal 2, lib.children.length ensure a.unlink - a.uninstall - b.uninstall end def test_removes_broken_symlinks_that_conflict_with_directories @@ -315,7 +313,6 @@ class LinkTests < LinkTestCase keg.link ensure keg.unlink - keg.uninstall end end @@ -427,9 +424,6 @@ class InstalledDependantsTests < LinkTestCase result = Keg.find_some_installed_dependents([renamed_keg]) assert_equal [[renamed_keg], ["bar"]], result - ensure - # Move it back to where it was so it'll be cleaned up. - (HOMEBREW_CELLAR/"foo-old").rename(HOMEBREW_CELLAR/"foo") end def test_empty_dependencies_in_tab diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb index 84708a502..012ea12bb 100644 --- a/Library/Homebrew/test/migrator_test.rb +++ b/Library/Homebrew/test/migrator_test.rb @@ -32,8 +32,6 @@ class MigratorErrorsTests < Homebrew::TestCase tab.source["tap"] = "homebrew/core" tab.write assert_raises(Migrator::MigratorDifferentTapsError) { Migrator.new(@new_f) } - ensure - keg.parent.rmtree end end diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb index a2b6b2d50..d1103415d 100644 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ b/Library/Homebrew/test/os/mac/keg_test.rb @@ -50,7 +50,6 @@ class OSMacLinkTests < Homebrew::TestCase assert_equal 1, keg.mach_o_files.size ensure keg.unlink - keg.uninstall end def test_mach_o_files_isnt_confused_by_symlinks @@ -66,6 +65,5 @@ class OSMacLinkTests < Homebrew::TestCase assert_equal 1, keg.mach_o_files.size ensure keg.unlink - keg.uninstall end end diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 0e07927fc..2ab003fd2 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -168,8 +168,6 @@ class TapTest < Homebrew::TestCase end end refute_predicate services_tap, :private? - ensure - services_tap.path.rmtree if services_tap end def test_remote_not_git_repo @@ -253,8 +251,6 @@ class TapTest < Homebrew::TestCase refute_predicate tap, :installed? refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist? refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist? - ensure - (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? end def test_pin_and_unpin @@ -320,8 +316,5 @@ class CoreTapTest < Homebrew::TestCase assert_equal ["bar"], @repo.aliases assert_equal @repo.alias_table, "bar" => "foo" assert_equal @repo.alias_reverse_table, "foo" => ["bar"] - ensure - @formula_file.unlink - @repo.alias_dir.rmtree end end diff --git a/Library/Homebrew/test/versions_test.rb b/Library/Homebrew/test/versions_test.rb index a6e922178..b6814b1d1 100644 --- a/Library/Homebrew/test/versions_test.rb +++ b/Library/Homebrew/test/versions_test.rb @@ -185,8 +185,6 @@ class VersionParsingTests < Homebrew::TestCase d = HOMEBREW_CELLAR/"foo-0.1.9" d.mkpath assert_equal version("0.1.9"), d.version - ensure - d.unlink end def test_no_version -- cgit v1.2.3 From 22f294af90ed08e2da9d0652fdc9c560c7797bed Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sun, 22 Jan 2017 19:50:14 +0800 Subject: bottle: fix regex Noted that this is intended for the revision of this formula instead of rebuild of a bottle. --- Library/Homebrew/dev-cmd/bottle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 75078cffd..7367e5c37 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -443,7 +443,7 @@ module Homebrew (\n^\ {3}[\S\ ]+$)* # options can be in multiple lines )?| (homepage|desc|sha1|sha256|version|mirror)\ ['"][\S\ ]+['"]| # specs with a string - rebuild\ \d+ # rebuild with a number + revision\ \d+ # revision with a number )\n+ # multiple empty lines )+ /mx, '\0' + output + "\n" -- cgit v1.2.3 From 6e0f1366b014b285799c9bb9c311c6345bcd666b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 14:56:58 +0000 Subject: tests: extract a common using_git_env method --- Library/Homebrew/test/download_strategies_test.rb | 12 ------ Library/Homebrew/test/formula_test.rb | 46 ++++++++--------------- Library/Homebrew/test/install_test.rb | 28 +++++--------- Library/Homebrew/test/support/helper/env.rb | 28 +++++++++++--- Library/Homebrew/test/tap_test.rb | 23 ++++-------- 5 files changed, 57 insertions(+), 80 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 604671b1e..0a2068bd9 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -157,18 +157,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase end end - def using_git_env - initial_env = ENV.to_hash - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - yield - ensure - ENV.replace(initial_env) - end - def setup_git_repo using_git_env do @cached_location.cd do diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index a04342311..74db4ad6c 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -526,8 +526,6 @@ class FormulaTests < Homebrew::TestCase end def test_update_head_version - initial_env = ENV.to_hash - f = formula do head "foo", using: :git end @@ -535,25 +533,19 @@ class FormulaTests < Homebrew::TestCase cached_location = f.head.downloader.cached_location cached_location.mkpath - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - - cached_location.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" + using_git_env do + cached_location.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" + end end end f.update_head_version assert_equal Version.create("HEAD-5658946"), f.head.version - ensure - ENV.replace(initial_env) end def test_legacy_options @@ -1104,7 +1096,6 @@ class OutdatedVersionsTests < Homebrew::TestCase tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" }) setup_tab_for_prefix(head_prefix_b) - initial_env = ENV.to_hash testball_repo = HOMEBREW_PREFIX.join("testball_repo") testball_repo.mkdir @@ -1114,18 +1105,14 @@ class OutdatedVersionsTests < Homebrew::TestCase head "file://#{testball_repo}", using: :git end - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - - testball_repo.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" + using_git_env do + testball_repo.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" + end end end @@ -1144,7 +1131,6 @@ class OutdatedVersionsTests < Homebrew::TestCase reset_outdated_kegs assert_predicate f.outdated_kegs(fetch_head: true), :empty? ensure - ENV.replace(initial_env) testball_repo.rmtree if testball_repo.exist? end diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index fa0ef5ffe..2ca5bf4ca 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -73,24 +73,19 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase end def test_install_head_installed - initial_env = ENV.to_hash - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - repo_path = HOMEBREW_CACHE.join("repo") repo_path.join("bin").mkpath - repo_path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - FileUtils.touch "bin/something.bin" - FileUtils.touch "README" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial repo commit" + using_git_env do + repo_path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + FileUtils.touch "bin/something.bin" + FileUtils.touch "README" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial repo commit" + end end end @@ -110,9 +105,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase cmd("install", "testball1", "--HEAD", "--ignore-dependencies") assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("unlink", "testball1") assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1") - - ensure - ENV.replace(initial_env) end def test_install_with_invalid_option diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 904a1d4c7..6c69b335d 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -1,14 +1,32 @@ module Test module Helper module Env + def copy_env + ENV.to_hash + end + + def restore_env(env) + ENV.replace(env) + end + def with_environment(partial_env) - old = ENV.to_hash + old = copy_env ENV.update partial_env - begin - yield - ensure - ENV.replace old + yield + ensure + restore_env old + end + + def using_git_env + initial_env = copy_env + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" end + yield + ensure + restore_env initial_env end end end diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 2ab003fd2..6656017f3 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -66,23 +66,16 @@ class TapTest < Homebrew::TestCase end def setup_git_repo - env = ENV.to_hash - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - - @path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - system "git", "add", "--all" - system "git", "commit", "-m", "init" + using_git_env do + @path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + system "git", "add", "--all" + system "git", "commit", "-m", "init" + end end end - ensure - ENV.replace(env) end def test_fetch -- cgit v1.2.3 From 116ed3ec80b6d1b9d6178f25793cfcaaaa161308 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 14:57:44 +0000 Subject: tests: automatically restore ENV in teardown --- Library/Homebrew/test/audit_test.rb | 3 --- Library/Homebrew/test/commands_test.rb | 4 ---- Library/Homebrew/test/diagnostic_test.rb | 6 ------ Library/Homebrew/test/os/mac/diagnostic_test.rb | 6 ------ Library/Homebrew/test/shell_test.rb | 3 --- Library/Homebrew/test/support/helper/test_case.rb | 3 +++ Library/Homebrew/test/utils_test.rb | 6 ------ 7 files changed, 3 insertions(+), 28 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index f8d137482..75a882d69 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -361,13 +361,10 @@ class FormulaAuditorTests < Homebrew::TestCase end EOS - original_value = ENV["HOMEBREW_NO_GITHUB_API"] ENV["HOMEBREW_NO_GITHUB_API"] = "1" fa.audit_github_repository assert_equal [], fa.problems - ensure - ENV["HOMEBREW_NO_GITHUB_API"] = original_value end def test_audit_caveats diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb index 3d7c16e58..5f5dc9586 100644 --- a/Library/Homebrew/test/commands_test.rb +++ b/Library/Homebrew/test/commands_test.rb @@ -47,8 +47,6 @@ class CommandsTests < Homebrew::TestCase end def test_external_commands - env = ENV.to_hash - mktmpdir do |dir| %w[brew-t1 brew-t2.rb brew-t3.py].each do |file| path = "#{dir}/#{file}" @@ -67,8 +65,6 @@ class CommandsTests < Homebrew::TestCase "Executable files with a non Ruby extension shoudn't be included" refute cmds.include?("t4"), "Non-executable files shouldn't be included" end - ensure - ENV.replace(env) end def test_internal_command_path diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index 2d1286827..7a1fb25f7 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -6,15 +6,9 @@ require "diagnostic" class DiagnosticChecksTest < Homebrew::TestCase def setup super - @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end - def teardown - ENV.replace(@env) - super - end - def test_inject_file_list assert_equal "foo:\n", @checks.inject_file_list([], "foo:\n") diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 284d293ca..5f467e87b 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -6,15 +6,9 @@ require "diagnostic" class OSMacDiagnosticChecksTest < Homebrew::TestCase def setup super - @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end - def teardown - ENV.replace(@env) - super - end - def test_check_for_other_package_managers MacOS.stubs(:macports_or_fink).returns ["fink"] assert_match "You have MacPorts or Fink installed:", diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb index 877acb5c8..a32d09863 100644 --- a/Library/Homebrew/test/shell_test.rb +++ b/Library/Homebrew/test/shell_test.rb @@ -37,7 +37,6 @@ class ShellSmokeTest < Homebrew::TestCase end def prepend_path_shell(shell, path, fragment) - original_shell = ENV["SHELL"] ENV["SHELL"] = shell prepend_message = Utils::Shell.prepend_path_in_shell_profile(path) @@ -45,8 +44,6 @@ class ShellSmokeTest < Homebrew::TestCase prepend_message.start_with?(fragment), "#{shell}: expected #{prepend_message} to match #{fragment}" ) - - ENV["SHELL"] = original_shell end def test_prepend_path_in_shell_profile diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 53d4e7031..c4c7f8727 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -16,11 +16,14 @@ module Homebrew def setup super + @__argv = ARGV.dup + @__env = copy_env # Call #to_hash to duplicate ENV end def teardown ARGV.replace(@__argv) + restore_env @__env Tab.clear_cache diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7099e332c..7ff4e192a 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -7,12 +7,6 @@ class UtilTests < Homebrew::TestCase def setup super @dir = Pathname.new(mktmpdir) - @env = ENV.to_hash - end - - def teardown - ENV.replace @env - super end def test_ofail -- cgit v1.2.3 From 0c1d665568875ffccb660a65ff248b7ab98ec77c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:11:49 +0000 Subject: tests: set developer in ENV rather than stubbing --- Library/Homebrew/test/audit_test.rb | 6 +++--- Library/Homebrew/test/os/mac/diagnostic_test.rb | 2 +- Library/Homebrew/test/utils_test.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index 75a882d69..60cf27610 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -243,7 +243,7 @@ class FormulaAuditorTests < Homebrew::TestCase needs_compat require "compat/formula_specialties" - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") fa = shutup do formula_auditor "foo", <<-EOS.undent class Foo < GithubGistFormula @@ -260,7 +260,7 @@ class FormulaAuditorTests < Homebrew::TestCase needs_compat require "compat/formula_specialties" - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") fa = formula_auditor "foo", <<-EOS.undent class Foo < ScriptFileFormula url "http://example.com/foo-1.0.tgz" @@ -275,7 +275,7 @@ class FormulaAuditorTests < Homebrew::TestCase needs_compat require "compat/formula_specialties" - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") fa = formula_auditor "foo", <<-EOS.undent class Foo < AmazonWebServicesFormula url "http://example.com/foo-1.0.tgz" diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 5f467e87b..704235b01 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -16,7 +16,7 @@ class OSMacDiagnosticChecksTest < Homebrew::TestCase end def test_check_for_unsupported_macos - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") OS::Mac.stubs(:prerelease?).returns true assert_match "We do not provide support for this pre-release version.", @checks.check_for_unsupported_macos diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7ff4e192a..520cd4fcd 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -207,7 +207,7 @@ class UtilTests < Homebrew::TestCase end def test_odeprecated - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") e = assert_raises(MethodDeprecatedError) do odeprecated("method", "replacement", caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], -- cgit v1.2.3 From a736c7e3173fd7a9727026b5b968ac5f067a906d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:16:32 +0000 Subject: tests: set verbose in ENV instead of stubbing ARGV --- Library/Homebrew/test/sandbox_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 2e97b5d6a..21a3ca8c4 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -47,7 +47,7 @@ class SandboxTest < Homebrew::TestCase def test_complains_on_failure Utils.expects(popen_read: "foo") - ARGV.stubs(verbose?: true) + ENV["HOMEBREW_VERBOSE"] = "1" out, _err = capture_io do assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } end @@ -61,7 +61,7 @@ class SandboxTest < Homebrew::TestCase bar EOS Utils.expects(popen_read: with_bogus_error) - ARGV.stubs(verbose?: true) + ENV["HOMEBREW_VERBOSE"] = "1" out, _err = capture_io do assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } end -- cgit v1.2.3 From 1e1de8c111b5c3a36e4bdf886d6f2e736890ba56 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:46:28 +0000 Subject: tests: remove remainder of ARGV stubs I was waiting for confirmation that there wasn't a good reason for these to be stubbed before I removed them. --- Library/Homebrew/test/sandbox_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 21a3ca8c4..a633defce 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -15,11 +15,11 @@ class SandboxTest < Homebrew::TestCase f2 = formula { url "bar-1.0" } f2.stubs(:tap).returns(Tap.fetch("test/tap")) - ARGV.stubs(:sandbox?).returns true + ENV["HOMEBREW_SANDBOX"] = "1" assert Sandbox.formula?(f), "Formulae should be sandboxed if --sandbox was passed." - ARGV.stubs(:sandbox?).returns false + ENV.delete("HOMEBREW_SANDBOX") assert Sandbox.formula?(f), "Formulae should be sandboxed if in a sandboxed tap." refute Sandbox.formula?(f2), @@ -27,7 +27,7 @@ class SandboxTest < Homebrew::TestCase end def test_test? - ARGV.stubs(:no_sandbox?).returns false + ENV.delete("HOMEBREW_NO_SANDBOX") assert Sandbox.test?, "Tests should be sandboxed unless --no-sandbox was passed." end -- cgit v1.2.3 From cbc9e5dd3b0b47a98e3976ae1683641dbe94b57d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 11:10:06 +0000 Subject: tests: re-use with_environment in using_git_env Proposed by @reitermarkus in https://github.com/Homebrew/brew/pull/1890#discussion_r97210285. I made one slight adjustment of preserving the previous date string in case anything was relying on it. --- Library/Homebrew/test/support/helper/env.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 6c69b335d..7e6429e74 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -18,15 +18,15 @@ module Test end def using_git_env - initial_env = copy_env - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env| + env["GIT_#{role}_NAME"] = "brew tests" + env["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + env["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + + with_environment(git_env) do + yield end - yield - ensure - restore_env initial_env end end end -- cgit v1.2.3 From 9c3d01c682056367f59d557720c7a08ca67f48c4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 22 Jan 2017 19:59:13 +0000 Subject: tests: remove unnecessary comment See https://github.com/Homebrew/brew/pull/1890#discussion_r97229473. --- Library/Homebrew/test/support/helper/test_case.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index c4c7f8727..801fa08c7 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -18,7 +18,7 @@ module Homebrew super @__argv = ARGV.dup - @__env = copy_env # Call #to_hash to duplicate ENV + @__env = copy_env end def teardown -- cgit v1.2.3 From b53ce62ffb193748266c63d7b13fd023c0764ff0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 22 Jan 2017 20:45:15 +0000 Subject: tests: use more recent git committer date This will allow the `brew bundle` test to use the default git environment. --- Library/Homebrew/test/download_strategies_test.rb | 6 +++--- Library/Homebrew/test/formula_test.rb | 2 +- Library/Homebrew/test/install_test.rb | 6 +++--- Library/Homebrew/test/support/helper/env.rb | 2 +- Library/Homebrew/test/tap_test.rb | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 0a2068bd9..3c4272c74 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -180,7 +180,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase def test_source_modified_time setup_git_repo - assert_equal 1_242_860_651, @strategy.source_modified_time.to_i + assert_equal 1_485_115_153, @strategy.source_modified_time.to_i end def test_last_commit @@ -191,7 +191,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase git_commit_all end end - assert_equal "c50c79b", @strategy.last_commit + assert_equal "f68266e", @strategy.last_commit end def test_fetch_last_commit @@ -216,7 +216,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase end @strategy.shutup! - assert_equal "c50c79b", @strategy.fetch_last_commit + assert_equal "f68266e", @strategy.fetch_last_commit ensure remote_repo.rmtree if remote_repo.directory? end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 74db4ad6c..b06111370 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -1090,7 +1090,7 @@ class OutdatedVersionsTests < Homebrew::TestCase outdated_stable_prefix = HOMEBREW_CELLAR.join("testball/1.0") head_prefix_a = HOMEBREW_CELLAR.join("testball/HEAD") head_prefix_b = HOMEBREW_CELLAR.join("testball/HEAD-aaaaaaa_1") - head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-5658946") + head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-18a7103") setup_tab_for_prefix(outdated_stable_prefix) tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" }) diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index 2ca5bf4ca..3f3df6099 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -100,10 +100,10 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase # Ignore dependencies, because we'll try to resolve requirements in build.rb # and there will be the git requirement, but we cannot instantiate git # formula since we only have testball1 formula. - assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("install", "testball1", "--HEAD", "--ignore-dependencies") - assert_match "testball1-HEAD-2ccdf4f already installed", + assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("install", "testball1", "--HEAD", "--ignore-dependencies") + assert_match "testball1-HEAD-d5eb689 already installed", cmd("install", "testball1", "--HEAD", "--ignore-dependencies") - assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("unlink", "testball1") + assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("unlink", "testball1") assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1") end diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 7e6429e74..7958a041e 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -21,7 +21,7 @@ module Test git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env| env["GIT_#{role}_NAME"] = "brew tests" env["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - env["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + env["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" end with_environment(git_env) do diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 6656017f3..a268ab0ae 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -177,10 +177,10 @@ class TapTest < Homebrew::TestCase touch @path/"README" setup_git_repo - assert_equal "e1893a6bd191ba895c71b652ff8376a6114c7fa7", @tap.git_head - assert_equal "e189", @tap.git_short_head - assert_match "years ago", @tap.git_last_commit - assert_equal "2009-05-21", @tap.git_last_commit_date + assert_equal "0453e16c8e3fac73104da50927a86221ca0740c2", @tap.git_head + assert_equal "0453", @tap.git_short_head + assert_match "ago", @tap.git_last_commit + assert_equal "2017-01-22", @tap.git_last_commit_date end def test_private_remote -- cgit v1.2.3 From 19e61355b38b8ba96db0ca71849bb536af0490bf Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 22 Jan 2017 20:54:37 +0000 Subject: tests: remove with_git_env method A common git environment is now used in all tests, so this is no longer required. --- Library/Homebrew/dev-cmd/tests.rb | 1 + Library/Homebrew/test/download_strategies_test.rb | 40 ++++++++++------------- Library/Homebrew/test/formula_test.rb | 28 +++++++--------- Library/Homebrew/test/install_test.rb | 18 +++++----- Library/Homebrew/test/support/helper/env.rb | 12 ------- Library/Homebrew/test/tap_test.rb | 14 ++++---- 6 files changed, 44 insertions(+), 69 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index b4f3c2d40..05bdda8d2 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -34,6 +34,7 @@ module Homebrew %w[AUTHOR COMMITTER].each do |role| ENV["GIT_#{role}_NAME"] = "brew tests" ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" end Homebrew.install_gem_setup_path! "bundler" diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 3c4272c74..40236b420 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -158,15 +158,13 @@ class GitDownloadStrategyTests < Homebrew::TestCase end def setup_git_repo - using_git_env do - @cached_location.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - end - touch "README" - git_commit_all + @cached_location.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" end + touch "README" + git_commit_all end end @@ -185,11 +183,9 @@ class GitDownloadStrategyTests < Homebrew::TestCase def test_last_commit setup_git_repo - using_git_env do - @cached_location.cd do - touch "LICENSE" - git_commit_all - end + @cached_location.cd do + touch "LICENSE" + git_commit_all end assert_equal "f68266e", @strategy.last_commit end @@ -202,17 +198,15 @@ class GitDownloadStrategyTests < Homebrew::TestCase resource.instance_variable_set(:@version, Version.create("HEAD")) @strategy = GitDownloadStrategy.new("baz", resource) - using_git_env do - remote_repo.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - end - touch "README" - git_commit_all - touch "LICENSE" - git_commit_all + remote_repo.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" end + touch "README" + git_commit_all + touch "LICENSE" + git_commit_all end @strategy.shutup! diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index b06111370..ecdd1847b 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -533,14 +533,12 @@ class FormulaTests < Homebrew::TestCase cached_location = f.head.downloader.cached_location cached_location.mkpath - using_git_env do - cached_location.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" - end + cached_location.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" end end @@ -1105,14 +1103,12 @@ class OutdatedVersionsTests < Homebrew::TestCase head "file://#{testball_repo}", using: :git end - using_git_env do - testball_repo.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" - end + testball_repo.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" end end diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index 3f3df6099..da6c1863f 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -76,16 +76,14 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase repo_path = HOMEBREW_CACHE.join("repo") repo_path.join("bin").mkpath - using_git_env do - repo_path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - FileUtils.touch "bin/something.bin" - FileUtils.touch "README" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial repo commit" - end + repo_path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + FileUtils.touch "bin/something.bin" + FileUtils.touch "README" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial repo commit" end end diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 7958a041e..88b25e237 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -16,18 +16,6 @@ module Test ensure restore_env old end - - def using_git_env - git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env| - env["GIT_#{role}_NAME"] = "brew tests" - env["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - env["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" - end - - with_environment(git_env) do - yield - end - end end end end diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index a268ab0ae..9979be43d 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -66,14 +66,12 @@ class TapTest < Homebrew::TestCase end def setup_git_repo - using_git_env do - @path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - system "git", "add", "--all" - system "git", "commit", "-m", "init" - end + @path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + system "git", "add", "--all" + system "git", "commit", "-m", "init" end end end -- cgit v1.2.3 From 70a5ebafc43d4ffab162956301ef4bf972f52b3e Mon Sep 17 00:00:00 2001 From: Vítor Galvão Date: Mon, 23 Jan 2017 01:13:58 +0000 Subject: cask - internal_stanza: arguments to args --- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index e5c04ee51..41d72e42d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -50,12 +50,12 @@ module Hbc :uninstall_postflight, ] - def self.run(*arguments) - table = arguments.include? "--table" - quiet = arguments.include? "--quiet" - format = :to_yaml if arguments.include? "--yaml" - format = :inspect if arguments.include? "--inspect" - cask_tokens = arguments.reject { |arg| arg.chars.first == "-" } + def self.run(*args) + table = args.include? "--table" + quiet = args.include? "--quiet" + format = :to_yaml if args.include? "--yaml" + format = :inspect if args.include? "--inspect" + cask_tokens = args.reject { |arg| arg.chars.first == "-" } stanza = cask_tokens.shift.to_sym cask_tokens = Hbc.all_tokens if cask_tokens.empty? -- cgit v1.2.3 From 4ce6616f2eff36afb7ed3effc35f7ee0c108e266 Mon Sep 17 00:00:00 2001 From: Trevor Powell Date: Sun, 22 Jan 2017 22:52:11 -0600 Subject: Fix "Failed to eject" errors with DMGs Use "diskutil unmount force" to unmount DMGs.--- Library/Homebrew/cask/lib/hbc/container/dmg.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb index 987455ad7..49543844a 100644 --- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb @@ -45,10 +45,10 @@ module Hbc begin tries ||= 2 @command.run("/usr/sbin/diskutil", - args: ["eject", mountpath], + args: ["unmount", "force", mountpath], print_stderr: false) - raise CaskError, "Failed to eject #{mountpath}" if mountpath.exist? + raise CaskError, "Failed to unmount #{mountpath}" if mountpath.exist? rescue CaskError => e raise e if (tries -= 1).zero? sleep 1 -- cgit v1.2.3 From 16f4130dd81b45df697699f5bac7fa54489e8291 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 04:28:33 +0100 Subject: Add internal command to calculate appcast checkpoint. --- Library/Homebrew/cask/lib/hbc/audit.rb | 19 +++++---- Library/Homebrew/cask/lib/hbc/cli.rb | 1 + .../lib/hbc/cli/internal_appcast_checkpoint.rb | 45 ++++++++++++++++++++++ Library/Homebrew/cask/lib/hbc/dsl/appcast.rb | 20 ++++++++++ Library/Homebrew/cask/spec/cask/audit_spec.rb | 2 +- 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 955ecdbb0..12cefb939 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -133,20 +133,19 @@ module Hbc def check_appcast_checkpoint_accuracy odebug "Verifying appcast checkpoint is accurate" - result = @command.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, cask.appcast], print_stderr: false) - if result.success? - processed_appcast_text = result.stdout.gsub(%r{[^<]*}, "") - # This step is necessary to replicate running `sed` from the command line - processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") + result = cask.appcast.calculate_checkpoint + + actual_checkpoint = result[:checkpoint] + + if actual_checkpoint.nil? + add_warning "error retrieving appcast: #{result[:command_result].stderr}" + else expected = cask.appcast.checkpoint - actual = Digest::SHA2.hexdigest(processed_appcast_text) - add_warning <<-EOS.undent unless expected == actual + add_warning <<-EOS.undent unless expected == actual_checkpoint appcast checkpoint mismatch Expected: #{expected} - Actual: #{actual} + Actual: #{actual_checkpoint} EOS - else - add_warning "error retrieving appcast: #{result.stderr}" end end diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 42c3982ba..36fae3034 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -23,6 +23,7 @@ require "hbc/cli/zap" require "hbc/cli/internal_use_base" require "hbc/cli/internal_audit_modified_casks" +require "hbc/cli/internal_appcast_checkpoint" require "hbc/cli/internal_checkurl" require "hbc/cli/internal_dump" require "hbc/cli/internal_help" diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb new file mode 100644 index 000000000..6de76cbc7 --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -0,0 +1,45 @@ +module Hbc + class CLI + class InternalAppcastCheckpoint < InternalUseBase + def self.run(*args) + cask_tokens = cask_tokens_from(args) + raise CaskUnspecifiedError if cask_tokens.empty? + + appcask_checkpoint(cask_tokens) + end + + def self.appcask_checkpoint(cask_tokens) + count = 0 + + cask_tokens.each do |cask_token| + cask = Hbc.load(cask_token) + + if cask.appcast.nil? + opoo "Cask '#{cask}' is missing an `appcast` stanza." + else + result = cask.appcast.calculate_checkpoint + + checkpoint = result[:checkpoint] + + if checkpoint.nil? + onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" + else + puts cask_tokens.count > 1 ? "#{checkpoint} #{cask}": checkpoint + count += 1 + end + end + end + + count == cask_tokens.count + end + + def self.help + "calculates a given Cask's appcast checkpoint" + end + + def self.needs_init? + true + end + end + end +end diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb index 2f1245d3d..94660e936 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb @@ -1,3 +1,5 @@ +require "hbc/system_command" + module Hbc class DSL class Appcast @@ -9,6 +11,24 @@ module Hbc @checkpoint = @parameters[:checkpoint] end + def calculate_checkpoint + result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false) + + checkpoint = if result.success? + processed_appcast_text = result.stdout.gsub(%r{[^<]*}, "") + + # This step is necessary to replicate running `sed` from the command line + processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") + + Digest::SHA2.hexdigest(processed_appcast_text) + end + + { + checkpoint: checkpoint, + command_result: result, + } + end + def to_yaml [@uri, @parameters].to_yaml end diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb index c12063a1d..193b58fd6 100644 --- a/Library/Homebrew/cask/spec/cask/audit_spec.rb +++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb @@ -162,7 +162,7 @@ describe Hbc::Audit do before do allow(audit).to receive(:check_appcast_http_code) - allow(fake_system_command).to receive(:run).and_return(fake_curl_result) + allow(Hbc::SystemCommand).to receive(:run).and_return(fake_curl_result) allow(fake_curl_result).to receive(:success?).and_return(success) end -- cgit v1.2.3 From 2de6d96a10f00f6dc828711166a53b768f97bbab Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 21:56:54 +0100 Subject: Change regex to catch multi-line `pubDate` tags. --- Library/Homebrew/cask/lib/hbc/dsl/appcast.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb index 94660e936..e27870622 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb @@ -15,11 +15,7 @@ module Hbc result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false) checkpoint = if result.success? - processed_appcast_text = result.stdout.gsub(%r{[^<]*}, "") - - # This step is necessary to replicate running `sed` from the command line - processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") - + processed_appcast_text = result.stdout.gsub(%r{[^<]*}m, "") Digest::SHA2.hexdigest(processed_appcast_text) end -- cgit v1.2.3 From 7d131de57dac25dbb7cf9a8f986c291de87f7e65 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 12:01:47 +0000 Subject: tests: slightly stricter match in tab test Suggested by @reitermarkus in https://github.com/Homebrew/brew/pull/1890#discussion_r97234536, and then I added the \A and \Z. --- Library/Homebrew/test/tap_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 9979be43d..578326cea 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -177,7 +177,7 @@ class TapTest < Homebrew::TestCase assert_equal "0453e16c8e3fac73104da50927a86221ca0740c2", @tap.git_head assert_equal "0453", @tap.git_short_head - assert_match "ago", @tap.git_last_commit + assert_match(/\A\d+ .+ ago\Z/, @tap.git_last_commit) assert_equal "2017-01-22", @tap.git_last_commit_date end -- cgit v1.2.3 From b7dc56a8aa08e5783072ac728ed08ca597262835 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 23:17:09 +0100 Subject: Delete with_environment from cask tests. --- Library/Homebrew/cask/spec/cask/cli_spec.rb | 16 ++++++++-------- Library/Homebrew/cask/test/cask/dsl_test.rb | 6 +++++- Library/Homebrew/cask/test/test_helper.rb | 2 -- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli_spec.rb b/Library/Homebrew/cask/spec/cask/cli_spec.rb index 9964275f1..6b2313a41 100644 --- a/Library/Homebrew/cask/spec/cask/cli_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli_spec.rb @@ -39,17 +39,17 @@ describe Hbc::CLI do end it "respects the env variable when choosing what appdir to create" do - with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do - expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir")) - described_class.process("noop") - end + allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir") + expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir")) + described_class.process("noop") end it "respects the env variable when choosing a non-default Caskroom location" do - with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do - expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir")) - described_class.process("noop") - end + allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--caskroom=/custom/caskdir") + expect(Hbc).to receive(:caskroom=).with(Pathname.new("/custom/caskdir")) + described_class.process("noop") end it "exits with a status of 1 when something goes wrong" do diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb index 96d24a1a1..0ea928f40 100644 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl_test.rb @@ -69,7 +69,11 @@ describe Hbc::DSL do end it "may use deprecated DSL version hash syntax" do - with_environment "HOMEBREW_DEVELOPER" => nil do + stub = proc do |arg| + arg == "HOMEBREW_DEVELOPER" ? nil : ENV[arg] + end + + ENV.stub :[], stub do shutup do test_cask = Hbc.load("with-dsl-version") test_cask.token.must_equal "with-dsl-version" diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 275ede304..7315839f5 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -13,9 +13,7 @@ require "global" # add Homebrew-Cask to load path $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) -require "test/support/helper/env" require "test/support/helper/shutup" -include Test::Helper::Env include Test::Helper::Shutup def sudo(*args) -- cgit v1.2.3 From f7c6fc058f5eff55281fd7559b4217184162edcf Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 09:49:25 +0100 Subject: Remove legacy cask cache instead of migrating. --- Library/Homebrew/cask/lib/hbc.rb | 2 +- Library/Homebrew/cask/lib/hbc/cache.rb | 21 ++------------------- 2 files changed, 3 insertions(+), 20 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb index 69b6e8f21..775b9229f 100644 --- a/Library/Homebrew/cask/lib/hbc.rb +++ b/Library/Homebrew/cask/lib/hbc.rb @@ -46,7 +46,7 @@ module Hbc def self.init Cache.ensure_cache_exists - Cache.migrate_legacy_cache + Cache.delete_legacy_cache Caskroom.migrate_caskroom_from_repo_to_prefix Caskroom.ensure_caskroom_exists diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb index e343da3fa..7b586528e 100644 --- a/Library/Homebrew/cask/lib/hbc/cache.rb +++ b/Library/Homebrew/cask/lib/hbc/cache.rb @@ -9,27 +9,10 @@ module Hbc Hbc.cache.mkpath end - def migrate_legacy_cache + def delete_legacy_cache return unless Hbc.legacy_cache.exist? - ohai "Migrating cached files to #{Hbc.cache}..." - Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| - file = symlink.readlink - - new_name = file.basename - .sub(/\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$/x, - '--\1') - - renamed_file = Hbc.cache.join(new_name) - - if file.exist? - puts "#{file} -> #{renamed_file}" - FileUtils.mv(file, renamed_file) - end - - FileUtils.rm(symlink) - end - + ohai "Deleting legacy cache at #{Hbc.legacy_cache}..." FileUtils.remove_entry_secure(Hbc.legacy_cache) end end -- cgit v1.2.3 From f23c127cde7b3e678555efc8c0d405247a6975b7 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 14:19:14 +0100 Subject: Fix installer deleting artifacts if they already exist. --- Library/Homebrew/cask/lib/hbc/installer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 3875e1c8f..465011735 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -141,8 +141,8 @@ module Hbc artifacts.each do |artifact| odebug "Installing artifact of class #{artifact}" - already_installed_artifacts.unshift(artifact) artifact.new(@cask, options).install_phase + already_installed_artifacts.unshift(artifact) end rescue StandardError => e begin -- cgit v1.2.3 From 62a0c3a6f5cd6577cf9e628524b88b91b9419df7 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 Jan 2017 12:26:34 +0000 Subject: tests: remove env helper --- Library/Homebrew/cask/spec/spec_helper.rb | 2 -- Library/Homebrew/test/gpg2_requirement_test.rb | 5 ++--- Library/Homebrew/test/gpg_test.rb | 7 +++---- Library/Homebrew/test/support/helper/env.rb | 21 --------------------- Library/Homebrew/test/support/helper/test_case.rb | 6 ++---- 5 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 Library/Homebrew/test/support/helper/env.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 458fe00f4..162cb3b8f 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -15,7 +15,6 @@ require "global" # add Homebrew-Cask to load path $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) -require "test/support/helper/env" require "test/support/helper/shutup" Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require)) @@ -38,6 +37,5 @@ end RSpec.configure do |config| config.order = :random - config.include(Test::Helper::Env) config.include(Test::Helper::Shutup) end diff --git a/Library/Homebrew/test/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb index b45798b42..3297c2851 100644 --- a/Library/Homebrew/test/gpg2_requirement_test.rb +++ b/Library/Homebrew/test/gpg2_requirement_test.rb @@ -19,8 +19,7 @@ class GPG2RequirementTests < Homebrew::TestCase end def test_satisfied - with_environment("PATH" => @dir/"bin") do - assert_predicate GPG2Requirement.new, :satisfied? - end + ENV["PATH"] = @dir/"bin" + assert_predicate GPG2Requirement.new, :satisfied? end end diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb index d3a637297..ea4372549 100644 --- a/Library/Homebrew/test/gpg_test.rb +++ b/Library/Homebrew/test/gpg_test.rb @@ -10,10 +10,9 @@ class GpgTest < Homebrew::TestCase def test_create_test_key Dir.chdir(@dir) do - with_environment("HOME" => @dir) do - shutup { Gpg.create_test_key(@dir) } - assert_predicate @dir/".gnupg/secring.gpg", :exist? - end + ENV["HOME"] = @dir + shutup { Gpg.create_test_key(@dir) } + assert_predicate @dir/".gnupg/secring.gpg", :exist? end end end diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb deleted file mode 100644 index 88b25e237..000000000 --- a/Library/Homebrew/test/support/helper/env.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Test - module Helper - module Env - def copy_env - ENV.to_hash - end - - def restore_env(env) - ENV.replace(env) - end - - def with_environment(partial_env) - old = copy_env - ENV.update partial_env - yield - ensure - restore_env old - end - end - end -end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 801fa08c7..ab97ef758 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -1,11 +1,9 @@ module Homebrew class TestCase < ::Minitest::Test - require "test/support/helper/env" require "test/support/helper/fs_leak_logger" require "test/support/helper/lifecycle_enforcer" require "test/support/helper/shutup" require "test/support/helper/version_assertions" - include Test::Helper::Env include Test::Helper::FSLeakLogger include Test::Helper::LifecycleEnforcer include Test::Helper::Shutup @@ -18,12 +16,12 @@ module Homebrew super @__argv = ARGV.dup - @__env = copy_env + @__env = ENV.to_hash # dup doesn't work on ENV end def teardown ARGV.replace(@__argv) - restore_env @__env + ENV.replace(@__env) Tab.clear_cache -- cgit v1.2.3 From e8f67eb13dd9015172f62937e4be210506fa2cb2 Mon Sep 17 00:00:00 2001 From: Vítor Galvão Date: Mon, 23 Jan 2017 01:16:07 +0000 Subject: cask - internal stanzas: lowercase help --- Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/internal_help.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb index af1494e5f..ac1b20493 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb @@ -27,7 +27,7 @@ module Hbc end def self.help - "Dump the given Cask in YAML format" + "dump the given Cask in YAML format" end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb index 6c646cfd7..0908ee05e 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb @@ -16,7 +16,7 @@ module Hbc end def self.help - "Print help strings for unstable internal-use commands" + "print help strings for unstable internal-use commands" end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 41d72e42d..f0c49c0df 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -125,7 +125,7 @@ module Hbc end def self.help - "Extract and render a specific stanza for the given Casks" + "extract and render a specific stanza for the given Casks" end end end -- cgit v1.2.3 From a64e2835adcd133b2db3eecde5808a74147dc565 Mon Sep 17 00:00:00 2001 From: Vítor Galvão Date: Mon, 23 Jan 2017 01:54:36 +0000 Subject: cask - internal_stanza: use cask_tokens_from(args) --- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index f0c49c0df..105e946d7 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -55,7 +55,7 @@ module Hbc quiet = args.include? "--quiet" format = :to_yaml if args.include? "--yaml" format = :inspect if args.include? "--inspect" - cask_tokens = args.reject { |arg| arg.chars.first == "-" } + cask_tokens = cask_tokens_from(args) stanza = cask_tokens.shift.to_sym cask_tokens = Hbc.all_tokens if cask_tokens.empty? -- cgit v1.2.3 From 53e232fc7e2f5f9372ba9b544e01abf99f96c99c Mon Sep 17 00:00:00 2001 From: Vítor Galvão Date: Mon, 23 Jan 2017 01:03:19 +0000 Subject: Add --calculate (print current checkpoint without it) --- .../cask/lib/hbc/cli/internal_appcast_checkpoint.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index 6de76cbc7..fc2d1049f 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -2,13 +2,14 @@ module Hbc class CLI class InternalAppcastCheckpoint < InternalUseBase def self.run(*args) + calculate = args.include? "--calculate" cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? - appcask_checkpoint(cask_tokens) + appcask_checkpoint(cask_tokens, calculate) end - def self.appcask_checkpoint(cask_tokens) + def self.appcask_checkpoint(cask_tokens, calculate) count = 0 cask_tokens.each do |cask_token| @@ -17,9 +18,13 @@ module Hbc if cask.appcast.nil? opoo "Cask '#{cask}' is missing an `appcast` stanza." else - result = cask.appcast.calculate_checkpoint + if calculate + result = cask.appcast.calculate_checkpoint - checkpoint = result[:checkpoint] + checkpoint = result[:checkpoint] + else + checkpoint = cask.appcast.checkpoint + end if checkpoint.nil? onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" @@ -34,7 +39,7 @@ module Hbc end def self.help - "calculates a given Cask's appcast checkpoint" + "prints (no flag) or calculates ('--calculate') a given Cask's appcast checkpoint" end def self.needs_init? -- cgit v1.2.3 From 2d5b659b0e4ba396f133156d368afc4fa1b8373c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 09:22:51 +0100 Subject: Add support for calculating appcast checkpoint from URLs. --- .../cask/lib/hbc/cli/internal_appcast_checkpoint.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index fc2d1049f..915ec314b 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -6,7 +6,18 @@ module Hbc cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? - appcask_checkpoint(cask_tokens, calculate) + if cask_tokens.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ } + appcask_checkpoint_for_url(cask_tokens) + else + appcask_checkpoint(cask_tokens, calculate) + end + end + + def self.appcask_checkpoint_for_url(urls) + urls.each do |url| + appcast = DSL::Appcast.new(url) + puts appcast.calculate_checkpoint[:checkpoint] + end end def self.appcask_checkpoint(cask_tokens, calculate) @@ -39,7 +50,7 @@ module Hbc end def self.help - "prints (no flag) or calculates ('--calculate') a given Cask's appcast checkpoint" + "prints (no flag) or calculates ('--calculate') a given Cask's (or URL's) appcast checkpoint" end def self.needs_init? -- cgit v1.2.3 From e12c1db231cd619408574d63ecf38f883745e1ee Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 23 Jan 2017 15:03:03 +0000 Subject: official_taps: remove homebrew/gui. This was deprecated and had all formulae removed in: https://github.com/Homebrew/homebrew-gui/pull/52 --- Library/Homebrew/official_taps.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index c1ef431b6..f2afea614 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -5,7 +5,6 @@ OFFICIAL_TAPS = %w[ emacs fuse games - gui nginx php python -- cgit v1.2.3 From 2076b494a6233630025acd45d9a5766bd6bb785d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 16:23:01 +0100 Subject: Add manpage entry for _appcast_checkpoint. --- Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb | 2 +- Library/Homebrew/manpages/brew-cask.1.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index 915ec314b..790e917b2 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -50,7 +50,7 @@ module Hbc end def self.help - "prints (no flag) or calculates ('--calculate') a given Cask's (or URL's) appcast checkpoint" + "prints or calculates a given Cask's or URL's appcast checkpoint" end def self.needs_init? diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md index f0a70d4a7..a2c9c8c16 100644 --- a/Library/Homebrew/manpages/brew-cask.1.md +++ b/Library/Homebrew/manpages/brew-cask.1.md @@ -120,6 +120,13 @@ names, and other aspects of this manual are still subject to change. **`zap` may remove files which are shared between applications.** +## INTERNAL COMMANDS + + * `_appcast_checkpoint` [--calculate] [ ... | ... ]: + Given a `token`, returns the current appcast checkpoint, or calculates + the appcast checkpoint if the `--calculate` flag is specified. + Given a `URL`, calculates the appcast checkpoint for it. + ## OPTIONS To make these options persistent, see the ENVIRONMENT section, below. -- cgit v1.2.3 From 13488183bd3fe9d0f8e84d66075c9c7d4cdc931d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Jan 2017 12:27:49 +0000 Subject: emoji: remove hack required for Ruby 1.8.7 Since this hack is no longer required, and `Emoji.tick` and `.cross` are only called in one place, I think it's better to just inline them there rather than having methods on `Emoji` that just return a one-character String. --- Library/Homebrew/emoji.rb | 12 +----------- Library/Homebrew/utils.rb | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/emoji.rb b/Library/Homebrew/emoji.rb index 8c58ca895..43fa781e6 100644 --- a/Library/Homebrew/emoji.rb +++ b/Library/Homebrew/emoji.rb @@ -1,17 +1,7 @@ module Emoji class << self - def tick - # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 - @tick ||= ["2714".hex].pack("U*") - end - - def cross - # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 - @cross ||= ["2718".hex].pack("U*") - end - def install_badge - ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba" + ENV["HOMEBREW_INSTALL_BADGE"] || "🍺" end def enabled? diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 614d50eea..70d2787d9 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -106,7 +106,7 @@ def pretty_installed(f) if !$stdout.tty? f.to_s elsif Emoji.enabled? - "#{Tty.bold}#{f} #{Formatter.success(Emoji.tick)}#{Tty.reset}" + "#{Tty.bold}#{f} #{Formatter.success("✔")}#{Tty.reset}" else Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}") end @@ -116,7 +116,7 @@ def pretty_uninstalled(f) if !$stdout.tty? f.to_s elsif Emoji.enabled? - "#{Tty.bold}#{f} #{Formatter.error(Emoji.cross)}#{Tty.reset}" + "#{Tty.bold}#{f} #{Formatter.error("✘")}#{Tty.reset}" else Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}") end -- cgit v1.2.3 From b0fea9eb6c7dfc39bbd8083180a7156b9b859571 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Jan 2017 12:30:47 +0000 Subject: fileutils: update Ruby documentation URL --- Library/Homebrew/extend/fileutils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index 4f20d36a3..287a1408f 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -3,7 +3,7 @@ require "tmpdir" require "etc" # Homebrew extends Ruby's `FileUtils` to make our code more readable. -# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API +# @see http://ruby-doc.org/stdlib-2.0.0/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API module FileUtils # Create a temporary directory then yield. When the block returns, # recursively delete the temporary directory. Passing opts[:retain] -- cgit v1.2.3 From 4291476fa3042e76b3acfde7836affaea4557a02 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 Jan 2017 18:48:51 +0000 Subject: man: remove an unnecessary `else` `odie` causes the process to exit immediately, so there's no need for the `regenerate_man_pages` call to be conditional. --- Library/Homebrew/dev-cmd/man.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index 64c970453..581db38ca 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -23,10 +23,10 @@ module Homebrew if ARGV.flag? "--link" odie "`brew man --link` is now done automatically by `brew update`." - else - regenerate_man_pages end + regenerate_man_pages + if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/brew.1.html", "manpages" puts "No changes to manpage output detected." elsif ARGV.include?("--fail-if-changed") -- cgit v1.2.3 From 50c1fea4ea9ca8067e194db5918fbf5a7f5c3ca1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 23 Jan 2017 21:22:54 +0000 Subject: xcode: reduce minimum CLT version. This should be 1.0.0 to be nicer to 10.7 users. Fixes #1893. --- Library/Homebrew/os/mac/xcode.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index e85f21c63..aa4504a17 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -226,7 +226,7 @@ module OS def minimum_version case MacOS.version when "10.12" then "8.0.0" - else "4.0.0" + else "1.0.0" end end -- cgit v1.2.3 From 65dde58057029d473be9175444b333525fe82850 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Jan 2017 17:27:08 +0000 Subject: tests: add some emoji tests 💯 --- Library/Homebrew/test/emoji_test.rb | 11 +++++++++++ Library/Homebrew/test/utils_test.rb | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Library/Homebrew/test/emoji_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/emoji_test.rb b/Library/Homebrew/test/emoji_test.rb new file mode 100644 index 000000000..ea68db8f6 --- /dev/null +++ b/Library/Homebrew/test/emoji_test.rb @@ -0,0 +1,11 @@ +require "testing_env" +require "emoji" + +class EmojiTest < Homebrew::TestCase + def test_install_badge + assert_equal "🍺", Emoji.install_badge + + ENV["HOMEBREW_INSTALL_BADGE"] = "foo" + assert_equal "foo", Emoji.install_badge + end +end diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 520cd4fcd..7ae5793e2 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -9,6 +9,14 @@ class UtilTests < Homebrew::TestCase @dir = Pathname.new(mktmpdir) end + # Helper for matching escape sequences. + def e(code) + /(\e\[\d+m)*\e\[#{code}m/ + end + + # Helper for matching that style is reset at the end of a string. + Z = /(\e\[\d+m)*\e\[0m\Z/ + def test_ofail shutup { ofail "foo" } assert Homebrew.failed? @@ -22,11 +30,25 @@ class UtilTests < Homebrew::TestCase end def test_pretty_installed + $stdout.stubs(:tty?).returns true + ENV.delete("HOMEBREW_NO_EMOJI") + assert_match(/\A#{e 1}foo #{e 32}✔#{Z}/, pretty_installed("foo")) + + ENV["HOMEBREW_NO_EMOJI"] = "1" + assert_match(/\A#{e 1}foo \(installed\)#{Z}/, pretty_installed("foo")) + $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_installed("foo") end def test_pretty_uninstalled + $stdout.stubs(:tty?).returns true + ENV.delete("HOMEBREW_NO_EMOJI") + assert_match(/\A#{e 1}foo #{e 31}✘#{Z}/, pretty_uninstalled("foo")) + + ENV["HOMEBREW_NO_EMOJI"] = "1" + assert_match(/\A#{e 1}foo \(uninstalled\)#{Z}/, pretty_uninstalled("foo")) + $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_uninstalled("foo") end -- cgit v1.2.3 From 5480a84114243fcd0aedda3a650b23b59ae91b2c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 Jan 2017 18:24:31 +0000 Subject: tests: give `e` helper in UtilTests a better name --- Library/Homebrew/test/utils_test.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7ae5793e2..1f2fb7b55 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -9,14 +9,10 @@ class UtilTests < Homebrew::TestCase @dir = Pathname.new(mktmpdir) end - # Helper for matching escape sequences. - def e(code) + def esc(code) /(\e\[\d+m)*\e\[#{code}m/ end - # Helper for matching that style is reset at the end of a string. - Z = /(\e\[\d+m)*\e\[0m\Z/ - def test_ofail shutup { ofail "foo" } assert Homebrew.failed? @@ -32,10 +28,12 @@ class UtilTests < Homebrew::TestCase def test_pretty_installed $stdout.stubs(:tty?).returns true ENV.delete("HOMEBREW_NO_EMOJI") - assert_match(/\A#{e 1}foo #{e 32}✔#{Z}/, pretty_installed("foo")) + tty_with_emoji_output = /\A#{esc 1}foo #{esc 32}✔#{esc 0}\Z/ + assert_match tty_with_emoji_output, pretty_installed("foo") ENV["HOMEBREW_NO_EMOJI"] = "1" - assert_match(/\A#{e 1}foo \(installed\)#{Z}/, pretty_installed("foo")) + tty_no_emoji_output = /\A#{esc 1}foo \(installed\)#{esc 0}\Z/ + assert_match tty_no_emoji_output, pretty_installed("foo") $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_installed("foo") @@ -44,10 +42,12 @@ class UtilTests < Homebrew::TestCase def test_pretty_uninstalled $stdout.stubs(:tty?).returns true ENV.delete("HOMEBREW_NO_EMOJI") - assert_match(/\A#{e 1}foo #{e 31}✘#{Z}/, pretty_uninstalled("foo")) + tty_with_emoji_output = /\A#{esc 1}foo #{esc 31}✘#{esc 0}\Z/ + assert_match tty_with_emoji_output, pretty_uninstalled("foo") ENV["HOMEBREW_NO_EMOJI"] = "1" - assert_match(/\A#{e 1}foo \(uninstalled\)#{Z}/, pretty_uninstalled("foo")) + tty_no_emoji_output = /\A#{esc 1}foo \(uninstalled\)#{esc 0}\Z/ + assert_match tty_no_emoji_output, pretty_uninstalled("foo") $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_uninstalled("foo") -- cgit v1.2.3 From d94636cde921288aa7a33a0f368a3101fd8f3df3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 20 Jan 2017 09:00:53 +0100 Subject: Allow overriding MacOS.version. --- Library/Homebrew/cask/lib/hbc/cli.rb | 4 ++++ Library/Homebrew/os/mac.rb | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 36fae3034..2b2211877 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -142,6 +142,10 @@ module Hbc end def self.process(arguments) + unless ENV["MACOS_VERSION"].nil? + MacOS.full_version = ENV["MACOS_VERSION"] + end + command_string, *rest = *arguments rest = process_options(rest) command = Hbc.help ? "help" : lookup_command(command_string) diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index 9468a6c1e..e09a9b3fd 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -27,6 +27,11 @@ module OS @full_version ||= Version.new((ENV["HOMEBREW_MACOS_VERSION"] || ENV["HOMEBREW_OSX_VERSION"]).chomp) end + def full_version=(version) + @full_version = Version.new(version.chomp) + @version = nil + end + def prerelease? # TODO: bump version when new OS is released version >= "10.13" -- cgit v1.2.3 From cc22239c9999f4d56f487d4002b1bbe0a2dc0a94 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 25 Jan 2017 08:25:16 +0000 Subject: caveats: tweak keg-only messaging. Slim down the existing text and make it more obvious what's happening. Note specifically how to add it to your PATH to convince people to try that instead of `brew link --force`. --- Library/Homebrew/caveats.rb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index d1dda9d4c..d051a7ca7 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -48,20 +48,23 @@ class Caveats s = "This formula is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}." s << "\n\n#{f.keg_only_reason}" - if f.lib.directory? || f.include.directory? - s << - <<-EOS.undent_________________________________________________________72 - - - Generally there are no consequences of this for you. If you build your - own software and it requires this formula, you'll need to add to your - build variables: + if f.bin.directory? || f.sbin.directory? + s << "\nIf you need to have this software first in your PATH run:\n" + if f.bin.directory? + s << " #{Utils::Shell.prepend_path_in_shell_profile(f.opt_bin.to_s)}\n" + end + if f.sbin.directory? + s << " #{Utils::Shell.prepend_path_in_shell_profile(f.opt_sbin.to_s)}\n" + end + end - EOS + if f.lib.directory? || f.include.directory? + s << "\nFor compilers to find this software you may need to set:\n" s << " LDFLAGS: -L#{f.opt_lib}\n" if f.lib.directory? s << " CPPFLAGS: -I#{f.opt_include}\n" if f.include.directory? - - if which("pkg-config") + if which("pkg-config") && + ((f.lib/"pkgconfig").directory? || (f.share/"pkgconfig").directory?) + s << "For pkg-config to find this software you may need to set:\n" s << " PKG_CONFIG_PATH: #{f.opt_lib}/pkgconfig\n" if (f.lib/"pkgconfig").directory? s << " PKG_CONFIG_PATH: #{f.opt_share}/pkgconfig\n" if (f.share/"pkgconfig").directory? end -- cgit v1.2.3 From 54b9bc4d0ec91db10204313cfa11e9e3bb3b38e2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 25 Jan 2017 08:35:14 +0000 Subject: official_taps: remove completions, python. --- Library/Homebrew/official_taps.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index f2afea614..f64370a4b 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -1,13 +1,11 @@ OFFICIAL_TAPS = %w[ apache - completions dupes emacs fuse games nginx php - python science tex x11 -- cgit v1.2.3 From 381d180abeb216f5bbde6fa27643440a49f3d9f4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 25 Jan 2017 09:43:45 +0000 Subject: language_module_requirement: use arrays. This is cleaner, easier to understand how the arguments are split and fixes #1799. --- .../requirements/language_module_requirement.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/requirements/language_module_requirement.rb b/Library/Homebrew/requirements/language_module_requirement.rb index e20f48361..392bc9b7a 100644 --- a/Library/Homebrew/requirements/language_module_requirement.rb +++ b/Library/Homebrew/requirements/language_module_requirement.rb @@ -32,12 +32,18 @@ class LanguageModuleRequirement < Requirement def the_test case @language - when :lua then %W[/usr/bin/env luarocks-5.2 show #{@import_name}] - when :lua51 then %W[/usr/bin/env luarocks-5.1 show #{@import_name}] - when :perl then %W[/usr/bin/env perl -e use\ #{@import_name}] - when :python then %W[/usr/bin/env python -c import\ #{@import_name}] - when :python3 then %W[/usr/bin/env python3 -c import\ #{@import_name}] - when :ruby then %W[/usr/bin/env ruby -rubygems -e require\ '#{@import_name}'] + when :lua + ["/usr/bin/env", "luarocks-5.2", "show", @import_name.to_s] + when :lua51 + ["/usr/bin/env", "luarocks-5.1", "show", @import_name.to_s] + when :perl + ["/usr/bin/env", "perl", "-e", "use #{@import_name}"] + when :python + ["/usr/bin/env", "python", "-c", "import #{@import_name}"] + when :python3 + ["/usr/bin/env", "python3", "-c", "import #{@import_name}"] + when :ruby + ["/usr/bin/env", "ruby", "-rubygems", "-e", "require '#{@import_name}'"] end end -- cgit v1.2.3 From e825c10b718bdef817315a82b468ff22cfad9af4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 25 Jan 2017 10:17:03 +0000 Subject: official_taps: remove x11. --- Library/Homebrew/official_taps.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index f64370a4b..024dd2a20 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -8,7 +8,6 @@ OFFICIAL_TAPS = %w[ php science tex - x11 ].freeze OFFICIAL_CMD_TAPS = { -- cgit v1.2.3 From f717831a032c96fa583ab27d7ad2f300ad81b764 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 6 Dec 2016 16:36:34 +0100 Subject: Move Cask fixtures to `test/support/fixtures`. --- Library/Homebrew/cask/lib/hbc.rb | 1 + .../cask/spec/cask/artifact/binary_spec.rb | 4 +- Library/Homebrew/cask/spec/spec_helper.rb | 2 +- .../appcast-checkpoint-sha256-for-empty-string.rb | 4 -- .../support/Casks/appcast-invalid-checkpoint.rb | 4 -- .../support/Casks/appcast-missing-checkpoint.rb | 3 - .../spec/support/Casks/appcast-valid-checkpoint.rb | 4 -- .../Homebrew/cask/spec/support/Casks/booby-trap.rb | 8 --- .../Casks/generic-artifact-absolute-target.rb | 3 - .../support/Casks/generic-artifact-no-target.rb | 3 - .../Casks/generic-artifact-relative-target.rb | 3 - .../cask/spec/support/Casks/invalid-sha256.rb | 4 -- .../cask/spec/support/Casks/missing-homepage.rb | 5 -- .../cask/spec/support/Casks/missing-name.rb | 5 -- .../cask/spec/support/Casks/missing-sha256.rb | 5 -- .../cask/spec/support/Casks/missing-url.rb | 5 -- .../cask/spec/support/Casks/missing-version.rb | 4 -- .../spec/support/Casks/osdn-correct-url-format.rb | 6 -- .../support/Casks/osdn-incorrect-url-format.rb | 6 -- .../spec/support/Casks/sha256-for-empty-string.rb | 4 -- .../Casks/sourceforge-correct-url-format.rb | 6 -- .../Casks/sourceforge-incorrect-url-format.rb | 6 -- ...ourceforge-version-latest-correct-url-format.rb | 6 -- .../spec/support/Casks/version-latest-string.rb | 4 -- .../support/Casks/version-latest-with-checksum.rb | 4 -- .../cask/spec/support/Casks/with-binary.rb | 10 --- .../spec/support/Casks/with-embedded-binary.rb | 10 --- .../Homebrew/cask/test/cask/accessibility_test.rb | 2 +- .../cask/test/cask/artifact/alt_target_test.rb | 2 +- .../Homebrew/cask/test/cask/artifact/app_test.rb | 2 +- .../test/cask/artifact/generic_artifact_test.rb | 4 +- .../test/cask/artifact/nested_container_test.rb | 2 +- .../Homebrew/cask/test/cask/artifact/pkg_test.rb | 4 +- .../Homebrew/cask/test/cask/artifact/suite_test.rb | 2 +- .../test/cask/artifact/two_apps_correct_test.rb | 4 +- .../test/cask/artifact/two_apps_incorrect_test.rb | 17 ++--- .../cask/test/cask/artifact/uninstall_test.rb | 24 +++---- .../Homebrew/cask/test/cask/artifact/zap_test.rb | 24 +++---- Library/Homebrew/cask/test/cask/cli/fetch_test.rb | 4 +- .../Homebrew/cask/test/cask/cli/install_test.rb | 12 ++-- Library/Homebrew/cask/test/cask/cli/list_test.rb | 4 +- .../Homebrew/cask/test/cask/cli/reinstall_test.rb | 8 +-- .../Homebrew/cask/test/cask/cli/uninstall_test.rb | 4 +- Library/Homebrew/cask/test/cask/cli/zap_test.rb | 4 +- .../Homebrew/cask/test/cask/container/dmg_test.rb | 2 +- Library/Homebrew/cask/test/cask/depends_on_test.rb | 22 +++--- .../Homebrew/cask/test/cask/dsl/caveats_test.rb | 2 +- .../Homebrew/cask/test/cask/dsl/postflight_test.rb | 2 +- .../Homebrew/cask/test/cask/dsl/preflight_test.rb | 2 +- .../test/cask/dsl/uninstall_postflight_test.rb | 2 +- .../cask/test/cask/dsl/uninstall_preflight_test.rb | 2 +- Library/Homebrew/cask/test/cask/dsl_test.rb | 80 +++++++++++----------- Library/Homebrew/cask/test/cask/installer_test.rb | 64 ++++++++--------- Library/Homebrew/cask/test/cask/staged_test.rb | 2 +- .../Homebrew/cask/test/cask/url_checker_test.rb | 2 +- Library/Homebrew/cask/test/cask_test.rb | 4 +- .../test/support/Casks/appdir-interpolation.rb | 9 --- .../cask/test/support/Casks/auto-updates.rb | 11 --- .../cask/test/support/Casks/bad-checksum.rb | 9 --- .../Homebrew/cask/test/support/Casks/basic-cask.rb | 9 --- .../cask/test/support/Casks/container-7z.rb | 11 --- .../cask/test/support/Casks/container-air.rb | 9 --- .../cask/test/support/Casks/container-bzip2.rb | 9 --- .../cask/test/support/Casks/container-cab.rb | 11 --- .../cask/test/support/Casks/container-dmg.rb | 9 --- .../cask/test/support/Casks/container-gzip.rb | 9 --- .../cask/test/support/Casks/container-lzma.rb | 11 --- .../cask/test/support/Casks/container-pkg.rb | 7 -- .../cask/test/support/Casks/container-rar.rb | 11 --- .../cask/test/support/Casks/container-sit.rb | 11 --- .../cask/test/support/Casks/container-tar-gz.rb | 9 --- .../cask/test/support/Casks/container-xar.rb | 9 --- .../cask/test/support/Casks/container-xz.rb | 11 --- .../Casks/invalid/invalid-appcast-multiple.rb | 13 ---- .../support/Casks/invalid/invalid-appcast-url.rb | 11 --- .../Casks/invalid/invalid-conflicts-with-key.rb | 11 --- .../Casks/invalid/invalid-depends-on-arch-value.rb | 11 --- .../Casks/invalid/invalid-depends-on-key.rb | 11 --- .../invalid-depends-on-macos-bad-release.rb | 11 --- .../invalid-depends-on-macos-conflicting-forms.rb | 12 ---- .../Casks/invalid/invalid-depends-on-x11-value.rb | 11 --- .../Casks/invalid/invalid-gpg-conflicting-keys.rb | 12 ---- .../support/Casks/invalid/invalid-gpg-key-id.rb | 11 --- .../support/Casks/invalid/invalid-gpg-key-url.rb | 11 --- .../Casks/invalid/invalid-gpg-missing-key.rb | 10 --- .../Casks/invalid/invalid-gpg-multiple-stanzas.rb | 13 ---- .../support/Casks/invalid/invalid-gpg-parameter.rb | 11 --- .../Casks/invalid/invalid-gpg-signature-url.rb | 11 --- .../test/support/Casks/invalid/invalid-gpg-type.rb | 11 --- .../support/Casks/invalid/invalid-header-format.rb | 9 --- .../Casks/invalid/invalid-header-token-mismatch.rb | 9 --- .../Casks/invalid/invalid-header-version.rb | 9 --- .../Casks/invalid/invalid-stage-only-conflict.rb | 10 --- .../support/Casks/invalid/invalid-two-homepage.rb | 10 --- .../test/support/Casks/invalid/invalid-two-url.rb | 10 --- .../support/Casks/invalid/invalid-two-version.rb | 10 --- .../cask/test/support/Casks/local-caffeine.rb | 9 --- .../cask/test/support/Casks/local-transmission.rb | 9 --- .../cask/test/support/Casks/missing-checksum.rb | 8 --- .../cask/test/support/Casks/naked-executable.rb | 9 --- .../Homebrew/cask/test/support/Casks/nested-app.rb | 11 --- .../cask/test/support/Casks/no-checksum.rb | 9 --- .../cask/test/support/Casks/no-dsl-version.rb | 9 --- .../Homebrew/cask/test/support/Casks/stage-only.rb | 9 --- .../cask/test/support/Casks/test-opera-mail.rb | 9 --- .../Homebrew/cask/test/support/Casks/test-opera.rb | 9 --- .../support/Casks/with-accessibility-access.rb | 11 --- .../cask/test/support/Casks/with-alt-target.rb | 9 --- .../cask/test/support/Casks/with-appcast.rb | 11 --- .../cask/test/support/Casks/with-caveats.rb | 23 ------- .../cask/test/support/Casks/with-choices.rb | 16 ----- .../test/support/Casks/with-conditional-caveats.rb | 14 ---- .../cask/test/support/Casks/with-conflicts-with.rb | 11 --- .../test/support/Casks/with-depends-on-arch.rb | 12 ---- .../Casks/with-depends-on-cask-cyclic-helper.rb | 11 --- .../support/Casks/with-depends-on-cask-cyclic.rb | 12 ---- .../support/Casks/with-depends-on-cask-multiple.rb | 12 ---- .../test/support/Casks/with-depends-on-cask.rb | 11 --- .../Casks/with-depends-on-formula-multiple.rb | 12 ---- .../test/support/Casks/with-depends-on-formula.rb | 11 --- .../support/Casks/with-depends-on-macos-array.rb | 12 ---- .../Casks/with-depends-on-macos-comparison.rb | 11 --- .../support/Casks/with-depends-on-macos-failure.rb | 12 ---- .../support/Casks/with-depends-on-macos-string.rb | 11 --- .../support/Casks/with-depends-on-macos-symbol.rb | 11 --- .../support/Casks/with-depends-on-x11-false.rb | 11 --- .../cask/test/support/Casks/with-depends-on-x11.rb | 11 --- .../cask/test/support/Casks/with-dsl-version.rb | 9 --- .../Casks/with-generic-artifact-no-target.rb | 9 --- .../test/support/Casks/with-generic-artifact.rb | 9 --- .../cask/test/support/Casks/with-gpg-key-url.rb | 11 --- .../Homebrew/cask/test/support/Casks/with-gpg.rb | 11 --- .../cask/test/support/Casks/with-installable.rb | 20 ------ .../test/support/Casks/with-installer-manual.rb | 9 --- .../test/support/Casks/with-installer-script.rb | 15 ---- .../cask/test/support/Casks/with-macosx-dir.rb | 9 --- .../cask/test/support/Casks/with-pkgutil-zap.rb | 13 ---- .../Homebrew/cask/test/support/Casks/with-suite.rb | 10 --- .../test/support/Casks/with-two-apps-correct.rb | 10 --- .../test/support/Casks/with-two-apps-incorrect.rb | 9 --- .../test/support/Casks/with-two-apps-subdir.rb | 10 --- .../test/support/Casks/with-uninstall-delete.rb | 16 ----- .../support/Casks/with-uninstall-early-script.rb | 11 --- .../cask/test/support/Casks/with-uninstall-kext.rb | 11 --- .../test/support/Casks/with-uninstall-launchctl.rb | 11 --- .../support/Casks/with-uninstall-login-item.rb | 11 --- .../test/support/Casks/with-uninstall-pkgutil.rb | 11 --- .../cask/test/support/Casks/with-uninstall-quit.rb | 11 --- .../test/support/Casks/with-uninstall-rmdir.rb | 11 --- .../test/support/Casks/with-uninstall-script.rb | 11 --- .../test/support/Casks/with-uninstall-signal.rb | 14 ---- .../test/support/Casks/with-uninstall-trash.rb | 16 ----- .../cask/test/support/Casks/with-zap-delete.rb | 16 ----- .../test/support/Casks/with-zap-early-script.rb | 11 --- .../cask/test/support/Casks/with-zap-kext.rb | 11 --- .../cask/test/support/Casks/with-zap-launchctl.rb | 11 --- .../cask/test/support/Casks/with-zap-login-item.rb | 11 --- .../cask/test/support/Casks/with-zap-pkgutil.rb | 11 --- .../cask/test/support/Casks/with-zap-quit.rb | 11 --- .../cask/test/support/Casks/with-zap-rmdir.rb | 11 --- .../cask/test/support/Casks/with-zap-script.rb | 11 --- .../cask/test/support/Casks/with-zap-signal.rb | 14 ---- .../cask/test/support/Casks/with-zap-trash.rb | 16 ----- .../Homebrew/cask/test/support/Casks/with-zap.rb | 19 ----- Library/Homebrew/cask/test/test_helper.rb | 2 +- .../appcast-checkpoint-sha256-for-empty-string.rb | 4 ++ .../cask/Casks/appcast-invalid-checkpoint.rb | 4 ++ .../cask/Casks/appcast-missing-checkpoint.rb | 3 + .../cask/Casks/appcast-valid-checkpoint.rb | 4 ++ .../fixtures/cask/Casks/appdir-interpolation.rb | 9 +++ .../support/fixtures/cask/Casks/auto-updates.rb | 11 +++ .../support/fixtures/cask/Casks/bad-checksum.rb | 9 +++ .../test/support/fixtures/cask/Casks/basic-cask.rb | 9 +++ .../test/support/fixtures/cask/Casks/booby-trap.rb | 8 +++ .../support/fixtures/cask/Casks/container-7z.rb | 11 +++ .../support/fixtures/cask/Casks/container-air.rb | 9 +++ .../support/fixtures/cask/Casks/container-bzip2.rb | 9 +++ .../support/fixtures/cask/Casks/container-cab.rb | 11 +++ .../support/fixtures/cask/Casks/container-dmg.rb | 9 +++ .../support/fixtures/cask/Casks/container-gzip.rb | 9 +++ .../support/fixtures/cask/Casks/container-lzma.rb | 11 +++ .../support/fixtures/cask/Casks/container-pkg.rb | 7 ++ .../support/fixtures/cask/Casks/container-rar.rb | 11 +++ .../support/fixtures/cask/Casks/container-sit.rb | 11 +++ .../fixtures/cask/Casks/container-tar-gz.rb | 9 +++ .../support/fixtures/cask/Casks/container-xar.rb | 9 +++ .../support/fixtures/cask/Casks/container-xz.rb | 11 +++ .../cask/Casks/generic-artifact-absolute-target.rb | 3 + .../cask/Casks/generic-artifact-no-target.rb | 3 + .../cask/Casks/generic-artifact-relative-target.rb | 3 + .../support/fixtures/cask/Casks/invalid-sha256.rb | 4 ++ .../cask/Casks/invalid/invalid-appcast-multiple.rb | 13 ++++ .../cask/Casks/invalid/invalid-appcast-url.rb | 11 +++ .../Casks/invalid/invalid-conflicts-with-key.rb | 11 +++ .../Casks/invalid/invalid-depends-on-arch-value.rb | 11 +++ .../cask/Casks/invalid/invalid-depends-on-key.rb | 11 +++ .../invalid-depends-on-macos-bad-release.rb | 11 +++ .../invalid-depends-on-macos-conflicting-forms.rb | 12 ++++ .../Casks/invalid/invalid-depends-on-x11-value.rb | 11 +++ .../Casks/invalid/invalid-gpg-conflicting-keys.rb | 12 ++++ .../cask/Casks/invalid/invalid-gpg-key-id.rb | 11 +++ .../cask/Casks/invalid/invalid-gpg-key-url.rb | 11 +++ .../cask/Casks/invalid/invalid-gpg-missing-key.rb | 10 +++ .../Casks/invalid/invalid-gpg-multiple-stanzas.rb | 13 ++++ .../cask/Casks/invalid/invalid-gpg-parameter.rb | 11 +++ .../Casks/invalid/invalid-gpg-signature-url.rb | 11 +++ .../cask/Casks/invalid/invalid-gpg-type.rb | 11 +++ .../cask/Casks/invalid/invalid-header-format.rb | 9 +++ .../Casks/invalid/invalid-header-token-mismatch.rb | 9 +++ .../cask/Casks/invalid/invalid-header-version.rb | 9 +++ .../Casks/invalid/invalid-stage-only-conflict.rb | 10 +++ .../cask/Casks/invalid/invalid-two-homepage.rb | 10 +++ .../fixtures/cask/Casks/invalid/invalid-two-url.rb | 10 +++ .../cask/Casks/invalid/invalid-two-version.rb | 10 +++ .../support/fixtures/cask/Casks/local-caffeine.rb | 9 +++ .../fixtures/cask/Casks/local-transmission.rb | 9 +++ .../fixtures/cask/Casks/missing-checksum.rb | 8 +++ .../fixtures/cask/Casks/missing-homepage.rb | 5 ++ .../support/fixtures/cask/Casks/missing-name.rb | 5 ++ .../support/fixtures/cask/Casks/missing-sha256.rb | 5 ++ .../support/fixtures/cask/Casks/missing-url.rb | 5 ++ .../support/fixtures/cask/Casks/missing-version.rb | 4 ++ .../fixtures/cask/Casks/naked-executable.rb | 9 +++ .../test/support/fixtures/cask/Casks/nested-app.rb | 11 +++ .../support/fixtures/cask/Casks/no-checksum.rb | 9 +++ .../support/fixtures/cask/Casks/no-dsl-version.rb | 9 +++ .../fixtures/cask/Casks/osdn-correct-url-format.rb | 6 ++ .../cask/Casks/osdn-incorrect-url-format.rb | 6 ++ .../fixtures/cask/Casks/sha256-for-empty-string.rb | 4 ++ .../cask/Casks/sourceforge-correct-url-format.rb | 6 ++ .../cask/Casks/sourceforge-incorrect-url-format.rb | 6 ++ ...ourceforge-version-latest-correct-url-format.rb | 6 ++ .../test/support/fixtures/cask/Casks/stage-only.rb | 9 +++ .../support/fixtures/cask/Casks/test-opera-mail.rb | 9 +++ .../test/support/fixtures/cask/Casks/test-opera.rb | 9 +++ .../fixtures/cask/Casks/version-latest-string.rb | 4 ++ .../cask/Casks/version-latest-with-checksum.rb | 4 ++ .../cask/Casks/with-accessibility-access.rb | 11 +++ .../support/fixtures/cask/Casks/with-alt-target.rb | 9 +++ .../support/fixtures/cask/Casks/with-appcast.rb | 11 +++ .../support/fixtures/cask/Casks/with-binary.rb | 10 +++ .../support/fixtures/cask/Casks/with-caveats.rb | 23 +++++++ .../support/fixtures/cask/Casks/with-choices.rb | 16 +++++ .../cask/Casks/with-conditional-caveats.rb | 14 ++++ .../fixtures/cask/Casks/with-conflicts-with.rb | 11 +++ .../fixtures/cask/Casks/with-depends-on-arch.rb | 12 ++++ .../Casks/with-depends-on-cask-cyclic-helper.rb | 11 +++ .../cask/Casks/with-depends-on-cask-cyclic.rb | 12 ++++ .../cask/Casks/with-depends-on-cask-multiple.rb | 12 ++++ .../fixtures/cask/Casks/with-depends-on-cask.rb | 11 +++ .../cask/Casks/with-depends-on-formula-multiple.rb | 12 ++++ .../fixtures/cask/Casks/with-depends-on-formula.rb | 11 +++ .../cask/Casks/with-depends-on-macos-array.rb | 12 ++++ .../cask/Casks/with-depends-on-macos-comparison.rb | 11 +++ .../cask/Casks/with-depends-on-macos-failure.rb | 12 ++++ .../cask/Casks/with-depends-on-macos-string.rb | 11 +++ .../cask/Casks/with-depends-on-macos-symbol.rb | 11 +++ .../cask/Casks/with-depends-on-x11-false.rb | 11 +++ .../fixtures/cask/Casks/with-depends-on-x11.rb | 11 +++ .../fixtures/cask/Casks/with-dsl-version.rb | 9 +++ .../fixtures/cask/Casks/with-embedded-binary.rb | 10 +++ .../cask/Casks/with-generic-artifact-no-target.rb | 9 +++ .../fixtures/cask/Casks/with-generic-artifact.rb | 9 +++ .../fixtures/cask/Casks/with-gpg-key-url.rb | 11 +++ .../test/support/fixtures/cask/Casks/with-gpg.rb | 11 +++ .../fixtures/cask/Casks/with-installable.rb | 20 ++++++ .../fixtures/cask/Casks/with-installer-manual.rb | 9 +++ .../fixtures/cask/Casks/with-installer-script.rb | 15 ++++ .../support/fixtures/cask/Casks/with-macosx-dir.rb | 9 +++ .../fixtures/cask/Casks/with-pkgutil-zap.rb | 13 ++++ .../test/support/fixtures/cask/Casks/with-suite.rb | 10 +++ .../fixtures/cask/Casks/with-two-apps-correct.rb | 10 +++ .../fixtures/cask/Casks/with-two-apps-incorrect.rb | 9 +++ .../fixtures/cask/Casks/with-two-apps-subdir.rb | 10 +++ .../fixtures/cask/Casks/with-uninstall-delete.rb | 16 +++++ .../cask/Casks/with-uninstall-early-script.rb | 11 +++ .../fixtures/cask/Casks/with-uninstall-kext.rb | 11 +++ .../cask/Casks/with-uninstall-launchctl.rb | 11 +++ .../cask/Casks/with-uninstall-login-item.rb | 11 +++ .../fixtures/cask/Casks/with-uninstall-pkgutil.rb | 11 +++ .../fixtures/cask/Casks/with-uninstall-quit.rb | 11 +++ .../fixtures/cask/Casks/with-uninstall-rmdir.rb | 11 +++ .../fixtures/cask/Casks/with-uninstall-script.rb | 11 +++ .../fixtures/cask/Casks/with-uninstall-signal.rb | 14 ++++ .../fixtures/cask/Casks/with-uninstall-trash.rb | 16 +++++ .../support/fixtures/cask/Casks/with-zap-delete.rb | 16 +++++ .../fixtures/cask/Casks/with-zap-early-script.rb | 11 +++ .../support/fixtures/cask/Casks/with-zap-kext.rb | 11 +++ .../fixtures/cask/Casks/with-zap-launchctl.rb | 11 +++ .../fixtures/cask/Casks/with-zap-login-item.rb | 11 +++ .../fixtures/cask/Casks/with-zap-pkgutil.rb | 11 +++ .../support/fixtures/cask/Casks/with-zap-quit.rb | 11 +++ .../support/fixtures/cask/Casks/with-zap-rmdir.rb | 11 +++ .../support/fixtures/cask/Casks/with-zap-script.rb | 11 +++ .../support/fixtures/cask/Casks/with-zap-signal.rb | 14 ++++ .../support/fixtures/cask/Casks/with-zap-trash.rb | 16 +++++ .../test/support/fixtures/cask/Casks/with-zap.rb | 19 +++++ 297 files changed, 1480 insertions(+), 1482 deletions(-) delete mode 100644 Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/booby-trap.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/missing-name.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/missing-url.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/missing-version.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/with-binary.rb delete mode 100644 Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/auto-updates.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/bad-checksum.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/basic-cask.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-7z.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-air.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-bzip2.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-cab.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-dmg.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-gzip.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-lzma.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-pkg.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-rar.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-sit.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-xar.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/container-xz.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/local-caffeine.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/local-transmission.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/missing-checksum.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/naked-executable.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/nested-app.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/no-checksum.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/stage-only.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/test-opera.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-alt-target.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-appcast.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-caveats.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-choices.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-gpg.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-installable.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-installer-script.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-suite.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-script.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-zap.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb index 775b9229f..80f1f1da0 100644 --- a/Library/Homebrew/cask/lib/hbc.rb +++ b/Library/Homebrew/cask/lib/hbc.rb @@ -6,6 +6,7 @@ require "hbc/audit" require "hbc/auditor" require "hbc/cache" require "hbc/cask" +require "hbc/cask_loader" require "hbc/without_source" require "hbc/caskroom" require "hbc/checkable" diff --git a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb index fbb117f67..95ac2b5f5 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb @@ -1,6 +1,6 @@ describe Hbc::Artifact::Binary do let(:cask) { - Hbc.load("with-binary").tap do |cask| + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask| shutup do InstallHelper.install_without_artifacts(cask) end @@ -69,7 +69,7 @@ describe Hbc::Artifact::Binary do context "binary is inside an app package" do let(:cask) { - Hbc.load("with-embedded-binary").tap do |cask| + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask| shutup do InstallHelper.install_without_artifacts(cask) end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 162cb3b8f..a9a5bb0a3 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -32,7 +32,7 @@ Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| # link test casks FileUtils.mkdir_p tap.path.dirname - FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path + FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path end RSpec.configure do |config| diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb deleted file mode 100644 index f40f244f2..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'appcast-checkpoint-sha256-for-empty-string' do - appcast 'http://localhost/appcast.xml', - checkpoint: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb deleted file mode 100644 index e182c2389..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'appcast-invalid-checkpoint' do - appcast 'http://localhost/appcast.xml', - checkpoint: 'not a valid shasum' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb deleted file mode 100644 index 5ab2c0665..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'appcast-missing-checkpoint' do - appcast 'http://localhost/appcast.xml' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb b/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb deleted file mode 100644 index 96d7edbba..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'appcast-valid-checkpoint' do - appcast 'http://localhost/appcast.xml', - checkpoint: 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb b/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb deleted file mode 100644 index 21bd97952..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb +++ /dev/null @@ -1,8 +0,0 @@ -cask 'booby-trap' do - version '0.0.7' - - url do - # to be lazily evaluated - fail 'Boom' - end -end diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb deleted file mode 100644 index 475fb055f..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'generic-artifact-absolute-target' do - artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" -end diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb deleted file mode 100644 index f7657dbb5..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'generic-artifact-no-target' do - artifact 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb deleted file mode 100644 index f97441751..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb +++ /dev/null @@ -1,3 +0,0 @@ -test_cask 'generic-artifact-relative-target' do - artifact 'Caffeine.app', target: 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb b/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb deleted file mode 100644 index aac00f495..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'invalid-sha256' do - version '1.2.3' - sha256 'not a valid shasum' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb b/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb deleted file mode 100644 index ff924541d..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-homepage' do - version '1.2.3' - - url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-name.rb b/Library/Homebrew/cask/spec/support/Casks/missing-name.rb deleted file mode 100644 index a5265b379..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-name.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-name' do - version '1.2.3' - - url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb b/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb deleted file mode 100644 index 7f8027907..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-sha256' do - version '1.2.3' - - url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-url.rb b/Library/Homebrew/cask/spec/support/Casks/missing-url.rb deleted file mode 100644 index 1b3e76b9c..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-url.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-url' do - version '1.2.3' - - homepage 'http://example.com' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-version.rb b/Library/Homebrew/cask/spec/support/Casks/missing-version.rb deleted file mode 100644 index da2160bce..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-version.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'missing-version' do - url 'http://localhost/something.dmg' - homepage 'http://example.com' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb deleted file mode 100644 index da6ff0fcd..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'osdn-correct-url-format' do - version '1.2.3' - - url 'http://user.dl.osdn.jp/something/id/Something-1.2.3.dmg' - homepage 'http://osdn.jp/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb deleted file mode 100644 index 8400159a1..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'osdn-incorrect-url-format' do - version '1.2.3' - - url 'http://osdn.jp/projects/something/files/Something-1.2.3.dmg/download' - homepage 'http://osdn.jp/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb b/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb deleted file mode 100644 index b97764071..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'sha256-for-empty-string' do - version '1.2.3' - sha256 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb deleted file mode 100644 index 41ef73500..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'sourceforge-correct-url-format' do - version '1.2.3' - - url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg' - homepage 'https://sourceforge.net/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb deleted file mode 100644 index 27b5490b7..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'sourceforge-incorrect-url-format' do - version '1.2.3' - - url 'http://sourceforge.net/projects/something/files/Something-1.2.3.dmg/download' - homepage 'http://sourceforge.net/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb b/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb deleted file mode 100644 index d9546c5e1..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb +++ /dev/null @@ -1,6 +0,0 @@ -test_cask 'sourceforge-version-latest-correct-url-format' do - version :latest - - url 'https://sourceforge.net/projects/something/files/latest/download' - homepage 'https://sourceforge.net/projects/something/' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb b/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb deleted file mode 100644 index 3b4723f45..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'version-latest-string' do - version 'latest' - sha256 :no_check -end diff --git a/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb b/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb deleted file mode 100644 index 884ddff90..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb +++ /dev/null @@ -1,4 +0,0 @@ -test_cask 'version-latest-with-checksum' do - version :latest - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/with-binary.rb b/Library/Homebrew/cask/spec/support/Casks/with-binary.rb deleted file mode 100644 index d8cede7aa..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/with-binary.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-binary' do - version '1.2.3' - sha256 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' - - url "file://#{TEST_FIXTURE_DIR}/cask/AppWithBinary.zip" - homepage 'http://example.com/with-binary' - - app 'App.app' - binary 'binary' -end diff --git a/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb b/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb deleted file mode 100644 index 107c6cbe2..000000000 --- a/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-embedded-binary' do - version '1.2.3' - sha256 'fe052d3e77d92676775fd916ddb8942e72a565b844ea7f6d055474c99bb4e47b' - - url "file://#{TEST_FIXTURE_DIR}/cask/AppWithEmbeddedBinary.zip" - homepage 'http://example.com/with-binary' - - app 'App.app' - binary "#{appdir}/App.app/Contents/MacOS/App/binary" -end diff --git a/Library/Homebrew/cask/test/cask/accessibility_test.rb b/Library/Homebrew/cask/test/cask/accessibility_test.rb index 7c6484dd4..657629469 100644 --- a/Library/Homebrew/cask/test/cask/accessibility_test.rb +++ b/Library/Homebrew/cask/test/cask/accessibility_test.rb @@ -3,7 +3,7 @@ require "test_helper" # TODO: this test should be named after the corresponding class, once # that class is abstracted from installer.rb. describe "Accessibility Access" do - let(:cask) { Hbc.load("with-accessibility-access") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") } let(:with_fake_command) { { command: Hbc::FakeSystemCommand } } let(:installer) { Hbc::Installer.new(cask, with_fake_command) } diff --git a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb b/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb index d1fe26eaa..06c76f337 100644 --- a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb @@ -2,7 +2,7 @@ require "test_helper" describe Hbc::Artifact::App do describe "activate to alternate target" do - let(:cask) { Hbc.load("with-alt-target") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") } let(:install_phase) { -> { Hbc::Artifact::App.new(cask).install_phase } diff --git a/Library/Homebrew/cask/test/cask/artifact/app_test.rb b/Library/Homebrew/cask/test/cask/artifact/app_test.rb index 3eeeb729f..1403a34a9 100644 --- a/Library/Homebrew/cask/test/cask/artifact/app_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/app_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::Artifact::App do - let(:cask) { Hbc.load("local-caffeine") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } let(:command) { Hbc::SystemCommand } let(:force) { false } let(:app) { Hbc::Artifact::App.new(cask, command: command, force: force) } diff --git a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb b/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb index 42740cd44..21584b92a 100644 --- a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::Artifact::Artifact do - let(:cask) { Hbc.load("with-generic-artifact") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } let(:install_phase) { -> { Hbc::Artifact::Artifact.new(cask).install_phase } @@ -15,7 +15,7 @@ describe Hbc::Artifact::Artifact do end describe "with no target" do - let(:cask) { Hbc.load("with-generic-artifact-no-target") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") } it "fails to install with no target" do install_phase.must_raise Hbc::CaskInvalidError diff --git a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb b/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb index b771ba345..4d7ceaaa0 100644 --- a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb @@ -3,7 +3,7 @@ require "test_helper" describe Hbc::Artifact::NestedContainer do describe "install" do it "extracts the specified paths as containers" do - cask = Hbc.load("nested-app").tap do |c| + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c| TestHelper.install_without_artifacts(c) end diff --git a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb index 3ed427763..a77fb0a07 100644 --- a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb @@ -2,7 +2,7 @@ require "test_helper" describe Hbc::Artifact::Pkg do before do - @cask = Hbc.load("with-installable") + @cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") shutup do TestHelper.install_without_artifacts(@cask) end @@ -33,7 +33,7 @@ describe Hbc::Artifact::Pkg do describe "choices" do before do - @cask = Hbc.load("with-choices") + @cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") shutup do TestHelper.install_without_artifacts(@cask) end diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb index ed151e45c..0584dcbeb 100644 --- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::Artifact::Suite do - let(:cask) { Hbc.load("with-suite") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") } let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } } diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb index c699d247f..c6ad9db47 100644 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb @@ -2,7 +2,7 @@ require "test_helper" describe Hbc::Artifact::App do describe "multiple apps" do - let(:cask) { Hbc.load("with-two-apps-correct") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") } let(:install_phase) { -> { Hbc::Artifact::App.new(cask).install_phase } @@ -31,7 +31,7 @@ describe Hbc::Artifact::App do end describe "when apps are in a subdirectory" do - let(:cask) { Hbc.load("with-two-apps-subdir") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") } it "installs both apps using the proper target directory" do shutup do diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb index a89a94fba..a79fc6378 100644 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb @@ -1,14 +1,11 @@ require "test_helper" describe Hbc::Artifact::App do - it "must raise" do - exception_raised = begin - Hbc.load("two-apps-incorrect") - false - rescue - true - end - # TODO: later give the user a nice exception for this case and check for it here - assert exception_raised - end + # FIXME: Doesn't actually raise because the `app` stanza is not evaluated on load. + # it "must raise" do + # lambda { + # Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-incorrect.rb") + # }.must_raise + # # TODO: later give the user a nice exception for this case and check for it here + # end end diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb index b09d39833..3fb679196 100644 --- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::Artifact::Uninstall do - let(:cask) { Hbc.load("with-installable") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } let(:uninstall_artifact) { Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand) @@ -37,7 +37,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using launchctl" do - let(:cask) { Hbc.load("with-uninstall-launchctl") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") } let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] } let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] } let(:unknown_response) { "launchctl list returned unknown response\n" } @@ -94,7 +94,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using pkgutil" do - let(:cask) { Hbc.load("with-uninstall-pkgutil") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-pkgutil.rb") } let(:main_pkg_id) { "my.fancy.package.main" } let(:agent_pkg_id) { "my.fancy.package.agent" } let(:main_files) { @@ -180,7 +180,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using kext" do - let(:cask) { Hbc.load("with-uninstall-kext") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-kext.rb") } let(:kext_id) { "my.fancy.package.kernelextension" } it "can uninstall" do @@ -205,7 +205,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using quit" do - let(:cask) { Hbc.load("with-uninstall-quit") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-quit.rb") } let(:bundle_id) { "my.fancy.package.app" } let(:quit_application_script) { %Q(tell application id "#{bundle_id}" to quit) @@ -225,7 +225,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using signal" do - let(:cask) { Hbc.load("with-uninstall-signal") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-signal.rb") } let(:bundle_id) { "my.fancy.package.app" } let(:signals) { %w[TERM KILL] } let(:unix_pids) { [12_345, 67_890] } @@ -244,7 +244,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using delete" do - let(:cask) { Hbc.load("with-uninstall-delete") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-delete.rb") } it "can uninstall" do Hbc::FakeSystemCommand.expects_command( @@ -258,7 +258,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using trash" do - let(:cask) { Hbc.load("with-uninstall-trash") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-trash.rb") } it "can uninstall" do Hbc::FakeSystemCommand.expects_command( @@ -272,7 +272,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using rmdir" do - let(:cask) { Hbc.load("with-uninstall-rmdir") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") } let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } it "can uninstall" do @@ -289,7 +289,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using script" do - let(:cask) { Hbc.load("with-uninstall-script") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script.rb") } let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } it "can uninstall" do @@ -304,7 +304,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using early_script" do - let(:cask) { Hbc.load("with-uninstall-early-script") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-early-script.rb") } let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } it "can uninstall" do @@ -319,7 +319,7 @@ describe Hbc::Artifact::Uninstall do end describe "when using login_item" do - let(:cask) { Hbc.load("with-uninstall-login-item") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-login-item.rb") } it "can uninstall" do Hbc::FakeSystemCommand.expects_command( diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb index b65b0bf5c..0ebd9b304 100644 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb @@ -2,7 +2,7 @@ require "test_helper" # TODO: test that zap removes an alternate version of the same Cask describe Hbc::Artifact::Zap do - let(:cask) { Hbc.load("with-installable") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } let(:zap_artifact) { Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand) @@ -38,7 +38,7 @@ describe Hbc::Artifact::Zap do end describe "when using launchctl" do - let(:cask) { Hbc.load("with-zap-launchctl") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") } let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] } let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] } let(:unknown_response) { "launchctl list returned unknown response\n" } @@ -95,7 +95,7 @@ describe Hbc::Artifact::Zap do end describe "when using pkgutil" do - let(:cask) { Hbc.load("with-zap-pkgutil") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-pkgutil.rb") } let(:main_pkg_id) { "my.fancy.package.main" } let(:agent_pkg_id) { "my.fancy.package.agent" } let(:main_files) { @@ -181,7 +181,7 @@ describe Hbc::Artifact::Zap do end describe "when using kext" do - let(:cask) { Hbc.load("with-zap-kext") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-kext.rb") } let(:kext_id) { "my.fancy.package.kernelextension" } it "can zap" do @@ -206,7 +206,7 @@ describe Hbc::Artifact::Zap do end describe "when using quit" do - let(:cask) { Hbc.load("with-zap-quit") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-quit.rb") } let(:bundle_id) { "my.fancy.package.app" } let(:quit_application_script) { %Q(tell application id "#{bundle_id}" to quit) @@ -226,7 +226,7 @@ describe Hbc::Artifact::Zap do end describe "when using signal" do - let(:cask) { Hbc.load("with-zap-signal") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-signal.rb") } let(:bundle_id) { "my.fancy.package.app" } let(:signals) { %w[TERM KILL] } let(:unix_pids) { [12_345, 67_890] } @@ -245,7 +245,7 @@ describe Hbc::Artifact::Zap do end describe "when using delete" do - let(:cask) { Hbc.load("with-zap-delete") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-delete.rb") } it "can zap" do Hbc::FakeSystemCommand.expects_command( @@ -259,7 +259,7 @@ describe Hbc::Artifact::Zap do end describe "when using trash" do - let(:cask) { Hbc.load("with-zap-trash") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-trash.rb") } it "can zap" do Hbc::FakeSystemCommand.expects_command( @@ -273,7 +273,7 @@ describe Hbc::Artifact::Zap do end describe "when using rmdir" do - let(:cask) { Hbc.load("with-zap-rmdir") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") } let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } it "can zap" do @@ -290,7 +290,7 @@ describe Hbc::Artifact::Zap do end describe "when using script" do - let(:cask) { Hbc.load("with-zap-script") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-script.rb") } let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } it "can zap" do @@ -305,7 +305,7 @@ describe Hbc::Artifact::Zap do end describe "when using early_script" do - let(:cask) { Hbc.load("with-zap-early-script") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-early-script.rb") } let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } it "can zap" do @@ -320,7 +320,7 @@ describe Hbc::Artifact::Zap do end describe "when using login_item" do - let(:cask) { Hbc.load("with-zap-login-item") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-login-item.rb") } it "can zap" do Hbc::FakeSystemCommand.expects_command( diff --git a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb b/Library/Homebrew/cask/test/cask/cli/fetch_test.rb index 70c25646d..8dd7e0ebf 100644 --- a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/fetch_test.rb @@ -2,11 +2,11 @@ require "test_helper" describe Hbc::CLI::Fetch do let(:local_transmission) { - Hbc.load("local-transmission") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } let(:local_caffeine) { - Hbc.load("local-caffeine") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } it "allows download the installer of a Cask" do diff --git a/Library/Homebrew/cask/test/cask/cli/install_test.rb b/Library/Homebrew/cask/test/cask/cli/install_test.rb index eef3f2e5b..d47d55a50 100644 --- a/Library/Homebrew/cask/test/cask/cli/install_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/install_test.rb @@ -6,9 +6,9 @@ describe Hbc::CLI::Install do Hbc::CLI::Install.run("local-transmission", "local-caffeine") end - Hbc.load("local-transmission").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? Hbc.appdir.join("Transmission.app").must_be :directory? - Hbc.load("local-caffeine").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb").must_be :installed? Hbc.appdir.join("Caffeine.app").must_be :directory? end @@ -19,7 +19,7 @@ describe Hbc::CLI::Install do shutup do Hbc::CLI::Install.run("local-transmission") end - Hbc.load("local-transmission").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? end it "prints a warning message on double install" do @@ -46,9 +46,9 @@ describe Hbc::CLI::Install do shutup do Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps") end - Hbc.load("with-depends-on-cask-multiple").must_be :installed? - Hbc.load("local-caffeine").wont_be :installed? - Hbc.load("local-transmission").wont_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb").wont_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").wont_be :installed? end it "properly handles Casks that are not present" do diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/test/cask/cli/list_test.rb index 4220ea510..9acf37efe 100644 --- a/Library/Homebrew/cask/test/cask/cli/list_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/list_test.rb @@ -64,8 +64,8 @@ describe Hbc::CLI::List do end describe "given a set of installed Casks" do - let(:caffeine) { Hbc.load("local-caffeine") } - let(:transmission) { Hbc.load("local-transmission") } + let(:caffeine) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } + let(:transmission) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } let(:casks) { [caffeine, transmission] } it "lists the installed files for those Casks" do diff --git a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb b/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb index 02cdeb763..d34a2c6bb 100644 --- a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb @@ -5,20 +5,20 @@ describe Hbc::CLI::Reinstall do shutup do Hbc::CLI::Install.run("local-transmission") end - Hbc.load("local-transmission").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? shutup do Hbc::CLI::Reinstall.run("local-transmission") end - Hbc.load("local-transmission").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? end it "allows reinstalling a non installed Cask" do - Hbc.load("local-transmission").wont_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").wont_be :installed? shutup do Hbc::CLI::Reinstall.run("local-transmission") end - Hbc.load("local-transmission").must_be :installed? + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? end end diff --git a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb b/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb index 0368ad87c..540909be3 100644 --- a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb @@ -20,8 +20,8 @@ describe Hbc::CLI::Uninstall do end it "can uninstall and unlink multiple Casks at once" do - caffeine = Hbc.load("local-caffeine") - transmission = Hbc.load("local-transmission") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") shutup do Hbc::Installer.new(caffeine).install diff --git a/Library/Homebrew/cask/test/cask/cli/zap_test.rb b/Library/Homebrew/cask/test/cask/cli/zap_test.rb index a9e862b11..0f2aa4f8e 100644 --- a/Library/Homebrew/cask/test/cask/cli/zap_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/zap_test.rb @@ -8,8 +8,8 @@ describe Hbc::CLI::Zap do end it "can zap and unlink multiple Casks at once" do - caffeine = Hbc.load("local-caffeine") - transmission = Hbc.load("local-transmission") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") shutup do Hbc::Installer.new(caffeine).install diff --git a/Library/Homebrew/cask/test/cask/container/dmg_test.rb b/Library/Homebrew/cask/test/cask/container/dmg_test.rb index 2c33b88b6..67161c580 100644 --- a/Library/Homebrew/cask/test/cask/container/dmg_test.rb +++ b/Library/Homebrew/cask/test/cask/container/dmg_test.rb @@ -3,7 +3,7 @@ require "test_helper" describe Hbc::Container::Dmg do describe "mount!" do it "does not store nil mounts for dmgs with extra data" do - transmission = Hbc.load("local-transmission") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") dmg = Hbc::Container::Dmg.new( transmission, diff --git a/Library/Homebrew/cask/test/cask/depends_on_test.rb b/Library/Homebrew/cask/test/cask/depends_on_test.rb index 4516dad37..1ec85b520 100644 --- a/Library/Homebrew/cask/test/cask/depends_on_test.rb +++ b/Library/Homebrew/cask/test/cask/depends_on_test.rb @@ -13,7 +13,7 @@ describe "Satisfy Dependencies and Requirements" do describe "depends_on cask" do it "raises an exception when depends_on cask is cyclic" do - dep_cask = Hbc.load("with-depends-on-cask-cyclic") + dep_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb") lambda { shutup do Hbc::Installer.new(dep_cask).install @@ -22,7 +22,7 @@ describe "Satisfy Dependencies and Requirements" do end it "installs the dependency of a Cask and the Cask itself" do - csk = Hbc.load("with-depends-on-cask") + csk = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") dependency = Hbc.load(csk.depends_on.cask.first) shutup do Hbc::Installer.new(csk).install @@ -35,35 +35,35 @@ describe "Satisfy Dependencies and Requirements" do describe "depends_on macos" do it "understands depends_on macos: " do - macos_cask = Hbc.load("with-depends-on-macos-array") + macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb") shutup do Hbc::Installer.new(macos_cask).install end end it "understands depends_on macos: " do - macos_cask = Hbc.load("with-depends-on-macos-comparison") + macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb") shutup do Hbc::Installer.new(macos_cask).install end end it "understands depends_on macos: " do - macos_cask = Hbc.load("with-depends-on-macos-string") + macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") shutup do Hbc::Installer.new(macos_cask).install end end it "understands depends_on macos: " do - macos_cask = Hbc.load("with-depends-on-macos-symbol") + macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb") shutup do Hbc::Installer.new(macos_cask).install end end it "raises an exception when depends_on macos is not satisfied" do - macos_cask = Hbc.load("with-depends-on-macos-failure") + macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb") lambda { shutup do Hbc::Installer.new(macos_cask).install @@ -74,7 +74,7 @@ describe "Satisfy Dependencies and Requirements" do describe "depends_on arch" do it "succeeds when depends_on arch is satisfied" do - arch_cask = Hbc.load("with-depends-on-arch") + arch_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") shutup do Hbc::Installer.new(arch_cask).install end @@ -83,7 +83,7 @@ describe "Satisfy Dependencies and Requirements" do describe "depends_on x11" do it "succeeds when depends_on x11 is satisfied" do - x11_cask = Hbc.load("with-depends-on-x11") + x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") MacOS::X11.stubs(:installed?).returns(true) shutup do Hbc::Installer.new(x11_cask).install @@ -91,7 +91,7 @@ describe "Satisfy Dependencies and Requirements" do end it "raises an exception when depends_on x11 is not satisfied" do - x11_cask = Hbc.load("with-depends-on-x11") + x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") MacOS::X11.stubs(:installed?).returns(false) lambda { shutup do @@ -101,7 +101,7 @@ describe "Satisfy Dependencies and Requirements" do end it "never raises when depends_on x11: false" do - x11_cask = Hbc.load("with-depends-on-x11-false") + x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb") MacOS::X11.stubs(:installed?).returns(false) lambda do shutup do diff --git a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb b/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb index d0c7eef34..37845e7c3 100644 --- a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::DSL::Caveats do - let(:cask) { Hbc.load("basic-cask") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } let(:dsl) { Hbc::DSL::Caveats.new(cask) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb index c5e80b6d0..b5b38102d 100644 --- a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::DSL::Postflight do - let(:cask) { Hbc.load("basic-cask") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb index 1c49a62ad..555be7ed9 100644 --- a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::DSL::Preflight do - let(:cask) { Hbc.load("basic-cask") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb index c704706ad..ae4db979e 100644 --- a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::DSL::UninstallPostflight do - let(:cask) { Hbc.load("basic-cask") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb index f6ab36b60..f964b0098 100644 --- a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb @@ -1,7 +1,7 @@ require "test_helper" describe Hbc::DSL::UninstallPreflight do - let(:cask) { Hbc.load("basic-cask") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb index 0ea928f40..cdd06a836 100644 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl_test.rb @@ -2,7 +2,7 @@ require "test_helper" describe Hbc::DSL do it "lets you set url, homepage, and version" do - test_cask = Hbc.load("basic-cask") + test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" test_cask.homepage.must_equal "http://example.com/" test_cask.version.to_s.must_equal "1.2.3" @@ -48,20 +48,20 @@ describe Hbc::DSL do describe "header line" do it "requires a valid header format" do lambda { - Hbc.load("invalid/invalid-header-format") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-header-format.rb") }.must_raise(SyntaxError) end it "requires the header token to match the file name" do err = lambda { - Hbc.load("invalid/invalid-header-token-mismatch") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-header-token-mismatch.rb") }.must_raise(Hbc::CaskTokenDoesNotMatchError) err.message.must_include "Bad header line:" err.message.must_include "does not match file name" end it "does not require a DSL version in the header" do - test_cask = Hbc.load("no-dsl-version") + test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-dsl-version.rb") test_cask.token.must_equal "no-dsl-version" test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" test_cask.homepage.must_equal "http://example.com/" @@ -75,7 +75,7 @@ describe Hbc::DSL do ENV.stub :[], stub do shutup do - test_cask = Hbc.load("with-dsl-version") + test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-dsl-version.rb") test_cask.token.must_equal "with-dsl-version" test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" test_cask.homepage.must_equal "http://example.com/" @@ -233,7 +233,7 @@ describe Hbc::DSL do describe "url stanza" do it "prevents defining multiple urls" do err = lambda { - Hbc.load("invalid/invalid-two-url") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-url.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'url' stanza may only appear once" end @@ -242,7 +242,7 @@ describe Hbc::DSL do describe "homepage stanza" do it "prevents defining multiple homepages" do err = lambda { - Hbc.load("invalid/invalid-two-homepage") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-homepage.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'homepage' stanza may only appear once" end @@ -251,7 +251,7 @@ describe Hbc::DSL do describe "version stanza" do it "prevents defining multiple versions" do err = lambda { - Hbc.load("invalid/invalid-two-version") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-version.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'version' stanza may only appear once" end @@ -259,77 +259,77 @@ describe Hbc::DSL do describe "appcast stanza" do it "allows appcasts to be specified" do - cask = Hbc.load("with-appcast") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-appcast.rb") cask.appcast.to_s.must_match(/^http/) end it "prevents defining multiple appcasts" do err = lambda { - Hbc.load("invalid/invalid-appcast-multiple") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-appcast-multiple.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'appcast' stanza may only appear once" end it "refuses to load invalid appcast URLs" do lambda { - Hbc.load("invalid/invalid-appcast-url") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-appcast-url.rb") }.must_raise(Hbc::CaskInvalidError) end end describe "gpg stanza" do it "allows gpg stanza to be specified" do - cask = Hbc.load("with-gpg") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-gpg.rb") cask.gpg.to_s.must_match(/\S/) end it "allows gpg stanza to be specified with :key_url" do - cask = Hbc.load("with-gpg-key-url") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-gpg-key-url.rb") cask.gpg.to_s.must_match(/\S/) end it "prevents specifying gpg stanza multiple times" do err = lambda { - Hbc.load("invalid/invalid-gpg-multiple-stanzas") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'gpg' stanza may only appear once" end it "prevents missing gpg key parameters" do err = lambda { - Hbc.load("invalid/invalid-gpg-missing-key") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-missing-key.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'gpg' stanza must include exactly one" end it "prevents conflicting gpg key parameters" do err = lambda { - Hbc.load("invalid/invalid-gpg-conflicting-keys") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-conflicting-keys.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'gpg' stanza must include exactly one" end it "refuses to load invalid gpg signature URLs" do lambda { - Hbc.load("invalid/invalid-gpg-signature-url") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-signature-url.rb") }.must_raise(Hbc::CaskInvalidError) end it "refuses to load invalid gpg key URLs" do lambda { - Hbc.load("invalid/invalid-gpg-key-url") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-key-url.rb") }.must_raise(Hbc::CaskInvalidError) end it "refuses to load invalid gpg key IDs" do lambda { - Hbc.load("invalid/invalid-gpg-key-id") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-key-id.rb") }.must_raise(Hbc::CaskInvalidError) end it "refuses to load if gpg parameter is unknown" do lambda { - Hbc.load("invalid/invalid-gpg-parameter") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-parameter.rb") }.must_raise(Hbc::CaskInvalidError) end end @@ -337,112 +337,112 @@ describe Hbc::DSL do describe "depends_on stanza" do it "refuses to load with an invalid depends_on key" do lambda { - Hbc.load("invalid/invalid-depends-on-key") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-key.rb") }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on formula" do it "allows depends_on formula to be specified" do - cask = Hbc.load("with-depends-on-formula") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-formula.rb") cask.depends_on.formula.wont_be_nil end it "allows multiple depends_on formula to be specified" do - cask = Hbc.load("with-depends-on-formula-multiple") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-formula-multiple.rb") cask.depends_on.formula.wont_be_nil end end describe "depends_on cask" do it "allows depends_on cask to be specified" do - cask = Hbc.load("with-depends-on-cask") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") cask.depends_on.cask.wont_be_nil end it "allows multiple depends_on cask to be specified" do - cask = Hbc.load("with-depends-on-cask-multiple") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb") cask.depends_on.cask.wont_be_nil end end describe "depends_on macos" do it "allows depends_on macos to be specified" do - cask = Hbc.load("with-depends-on-macos-string") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") cask.depends_on.macos.wont_be_nil end it "refuses to load with an invalid depends_on macos value" do lambda { - Hbc.load("invalid/invalid-depends-on-macos-bad-release") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb") }.must_raise(Hbc::CaskInvalidError) end it "refuses to load with conflicting depends_on macos forms" do lambda { - Hbc.load("invalid/invalid-depends-on-macos-conflicting-forms") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb") }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on arch" do it "allows depends_on arch to be specified" do - cask = Hbc.load("with-depends-on-arch") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") cask.depends_on.arch.wont_be_nil end it "refuses to load with an invalid depends_on arch value" do lambda { - Hbc.load("invalid/invalid-depends-on-arch-value") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-arch-value.rb") }.must_raise(Hbc::CaskInvalidError) end end describe "depends_on x11" do it "allows depends_on x11 to be specified" do - cask = Hbc.load("with-depends-on-x11") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") cask.depends_on.x11.wont_be_nil end it "refuses to load with an invalid depends_on x11 value" do lambda { - Hbc.load("invalid/invalid-depends-on-x11-value") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-x11-value.rb") }.must_raise(Hbc::CaskInvalidError) end end describe "conflicts_with stanza" do it "allows conflicts_with stanza to be specified" do - cask = Hbc.load("with-conflicts-with") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-conflicts-with.rb") cask.conflicts_with.formula.wont_be_nil end it "refuses to load invalid conflicts_with key" do lambda { - Hbc.load("invalid/invalid-conflicts-with-key") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-conflicts-with-key.rb") }.must_raise(Hbc::CaskInvalidError) end end describe "installer stanza" do it "allows installer script to be specified" do - cask = Hbc.load("with-installer-script") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-script.rb") cask.artifacts[:installer].first.script[:executable].must_equal "/usr/bin/true" cask.artifacts[:installer].first.script[:args].must_equal ["--flag"] cask.artifacts[:installer].to_a[1].script[:executable].must_equal "/usr/bin/false" cask.artifacts[:installer].to_a[1].script[:args].must_equal ["--flag"] end it "allows installer manual to be specified" do - cask = Hbc.load("with-installer-manual") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") cask.artifacts[:installer].first.manual.must_equal "Caffeine.app" end end describe "stage_only stanza" do it "allows stage_only stanza to be specified" do - cask = Hbc.load("stage-only") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/stage-only.rb") cask.artifacts[:stage_only].first.must_equal [true] end it "prevents specifying stage_only with other activatables" do err = lambda { - Hbc.load("invalid/invalid-stage-only-conflict") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-stage-only-conflict.rb") }.must_raise(Hbc::CaskInvalidError) err.message.must_include "'stage_only' must be the only activatable artifact" end @@ -450,14 +450,14 @@ describe Hbc::DSL do describe "auto_updates stanza" do it "allows auto_updates stanza to be specified" do - cask = Hbc.load("auto-updates") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") cask.auto_updates.must_equal true end end describe "appdir" do it "allows interpolation of the appdir value in stanzas" do - cask = Hbc.load("appdir-interpolation") + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/appdir-interpolation.rb") cask.artifacts[:binary].first.must_equal ["#{Hbc.appdir}/some/path"] end diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb index d76411ae6..b26c28847 100644 --- a/Library/Homebrew/cask/test/cask/installer_test.rb +++ b/Library/Homebrew/cask/test/cask/installer_test.rb @@ -7,7 +7,7 @@ describe Hbc::Installer do } it "downloads and installs a nice fresh Cask" do - caffeine = Hbc.load("local-caffeine") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") shutup do Hbc::Installer.new(caffeine).install @@ -20,7 +20,7 @@ describe Hbc::Installer do end it "works with dmg-based Casks" do - asset = Hbc.load("container-dmg") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb") shutup do Hbc::Installer.new(asset).install @@ -33,7 +33,7 @@ describe Hbc::Installer do end it "works with tar-gz-based Casks" do - asset = Hbc.load("container-tar-gz") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb") shutup do Hbc::Installer.new(asset).install @@ -47,7 +47,7 @@ describe Hbc::Installer do it "works with cab-based Casks" do skip("cabextract not installed") if which("cabextract").nil? - asset = Hbc.load("container-cab") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-cab.rb") asset.stub :depends_on, empty_depends_on_stub do shutup do @@ -63,7 +63,7 @@ describe Hbc::Installer do it "works with Adobe AIR-based Casks" do skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist? - asset = Hbc.load("container-air") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-air.rb") shutup do Hbc::Installer.new(asset).install @@ -77,7 +77,7 @@ describe Hbc::Installer do it "works with 7z-based Casks" do skip("unar not installed") if which("unar").nil? - asset = Hbc.load("container-7z") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-7z.rb") asset.stub :depends_on, empty_depends_on_stub do shutup do @@ -92,7 +92,7 @@ describe Hbc::Installer do end it "works with xar-based Casks" do - asset = Hbc.load("container-xar") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb") shutup do Hbc::Installer.new(asset).install @@ -106,7 +106,7 @@ describe Hbc::Installer do it "works with Stuffit-based Casks" do skip("unar not installed") if which("unar").nil? - asset = Hbc.load("container-sit") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-sit.rb") asset.stub :depends_on, empty_depends_on_stub do shutup do @@ -122,7 +122,7 @@ describe Hbc::Installer do it "works with RAR-based Casks" do skip("unar not installed") if which("unar").nil? - asset = Hbc.load("container-rar") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-rar.rb") asset.stub :depends_on, empty_depends_on_stub do shutup do @@ -137,7 +137,7 @@ describe Hbc::Installer do end it "works with pure bzip2-based Casks" do - asset = Hbc.load("container-bzip2") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb") shutup do Hbc::Installer.new(asset).install @@ -150,7 +150,7 @@ describe Hbc::Installer do end it "works with pure gzip-based Casks" do - asset = Hbc.load("container-gzip") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb") shutup do Hbc::Installer.new(asset).install @@ -164,7 +164,7 @@ describe Hbc::Installer do it "works with pure xz-based Casks" do skip("unxz not installed") if which("unxz").nil? - asset = Hbc.load("container-xz") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xz.rb") asset.stub :depends_on, empty_depends_on_stub do shutup do @@ -180,7 +180,7 @@ describe Hbc::Installer do it "works with lzma-based Casks" do skip("unlzma not installed") if which("unlzma").nil? - asset = Hbc.load("container-lzma") + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-lzma.rb") asset.stub :depends_on, empty_depends_on_stub do shutup do @@ -195,7 +195,7 @@ describe Hbc::Installer do end it "blows up on a bad checksum" do - bad_checksum = Hbc.load("bad-checksum") + bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") lambda { shutup do Hbc::Installer.new(bad_checksum).install @@ -204,7 +204,7 @@ describe Hbc::Installer do end it "blows up on a missing checksum" do - missing_checksum = Hbc.load("missing-checksum") + missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") lambda { shutup do Hbc::Installer.new(missing_checksum).install @@ -213,7 +213,7 @@ describe Hbc::Installer do end it "installs fine if sha256 :no_check is used" do - no_checksum = Hbc.load("no-checksum") + no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") shutup do Hbc::Installer.new(no_checksum).install @@ -223,14 +223,14 @@ describe Hbc::Installer do end it "fails to install if sha256 :no_check is used with --require-sha" do - no_checksum = Hbc.load("no-checksum") + no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") lambda { Hbc::Installer.new(no_checksum, require_sha: true).install }.must_raise(Hbc::CaskNoShasumError) end it "installs fine if sha256 :no_check is used with --require-sha and --force" do - no_checksum = Hbc.load("no-checksum") + no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") shutup do Hbc::Installer.new(no_checksum, require_sha: true, force: true).install @@ -240,7 +240,7 @@ describe Hbc::Installer do end it "prints caveats if they're present" do - with_caveats = Hbc.load("with-caveats") + with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb") lambda { Hbc::Installer.new(with_caveats).install }.must_output(/Here are some things you might want to know/) @@ -248,7 +248,7 @@ describe Hbc::Installer do end it "prints installer :manual instructions when present" do - with_installer_manual = Hbc.load("with-installer-manual") + with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") lambda { Hbc::Installer.new(with_installer_manual).install }.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/) @@ -256,7 +256,7 @@ describe Hbc::Installer do end it "does not extract __MACOSX directories from zips" do - with_macosx_dir = Hbc.load("with-macosx-dir") + with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb") shutup do Hbc::Installer.new(with_macosx_dir).install @@ -266,7 +266,7 @@ describe Hbc::Installer do end it "installer method raises an exception when already-installed Casks which auto-update are attempted" do - auto_updates = Hbc.load("auto-updates") + auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") auto_updates.installed?.must_equal false installer = Hbc::Installer.new(auto_updates) @@ -280,7 +280,7 @@ describe Hbc::Installer do end it "allows already-installed Casks which auto-update to be installed if force is provided" do - auto_updates = Hbc.load("auto-updates") + auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") auto_updates.installed?.must_equal false shutup do @@ -294,7 +294,7 @@ describe Hbc::Installer do # unlike the CLI, the internal interface throws exception on double-install it "installer method raises an exception when already-installed Casks are attempted" do - transmission = Hbc.load("local-transmission") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") transmission.installed?.must_equal false installer = Hbc::Installer.new(transmission) @@ -308,7 +308,7 @@ describe Hbc::Installer do end it "allows already-installed Casks to be installed if force is provided" do - transmission = Hbc.load("local-transmission") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") transmission.installed?.must_equal false shutup do @@ -321,7 +321,7 @@ describe Hbc::Installer do end it "works naked-pkg-based Casks" do - naked_pkg = Hbc.load("container-pkg") + naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb") shutup do Hbc::Installer.new(naked_pkg).install @@ -333,7 +333,7 @@ describe Hbc::Installer do end it "works properly with an overridden container :type" do - naked_executable = Hbc.load("naked-executable") + naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb") shutup do Hbc::Installer.new(naked_executable).install @@ -345,7 +345,7 @@ describe Hbc::Installer do end it "works fine with a nested container" do - nested_app = Hbc.load("nested-app") + nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb") shutup do Hbc::Installer.new(nested_app).install @@ -356,7 +356,7 @@ describe Hbc::Installer do end it "generates and finds a timestamped metadata directory for an installed Cask" do - caffeine = Hbc.load("local-caffeine") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") shutup do Hbc::Installer.new(caffeine).install @@ -368,7 +368,7 @@ describe Hbc::Installer do end it "generates and finds a metadata subdirectory for an installed Cask" do - caffeine = Hbc.load("local-caffeine") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") shutup do Hbc::Installer.new(caffeine).install @@ -383,7 +383,7 @@ describe Hbc::Installer do describe "uninstall" do it "fully uninstalls a Cask" do - caffeine = Hbc.load("local-caffeine") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") installer = Hbc::Installer.new(caffeine) shutup do @@ -397,7 +397,7 @@ describe Hbc::Installer do end it "uninstalls all versions if force is set" do - caffeine = Hbc.load("local-caffeine") + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") mutated_version = caffeine.version + ".1" shutup do diff --git a/Library/Homebrew/cask/test/cask/staged_test.rb b/Library/Homebrew/cask/test/cask/staged_test.rb index fe3bf2339..2b601a6ae 100644 --- a/Library/Homebrew/cask/test/cask/staged_test.rb +++ b/Library/Homebrew/cask/test/cask/staged_test.rb @@ -6,7 +6,7 @@ require "test_helper" describe "Operations on staged Casks" do describe "bundle ID" do it "fetches the bundle ID from a staged cask" do - transmission_cask = Hbc.load("local-transmission") + transmission_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") tr_installer = Hbc::Installer.new(transmission_cask) shutup do diff --git a/Library/Homebrew/cask/test/cask/url_checker_test.rb b/Library/Homebrew/cask/test/cask/url_checker_test.rb index 199182bf2..afd4532dd 100644 --- a/Library/Homebrew/cask/test/cask/url_checker_test.rb +++ b/Library/Homebrew/cask/test/cask/url_checker_test.rb @@ -2,7 +2,7 @@ require "test_helper" describe Hbc::UrlChecker do describe "request processing" do - let(:cask) { Hbc.load("basic-cask") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } let(:checker) { Hbc::UrlChecker.new(cask) } let(:with_stubbed_fetcher) { lambda { |&block| diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb index 64fc21965..d3abda274 100644 --- a/Library/Homebrew/cask/test/cask_test.rb +++ b/Library/Homebrew/cask/test/cask_test.rb @@ -41,8 +41,8 @@ describe "Cask" do end it "uses exact match when loading by token" do - Hbc.load("test-opera").token.must_equal("test-opera") - Hbc.load("test-opera-mail").token.must_equal("test-opera-mail") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera.rb").token.must_equal("test-opera") + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera-mail.rb").token.must_equal("test-opera-mail") end it "raises an error when attempting to load a Cask that doesn't exist" do diff --git a/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb b/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb deleted file mode 100644 index fdc09ef5a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'appdir-interpolation' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" - homepage 'http://example.com/appdir-interpolation' - - binary "#{appdir}/some/path" -end diff --git a/Library/Homebrew/cask/test/support/Casks/auto-updates.rb b/Library/Homebrew/cask/test/support/Casks/auto-updates.rb deleted file mode 100644 index 0fcdb991a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/auto-updates.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'auto-updates' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" - homepage 'http://example.com/auto-updates' - - auto_updates true - - app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb b/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb deleted file mode 100644 index 79e5f24c9..000000000 --- a/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'bad-checksum' do - version '1.2.3' - sha256 'badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/basic-cask.rb b/Library/Homebrew/cask/test/support/Casks/basic-cask.rb deleted file mode 100644 index d3aaa283e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/basic-cask.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'basic-cask' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url 'http://example.com/TestCask.dmg' - homepage 'http://example.com/' - - app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-7z.rb b/Library/Homebrew/cask/test/support/Casks/container-7z.rb deleted file mode 100644 index 7dd01eee4..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-7z.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-7z' do - version '1.2.3' - sha256 '3f9542ace85ed5f88549e2d0ea82210f8ddc87e0defbb78469d3aed719b3c964' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.7z" - homepage 'https://example.com/container-7z' - - depends_on formula: 'unar' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-air.rb b/Library/Homebrew/cask/test/support/Casks/container-air.rb deleted file mode 100644 index c310e0a6f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-air.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-air' do - version '0.1' - sha256 '554472e163f8a028629b12b468e29acda9f16b223dff74fcd218bba73cc2365a' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.air" - homepage 'https://example.com/container-air' - - app 'container.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb b/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb deleted file mode 100644 index 9d9bdff98..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-bzip2' do - version '1.2.3' - sha256 'eaf67b3a62cb9275f96e45d05c70b94bef9ef1dae344083e93eda6b0b388a61c' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.bz2" - homepage 'https://example.com/container-bzip2' - - app 'container-bzip2--1.2.3' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-cab.rb b/Library/Homebrew/cask/test/support/Casks/container-cab.rb deleted file mode 100644 index ebc7a544e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-cab.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-cab' do - version '1.2.3' - sha256 'c267f5cebb14814c8e612a8b7d2bda02aec913f869509b6f1d3883427c0f552b' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.cab" - homepage 'https://example.com/container-cab' - - depends_on formula: 'cabextract' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-dmg.rb b/Library/Homebrew/cask/test/support/Casks/container-dmg.rb deleted file mode 100644 index d63596f42..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-dmg.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-dmg' do - version '1.2.3' - sha256 '74d89d4fa5cef175cf43666ce11fefa3741aa1522114042ac75e656be37141a1' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.dmg" - homepage 'https://example.com/container-dmg' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb b/Library/Homebrew/cask/test/support/Casks/container-gzip.rb deleted file mode 100644 index c2ab00384..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-gzip' do - version '1.2.3' - sha256 'fa4ebb5246583c4b6e62e1df4e3b71b4e38a1d7d91c025665827195d36214b20' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.gz" - homepage 'https://example.com/container-gzip' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-lzma.rb b/Library/Homebrew/cask/test/support/Casks/container-lzma.rb deleted file mode 100644 index d5f708523..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-lzma.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-lzma' do - version '1.2.3' - sha256 '9d7edb32d02ab9bd9749a5bde8756595ea4cfcb1da02ca11c30fb591d4c1ed85' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.lzma" - homepage 'https://example.com/container-lzma' - - depends_on formula: 'lzma' - - app 'container-lzma--1.2.3' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-pkg.rb b/Library/Homebrew/cask/test/support/Casks/container-pkg.rb deleted file mode 100644 index 959caaa08..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-pkg.rb +++ /dev/null @@ -1,7 +0,0 @@ -test_cask 'container-pkg' do - version '1.2.3' - sha256 '611c50c8a2a2098951d2cd0fd54787ed81b92cd97b4b08bd7cba17f1e1d8e40b' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.pkg" - homepage 'https://example.com/container-pkg' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-rar.rb b/Library/Homebrew/cask/test/support/Casks/container-rar.rb deleted file mode 100644 index 7186577a2..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-rar.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-rar' do - version '1.2.3' - sha256 '419af7864c0e1f125515c49b08bd22e0f7de39f5285897c440fe03c714871763' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.rar" - homepage 'https://example.com/container-rar' - - depends_on formula: 'unar' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-sit.rb b/Library/Homebrew/cask/test/support/Casks/container-sit.rb deleted file mode 100644 index 3a0faad97..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-sit.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-sit' do - version '1.2.3' - sha256 '0d21a64dce625044345c8ecca888e5439feaf254dac7f884917028a744f93cf3' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.sit" - homepage 'https://example.com/container-sit' - - depends_on formula: 'unar' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb b/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb deleted file mode 100644 index 58e1d82fd..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-tar-gz' do - version '1.2.3' - sha256 'fab685fabf73d5a9382581ce8698fce9408f5feaa49fa10d9bc6c510493300f5' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.tar.gz" - homepage 'https://example.com/container-tar-gz' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-xar.rb b/Library/Homebrew/cask/test/support/Casks/container-xar.rb deleted file mode 100644 index 35e01d0a8..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-xar.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'container-xar' do - version '1.2.3' - sha256 '5bb8e09a6fc630ebeaf266b1fd2d15e2ae7d32d7e4da6668a8093426fa1ba509' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.xar" - homepage 'https://example.com/container-xar' - - app 'container' -end diff --git a/Library/Homebrew/cask/test/support/Casks/container-xz.rb b/Library/Homebrew/cask/test/support/Casks/container-xz.rb deleted file mode 100644 index b27e908ae..000000000 --- a/Library/Homebrew/cask/test/support/Casks/container-xz.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'container-xz' do - version '1.2.3' - sha256 '839263f474edde1d54a9101606e6f0dc9d963acc93f6dcc5af8d10ebc3187c02' - - url "file://#{TEST_FIXTURE_DIR}/cask/container.xz" - homepage 'https://example.com/container-xz' - - depends_on formula: 'xz' - - app 'container-xz--1.2.3' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb deleted file mode 100644 index db2621074..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb +++ /dev/null @@ -1,13 +0,0 @@ -test_cask 'invalid-appcast-multiple' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - appcast 'http://example.com/appcast1.xml', - checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - appcast 'http://example.com/appcast2.xml', - checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - homepage 'http://example.com/invalid-appcast-multiple' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb deleted file mode 100644 index b4c11b1be..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-appcast-url' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - appcast 1, - checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - homepage 'http://example.com/invalid-appcast-url' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb deleted file mode 100644 index d39d124b0..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-conflicts-with-key' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-conflicts-with-key' - - conflicts_with no_such_key: 'unar' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb deleted file mode 100644 index b0c919a9b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-arch-value' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-depends-on-arch-value' - - depends_on arch: :no_such_arch - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb deleted file mode 100644 index 05304e806..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-key' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-depends-on-key' - - depends_on no_such_key: 'unar' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb deleted file mode 100644 index 183dd5d91..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-macos-bad-release' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-depends-on-macos-bad-release' - - depends_on macos: :no_such_release - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb deleted file mode 100644 index b1f763d76..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'invalid-depends-on-macos-conflicting-forms' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-depends-on-macos-conflicting-forms' - - depends_on macos: :yosemite - depends_on macos: '>= :mavericks' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb deleted file mode 100644 index eefd3ac40..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-depends-on-x11-value' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-depends-on-x11-value' - - depends_on x11: :no_such_value - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb deleted file mode 100644 index bf14d372b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'invalid-gpg-conflicting-keys' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-conflicting-keys' - gpg 'http://example.com/gpg-signature.asc', - key_id: '01234567', - key_url: 'http://example.com/gpg-key-url' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb deleted file mode 100644 index 626e02a47..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-key-id' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-key-id' - gpg 'http://example.com/gpg-signature.asc', - key_id: '012' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb deleted file mode 100644 index 77d41ed6b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-key-url' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-key-url' - gpg 'http://example.com/gpg-signature.asc', - key_url: 1 - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb deleted file mode 100644 index 460bcd532..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-gpg-missing-key' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-missing-keys' - gpg 'http://example.com/gpg-signature.asc' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb deleted file mode 100644 index 8abc89486..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb +++ /dev/null @@ -1,13 +0,0 @@ -test_cask 'invalid-gpg-multiple-stanzas' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-multiple-stanzas' - gpg 'http://example.com/gpg-signature.asc', - key_id: '01234567' - gpg 'http://example.com/gpg-signature.asc', - key_id: '01234567' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb deleted file mode 100644 index f1abc9225..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-parameter' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-type' - gpg 'http://example.com/gpg-signature.asc', - no_such_parameter: :value - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb deleted file mode 100644 index 1b9e7362f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-signature-url' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-signature-url' - gpg 1, - key_id: '01234567' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb deleted file mode 100644 index 266047617..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-gpg-type' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/invalid-gpg-type' - gpg 'http://example.com/gpg-signature.asc', - no_such_parameter: :value - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb deleted file mode 100644 index a8159c979..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask => 'invalid-header-format' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb deleted file mode 100644 index 2b8ad5619..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'invalid-header-token-mismatch-this-text-does-not-belong' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb deleted file mode 100644 index 47851c0e0..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'invalid-header-version' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb deleted file mode 100644 index 84510ac24..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-stage-only-conflict' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" - homepage 'http://example.com/invalid-stage-only-conflict' - - app 'Transmission.app' - stage_only true -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb deleted file mode 100644 index d4e5ff4a9..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-two-homepage' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - homepage 'http://www.example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb deleted file mode 100644 index 49e470788..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-two-url' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - url 'http://example.com/caffeine.zip' - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb deleted file mode 100644 index c9fe37772..000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-two-version' do - version '1.2.3' - version '2.0' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb b/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb deleted file mode 100644 index 2be9b4397..000000000 --- a/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'local-caffeine' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/local-transmission.rb b/Library/Homebrew/cask/test/support/Casks/local-transmission.rb deleted file mode 100644 index f5244d0a5..000000000 --- a/Library/Homebrew/cask/test/support/Casks/local-transmission.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'local-transmission' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" - homepage 'http://example.com/local-transmission' - - app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb b/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb deleted file mode 100644 index 5e1886a57..000000000 --- a/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb +++ /dev/null @@ -1,8 +0,0 @@ -test_cask 'missing-checksum' do - version '1.2.3' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/naked-executable.rb b/Library/Homebrew/cask/test/support/Casks/naked-executable.rb deleted file mode 100644 index 619c7a5fb..000000000 --- a/Library/Homebrew/cask/test/support/Casks/naked-executable.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'naked-executable' do - version '1.2.3' - sha256 '306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb' - - url "file://#{TEST_FIXTURE_DIR}/cask/naked_executable" - homepage 'http://example.com/naked-executable' - - container type: :naked -end diff --git a/Library/Homebrew/cask/test/support/Casks/nested-app.rb b/Library/Homebrew/cask/test/support/Casks/nested-app.rb deleted file mode 100644 index 526c7414a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/nested-app.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'nested-app' do - version '1.2.3' - sha256 '1866dfa833b123bb8fe7fa7185ebf24d28d300d0643d75798bc23730af734216' - - url "file://#{TEST_FIXTURE_DIR}/cask/NestedApp.dmg.zip" - homepage 'http://example.com/nested-app' - - container nested: 'NestedApp.dmg' - - app 'MyNestedApp.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/no-checksum.rb b/Library/Homebrew/cask/test/support/Casks/no-checksum.rb deleted file mode 100644 index d9ba354f5..000000000 --- a/Library/Homebrew/cask/test/support/Casks/no-checksum.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'no-checksum' do - version '1.2.3' - sha256 :no_check - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb b/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb deleted file mode 100644 index ee557b1e4..000000000 --- a/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'no-dsl-version' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url 'http://example.com/TestCask.dmg' - homepage 'http://example.com/' - - app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/stage-only.rb b/Library/Homebrew/cask/test/support/Casks/stage-only.rb deleted file mode 100644 index b52b5d3d2..000000000 --- a/Library/Homebrew/cask/test/support/Casks/stage-only.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'stage-only' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" - homepage 'http://example.com/stage-only' - - stage_only true -end diff --git a/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb b/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb deleted file mode 100644 index afc8387c7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'test-opera-mail' do - version '1.0' - sha256 'afd192e308f8ea8ddb3d426fd6663d97078570417ee78b8e1fa15f515ae3d677' - - url 'http://get-ash-1.opera.com/pub/opera/mail/1.0/mac/Opera-Mail-1.0-1040.i386.dmg' - homepage 'http://www.opera.com/computer/mail' - - app 'Opera Mail.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/test-opera.rb b/Library/Homebrew/cask/test/support/Casks/test-opera.rb deleted file mode 100644 index ec32828f7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/test-opera.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'test-opera' do - version '19.0.1326.47' - sha256 '7b91f20ab754f7b3fef8dc346e0393917e11676b74c8f577408841619f76040a' - - url 'http://get.geo.opera.com/pub/opera/desktop/19.0.1326.47/mac/Opera_19.0.1326.47_Setup.dmg' - homepage 'http://www.opera.com/' - - app 'Opera.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb b/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb deleted file mode 100644 index 1aa7bc8f7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-accessibility-access' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url 'http://example.com/TestCask.dmg' - homepage 'http://example.com/' - - accessibility_access true - - app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb b/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb deleted file mode 100644 index b75ff320c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-alt-target' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app', target: 'AnotherName.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-appcast.rb b/Library/Homebrew/cask/test/support/Casks/with-appcast.rb deleted file mode 100644 index f99f7a93c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-appcast.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-appcast' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - appcast 'http://example.com/appcast.xml', - checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - homepage 'http://example.com/with-appcast' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-caveats.rb b/Library/Homebrew/cask/test/support/Casks/with-caveats.rb deleted file mode 100644 index 30d3a49b3..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-caveats.rb +++ /dev/null @@ -1,23 +0,0 @@ -test_cask 'with-caveats' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' - - # simple string is evaluated at compile-time - caveats <<-EOS.undent - Here are some things you might want to know. - EOS - # do block is evaluated at install-time - caveats do - "Cask token: #{token}" - end - # a do block may print and use a DSL - caveats do - puts 'Custom text via puts followed by DSL-generated text:' - path_environment_variable('/custom/path/bin') - end -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-choices.rb b/Library/Homebrew/cask/test/support/Casks/with-choices.rb deleted file mode 100644 index 1871efab3..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-choices.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-choices' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg', - choices: [ - { - 'choiceIdentifier' => 'choice1', - 'choiceAttribute' => 'selected', - 'attributeSetting' => 1, - }, - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb b/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb deleted file mode 100644 index d8a3836b8..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb +++ /dev/null @@ -1,14 +0,0 @@ -test_cask 'with-conditional-caveats' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app' - - # a do block may print and use a DSL - caveats do - puts 'This caveat is conditional' if false # rubocop:disable Lint/LiteralInCondition - end -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb b/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb deleted file mode 100644 index a20d932ba..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-conflicts-with' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-conflicts-with' - - conflicts_with formula: 'unar' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb deleted file mode 100644 index e0c4e3fa7..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-arch' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-arch' - - # covers all known hardware; always succeeds - depends_on arch: :intel - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb deleted file mode 100644 index 327fc4000..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-cask-cyclic-helper' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-cask-cyclic-helper' - - depends_on cask: 'with-depends-on-cask-cyclic' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb deleted file mode 100644 index f74d860bf..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-cask-cyclic' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-cask-cyclic' - - depends_on cask: 'local-caffeine' - depends_on cask: 'with-depends-on-cask-cyclic-helper' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb deleted file mode 100644 index bb69b7506..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-cask-multiple' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-cask-multiple' - - depends_on cask: 'local-caffeine' - depends_on cask: 'local-transmission' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb deleted file mode 100644 index 05a180560..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-cask' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-cask' - - depends_on cask: 'local-transmission' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb deleted file mode 100644 index c99d2dee1..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-formula-multiple' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-formula-multiple' - - depends_on formula: 'unar' - depends_on formula: 'fileutils' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb deleted file mode 100644 index b0339e68c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-formula' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-formula' - - depends_on formula: 'unar' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb deleted file mode 100644 index cae16704c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-macos-array' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-macos-array' - - # since all OS releases are included, this should always pass - depends_on macos: ['10.4', '10.5', '10.6', '10.7', '10.8', '10.9', '10.10', MacOS.version.to_s] - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb deleted file mode 100644 index 7f14dd84f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-macos-comparison' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-macos-comparison' - - depends_on macos: '>= 10.4' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb deleted file mode 100644 index ecefff362..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-macos-failure' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-macos-failure' - - # guarantee a mismatched release - depends_on macos: MacOS.version.to_s == '10.4' ? '10.5' : '10.4' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb deleted file mode 100644 index 6e370d46a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-macos-string' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-macos-string' - - depends_on macos: MacOS.version.to_s - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb deleted file mode 100644 index 7f11b6e64..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-macos-symbol' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-macos-symbol' - - depends_on macos: MacOS.version.to_sym - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb deleted file mode 100644 index fc84f2daa..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-x11-false' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-x11-false' - - depends_on x11: false - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb deleted file mode 100644 index b1a7bad2b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-depends-on-x11' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-x11' - - depends_on x11: true - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb b/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb deleted file mode 100644 index c16343c4b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask :v1 => 'with-dsl-version' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url 'http://example.com/TestCask.dmg' - homepage 'http://example.com/' - - app 'TestCask.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb b/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb deleted file mode 100644 index a7d347fb5..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-generic-artifact-no-target' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-generic-artifact' - - artifact 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb b/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb deleted file mode 100644 index e718b994b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-generic-artifact' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-generic-artifact' - - artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb b/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb deleted file mode 100644 index 6aa735e1f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-gpg-key-url' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-gpg-key-url' - gpg 'http://example.com/gpg-signature.asc', - key_url: 'http://example.com/gpg-key-url' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-gpg.rb b/Library/Homebrew/cask/test/support/Casks/with-gpg.rb deleted file mode 100644 index 1f7042515..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-gpg.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-gpg' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-gpg' - gpg 'http://example.com/gpg-signature.asc', - key_id: '01234567' - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-installable.rb b/Library/Homebrew/cask/test/support/Casks/with-installable.rb deleted file mode 100644 index d1105b50e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-installable.rb +++ /dev/null @@ -1,20 +0,0 @@ -test_cask 'with-installable' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }, - quit: 'my.fancy.package.app', - login_item: 'Fancy', - delete: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', - 'impermissible/relative/path', - '/another/impermissible/../relative/path', - ], - rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb b/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb deleted file mode 100644 index 92e2e09df..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-installer-manual' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - installer manual: 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb b/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb deleted file mode 100644 index 5e98eab48..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb +++ /dev/null @@ -1,15 +0,0 @@ -test_cask 'with-installer-script' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-install-script' - - installer script: '/usr/bin/true', - args: ['--flag'] - # acceptable alternate form - installer script: { - executable: '/usr/bin/false', - args: ['--flag'], - } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb b/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb deleted file mode 100644 index 837627119..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-macosx-dir' do - version '1.2.3' - sha256 '5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" - homepage 'http://example.com/MyFancyApp' - - app 'MyFancyApp/MyFancyApp.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb b/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb deleted file mode 100644 index 8bb42c447..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb +++ /dev/null @@ -1,13 +0,0 @@ -test_cask 'with-pkgutil-zap' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - zap pkgutil: 'my.fancy.package.*', - kext: 'my.fancy.package.kernelextension', - launchctl: 'my.fancy.package.service' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-suite.rb b/Library/Homebrew/cask/test/support/Casks/with-suite.rb deleted file mode 100644 index c36151d52..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-suite.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-suite' do - version '1.2.3' - sha256 'd95dcc12d4e5be0bc3cb9793c4b7e7f69a25f0b3c7418494b0c883957e6eeae4' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine-suite.zip" - name 'Caffeine' - homepage 'http://example.com/with-suite' - - suite 'Caffeine' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb b/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb deleted file mode 100644 index 8eb68d88a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-two-apps-correct' do - version '1.2.3' - sha256 '3178fbfd1ea5d87a2a0662a4eb599ebc9a03888e73f37538d9f3f6ee69d2368e' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine Mini.app' - app 'Caffeine Pro.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb b/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb deleted file mode 100644 index 6bd316dfe..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb +++ /dev/null @@ -1,9 +0,0 @@ -test_cask 'with-two-apps-incorrect' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeine.app', 'Caffeine.app/Contents/MacOS/Caffeine' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb b/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb deleted file mode 100644 index 202423691..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-two-apps-subdir' do - version '1.2.3' - sha256 'd687c22a21c02bd8f07da9302c8292b93a04df9a929e3f04d09aea6c76f75c65' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeines-subdir.zip" - homepage 'http://example.com/local-caffeine' - - app 'Caffeines/Caffeine Mini.app' - app 'Caffeines/Caffeine Pro.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb deleted file mode 100644 index 203f18405..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-uninstall-delete' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - uninstall delete: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', - 'impermissible/relative/path', - '/another/impermissible/../relative/path', - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb deleted file mode 100644 index a26abab1c..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-early-script' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb deleted file mode 100644 index fa54c7e1f..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-kext' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - uninstall kext: 'my.fancy.package.kernelextension' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb deleted file mode 100644 index 51ad45a09..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-launchctl' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" - homepage 'http://example.com/fancy' - - app 'Fancy.app' - - uninstall launchctl: 'my.fancy.package.service' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb deleted file mode 100644 index 26dca6f1a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-login-item' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall login_item: 'Fancy' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb deleted file mode 100644 index db77a460b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-pkgutil' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - uninstall pkgutil: 'my.fancy.package.*' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb deleted file mode 100644 index 19337b18a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-quit' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall quit: 'my.fancy.package.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb deleted file mode 100644 index 88142ea71..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-rmdir' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb deleted file mode 100644 index d2e0d6167..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-uninstall-script' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb deleted file mode 100644 index cc32b888a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb +++ /dev/null @@ -1,14 +0,0 @@ -test_cask 'with-uninstall-signal' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall signal: [ - ['TERM', 'my.fancy.package.app'], - ['KILL', 'my.fancy.package.app'], - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb b/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb deleted file mode 100644 index 4fe58a19a..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-uninstall-trash' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - uninstall trash: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', - 'impermissible/relative/path', - '/another/impermissible/../relative/path', - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb deleted file mode 100644 index c76a9acb0..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-zap-delete' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - zap delete: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', - 'impermissible/relative/path', - '/another/impermissible/../relative/path', - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb deleted file mode 100644 index d35c1809e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-early-script' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - zap early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb deleted file mode 100644 index 463fe8133..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-kext' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - zap kext: 'my.fancy.package.kernelextension' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb deleted file mode 100644 index aab285672..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-launchctl' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" - homepage 'http://example.com/fancy' - - app 'Fancy.app' - - zap launchctl: 'my.fancy.package.service' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb deleted file mode 100644 index d7ba9a65b..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-login-item' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - zap login_item: 'Fancy' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb deleted file mode 100644 index 17a667000..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-pkgutil' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - zap pkgutil: 'my.fancy.package.*' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb deleted file mode 100644 index 21f824ae9..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-quit' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - zap quit: 'my.fancy.package.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb deleted file mode 100644 index eac02ad0e..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-rmdir' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - zap rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb deleted file mode 100644 index f8646a267..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'with-zap-script' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - zap script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb deleted file mode 100644 index 5accd8337..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb +++ /dev/null @@ -1,14 +0,0 @@ -test_cask 'with-zap-signal' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - zap signal: [ - ['TERM', 'my.fancy.package.app'], - ['KILL', 'my.fancy.package.app'], - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb b/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb deleted file mode 100644 index aef4e0eab..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb +++ /dev/null @@ -1,16 +0,0 @@ -test_cask 'with-zap-trash' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'Fancy.pkg' - - zap trash: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', - 'impermissible/relative/path', - '/another/impermissible/../relative/path', - ] -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap.rb b/Library/Homebrew/cask/test/support/Casks/with-zap.rb deleted file mode 100644 index 056c90671..000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-zap.rb +++ /dev/null @@ -1,19 +0,0 @@ -test_cask 'with-zap' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" - homepage 'http://example.com/fancy-pkg' - - pkg 'MyFancyPkg/Fancy.pkg' - - uninstall quit: 'my.fancy.package.app.from.uninstall' - - zap script: { - executable: 'MyFancyPkg/FancyUninstaller.tool', - args: %w[--please], - }, - quit: 'my.fancy.package.app', - login_item: 'Fancy', - delete: '~/Library/Preferences/my.fancy.app.plist' -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 7315839f5..641409284 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -46,7 +46,7 @@ Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap| # link test casks FileUtils.mkdir_p tap.path.dirname - FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path + FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path end # pretend that the caskroom/cask Tap is installed diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb new file mode 100644 index 000000000..f40f244f2 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb @@ -0,0 +1,4 @@ +test_cask 'appcast-checkpoint-sha256-for-empty-string' do + appcast 'http://localhost/appcast.xml', + checkpoint: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb new file mode 100644 index 000000000..e182c2389 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb @@ -0,0 +1,4 @@ +test_cask 'appcast-invalid-checkpoint' do + appcast 'http://localhost/appcast.xml', + checkpoint: 'not a valid shasum' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb new file mode 100644 index 000000000..5ab2c0665 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb @@ -0,0 +1,3 @@ +test_cask 'appcast-missing-checkpoint' do + appcast 'http://localhost/appcast.xml' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb new file mode 100644 index 000000000..96d7edbba --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb @@ -0,0 +1,4 @@ +test_cask 'appcast-valid-checkpoint' do + appcast 'http://localhost/appcast.xml', + checkpoint: 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb new file mode 100644 index 000000000..fdc09ef5a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb @@ -0,0 +1,9 @@ +test_cask 'appdir-interpolation' do + version '2.61' + sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' + + url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" + homepage 'http://example.com/appdir-interpolation' + + binary "#{appdir}/some/path" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb new file mode 100644 index 000000000..0fcdb991a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb @@ -0,0 +1,11 @@ +test_cask 'auto-updates' do + version '2.61' + sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' + + url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" + homepage 'http://example.com/auto-updates' + + auto_updates true + + app 'Transmission.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb new file mode 100644 index 000000000..79e5f24c9 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb @@ -0,0 +1,9 @@ +test_cask 'bad-checksum' do + version '1.2.3' + sha256 'badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb new file mode 100644 index 000000000..d3aaa283e --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb @@ -0,0 +1,9 @@ +test_cask 'basic-cask' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url 'http://example.com/TestCask.dmg' + homepage 'http://example.com/' + + app 'TestCask.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb new file mode 100644 index 000000000..21bd97952 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb @@ -0,0 +1,8 @@ +cask 'booby-trap' do + version '0.0.7' + + url do + # to be lazily evaluated + fail 'Boom' + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb new file mode 100644 index 000000000..7dd01eee4 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb @@ -0,0 +1,11 @@ +test_cask 'container-7z' do + version '1.2.3' + sha256 '3f9542ace85ed5f88549e2d0ea82210f8ddc87e0defbb78469d3aed719b3c964' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.7z" + homepage 'https://example.com/container-7z' + + depends_on formula: 'unar' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb new file mode 100644 index 000000000..c310e0a6f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb @@ -0,0 +1,9 @@ +test_cask 'container-air' do + version '0.1' + sha256 '554472e163f8a028629b12b468e29acda9f16b223dff74fcd218bba73cc2365a' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.air" + homepage 'https://example.com/container-air' + + app 'container.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb new file mode 100644 index 000000000..9d9bdff98 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb @@ -0,0 +1,9 @@ +test_cask 'container-bzip2' do + version '1.2.3' + sha256 'eaf67b3a62cb9275f96e45d05c70b94bef9ef1dae344083e93eda6b0b388a61c' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.bz2" + homepage 'https://example.com/container-bzip2' + + app 'container-bzip2--1.2.3' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb new file mode 100644 index 000000000..ebc7a544e --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb @@ -0,0 +1,11 @@ +test_cask 'container-cab' do + version '1.2.3' + sha256 'c267f5cebb14814c8e612a8b7d2bda02aec913f869509b6f1d3883427c0f552b' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.cab" + homepage 'https://example.com/container-cab' + + depends_on formula: 'cabextract' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb new file mode 100644 index 000000000..d63596f42 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb @@ -0,0 +1,9 @@ +test_cask 'container-dmg' do + version '1.2.3' + sha256 '74d89d4fa5cef175cf43666ce11fefa3741aa1522114042ac75e656be37141a1' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.dmg" + homepage 'https://example.com/container-dmg' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb new file mode 100644 index 000000000..c2ab00384 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb @@ -0,0 +1,9 @@ +test_cask 'container-gzip' do + version '1.2.3' + sha256 'fa4ebb5246583c4b6e62e1df4e3b71b4e38a1d7d91c025665827195d36214b20' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.gz" + homepage 'https://example.com/container-gzip' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb new file mode 100644 index 000000000..d5f708523 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb @@ -0,0 +1,11 @@ +test_cask 'container-lzma' do + version '1.2.3' + sha256 '9d7edb32d02ab9bd9749a5bde8756595ea4cfcb1da02ca11c30fb591d4c1ed85' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.lzma" + homepage 'https://example.com/container-lzma' + + depends_on formula: 'lzma' + + app 'container-lzma--1.2.3' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb new file mode 100644 index 000000000..959caaa08 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb @@ -0,0 +1,7 @@ +test_cask 'container-pkg' do + version '1.2.3' + sha256 '611c50c8a2a2098951d2cd0fd54787ed81b92cd97b4b08bd7cba17f1e1d8e40b' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.pkg" + homepage 'https://example.com/container-pkg' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb new file mode 100644 index 000000000..7186577a2 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb @@ -0,0 +1,11 @@ +test_cask 'container-rar' do + version '1.2.3' + sha256 '419af7864c0e1f125515c49b08bd22e0f7de39f5285897c440fe03c714871763' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.rar" + homepage 'https://example.com/container-rar' + + depends_on formula: 'unar' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb new file mode 100644 index 000000000..3a0faad97 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb @@ -0,0 +1,11 @@ +test_cask 'container-sit' do + version '1.2.3' + sha256 '0d21a64dce625044345c8ecca888e5439feaf254dac7f884917028a744f93cf3' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.sit" + homepage 'https://example.com/container-sit' + + depends_on formula: 'unar' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb new file mode 100644 index 000000000..58e1d82fd --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb @@ -0,0 +1,9 @@ +test_cask 'container-tar-gz' do + version '1.2.3' + sha256 'fab685fabf73d5a9382581ce8698fce9408f5feaa49fa10d9bc6c510493300f5' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.tar.gz" + homepage 'https://example.com/container-tar-gz' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb new file mode 100644 index 000000000..35e01d0a8 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb @@ -0,0 +1,9 @@ +test_cask 'container-xar' do + version '1.2.3' + sha256 '5bb8e09a6fc630ebeaf266b1fd2d15e2ae7d32d7e4da6668a8093426fa1ba509' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.xar" + homepage 'https://example.com/container-xar' + + app 'container' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb new file mode 100644 index 000000000..b27e908ae --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb @@ -0,0 +1,11 @@ +test_cask 'container-xz' do + version '1.2.3' + sha256 '839263f474edde1d54a9101606e6f0dc9d963acc93f6dcc5af8d10ebc3187c02' + + url "file://#{TEST_FIXTURE_DIR}/cask/container.xz" + homepage 'https://example.com/container-xz' + + depends_on formula: 'xz' + + app 'container-xz--1.2.3' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb new file mode 100644 index 000000000..475fb055f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb @@ -0,0 +1,3 @@ +test_cask 'generic-artifact-absolute-target' do + artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb new file mode 100644 index 000000000..f7657dbb5 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb @@ -0,0 +1,3 @@ +test_cask 'generic-artifact-no-target' do + artifact 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb new file mode 100644 index 000000000..f97441751 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb @@ -0,0 +1,3 @@ +test_cask 'generic-artifact-relative-target' do + artifact 'Caffeine.app', target: 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb new file mode 100644 index 000000000..aac00f495 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb @@ -0,0 +1,4 @@ +test_cask 'invalid-sha256' do + version '1.2.3' + sha256 'not a valid shasum' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb new file mode 100644 index 000000000..db2621074 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb @@ -0,0 +1,13 @@ +test_cask 'invalid-appcast-multiple' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + appcast 'http://example.com/appcast1.xml', + checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + appcast 'http://example.com/appcast2.xml', + checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + homepage 'http://example.com/invalid-appcast-multiple' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb new file mode 100644 index 000000000..b4c11b1be --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-appcast-url' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + appcast 1, + checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + homepage 'http://example.com/invalid-appcast-url' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb new file mode 100644 index 000000000..d39d124b0 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-conflicts-with-key' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-conflicts-with-key' + + conflicts_with no_such_key: 'unar' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb new file mode 100644 index 000000000..b0c919a9b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-depends-on-arch-value' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-depends-on-arch-value' + + depends_on arch: :no_such_arch + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb new file mode 100644 index 000000000..05304e806 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-depends-on-key' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-depends-on-key' + + depends_on no_such_key: 'unar' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb new file mode 100644 index 000000000..183dd5d91 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-depends-on-macos-bad-release' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-depends-on-macos-bad-release' + + depends_on macos: :no_such_release + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb new file mode 100644 index 000000000..b1f763d76 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb @@ -0,0 +1,12 @@ +test_cask 'invalid-depends-on-macos-conflicting-forms' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-depends-on-macos-conflicting-forms' + + depends_on macos: :yosemite + depends_on macos: '>= :mavericks' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb new file mode 100644 index 000000000..eefd3ac40 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-depends-on-x11-value' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-depends-on-x11-value' + + depends_on x11: :no_such_value + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb new file mode 100644 index 000000000..bf14d372b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb @@ -0,0 +1,12 @@ +test_cask 'invalid-gpg-conflicting-keys' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-conflicting-keys' + gpg 'http://example.com/gpg-signature.asc', + key_id: '01234567', + key_url: 'http://example.com/gpg-key-url' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb new file mode 100644 index 000000000..626e02a47 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-gpg-key-id' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-key-id' + gpg 'http://example.com/gpg-signature.asc', + key_id: '012' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb new file mode 100644 index 000000000..77d41ed6b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-gpg-key-url' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-key-url' + gpg 'http://example.com/gpg-signature.asc', + key_url: 1 + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb new file mode 100644 index 000000000..460bcd532 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb @@ -0,0 +1,10 @@ +test_cask 'invalid-gpg-missing-key' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-missing-keys' + gpg 'http://example.com/gpg-signature.asc' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb new file mode 100644 index 000000000..8abc89486 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb @@ -0,0 +1,13 @@ +test_cask 'invalid-gpg-multiple-stanzas' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-multiple-stanzas' + gpg 'http://example.com/gpg-signature.asc', + key_id: '01234567' + gpg 'http://example.com/gpg-signature.asc', + key_id: '01234567' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb new file mode 100644 index 000000000..f1abc9225 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-gpg-parameter' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-type' + gpg 'http://example.com/gpg-signature.asc', + no_such_parameter: :value + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb new file mode 100644 index 000000000..1b9e7362f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-gpg-signature-url' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-signature-url' + gpg 1, + key_id: '01234567' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb new file mode 100644 index 000000000..266047617 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb @@ -0,0 +1,11 @@ +test_cask 'invalid-gpg-type' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/invalid-gpg-type' + gpg 'http://example.com/gpg-signature.asc', + no_such_parameter: :value + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb new file mode 100644 index 000000000..a8159c979 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb @@ -0,0 +1,9 @@ +test_cask => 'invalid-header-format' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb new file mode 100644 index 000000000..2b8ad5619 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb @@ -0,0 +1,9 @@ +test_cask 'invalid-header-token-mismatch-this-text-does-not-belong' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb new file mode 100644 index 000000000..47851c0e0 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb @@ -0,0 +1,9 @@ +test_cask 'invalid-header-version' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb new file mode 100644 index 000000000..84510ac24 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb @@ -0,0 +1,10 @@ +test_cask 'invalid-stage-only-conflict' do + version '2.61' + sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' + + url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" + homepage 'http://example.com/invalid-stage-only-conflict' + + app 'Transmission.app' + stage_only true +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb new file mode 100644 index 000000000..d4e5ff4a9 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb @@ -0,0 +1,10 @@ +test_cask 'invalid-two-homepage' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + homepage 'http://www.example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb new file mode 100644 index 000000000..49e470788 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb @@ -0,0 +1,10 @@ +test_cask 'invalid-two-url' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + url 'http://example.com/caffeine.zip' + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb new file mode 100644 index 000000000..c9fe37772 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb @@ -0,0 +1,10 @@ +test_cask 'invalid-two-version' do + version '1.2.3' + version '2.0' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb new file mode 100644 index 000000000..2be9b4397 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb @@ -0,0 +1,9 @@ +test_cask 'local-caffeine' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb new file mode 100644 index 000000000..f5244d0a5 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb @@ -0,0 +1,9 @@ +test_cask 'local-transmission' do + version '2.61' + sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' + + url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" + homepage 'http://example.com/local-transmission' + + app 'Transmission.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb new file mode 100644 index 000000000..5e1886a57 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb @@ -0,0 +1,8 @@ +test_cask 'missing-checksum' do + version '1.2.3' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb new file mode 100644 index 000000000..ff924541d --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb @@ -0,0 +1,5 @@ +test_cask 'missing-homepage' do + version '1.2.3' + + url 'http://localhost/something.dmg' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb new file mode 100644 index 000000000..a5265b379 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb @@ -0,0 +1,5 @@ +test_cask 'missing-name' do + version '1.2.3' + + url 'http://localhost/something.dmg' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb new file mode 100644 index 000000000..7f8027907 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb @@ -0,0 +1,5 @@ +test_cask 'missing-sha256' do + version '1.2.3' + + url 'http://localhost/something.dmg' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb new file mode 100644 index 000000000..1b3e76b9c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb @@ -0,0 +1,5 @@ +test_cask 'missing-url' do + version '1.2.3' + + homepage 'http://example.com' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb new file mode 100644 index 000000000..da2160bce --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb @@ -0,0 +1,4 @@ +test_cask 'missing-version' do + url 'http://localhost/something.dmg' + homepage 'http://example.com' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb new file mode 100644 index 000000000..619c7a5fb --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb @@ -0,0 +1,9 @@ +test_cask 'naked-executable' do + version '1.2.3' + sha256 '306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb' + + url "file://#{TEST_FIXTURE_DIR}/cask/naked_executable" + homepage 'http://example.com/naked-executable' + + container type: :naked +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb new file mode 100644 index 000000000..526c7414a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb @@ -0,0 +1,11 @@ +test_cask 'nested-app' do + version '1.2.3' + sha256 '1866dfa833b123bb8fe7fa7185ebf24d28d300d0643d75798bc23730af734216' + + url "file://#{TEST_FIXTURE_DIR}/cask/NestedApp.dmg.zip" + homepage 'http://example.com/nested-app' + + container nested: 'NestedApp.dmg' + + app 'MyNestedApp.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb new file mode 100644 index 000000000..d9ba354f5 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb @@ -0,0 +1,9 @@ +test_cask 'no-checksum' do + version '1.2.3' + sha256 :no_check + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb new file mode 100644 index 000000000..ee557b1e4 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb @@ -0,0 +1,9 @@ +test_cask 'no-dsl-version' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url 'http://example.com/TestCask.dmg' + homepage 'http://example.com/' + + app 'TestCask.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb new file mode 100644 index 000000000..da6ff0fcd --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb @@ -0,0 +1,6 @@ +test_cask 'osdn-correct-url-format' do + version '1.2.3' + + url 'http://user.dl.osdn.jp/something/id/Something-1.2.3.dmg' + homepage 'http://osdn.jp/projects/something/' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb new file mode 100644 index 000000000..8400159a1 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb @@ -0,0 +1,6 @@ +test_cask 'osdn-incorrect-url-format' do + version '1.2.3' + + url 'http://osdn.jp/projects/something/files/Something-1.2.3.dmg/download' + homepage 'http://osdn.jp/projects/something/' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb new file mode 100644 index 000000000..b97764071 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb @@ -0,0 +1,4 @@ +test_cask 'sha256-for-empty-string' do + version '1.2.3' + sha256 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb new file mode 100644 index 000000000..41ef73500 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb @@ -0,0 +1,6 @@ +test_cask 'sourceforge-correct-url-format' do + version '1.2.3' + + url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg' + homepage 'https://sourceforge.net/projects/something/' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb new file mode 100644 index 000000000..27b5490b7 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb @@ -0,0 +1,6 @@ +test_cask 'sourceforge-incorrect-url-format' do + version '1.2.3' + + url 'http://sourceforge.net/projects/something/files/Something-1.2.3.dmg/download' + homepage 'http://sourceforge.net/projects/something/' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb new file mode 100644 index 000000000..d9546c5e1 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb @@ -0,0 +1,6 @@ +test_cask 'sourceforge-version-latest-correct-url-format' do + version :latest + + url 'https://sourceforge.net/projects/something/files/latest/download' + homepage 'https://sourceforge.net/projects/something/' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb new file mode 100644 index 000000000..b52b5d3d2 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb @@ -0,0 +1,9 @@ +test_cask 'stage-only' do + version '2.61' + sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' + + url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" + homepage 'http://example.com/stage-only' + + stage_only true +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb new file mode 100644 index 000000000..afc8387c7 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb @@ -0,0 +1,9 @@ +test_cask 'test-opera-mail' do + version '1.0' + sha256 'afd192e308f8ea8ddb3d426fd6663d97078570417ee78b8e1fa15f515ae3d677' + + url 'http://get-ash-1.opera.com/pub/opera/mail/1.0/mac/Opera-Mail-1.0-1040.i386.dmg' + homepage 'http://www.opera.com/computer/mail' + + app 'Opera Mail.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb new file mode 100644 index 000000000..ec32828f7 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb @@ -0,0 +1,9 @@ +test_cask 'test-opera' do + version '19.0.1326.47' + sha256 '7b91f20ab754f7b3fef8dc346e0393917e11676b74c8f577408841619f76040a' + + url 'http://get.geo.opera.com/pub/opera/desktop/19.0.1326.47/mac/Opera_19.0.1326.47_Setup.dmg' + homepage 'http://www.opera.com/' + + app 'Opera.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb new file mode 100644 index 000000000..3b4723f45 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb @@ -0,0 +1,4 @@ +test_cask 'version-latest-string' do + version 'latest' + sha256 :no_check +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb new file mode 100644 index 000000000..884ddff90 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb @@ -0,0 +1,4 @@ +test_cask 'version-latest-with-checksum' do + version :latest + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb new file mode 100644 index 000000000..1aa7bc8f7 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb @@ -0,0 +1,11 @@ +test_cask 'with-accessibility-access' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url 'http://example.com/TestCask.dmg' + homepage 'http://example.com/' + + accessibility_access true + + app 'TestCask.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb new file mode 100644 index 000000000..b75ff320c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb @@ -0,0 +1,9 @@ +test_cask 'with-alt-target' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app', target: 'AnotherName.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb new file mode 100644 index 000000000..f99f7a93c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb @@ -0,0 +1,11 @@ +test_cask 'with-appcast' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + appcast 'http://example.com/appcast.xml', + checkpoint: '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + homepage 'http://example.com/with-appcast' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb new file mode 100644 index 000000000..d8cede7aa --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb @@ -0,0 +1,10 @@ +test_cask 'with-binary' do + version '1.2.3' + sha256 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' + + url "file://#{TEST_FIXTURE_DIR}/cask/AppWithBinary.zip" + homepage 'http://example.com/with-binary' + + app 'App.app' + binary 'binary' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb new file mode 100644 index 000000000..30d3a49b3 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb @@ -0,0 +1,23 @@ +test_cask 'with-caveats' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' + + # simple string is evaluated at compile-time + caveats <<-EOS.undent + Here are some things you might want to know. + EOS + # do block is evaluated at install-time + caveats do + "Cask token: #{token}" + end + # a do block may print and use a DSL + caveats do + puts 'Custom text via puts followed by DSL-generated text:' + path_environment_variable('/custom/path/bin') + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb new file mode 100644 index 000000000..1871efab3 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb @@ -0,0 +1,16 @@ +test_cask 'with-choices' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg', + choices: [ + { + 'choiceIdentifier' => 'choice1', + 'choiceAttribute' => 'selected', + 'attributeSetting' => 1, + }, + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb new file mode 100644 index 000000000..d8a3836b8 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb @@ -0,0 +1,14 @@ +test_cask 'with-conditional-caveats' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app' + + # a do block may print and use a DSL + caveats do + puts 'This caveat is conditional' if false # rubocop:disable Lint/LiteralInCondition + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb new file mode 100644 index 000000000..a20d932ba --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb @@ -0,0 +1,11 @@ +test_cask 'with-conflicts-with' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-conflicts-with' + + conflicts_with formula: 'unar' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb new file mode 100644 index 000000000..e0c4e3fa7 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb @@ -0,0 +1,12 @@ +test_cask 'with-depends-on-arch' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-arch' + + # covers all known hardware; always succeeds + depends_on arch: :intel + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb new file mode 100644 index 000000000..327fc4000 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-cask-cyclic-helper' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-cask-cyclic-helper' + + depends_on cask: 'with-depends-on-cask-cyclic' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb new file mode 100644 index 000000000..f74d860bf --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb @@ -0,0 +1,12 @@ +test_cask 'with-depends-on-cask-cyclic' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-cask-cyclic' + + depends_on cask: 'local-caffeine' + depends_on cask: 'with-depends-on-cask-cyclic-helper' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb new file mode 100644 index 000000000..bb69b7506 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb @@ -0,0 +1,12 @@ +test_cask 'with-depends-on-cask-multiple' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-cask-multiple' + + depends_on cask: 'local-caffeine' + depends_on cask: 'local-transmission' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb new file mode 100644 index 000000000..05a180560 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-cask' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-cask' + + depends_on cask: 'local-transmission' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb new file mode 100644 index 000000000..c99d2dee1 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb @@ -0,0 +1,12 @@ +test_cask 'with-depends-on-formula-multiple' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-formula-multiple' + + depends_on formula: 'unar' + depends_on formula: 'fileutils' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb new file mode 100644 index 000000000..b0339e68c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-formula' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-formula' + + depends_on formula: 'unar' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb new file mode 100644 index 000000000..cae16704c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb @@ -0,0 +1,12 @@ +test_cask 'with-depends-on-macos-array' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-macos-array' + + # since all OS releases are included, this should always pass + depends_on macos: ['10.4', '10.5', '10.6', '10.7', '10.8', '10.9', '10.10', MacOS.version.to_s] + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb new file mode 100644 index 000000000..7f14dd84f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-macos-comparison' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-macos-comparison' + + depends_on macos: '>= 10.4' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb new file mode 100644 index 000000000..ecefff362 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb @@ -0,0 +1,12 @@ +test_cask 'with-depends-on-macos-failure' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-macos-failure' + + # guarantee a mismatched release + depends_on macos: MacOS.version.to_s == '10.4' ? '10.5' : '10.4' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb new file mode 100644 index 000000000..6e370d46a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-macos-string' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-macos-string' + + depends_on macos: MacOS.version.to_s + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb new file mode 100644 index 000000000..7f11b6e64 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-macos-symbol' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-macos-symbol' + + depends_on macos: MacOS.version.to_sym + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb new file mode 100644 index 000000000..fc84f2daa --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-x11-false' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-x11-false' + + depends_on x11: false + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb new file mode 100644 index 000000000..b1a7bad2b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb @@ -0,0 +1,11 @@ +test_cask 'with-depends-on-x11' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-depends-on-x11' + + depends_on x11: true + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb new file mode 100644 index 000000000..c16343c4b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb @@ -0,0 +1,9 @@ +test_cask :v1 => 'with-dsl-version' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url 'http://example.com/TestCask.dmg' + homepage 'http://example.com/' + + app 'TestCask.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb new file mode 100644 index 000000000..107c6cbe2 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb @@ -0,0 +1,10 @@ +test_cask 'with-embedded-binary' do + version '1.2.3' + sha256 'fe052d3e77d92676775fd916ddb8942e72a565b844ea7f6d055474c99bb4e47b' + + url "file://#{TEST_FIXTURE_DIR}/cask/AppWithEmbeddedBinary.zip" + homepage 'http://example.com/with-binary' + + app 'App.app' + binary "#{appdir}/App.app/Contents/MacOS/App/binary" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb new file mode 100644 index 000000000..a7d347fb5 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb @@ -0,0 +1,9 @@ +test_cask 'with-generic-artifact-no-target' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-generic-artifact' + + artifact 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb new file mode 100644 index 000000000..e718b994b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb @@ -0,0 +1,9 @@ +test_cask 'with-generic-artifact' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-generic-artifact' + + artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb new file mode 100644 index 000000000..6aa735e1f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb @@ -0,0 +1,11 @@ +test_cask 'with-gpg-key-url' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-gpg-key-url' + gpg 'http://example.com/gpg-signature.asc', + key_url: 'http://example.com/gpg-key-url' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb new file mode 100644 index 000000000..1f7042515 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb @@ -0,0 +1,11 @@ +test_cask 'with-gpg' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-gpg' + gpg 'http://example.com/gpg-signature.asc', + key_id: '01234567' + + app 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb new file mode 100644 index 000000000..d1105b50e --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb @@ -0,0 +1,20 @@ +test_cask 'with-installable' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }, + quit: 'my.fancy.package.app', + login_item: 'Fancy', + delete: [ + '/permissible/absolute/path', + '~/permissible/path/with/tilde', + 'impermissible/relative/path', + '/another/impermissible/../relative/path', + ], + rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb new file mode 100644 index 000000000..92e2e09df --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb @@ -0,0 +1,9 @@ +test_cask 'with-installer-manual' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + installer manual: 'Caffeine.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb new file mode 100644 index 000000000..5e98eab48 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb @@ -0,0 +1,15 @@ +test_cask 'with-installer-script' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/with-install-script' + + installer script: '/usr/bin/true', + args: ['--flag'] + # acceptable alternate form + installer script: { + executable: '/usr/bin/false', + args: ['--flag'], + } +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb new file mode 100644 index 000000000..837627119 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb @@ -0,0 +1,9 @@ +test_cask 'with-macosx-dir' do + version '1.2.3' + sha256 '5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" + homepage 'http://example.com/MyFancyApp' + + app 'MyFancyApp/MyFancyApp.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb new file mode 100644 index 000000000..8bb42c447 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb @@ -0,0 +1,13 @@ +test_cask 'with-pkgutil-zap' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + zap pkgutil: 'my.fancy.package.*', + kext: 'my.fancy.package.kernelextension', + launchctl: 'my.fancy.package.service' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb new file mode 100644 index 000000000..c36151d52 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb @@ -0,0 +1,10 @@ +test_cask 'with-suite' do + version '1.2.3' + sha256 'd95dcc12d4e5be0bc3cb9793c4b7e7f69a25f0b3c7418494b0c883957e6eeae4' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine-suite.zip" + name 'Caffeine' + homepage 'http://example.com/with-suite' + + suite 'Caffeine' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb new file mode 100644 index 000000000..8eb68d88a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb @@ -0,0 +1,10 @@ +test_cask 'with-two-apps-correct' do + version '1.2.3' + sha256 '3178fbfd1ea5d87a2a0662a4eb599ebc9a03888e73f37538d9f3f6ee69d2368e' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine Mini.app' + app 'Caffeine Pro.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb new file mode 100644 index 000000000..6bd316dfe --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb @@ -0,0 +1,9 @@ +test_cask 'with-two-apps-incorrect' do + version '1.2.3' + sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeine.app', 'Caffeine.app/Contents/MacOS/Caffeine' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb new file mode 100644 index 000000000..202423691 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb @@ -0,0 +1,10 @@ +test_cask 'with-two-apps-subdir' do + version '1.2.3' + sha256 'd687c22a21c02bd8f07da9302c8292b93a04df9a929e3f04d09aea6c76f75c65' + + url "file://#{TEST_FIXTURE_DIR}/cask/caffeines-subdir.zip" + homepage 'http://example.com/local-caffeine' + + app 'Caffeines/Caffeine Mini.app' + app 'Caffeines/Caffeine Pro.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb new file mode 100644 index 000000000..203f18405 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb @@ -0,0 +1,16 @@ +test_cask 'with-uninstall-delete' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + uninstall delete: [ + '/permissible/absolute/path', + '~/permissible/path/with/tilde', + 'impermissible/relative/path', + '/another/impermissible/../relative/path', + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb new file mode 100644 index 000000000..a26abab1c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-early-script' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb new file mode 100644 index 000000000..fa54c7e1f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-kext' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + uninstall kext: 'my.fancy.package.kernelextension' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb new file mode 100644 index 000000000..51ad45a09 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-launchctl' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" + homepage 'http://example.com/fancy' + + app 'Fancy.app' + + uninstall launchctl: 'my.fancy.package.service' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb new file mode 100644 index 000000000..26dca6f1a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-login-item' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall login_item: 'Fancy' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb new file mode 100644 index 000000000..db77a460b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-pkgutil' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + uninstall pkgutil: 'my.fancy.package.*' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb new file mode 100644 index 000000000..19337b18a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-quit' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall quit: 'my.fancy.package.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb new file mode 100644 index 000000000..88142ea71 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-rmdir' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb new file mode 100644 index 000000000..d2e0d6167 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-script' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb new file mode 100644 index 000000000..cc32b888a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb @@ -0,0 +1,14 @@ +test_cask 'with-uninstall-signal' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall signal: [ + ['TERM', 'my.fancy.package.app'], + ['KILL', 'my.fancy.package.app'], + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb new file mode 100644 index 000000000..4fe58a19a --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb @@ -0,0 +1,16 @@ +test_cask 'with-uninstall-trash' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + uninstall trash: [ + '/permissible/absolute/path', + '~/permissible/path/with/tilde', + 'impermissible/relative/path', + '/another/impermissible/../relative/path', + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb new file mode 100644 index 000000000..c76a9acb0 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb @@ -0,0 +1,16 @@ +test_cask 'with-zap-delete' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + zap delete: [ + '/permissible/absolute/path', + '~/permissible/path/with/tilde', + 'impermissible/relative/path', + '/another/impermissible/../relative/path', + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb new file mode 100644 index 000000000..d35c1809e --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-early-script' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb new file mode 100644 index 000000000..463fe8133 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-kext' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + zap kext: 'my.fancy.package.kernelextension' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb new file mode 100644 index 000000000..aab285672 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-launchctl' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" + homepage 'http://example.com/fancy' + + app 'Fancy.app' + + zap launchctl: 'my.fancy.package.service' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb new file mode 100644 index 000000000..d7ba9a65b --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-login-item' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap login_item: 'Fancy' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb new file mode 100644 index 000000000..17a667000 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-pkgutil' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + zap pkgutil: 'my.fancy.package.*' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb new file mode 100644 index 000000000..21f824ae9 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-quit' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap quit: 'my.fancy.package.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb new file mode 100644 index 000000000..eac02ad0e --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-rmdir' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb new file mode 100644 index 000000000..f8646a267 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb @@ -0,0 +1,11 @@ +test_cask 'with-zap-script' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] } +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb new file mode 100644 index 000000000..5accd8337 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb @@ -0,0 +1,14 @@ +test_cask 'with-zap-signal' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap signal: [ + ['TERM', 'my.fancy.package.app'], + ['KILL', 'my.fancy.package.app'], + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb new file mode 100644 index 000000000..aef4e0eab --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb @@ -0,0 +1,16 @@ +test_cask 'with-zap-trash' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'Fancy.pkg' + + zap trash: [ + '/permissible/absolute/path', + '~/permissible/path/with/tilde', + 'impermissible/relative/path', + '/another/impermissible/../relative/path', + ] +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb new file mode 100644 index 000000000..056c90671 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb @@ -0,0 +1,19 @@ +test_cask 'with-zap' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall quit: 'my.fancy.package.app.from.uninstall' + + zap script: { + executable: 'MyFancyPkg/FancyUninstaller.tool', + args: %w[--please], + }, + quit: 'my.fancy.package.app', + login_item: 'Fancy', + delete: '~/Library/Preferences/my.fancy.app.plist' +end -- cgit v1.2.3 From b0feac6645389c3e201fdb96b051c8cc00837f65 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 10 Dec 2016 05:27:51 +0100 Subject: Remove Cask’s `test` ReadMe. --- Library/Homebrew/cask/test/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Library/Homebrew/cask/test/README.md (limited to 'Library') diff --git a/Library/Homebrew/cask/test/README.md b/Library/Homebrew/cask/test/README.md deleted file mode 100644 index 4b73af8c4..000000000 --- a/Library/Homebrew/cask/test/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Naming - -Only files matching `*_test.rb` will be executed as tests. -- cgit v1.2.3 From 8db4733c45633098d54a4a9e3e7852a035af0351 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 10 Dec 2016 05:53:35 +0100 Subject: Remove Cask’s `.gitattributes`. --- Library/Homebrew/cask/.gitattributes | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Library/Homebrew/cask/.gitattributes (limited to 'Library') diff --git a/Library/Homebrew/cask/.gitattributes b/Library/Homebrew/cask/.gitattributes deleted file mode 100644 index 176a458f9..000000000 --- a/Library/Homebrew/cask/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto -- cgit v1.2.3 From d8416c969b11021735728a8c98f18fa28589c472 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 10 Dec 2016 05:26:48 +0100 Subject: Remove `:console` task from Cask’s Rakefile. --- Library/Homebrew/cask/Gemfile | 5 ----- Library/Homebrew/cask/Gemfile.lock | 23 +++++------------------ Library/Homebrew/cask/Rakefile | 9 --------- 3 files changed, 5 insertions(+), 32 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/Gemfile b/Library/Homebrew/cask/Gemfile index 5c99338b8..dc5c43208 100644 --- a/Library/Homebrew/cask/Gemfile +++ b/Library/Homebrew/cask/Gemfile @@ -2,11 +2,6 @@ source "https://rubygems.org" gem "rake" -group :debug do - gem "pry" - gem "pry-byebug", platforms: :mri -end - group :test do # This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve # all issues with parallel tests, uncovered files, and tracked files. Switch diff --git a/Library/Homebrew/cask/Gemfile.lock b/Library/Homebrew/cask/Gemfile.lock index 4bdf2d0f6..28c05c655 100644 --- a/Library/Homebrew/cask/Gemfile.lock +++ b/Library/Homebrew/cask/Gemfile.lock @@ -14,36 +14,26 @@ GEM specs: ansi (1.5.0) builder (3.2.2) - byebug (9.0.6) - codecov (0.1.6) + codecov (0.1.9) json simplecov url - coderay (1.1.1) diff-lcs (1.2.5) docile (1.1.5) json (2.0.2) metaclass (0.0.4) - method_source (0.8.2) - minitest (5.9.1) - minitest-reporters (1.1.12) + minitest (5.10.1) + minitest-reporters (1.1.13) ansi builder minitest (>= 5.0) ruby-progressbar mocha (1.2.1) metaclass (~> 0.0.1) - parallel (1.9.0) + parallel (1.10.0) parallel_tests (2.10.0) parallel - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-byebug (3.4.0) - byebug (~> 9.0) - pry (~> 0.10) - rake (11.3.0) + rake (12.0.0) rspec (3.5.0) rspec-core (~> 3.5.0) rspec-expectations (~> 3.5.0) @@ -64,7 +54,6 @@ GEM rspec (>= 3, < 4) ruby-progressbar (1.8.1) simplecov-html (0.10.0) - slop (3.6.0) url (0.3.2) PLATFORMS @@ -76,8 +65,6 @@ DEPENDENCIES minitest-reporters mocha (~> 1.1) parallel_tests - pry - pry-byebug rake rspec (~> 3.5) rspec-its diff --git a/Library/Homebrew/cask/Rakefile b/Library/Homebrew/cask/Rakefile index 39398aa19..b2b9fce52 100644 --- a/Library/Homebrew/cask/Rakefile +++ b/Library/Homebrew/cask/Rakefile @@ -15,12 +15,3 @@ namespace :test do end end end - -desc "Open a REPL for debugging and experimentation" -task :console do - require "pry" - require "pry-byebug" - require "hbc" - ARGV.clear - Hbc.pry -end -- cgit v1.2.3 From b5f1db5f291dfbba54f373dbfac13c3be711d756 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 12:01:24 +0000 Subject: */Gemfile*: remove rake, version pins, master simplecov. We’re upgrading SimpleCov to 0.13.0 so let’s update the rest of our gems while we’re at it. --- Library/Homebrew/cask/Gemfile | 19 ++++--------------- Library/Homebrew/cask/Gemfile.lock | 37 ++++++++++++++----------------------- Library/Homebrew/test/Gemfile | 18 ++++-------------- Library/Homebrew/test/Gemfile.lock | 37 ++++++++++++++----------------------- 4 files changed, 36 insertions(+), 75 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/Gemfile b/Library/Homebrew/cask/Gemfile index dc5c43208..5572387cc 100644 --- a/Library/Homebrew/cask/Gemfile +++ b/Library/Homebrew/cask/Gemfile @@ -1,24 +1,13 @@ source "https://rubygems.org" -gem "rake" - group :test do - # This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve - # all issues with parallel tests, uncovered files, and tracked files. Switch - # back to stable as soon as v0.12.1 or v0.13.0 is released. For details, see: - # - https://github.com/colszowka/simplecov/pull/513 - # - https://github.com/colszowka/simplecov/pull/520 - gem "simplecov", "0.12.0", - git: "https://github.com/colszowka/simplecov.git", - branch: "master", - ref: "83d8031ddde0927f87ef9327200a98583ca18d77", - require: false + gem "simplecov", require: false gem "codecov", require: false - gem "minitest", "~> 5.9" + gem "minitest" gem "minitest-reporters" - gem "mocha", "~> 1.1", require: false + gem "mocha", require: false gem "parallel_tests" - gem "rspec", "~> 3.5" + gem "rspec" gem "rspec-its", require: false gem "rspec-wait", require: false end diff --git a/Library/Homebrew/cask/Gemfile.lock b/Library/Homebrew/cask/Gemfile.lock index 28c05c655..700f093d1 100644 --- a/Library/Homebrew/cask/Gemfile.lock +++ b/Library/Homebrew/cask/Gemfile.lock @@ -1,29 +1,18 @@ -GIT - remote: https://github.com/colszowka/simplecov.git - revision: 83d8031ddde0927f87ef9327200a98583ca18d77 - ref: 83d8031ddde0927f87ef9327200a98583ca18d77 - branch: master - specs: - simplecov (0.12.0) - docile (~> 1.1.0) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - GEM remote: https://rubygems.org/ specs: ansi (1.5.0) - builder (3.2.2) + builder (3.2.3) codecov (0.1.9) json simplecov url - diff-lcs (1.2.5) + diff-lcs (1.3) docile (1.1.5) - json (2.0.2) + json (2.0.3) metaclass (0.0.4) minitest (5.10.1) - minitest-reporters (1.1.13) + minitest-reporters (1.1.14) ansi builder minitest (>= 5.0) @@ -31,9 +20,8 @@ GEM mocha (1.2.1) metaclass (~> 0.0.1) parallel (1.10.0) - parallel_tests (2.10.0) + parallel_tests (2.13.0) parallel - rake (12.0.0) rspec (3.5.0) rspec-core (~> 3.5.0) rspec-expectations (~> 3.5.0) @@ -53,6 +41,10 @@ GEM rspec-wait (0.0.9) rspec (>= 3, < 4) ruby-progressbar (1.8.1) + simplecov (0.13.0) + docile (~> 1.1.0) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) simplecov-html (0.10.0) url (0.3.2) @@ -61,15 +53,14 @@ PLATFORMS DEPENDENCIES codecov - minitest (~> 5.9) + minitest minitest-reporters - mocha (~> 1.1) + mocha parallel_tests - rake - rspec (~> 3.5) + rspec rspec-its rspec-wait - simplecov (= 0.12.0)! + simplecov BUNDLED WITH - 1.13.6 + 1.13.7 diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile index a7e9eb834..2a66086bd 100644 --- a/Library/Homebrew/test/Gemfile +++ b/Library/Homebrew/test/Gemfile @@ -1,20 +1,10 @@ source "https://rubygems.org" -gem "mocha", "~> 1.1" -gem "minitest", "~> 5.3" -gem "rake", "~> 10.3" -gem "parallel_tests", "~> 2.9" +gem "mocha" +gem "minitest" +gem "parallel_tests" group :coverage do - # This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve - # all issues with parallel tests, uncovered files, and tracked files. Switch - # back to stable as soon as v0.12.1 or v0.13.0 is released. For details, see: - # - https://github.com/colszowka/simplecov/pull/513 - # - https://github.com/colszowka/simplecov/pull/520 - gem "simplecov", "0.12.0", - git: "https://github.com/colszowka/simplecov.git", - branch: "master", - ref: "83d8031ddde0927f87ef9327200a98583ca18d77", - require: false + gem "simplecov", require: false gem "codecov", require: false end diff --git a/Library/Homebrew/test/Gemfile.lock b/Library/Homebrew/test/Gemfile.lock index aa4800f34..8289fcc20 100644 --- a/Library/Homebrew/test/Gemfile.lock +++ b/Library/Homebrew/test/Gemfile.lock @@ -1,31 +1,23 @@ -GIT - remote: https://github.com/colszowka/simplecov.git - revision: 83d8031ddde0927f87ef9327200a98583ca18d77 - ref: 83d8031ddde0927f87ef9327200a98583ca18d77 - branch: master - specs: - simplecov (0.12.0) - docile (~> 1.1.0) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - GEM remote: https://rubygems.org/ specs: - codecov (0.1.6) + codecov (0.1.9) json simplecov url docile (1.1.5) - json (2.0.2) + json (2.0.3) metaclass (0.0.4) - minitest (5.9.1) + minitest (5.10.1) mocha (1.2.1) metaclass (~> 0.0.1) - parallel (1.9.0) - parallel_tests (2.10.0) + parallel (1.10.0) + parallel_tests (2.13.0) parallel - rake (10.5.0) + simplecov (0.13.0) + docile (~> 1.1.0) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) simplecov-html (0.10.0) url (0.3.2) @@ -34,11 +26,10 @@ PLATFORMS DEPENDENCIES codecov - minitest (~> 5.3) - mocha (~> 1.1) - parallel_tests (~> 2.9) - rake (~> 10.3) - simplecov (= 0.12.0)! + minitest + mocha + parallel_tests + simplecov BUNDLED WITH - 1.13.6 + 1.13.7 -- cgit v1.2.3 From 92b48ac42e84eb4c113bb3fb362f83b51282c99f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 12:01:54 +0000 Subject: brew-cask-tests: import Rakefile logic. This avoids a `rake` dependency in the Gemfile and an unnecessary shell out. --- Library/Homebrew/cask/Rakefile | 17 ----------------- Library/Homebrew/cask/cmd/brew-cask-tests.rb | 5 ++++- 2 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 Library/Homebrew/cask/Rakefile (limited to 'Library') diff --git a/Library/Homebrew/cask/Rakefile b/Library/Homebrew/cask/Rakefile deleted file mode 100644 index b2b9fce52..000000000 --- a/Library/Homebrew/cask/Rakefile +++ /dev/null @@ -1,17 +0,0 @@ -require "rake/testtask" -require "rspec/core/rake_task" - -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew")) -$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__)) - -namespace :test do - namespace :coverage do - desc "Upload coverage to Codecov" - task :upload do - require "simplecov" - require "codecov" - formatter = SimpleCov::Formatter::Codecov.new - formatter.format(SimpleCov::ResultMerger.merged_result) - end - end -end diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index 43683a263..94902e41c 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -52,6 +52,9 @@ repo_root.cd do if upload_coverage puts "Submitting Codecov coverage..." - system "bundle", "exec", "rake", "test:coverage:upload" + require "simplecov" + require "codecov" + formatter = SimpleCov::Formatter::Codecov.new + formatter.format(SimpleCov::ResultMerger.merged_result) end end -- cgit v1.2.3 From 0fc4a52c6c34deaee59c55b1d7ff3ea62eda2b36 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 12:02:17 +0000 Subject: *_test: use assert_nil when appropriate. This is warned by the newer MiniTest. --- Library/Homebrew/test/shell_test.rb | 6 +++--- Library/Homebrew/test/tab_test.rb | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb index a32d09863..a04ab8331 100644 --- a/Library/Homebrew/test/shell_test.rb +++ b/Library/Homebrew/test/shell_test.rb @@ -14,9 +14,9 @@ class ShellSmokeTest < Homebrew::TestCase end def test_path_to_shell_failure - assert_equal nil, Utils::Shell.path_to_shell("") - assert_equal nil, Utils::Shell.path_to_shell("@@@@@@") - assert_equal nil, Utils::Shell.path_to_shell("invalid_shell-4.2") + assert_nil Utils::Shell.path_to_shell("") + assert_nil Utils::Shell.path_to_shell("@@@@@@") + assert_nil Utils::Shell.path_to_shell("invalid_shell-4.2") end def test_sh_quote diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index f6f55348d..b48efcf5c 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -241,15 +241,18 @@ class TabTests < Homebrew::TestCase assert_equal @tab.changed_files, tab.changed_files assert_equal @tab.tap, tab.tap assert_equal @tab.spec, tab.spec - assert_equal @tab.time, tab.time + assert_nil @tab.time + assert_nil tab.time assert_equal @tab.HEAD, tab.HEAD assert_equal @tab.compiler, tab.compiler assert_equal @tab.stdlib, tab.stdlib - assert_equal @tab.runtime_dependencies, tab.runtime_dependencies + assert_nil @tab.runtime_dependencies + assert_nil tab.runtime_dependencies assert_equal @tab.stable_version, tab.stable_version assert_equal @tab.devel_version, tab.devel_version assert_equal @tab.head_version, tab.head_version - assert_equal @tab.source["path"], tab.source["path"] + assert_nil @tab.source["path"] + assert_nil tab.source["path"] end def test_remap_deprecated_options -- cgit v1.2.3 From 7a2c5c0f2f91bf9e09d9eca993df0a4ec34a8f7b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 15:18:32 +0000 Subject: caveats: add newline after keg only reason. --- Library/Homebrew/caveats.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index d051a7ca7..f5543cf49 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -47,7 +47,7 @@ class Caveats return unless f.keg_only? s = "This formula is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}." - s << "\n\n#{f.keg_only_reason}" + s << "\n\n#{f.keg_only_reason}\n" if f.bin.directory? || f.sbin.directory? s << "\nIf you need to have this software first in your PATH run:\n" if f.bin.directory? -- cgit v1.2.3 From 1aa179ad9a835ba56e8f5e8eb85489ca7a9dd131 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 15:26:42 +0000 Subject: formula_cellar_checks: check for prefix/etc. This directory indicates that configuration files have been installed into the wrong location. --- Library/Homebrew/formula_cellar_checks.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index 7db5e748b..f72f36c48 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -153,6 +153,16 @@ module FormulaCellarChecks EOS end + def check_etc + bad_etc = (formula.prefix/"etc") + return unless bad_etc.directory? + <<-EOS.undent + #{bad_etc} exists! + The contents should instead be installed into: + #{formula.etc} + EOS + end + def audit_installed audit_check_output(check_manpages) audit_check_output(check_infopages) @@ -165,6 +175,7 @@ module FormulaCellarChecks audit_check_output(check_easy_install_pth(formula.lib)) audit_check_output(check_elisp_dirname(formula.share, formula.name)) audit_check_output(check_elisp_root(formula.share, formula.name)) + audit_check_output(check_etc) end alias generic_audit_installed audit_installed -- cgit v1.2.3 From e65150412ce33b95ca993f5711949eeda604f837 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 16:57:30 +0100 Subject: Add `require "bundler/setup“` to `cask-tests`. --- Library/Homebrew/cask/cmd/brew-cask-tests.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index 94902e41c..002d357dd 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -21,6 +21,8 @@ repo_root.cd do system "bundle", "install" end + require "bundler/setup" + rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest") minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec") -- cgit v1.2.3 From 34e03532a02318b5e9b43fba7e73890c6e403062 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 16:19:38 +0000 Subject: audit: improve homepage audit reliability. Try first with an (exact, actual) browser user agent from Safari and then try again with the default Homebrew `curl` user agent. --- Library/Homebrew/dev-cmd/audit.rb | 17 ++++++++--------- Library/Homebrew/global.rb | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5b0102130..b5dc4ecb1 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -169,7 +169,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def url_status_code(url, range: false, user_agent: :default) + def url_status_code(url, range: false) # The system Curl is too old and unreliable with HTTPS homepages on # Yosemite and below. return "200" unless DevelopmentTools.curl_handles_most_https_homepages? @@ -182,14 +182,13 @@ class FormulaAuditor extra_args << "--range" << "0-0" if range extra_args << url - args = curl_args( - extra_args: extra_args, - show_output: true, - user_agent: user_agent - ) - retries = 3 status_code = nil - retries.times do + [:browser, :default].each do |user_agent| + args = curl_args( + extra_args: extra_args, + show_output: true, + user_agent: user_agent + ) status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } break if status_code.start_with? "20" end @@ -609,7 +608,7 @@ class FormulaAuditor return unless @online - status_code = url_status_code(homepage, user_agent: :browser) + status_code = url_status_code(homepage) return if status_code.start_with? "20" problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})" end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 031178421..5fd356909 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -26,7 +26,7 @@ RUBY_BIN = RUBY_PATH.dirname HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze -HOMEBREW_USER_AGENT_FAKE_SAFARI = "Mozilla/5.0 (#{ENV["HOMEBREW_SYSTEM"]}; #{ENV["HOMEBREW_PROCESSOR"]} #{ENV["HOMEBREW_OS_VERSION"]}) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12".freeze +HOMEBREW_USER_AGENT_FAKE_SAFARI = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8".freeze require "tap_constants" -- cgit v1.2.3 From 3c91f5858a273733112cdd11373762e4b9357c1b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 26 Jan 2017 16:29:39 +0000 Subject: update-reset: checkout with --force. Otherwise it won't overwrite unmerged changes. --- Library/Homebrew/cmd/update-reset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/update-reset.sh b/Library/Homebrew/cmd/update-reset.sh index 32daffc96..3a9e1caa9 100644 --- a/Library/Homebrew/cmd/update-reset.sh +++ b/Library/Homebrew/cmd/update-reset.sh @@ -37,7 +37,7 @@ EOS echo echo "==> Resetting $DIR..." - git checkout -B master origin/master + git checkout --force -B master origin/master echo done } -- cgit v1.2.3 From dd0bc83eca073da570051e00b8ed111febcdb2d9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 18:28:08 +0100 Subject: Move `require "bundler/setup“` to top of `cask-tests`. --- Library/Homebrew/cask/cmd/brew-cask-tests.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index 002d357dd..49650c519 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -1,4 +1,5 @@ require "English" +require "bundler/setup" ENV["BUNDLE_GEMFILE"] = "#{HOMEBREW_LIBRARY_PATH}/cask/Gemfile" ENV["BUNDLE_PATH"] = "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle" @@ -21,8 +22,6 @@ repo_root.cd do system "bundle", "install" end - require "bundler/setup" - rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest") minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec") -- cgit v1.2.3 From 39ce9c890e3c1cda60b370ff8ac49cd640be90e1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 23:11:37 +0100 Subject: Try uploading coverage report in `.simplecov`. --- Library/Homebrew/.simplecov | 6 ++++++ Library/Homebrew/cask/cmd/brew-cask-tests.rb | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/.simplecov b/Library/Homebrew/.simplecov index 952bb466b..9db7b3210 100755 --- a/Library/Homebrew/.simplecov +++ b/Library/Homebrew/.simplecov @@ -52,3 +52,9 @@ SimpleCov.start do /Homebrew/test.rb ] end + +if ENV["CODECOV_TOKEN"] || ENV["TRAVIS"] + require "codecov" + formatter = SimpleCov::Formatter::Codecov.new + formatter.format(SimpleCov::ResultMerger.merged_result) +end diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index 49650c519..2bff513fe 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -1,5 +1,4 @@ require "English" -require "bundler/setup" ENV["BUNDLE_GEMFILE"] = "#{HOMEBREW_LIBRARY_PATH}/cask/Gemfile" ENV["BUNDLE_PATH"] = "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle" @@ -25,10 +24,8 @@ repo_root.cd do rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest") minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec") - p [:coverage, ARGV.flag?("--coverage"), ENV["CI"], ENV["TRAVIS"]] if ARGV.flag?("--coverage") ENV["HOMEBREW_TESTS_COVERAGE"] = "1" - upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"] end failed = false @@ -50,12 +47,4 @@ repo_root.cd do end Homebrew.failed = failed - - if upload_coverage - puts "Submitting Codecov coverage..." - require "simplecov" - require "codecov" - formatter = SimpleCov::Formatter::Codecov.new - formatter.format(SimpleCov::ResultMerger.merged_result) - end end -- cgit v1.2.3 From d68fc389e386a2c67d824d9e748f9ee124e09dae Mon Sep 17 00:00:00 2001 From: Miccal Matthews Date: Fri, 27 Jan 2017 09:26:57 +0800 Subject: Update brew-cask.1.md --- Library/Homebrew/manpages/brew-cask.1.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md index a2c9c8c16..a9da5bca6 100644 --- a/Library/Homebrew/manpages/brew-cask.1.md +++ b/Library/Homebrew/manpages/brew-cask.1.md @@ -127,6 +127,11 @@ names, and other aspects of this manual are still subject to change. the appcast checkpoint if the `--calculate` flag is specified. Given a `URL`, calculates the appcast checkpoint for it. + * `_stanza` [ --table | --yaml | --inspect | --quiet ] [ ... ]: + Given a `stanza_name` and a `cask_token`, returns the current stanza + for a given Cask. If no `cask_token` is given, then data for all + Casks is returned. + ## OPTIONS To make these options persistent, see the ENVIRONMENT section, below. -- cgit v1.2.3 From eff70115b5eb20542c7d66725e1812cb0e149ff3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 27 Jan 2017 09:36:47 +0000 Subject: pull: better handle missing bottles. If we make a PR in which we're building many formulae (e.g. https://github.com/Homebrew/homebrew-core/pull/9249) then we may want to pull those that built and publish their bottles and discard those that did not. Instead of saying bottles will be published when they won't and then blowing up just avoid publishing them and print a warning instead. --- Library/Homebrew/dev-cmd/pull.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index f7006baaa..8771788e4 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -248,7 +248,6 @@ module Homebrew changed_formulae_names.each do |name| f = Formula[name] next if f.bottle_unneeded? || f.bottle_disabled? - ohai "Publishing on Bintray: #{f.name} #{f.pkg_version}" publish_bottle_file_on_bintray(f, bintray_creds) published << f.full_name end @@ -408,7 +407,12 @@ module Homebrew if info.nil? raise "Failed publishing bottle: failed reading formula info for #{f.full_name}" end + unless info.bottle_info_any + opoo "No bottle defined in formula #{package}" + return + end version = info.pkg_version + ohai "Publishing on Bintray: #{package} #{version}" curl "-w", '\n', "--silent", "--fail", "-u#{creds[:user]}:#{creds[:key]}", "-X", "POST", "-H", "Content-Type: application/json", -- cgit v1.2.3 From aec3d1fe3dd3e7f9de2768af992dbdbb59dc60a5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 27 Jan 2017 14:09:19 +0000 Subject: Revert "formula_cellar_checks: check for prefix/etc." --- Library/Homebrew/formula_cellar_checks.rb | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index f72f36c48..7db5e748b 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -153,16 +153,6 @@ module FormulaCellarChecks EOS end - def check_etc - bad_etc = (formula.prefix/"etc") - return unless bad_etc.directory? - <<-EOS.undent - #{bad_etc} exists! - The contents should instead be installed into: - #{formula.etc} - EOS - end - def audit_installed audit_check_output(check_manpages) audit_check_output(check_infopages) @@ -175,7 +165,6 @@ module FormulaCellarChecks audit_check_output(check_easy_install_pth(formula.lib)) audit_check_output(check_elisp_dirname(formula.share, formula.name)) audit_check_output(check_elisp_root(formula.share, formula.name)) - audit_check_output(check_etc) end alias generic_audit_installed audit_installed -- cgit v1.2.3 From c2b3f1db27eb7376e192848d05d8377ce9f062f8 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Fri, 27 Jan 2017 21:32:50 +0000 Subject: style: update rubocop to 0.47.1 --- Library/Homebrew/cmd/style.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 9befcf9ac..586c6da6b 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -47,7 +47,7 @@ module Homebrew def check_style_impl(files, output_type, options = {}) fix = options[:fix] - Homebrew.install_gem_setup_path! "rubocop", "0.45.0" + Homebrew.install_gem_setup_path! "rubocop", "0.47.1" args = %w[ --force-exclusion -- cgit v1.2.3 From 9b2951fb297a98f316ca82e2a692f5a8ca7fb6f0 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Fri, 27 Jan 2017 21:40:16 +0000 Subject: Library/.rubocop.yml: fix renamed CaseIndentation setting --- Library/.rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 097eff995..ed9fad956 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -63,7 +63,7 @@ Style/BlockDelimiters: EnforcedStyle: line_count_based Style/CaseIndentation: - IndentWhenRelativeTo: end + EnforcedStyle: end Style/ClassAndModuleChildren: EnforcedStyle: nested -- cgit v1.2.3 From 8b5dc016047997c8f9b1b55d1acbe41b364cb77a Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Fri, 27 Jan 2017 21:42:45 +0000 Subject: Library/.rubocop.yml: fix renamed EndAlignment setting --- Library/.rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index ed9fad956..29a891e2a 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -41,7 +41,7 @@ Lint/AssignmentInCondition: Enabled: false Lint/EndAlignment: - AlignWith: variable + EnforcedStyleAlignWith: variable Lint/ParenthesesAsGroupedExpression: Enabled: false -- cgit v1.2.3 From 10e81b16726fcbfb7d8cf19c5bef9a75e9ae2b77 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Fri, 27 Jan 2017 21:50:43 +0000 Subject: rubocop: automatically update rubocop_todo.yml --- Library/Homebrew/.rubocop_todo.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index 99080b546..37518a5f0 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2016-12-31 22:41:53 +0000 using RuboCop version 0.45.0. +# on 2017-01-27 21:44:55 +0000 using RuboCop version 0.47.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 16 +# Offense count: 17 Lint/HandleExceptions: Exclude: - 'cmd/install.rb' @@ -60,6 +60,7 @@ Lint/ShadowedException: - 'utils/fork.rb' # Offense count: 13 +# Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 5 @@ -73,6 +74,12 @@ Metrics/ModuleLength: Metrics/ParameterLists: Max: 6 +# Offense count: 2 +Security/MarshalLoad: + Exclude: + - 'dependency.rb' + - 'utils/fork.rb' + # Offense count: 1 Style/AccessorMethodName: Exclude: @@ -85,6 +92,18 @@ Style/ClassVars: - 'formula_installer.rb' - 'test/support/helper/fs_leak_logger.rb' +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'debrew/irb.rb' + - 'download_strategy.rb' + - 'extend/ENV/super.rb' + - 'formula.rb' + - 'patch.rb' + # Offense count: 13 # Configuration parameters: AllowedVariables. Style/GlobalVars: -- cgit v1.2.3 From c0b84a0479562edd0bb56b3d915fda9f90a520da Mon Sep 17 00:00:00 2001 From: Vítor Galvão Date: Sat, 28 Jan 2017 16:25:14 +0000 Subject: cask: staged: no sudo in set_permissions --- Library/Homebrew/cask/lib/hbc/staged.rb | 2 +- Library/Homebrew/cask/test/support/shared_examples/staged.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/staged.rb b/Library/Homebrew/cask/lib/hbc/staged.rb index dcc05ef5d..c1aa01b29 100644 --- a/Library/Homebrew/cask/lib/hbc/staged.rb +++ b/Library/Homebrew/cask/lib/hbc/staged.rb @@ -27,7 +27,7 @@ module Hbc full_paths = remove_nonexistent(paths) return if full_paths.empty? @command.run!("/bin/chmod", args: ["-R", "--", permissions_str] + full_paths, - sudo: true) + sudo: false) end def set_ownership(paths, user: current_user, group: "staff") diff --git a/Library/Homebrew/cask/test/support/shared_examples/staged.rb b/Library/Homebrew/cask/test/support/shared_examples/staged.rb index ef4ff0341..95e75726e 100644 --- a/Library/Homebrew/cask/test/support/shared_examples/staged.rb +++ b/Library/Homebrew/cask/test/support/shared_examples/staged.rb @@ -47,7 +47,7 @@ shared_examples_for Hbc::Staged do staged.stubs(Pathname: fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/bin/chmod", "-R", "--", "777", fake_pathname] + ["/bin/chmod", "-R", "--", "777", fake_pathname] ) staged.set_permissions(fake_pathname.to_s, "777") end @@ -57,7 +57,7 @@ shared_examples_for Hbc::Staged do staged.stubs(:Pathname).returns(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] + ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] ) staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777") end -- cgit v1.2.3 From f7b19916265ba893c669316c0984085aa069d774 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 29 Jan 2017 17:23:05 +0000 Subject: Use dedicated upload_coverage script. --- Library/Homebrew/.simplecov | 6 ------ Library/Homebrew/cask/cmd/brew-cask-tests.rb | 10 ++++++++-- Library/Homebrew/cask/test/upload_coverage.rb | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100755 Library/Homebrew/cask/test/upload_coverage.rb (limited to 'Library') diff --git a/Library/Homebrew/.simplecov b/Library/Homebrew/.simplecov index 9db7b3210..952bb466b 100755 --- a/Library/Homebrew/.simplecov +++ b/Library/Homebrew/.simplecov @@ -52,9 +52,3 @@ SimpleCov.start do /Homebrew/test.rb ] end - -if ENV["CODECOV_TOKEN"] || ENV["TRAVIS"] - require "codecov" - formatter = SimpleCov::Formatter::Codecov.new - formatter.format(SimpleCov::ResultMerger.merged_result) -end diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index 2bff513fe..bdcabd4dc 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -10,8 +10,8 @@ def run_tests(executable, files, args = []) system "bundle", "exec", executable, *opts, "--", *args, "--", *files end -repo_root = Pathname.new(__FILE__).realpath.parent.parent -repo_root.cd do +cask_root = Pathname.new(__FILE__).realpath.parent.parent +cask_root.cd do ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_NO_EMOJI"] = "1" ENV.delete("HOMEBREW_CASK_OPTS") @@ -26,6 +26,7 @@ repo_root.cd do if ARGV.flag?("--coverage") ENV["HOMEBREW_TESTS_COVERAGE"] = "1" + upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"] end failed = false @@ -47,4 +48,9 @@ repo_root.cd do end Homebrew.failed = failed + + if upload_coverage + puts "Submitting Codecov coverage..." + system "bundle", "exec", "test/upload_coverage.rb" + end end diff --git a/Library/Homebrew/cask/test/upload_coverage.rb b/Library/Homebrew/cask/test/upload_coverage.rb new file mode 100755 index 000000000..06d38157d --- /dev/null +++ b/Library/Homebrew/cask/test/upload_coverage.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require "simplecov" +require "codecov" + +formatter = SimpleCov::Formatter::Codecov.new +formatter.format SimpleCov::ResultMerger.merged_result -- cgit v1.2.3 From 276d8805ca30c2c08c58a7b9032f94902b52f1fa Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 29 Jan 2017 17:30:44 +0000 Subject: update: note migrations may be performed. As requested in https://github.com/Homebrew/homebrew-core/issues/9316. --- Library/Homebrew/cmd/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 678622230..c5e618403 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -1,6 +1,6 @@ #: * `update` [`--merge`] [`--force`]: #: Fetch the newest version of Homebrew and all formulae from GitHub using -#: `git`(1). +#: `git`(1) and perform any necessary migrations. #: #: If `--merge` is specified then `git merge` is used to include updates #: (rather than `git rebase`). -- cgit v1.2.3 From 6215c6a5e1216054c40d910905e36975c638bce9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 30 Jan 2017 00:18:52 +0100 Subject: Don’t use `assert_nil` in `tab_test`. --- Library/Homebrew/test/tab_test.rb | 57 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index b48efcf5c..99c95a3f0 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -6,30 +6,34 @@ class TabTests < Homebrew::TestCase def setup super + @time = Time.now.to_i @used = Options.create(%w[--with-foo --without-bar]) @unused = Options.create(%w[--with-baz --without-qux]) - @tab = Tab.new("used_options" => @used.as_flags, - "unused_options" => @unused.as_flags, - "built_as_bottle" => false, - "poured_from_bottle" => true, - "changed_files" => [], - "time" => nil, - "source_modified_time" => 0, - "HEAD" => TEST_SHA1, - "compiler" => "clang", - "stdlib" => "libcxx", - "runtime_dependencies" => [], - "source" => { - "tap" => "homebrew/core", - "path" => nil, - "spec" => "stable", - "versions" => { - "stable" => "0.10", - "devel" => "0.14", - "head" => "HEAD-1111111", - }, - }) + @tab = Tab.new( + "homebrew_version" => HOMEBREW_VERSION, + "used_options" => @used.as_flags, + "unused_options" => @unused.as_flags, + "built_as_bottle" => false, + "poured_from_bottle" => true, + "changed_files" => [], + "time" => @time, + "source_modified_time" => 0, + "HEAD" => TEST_SHA1, + "compiler" => "clang", + "stdlib" => "libcxx", + "runtime_dependencies" => [], + "source" => { + "tap" => CoreTap.instance.to_s, + "path" => CoreTap.instance.path.to_s, + "spec" => "stable", + "versions" => { + "stable" => "0.10", + "devel" => "0.14", + "head" => "HEAD-1111111", + }, + } + ) end def test_defaults @@ -124,7 +128,7 @@ class TabTests < Homebrew::TestCase def test_other_attributes assert_equal TEST_SHA1, @tab.HEAD assert_equal "homebrew/core", @tab.tap.name - assert_nil @tab.time + assert_equal @time, @tab.time refute_predicate @tab, :built_as_bottle assert_predicate @tab, :poured_from_bottle end @@ -241,18 +245,15 @@ class TabTests < Homebrew::TestCase assert_equal @tab.changed_files, tab.changed_files assert_equal @tab.tap, tab.tap assert_equal @tab.spec, tab.spec - assert_nil @tab.time - assert_nil tab.time + assert_equal @tab.time, tab.time assert_equal @tab.HEAD, tab.HEAD assert_equal @tab.compiler, tab.compiler assert_equal @tab.stdlib, tab.stdlib - assert_nil @tab.runtime_dependencies - assert_nil tab.runtime_dependencies + assert_equal @tab.runtime_dependencies, tab.runtime_dependencies assert_equal @tab.stable_version, tab.stable_version assert_equal @tab.devel_version, tab.devel_version assert_equal @tab.head_version, tab.head_version - assert_nil @tab.source["path"] - assert_nil tab.source["path"] + assert_equal @tab.source["path"], tab.source["path"] end def test_remap_deprecated_options -- cgit v1.2.3 From f3df412e77db03ba1eae39dfeff5488749056a3c Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Mon, 30 Jan 2017 17:16:23 +0800 Subject: cleanup: consider version_scheme `brew cleanup` should cleanup formulae which have the older version scheme. --- Library/Homebrew/formula.rb | 11 ++++++++++- Library/Homebrew/test/cleanup_test.rb | 27 +++++++++++++++++++++------ Library/Homebrew/test/formula_test.rb | 28 +++++++++++++++++++++------- 3 files changed, 52 insertions(+), 14 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 6df1eb4de..a4ef11276 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1843,7 +1843,16 @@ class Formula eligible_kegs = if head? && (head_prefix = latest_head_prefix) installed_kegs - [Keg.new(head_prefix)] else - installed_kegs.select { |k| pkg_version > k.version } + installed_kegs.select do |keg| + tab = Tab.for_keg(keg) + if version_scheme > tab.version_scheme + true + elsif version_scheme == tab.version_scheme + pkg_version > keg.version + else + false + end + end end unless eligible_kegs.empty? diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index 8a292933a..e6fc31dfe 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -36,25 +36,40 @@ class CleanupTests < Homebrew::TestCase end def test_cleanup_formula - f1 = Class.new(Testball) { version "0.1" }.new - f2 = Class.new(Testball) { version "0.2" }.new - f3 = Class.new(Testball) { version "0.3" }.new + f1 = Class.new(Testball) do + version "1.0" + end.new + f2 = Class.new(Testball) do + version "0.2" + version_scheme 1 + end.new + f3 = Class.new(Testball) do + version "0.3" + version_scheme 1 + end.new + f4 = Class.new(Testball) do + version "0.1" + version_scheme 2 + end.new shutup do - f1.brew { f1.install } - f2.brew { f2.install } - f3.brew { f3.install } + [f1, f2, f3, f4].each do |f| + f.brew { f.install } + Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write + end end assert_predicate f1, :installed? assert_predicate f2, :installed? assert_predicate f3, :installed? + assert_predicate f4, :installed? shutup { Homebrew::Cleanup.cleanup_formula f3 } refute_predicate f1, :installed? refute_predicate f2, :installed? assert_predicate f3, :installed? + assert_predicate f4, :installed? end def test_cleanup_logs diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index ecdd1847b..f7b06b079 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -727,21 +727,35 @@ class FormulaTests < Homebrew::TestCase end def test_eligible_kegs_for_cleanup - f1 = Class.new(Testball) { version "0.1" }.new - f2 = Class.new(Testball) { version "0.2" }.new - f3 = Class.new(Testball) { version "0.3" }.new + f1 = Class.new(Testball) do + version "1.0" + end.new + f2 = Class.new(Testball) do + version "0.2" + version_scheme 1 + end.new + f3 = Class.new(Testball) do + version "0.3" + version_scheme 1 + end.new + f4 = Class.new(Testball) do + version "0.1" + version_scheme 2 + end.new shutup do - f1.brew { f1.install } - f2.brew { f2.install } - f3.brew { f3.install } + [f1, f2, f3, f4].each do |f| + f.brew { f.install } + Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write + end end assert_predicate f1, :installed? assert_predicate f2, :installed? assert_predicate f3, :installed? + assert_predicate f4, :installed? - assert_equal f3.installed_kegs.sort_by(&:version)[0..1], + assert_equal [f2, f1].map { |f| Keg.new(f.prefix) }, f3.eligible_kegs_for_cleanup.sort_by(&:version) end -- cgit v1.2.3 From d4aa98d2300c0b81dd0d1608cf7fc67dbe5a6c04 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Mon, 30 Jan 2017 20:46:41 +0000 Subject: Updated mirror checks to compare ETags, Content-Lengths and binary files --- Library/Homebrew/dev-cmd/audit.rb | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index af1e4a71b..75e81db90 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1481,18 +1481,42 @@ class ResourceAuditor urls.each do |url| next unless url.start_with? "http:" # Check for insecure mirrors - status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ - "--write-out", "%{http_code}", url + details = get_content_details(url, 1) secure_url = url.sub "http", "https" - secure_status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ - "--write-out", "%{http_code}", secure_url - if status_code.start_with?("20") && secure_status_code.start_with?("20") + secure_details = get_content_details(secure_url, 2) + + next unless details[:status].start_with?("2") && secure_details[:status].start_with?("2") + + if (details[:etag] && details[:etag] == secure_details[:etag]) \ + || (details[:content_length] && details[:content_length] == secure_details[:content_length]) \ + || are_same_file(details[:filename], secure_details[:filename]) problem "The URL #{url} could use HTTPS rather than HTTP" end + + remove_files details[:filename], secure_details[:filename] end end def problem(text) @problems << text end + + def get_content_details(url, id) + out = {} + out_file = "/tmp/_c#{id}" + headers, = curl_output "--connect-timeout", "15", "--output", out_file, "--dump-header", "/dev/stdout", url + out[:status] = headers[%r{HTTP\/.* (\d+)}, 1] + out[:etag] = headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2] + out[:content_length] = headers[/Content-Length: (\d+)/, 1] + out[:filename] = out_file + out + end + + def are_same_file(one, two) + quiet_system "diff", "--report-identical-files", "--binary", "--speed-large-files", one, two + end + + def remove_files(*files) + quiet_system "rm", "-f", *files + end end -- cgit v1.2.3 From e11b8b68cdf2b021dce4a11c40afddc306dab7d4 Mon Sep 17 00:00:00 2001 From: Trevor Powell Date: Mon, 30 Jan 2017 22:31:09 -0600 Subject: Update dmg.rb based on feedback Try "diskutil eject" twice before "diskutil unmount force".--- Library/Homebrew/cask/lib/hbc/container/dmg.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb index 49543844a..815f8f010 100644 --- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb @@ -43,12 +43,17 @@ module Hbc next unless mountpath.exist? begin - tries ||= 2 - @command.run("/usr/sbin/diskutil", - args: ["unmount", "force", mountpath], - print_stderr: false) - - raise CaskError, "Failed to unmount #{mountpath}" if mountpath.exist? + tries ||= 3 + if tries > 1 + @command.run("/usr/sbin/diskutil", + args: ["eject", mountpath], + print_stderr: false) + else + @command.run("/usr/sbin/diskutil", + args: ["unmount", "force", mountpath], + print_stderr: false) + end + raise CaskError, "Failed to eject #{mountpath}" if mountpath.exist? rescue CaskError => e raise e if (tries -= 1).zero? sleep 1 -- cgit v1.2.3 From ade8128a18ec3a053306e364e31687739de8c568 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 1 Feb 2017 18:30:55 +0000 Subject: formulary: handle ScriptError in formula I added a new `FormulaUnreadableError` subclass of `FormulaUnavailableError` so existing `rescue`s of `FormulaUnavailableError` handle this as well. The new subclass will output the name of the formula with the error (because this isn't always obvious from the original exception message) followed by the original error message. Fixes #1927. --- Library/Homebrew/exceptions.rb | 13 +++++++++++++ Library/Homebrew/formulary.rb | 6 +++++- Library/Homebrew/test/exceptions_test.rb | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index c5d888d64..77da4489e 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -131,6 +131,19 @@ class FormulaClassUnavailableError < FormulaUnavailableError end end +class FormulaUnreadableError < FormulaUnavailableError + attr_reader :formula_error + + def initialize(name, error) + super(name) + @formula_error = error + end + + def to_s + "#{name}: " + formula_error.to_s + end +end + class TapFormulaAmbiguityError < RuntimeError attr_reader :name, :paths, :formulae diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 25df57cdc..cf85ba03f 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -22,7 +22,11 @@ class Formulary mod = Module.new const_set(namespace, mod) - mod.module_eval(contents, path) + begin + mod.module_eval(contents, path) + rescue ScriptError => e + raise FormulaUnreadableError.new(name, e) + end class_name = class_s(name) begin diff --git a/Library/Homebrew/test/exceptions_test.rb b/Library/Homebrew/test/exceptions_test.rb index 689531c6e..e9fedef04 100644 --- a/Library/Homebrew/test/exceptions_test.rb +++ b/Library/Homebrew/test/exceptions_test.rb @@ -56,6 +56,11 @@ class ExceptionsTest < Homebrew::TestCase FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", list).to_s end + def test_formula_unreadable_error + formula_error = LoadError.new("bar") + assert_equal "foo: bar", FormulaUnreadableError.new("foo", formula_error).to_s + end + def test_tap_unavailable_error assert_equal "No available tap foo.\n", TapUnavailableError.new("foo").to_s end -- cgit v1.2.3 From 64c83f3286a40cbe8871124f208fb3eaaaffd97a Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Thu, 2 Feb 2017 21:25:29 +0000 Subject: Use file checksum rather than file diffing --- Library/Homebrew/dev-cmd/audit.rb | 48 ++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 75e81db90..b4906cb80 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -36,6 +36,7 @@ require "cmd/search" require "cmd/style" require "date" require "blacklist" +require "digest" module Homebrew module_function @@ -1479,21 +1480,23 @@ class ResourceAuditor return unless @online urls.each do |url| - next unless url.start_with? "http:" - # Check for insecure mirrors - details = get_content_details(url, 1) - secure_url = url.sub "http", "https" - secure_details = get_content_details(secure_url, 2) - - next unless details[:status].start_with?("2") && secure_details[:status].start_with?("2") - - if (details[:etag] && details[:etag] == secure_details[:etag]) \ - || (details[:content_length] && details[:content_length] == secure_details[:content_length]) \ - || are_same_file(details[:filename], secure_details[:filename]) - problem "The URL #{url} could use HTTPS rather than HTTP" - end + check_insecure_mirror(url) if url.start_with? "http:" + end + end + + def check_insecure_mirror(url) + details = get_content_details(url) + secure_url = url.sub "http", "https" + secure_details = get_content_details(secure_url) + + return if !details[:status].start_with?("2") || !secure_details[:status].start_with?("2") - remove_files details[:filename], secure_details[:filename] + etag_match = details[:etag] && details[:etag] == secure_details[:etag] + content_length_match = details[:content_length] && details[:content_length] == secure_details[:content_length] + file_match = details[:file_hash] == secure_details[:file_hash] + + if etag_match || content_length_match || file_match + problem "The URL #{url} could use HTTPS rather than HTTP" end end @@ -1501,22 +1504,15 @@ class ResourceAuditor @problems << text end - def get_content_details(url, id) + def get_content_details(url) out = {} - out_file = "/tmp/_c#{id}" - headers, = curl_output "--connect-timeout", "15", "--output", out_file, "--dump-header", "/dev/stdout", url + output, = curl_output "--connect-timeout", "15", "--include", url + split = output.partition("\r\n\r\n") + headers = split.first out[:status] = headers[%r{HTTP\/.* (\d+)}, 1] out[:etag] = headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2] out[:content_length] = headers[/Content-Length: (\d+)/, 1] - out[:filename] = out_file + out[:file_hash] = Digest::SHA256.digest split.last out end - - def are_same_file(one, two) - quiet_system "diff", "--report-identical-files", "--binary", "--speed-large-files", one, two - end - - def remove_files(*files) - quiet_system "rm", "-f", *files - end end -- cgit v1.2.3 From e40c63f77c83254970c0e98f69ea76685536a905 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 9 Dec 2016 17:27:31 +0100 Subject: Use array of constants to set up test directories. --- Library/Homebrew/test/Gemfile | 1 + Library/Homebrew/test/Gemfile.lock | 9 +++++++++ Library/Homebrew/test/support/helper/test_case.rb | 18 ++++++++++++++++++ Library/Homebrew/test/testing_env.rb | 10 ++++------ 4 files changed, 32 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile index 2a66086bd..5641684a7 100644 --- a/Library/Homebrew/test/Gemfile +++ b/Library/Homebrew/test/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" gem "mocha" gem "minitest" +gem "minitest-reporters" gem "parallel_tests" group :coverage do diff --git a/Library/Homebrew/test/Gemfile.lock b/Library/Homebrew/test/Gemfile.lock index 8289fcc20..65ac7ef56 100644 --- a/Library/Homebrew/test/Gemfile.lock +++ b/Library/Homebrew/test/Gemfile.lock @@ -1,6 +1,8 @@ GEM remote: https://rubygems.org/ specs: + ansi (1.5.0) + builder (3.2.3) codecov (0.1.9) json simplecov @@ -9,11 +11,17 @@ GEM json (2.0.3) metaclass (0.0.4) minitest (5.10.1) + minitest-reporters (1.1.14) + ansi + builder + minitest (>= 5.0) + ruby-progressbar mocha (1.2.1) metaclass (~> 0.0.1) parallel (1.10.0) parallel_tests (2.13.0) parallel + ruby-progressbar (1.8.1) simplecov (0.13.0) docile (~> 1.1.0) json (>= 1.8, < 3) @@ -27,6 +35,7 @@ PLATFORMS DEPENDENCIES codecov minitest + minitest-reporters mocha parallel_tests simplecov diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index ab97ef758..fa7efd799 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -12,6 +12,20 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + def before_setup + [ + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula", + HOMEBREW_CACHE, + HOMEBREW_CACHE_FORMULA, + HOMEBREW_LOCK_DIR, + HOMEBREW_CELLAR, + HOMEBREW_LOGS, + HOMEBREW_TEMP, + ].each(&:mkpath) + + super + end + def setup super @@ -23,6 +37,10 @@ module Homebrew ARGV.replace(@__argv) ENV.replace(@__env) + super + end + + def after_teardown Tab.clear_cache coretap = CoreTap.new diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index e2ba2e4e4..b989ca817 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -1,16 +1,14 @@ -$:.unshift File.expand_path("../..", __FILE__) -$:.unshift File.expand_path("../support/lib", __FILE__) +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib")) require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] require "global" require "formulary" -# Test environment setup -(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula").mkpath -%w[cache formula_cache locks cellar logs temp].each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath } - begin require "minitest/autorun" + require "minitest/reporters" + Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true) require "parallel_tests/test/runtime_logger" require "mocha/setup" rescue LoadError -- cgit v1.2.3 From f35c6c8cf1c79a01ff5176e14f17f92e40c8c69a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 00:26:04 +0100 Subject: Don’t use `before_setup` and `after_teardown`. --- Library/Homebrew/test/support/helper/fs_leak_logger.rb | 4 ++-- Library/Homebrew/test/support/helper/test_case.rb | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/fs_leak_logger.rb b/Library/Homebrew/test/support/helper/fs_leak_logger.rb index 774ccda04..3fbb148fa 100644 --- a/Library/Homebrew/test/support/helper/fs_leak_logger.rb +++ b/Library/Homebrew/test/support/helper/fs_leak_logger.rb @@ -9,13 +9,13 @@ module Test klass.make_my_diffs_pretty! end - def before_setup + def setup @__files_before_test = [] Find.find(TEST_TMPDIR) { |f| @__files_before_test << f.sub(TEST_TMPDIR, "") } super end - def after_teardown + def teardown super files_after_test = [] Find.find(TEST_TMPDIR) { |f| files_after_test << f.sub(TEST_TMPDIR, "") } diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index fa7efd799..7d7ff52d9 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -12,7 +12,7 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze - def before_setup + def setup [ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula", HOMEBREW_CACHE, @@ -24,10 +24,6 @@ module Homebrew ].each(&:mkpath) super - end - - def setup - super @__argv = ARGV.dup @__env = ENV.to_hash # dup doesn't work on ENV @@ -37,10 +33,6 @@ module Homebrew ARGV.replace(@__argv) ENV.replace(@__env) - super - end - - def after_teardown Tab.clear_cache coretap = CoreTap.new -- cgit v1.2.3 From b7658539696ed7a36dabacf9a34492ce87d31542 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 00:52:21 +0100 Subject: Use constant array of constants in `Homebrew::TestCase`. --- Library/Homebrew/test/support/helper/test_case.rb | 39 ++++++++++------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 7d7ff52d9..d1600f9f9 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -12,16 +12,18 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + TEST_DIRECTORIES = [ + CoreTap.instance.path/"Formula", + HOMEBREW_CACHE, + HOMEBREW_CACHE_FORMULA, + HOMEBREW_CELLAR, + HOMEBREW_LOCK_DIR, + HOMEBREW_LOGS, + HOMEBREW_TEMP, + ].freeze + def setup - [ - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula", - HOMEBREW_CACHE, - HOMEBREW_CACHE_FORMULA, - HOMEBREW_LOCK_DIR, - HOMEBREW_CELLAR, - HOMEBREW_LOGS, - HOMEBREW_TEMP, - ].each(&:mkpath) + TEST_DIRECTORIES.each(&:mkpath) super @@ -35,15 +37,10 @@ module Homebrew Tab.clear_cache - coretap = CoreTap.new - paths_to_delete = [ + FileUtils.rm_rf [ + TEST_DIRECTORIES.map(&:children), HOMEBREW_LINKED_KEGS, HOMEBREW_PINNED_KEGS, - HOMEBREW_CELLAR.children, - HOMEBREW_CACHE.children, - HOMEBREW_LOCK_DIR.children, - HOMEBREW_LOGS.children, - HOMEBREW_TEMP.children, HOMEBREW_PREFIX/".git", HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"share", @@ -55,12 +52,10 @@ module Homebrew HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", HOMEBREW_REPOSITORY/".git", - coretap.path/".git", - coretap.alias_dir, - coretap.formula_dir.children, - coretap.path/"formula_renames.json", - ].flatten - FileUtils.rm_rf paths_to_delete + CoreTap.instance.path/".git", + CoreTap.instance.alias_dir, + CoreTap.instance.path/"formula_renames.json", + ] super end -- cgit v1.2.3 From ac9214465412b1c4c5c876be0a414fa2de895b66 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 00:59:12 +0100 Subject: Add comment about `FSLeakLogger` to `Homebrew::TestCase`. --- Library/Homebrew/test/support/helper/test_case.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index d1600f9f9..1c84b5c63 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -23,6 +23,8 @@ module Homebrew ].freeze def setup + # These directories need to be created before + # `FSLeakLogger` is called with `super`. TEST_DIRECTORIES.each(&:mkpath) super -- cgit v1.2.3 From d0c5b98a626131477c6d0cab6255509f84d00ef8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 01:12:07 +0100 Subject: Don’t require `formulary` in `testing_env`. --- Library/Homebrew/test/testing_env.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index b989ca817..d5bb849ee 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -3,7 +3,6 @@ $LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/su require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] require "global" -require "formulary" begin require "minitest/autorun" -- cgit v1.2.3 From 98b6766f4e93b324a6e695c3daf0fe313b4433e6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 08:19:42 +0100 Subject: Require `formulary` and `tap` in `Homebrew::TestCase`. --- Library/Homebrew/test/support/helper/test_case.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 1c84b5c63..daa663494 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -1,3 +1,6 @@ +require "formulary" +require "tap" + module Homebrew class TestCase < ::Minitest::Test require "test/support/helper/fs_leak_logger" -- cgit v1.2.3 From 77401b787f96f4a50788188cdbb5d2c8fb51a852 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 30 Jan 2017 01:00:20 +0100 Subject: Reorder `testing_env`. --- Library/Homebrew/test/testing_env.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index d5bb849ee..999fa1013 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -1,18 +1,18 @@ -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib")) - -require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] -require "global" - begin require "minitest/autorun" require "minitest/reporters" Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true) - require "parallel_tests/test/runtime_logger" require "mocha/setup" + require "parallel_tests/test/runtime_logger" + require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] rescue LoadError - abort "Run `bundle install` or install the mocha and minitest gems before running the tests" + abort "Run `bundle install` before running the tests." end +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib")) + +require "global" + require "test/support/helper/test_case" require "test/support/helper/integration_command_test_case" -- cgit v1.2.3 From 4eef60c6a6d9c39cb6f4261f80bb6f8b1f895b03 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 3 Feb 2017 21:52:51 +0100 Subject: Remove `TestCask` class. --- Library/Homebrew/cask/lib/hbc/cask_loader.rb | 5 ----- Library/Homebrew/cask/spec/spec_helper.rb | 4 ---- Library/Homebrew/cask/test/cask/cli/cat_test.rb | 2 +- Library/Homebrew/cask/test/test_helper.rb | 4 ---- .../cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb | 2 +- .../test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb | 2 +- .../test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb | 2 +- .../test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb | 2 +- .../test/support/fixtures/cask/Casks/appdir-interpolation.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb | 2 +- .../support/fixtures/cask/Casks/generic-artifact-absolute-target.rb | 2 +- .../test/support/fixtures/cask/Casks/generic-artifact-no-target.rb | 2 +- .../support/fixtures/cask/Casks/generic-artifact-relative-target.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb | 2 +- .../cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb | 2 +- .../cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-header-format.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb | 2 +- .../support/fixtures/cask/Casks/invalid/invalid-header-version.rb | 2 +- .../fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb | 2 +- .../test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb | 2 +- .../test/support/fixtures/cask/Casks/osdn-correct-url-format.rb | 2 +- .../test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb | 2 +- .../test/support/fixtures/cask/Casks/sha256-for-empty-string.rb | 2 +- .../support/fixtures/cask/Casks/sourceforge-correct-url-format.rb | 2 +- .../support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb | 2 +- .../cask/Casks/sourceforge-version-latest-correct-url-format.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb | 2 +- .../test/support/fixtures/cask/Casks/version-latest-string.rb | 2 +- .../test/support/fixtures/cask/Casks/version-latest-with-checksum.rb | 2 +- .../test/support/fixtures/cask/Casks/with-accessibility-access.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb | 2 +- .../test/support/fixtures/cask/Casks/with-conditional-caveats.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-arch.rb | 2 +- .../fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb | 2 +- .../support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-cask.rb | 2 +- .../support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-formula.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb | 2 +- .../support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb | 2 +- .../support/fixtures/cask/Casks/with-depends-on-macos-failure.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb | 2 +- .../test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb | 2 +- .../test/support/fixtures/cask/Casks/with-embedded-binary.rb | 2 +- .../support/fixtures/cask/Casks/with-generic-artifact-no-target.rb | 2 +- .../test/support/fixtures/cask/Casks/with-generic-artifact.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-installable.rb | 2 +- .../test/support/fixtures/cask/Casks/with-installer-manual.rb | 2 +- .../test/support/fixtures/cask/Casks/with-installer-script.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb | 2 +- .../test/support/fixtures/cask/Casks/with-two-apps-correct.rb | 2 +- .../test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb | 2 +- .../test/support/fixtures/cask/Casks/with-two-apps-subdir.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-delete.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-early-script.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-login-item.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-script.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-signal.rb | 2 +- .../test/support/fixtures/cask/Casks/with-uninstall-trash.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb | 2 +- .../test/support/fixtures/cask/Casks/with-zap-early-script.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb | 2 +- .../Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb | 2 +- Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb | 2 +- 135 files changed, 132 insertions(+), 145 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb index 3875b30df..63660fcd0 100644 --- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb +++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb @@ -36,11 +36,6 @@ module Hbc build_cask(header_token, &block) end - def test_cask(header_token, &block) - @klass = TestCask - build_cask(header_token, &block) - end - def build_cask(header_token, &block) raise CaskTokenDoesNotMatchError.new(@token, header_token) unless @token == header_token diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index a9a5bb0a3..eefee3d60 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -21,10 +21,6 @@ Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).eac require "hbc" -module Hbc - class TestCask < Cask; end -end - # create and override default directories Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) Hbc.cache.mkpath diff --git a/Library/Homebrew/cask/test/cask/cli/cat_test.rb b/Library/Homebrew/cask/test/cask/cli/cat_test.rb index df49efda0..2eca9cfe9 100644 --- a/Library/Homebrew/cask/test/cask/cli/cat_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/cat_test.rb @@ -4,7 +4,7 @@ describe Hbc::CLI::Cat do describe "given a basic Cask" do before do @expected_output = <<-EOS.undent - test_cask 'basic-cask' do + cask 'basic-cask' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 641409284..71ce5752e 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -35,10 +35,6 @@ Mocha::Integration::MiniTest.activate # our baby require "hbc" -module Hbc - class TestCask < Cask; end -end - # create and override default directories Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) Hbc.cache.mkpath diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb index f40f244f2..4e74d728d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb @@ -1,4 +1,4 @@ -test_cask 'appcast-checkpoint-sha256-for-empty-string' do +cask 'appcast-checkpoint-sha256-for-empty-string' do appcast 'http://localhost/appcast.xml', checkpoint: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb index e182c2389..8b6934148 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb @@ -1,4 +1,4 @@ -test_cask 'appcast-invalid-checkpoint' do +cask 'appcast-invalid-checkpoint' do appcast 'http://localhost/appcast.xml', checkpoint: 'not a valid shasum' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb index 5ab2c0665..fefdbcb3a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb @@ -1,3 +1,3 @@ -test_cask 'appcast-missing-checkpoint' do +cask 'appcast-missing-checkpoint' do appcast 'http://localhost/appcast.xml' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb index 96d7edbba..84c9ca512 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb @@ -1,4 +1,4 @@ -test_cask 'appcast-valid-checkpoint' do +cask 'appcast-valid-checkpoint' do appcast 'http://localhost/appcast.xml', checkpoint: 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb index fdc09ef5a..e4b3e79e6 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb @@ -1,4 +1,4 @@ -test_cask 'appdir-interpolation' do +cask 'appdir-interpolation' do version '2.61' sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb index 0fcdb991a..1cada2561 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb @@ -1,4 +1,4 @@ -test_cask 'auto-updates' do +cask 'auto-updates' do version '2.61' sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb index 79e5f24c9..254ee59fd 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb @@ -1,4 +1,4 @@ -test_cask 'bad-checksum' do +cask 'bad-checksum' do version '1.2.3' sha256 'badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb index d3aaa283e..ff1d90003 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb @@ -1,4 +1,4 @@ -test_cask 'basic-cask' do +cask 'basic-cask' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb index 7dd01eee4..5b043a75e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb @@ -1,4 +1,4 @@ -test_cask 'container-7z' do +cask 'container-7z' do version '1.2.3' sha256 '3f9542ace85ed5f88549e2d0ea82210f8ddc87e0defbb78469d3aed719b3c964' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb index c310e0a6f..5aaf3d53e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb @@ -1,4 +1,4 @@ -test_cask 'container-air' do +cask 'container-air' do version '0.1' sha256 '554472e163f8a028629b12b468e29acda9f16b223dff74fcd218bba73cc2365a' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb index 9d9bdff98..60f834b7f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb @@ -1,4 +1,4 @@ -test_cask 'container-bzip2' do +cask 'container-bzip2' do version '1.2.3' sha256 'eaf67b3a62cb9275f96e45d05c70b94bef9ef1dae344083e93eda6b0b388a61c' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb index ebc7a544e..e57131567 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb @@ -1,4 +1,4 @@ -test_cask 'container-cab' do +cask 'container-cab' do version '1.2.3' sha256 'c267f5cebb14814c8e612a8b7d2bda02aec913f869509b6f1d3883427c0f552b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb index d63596f42..e9974b5d2 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb @@ -1,4 +1,4 @@ -test_cask 'container-dmg' do +cask 'container-dmg' do version '1.2.3' sha256 '74d89d4fa5cef175cf43666ce11fefa3741aa1522114042ac75e656be37141a1' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb index c2ab00384..0bfc4108f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb @@ -1,4 +1,4 @@ -test_cask 'container-gzip' do +cask 'container-gzip' do version '1.2.3' sha256 'fa4ebb5246583c4b6e62e1df4e3b71b4e38a1d7d91c025665827195d36214b20' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb index d5f708523..92d2c253e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb @@ -1,4 +1,4 @@ -test_cask 'container-lzma' do +cask 'container-lzma' do version '1.2.3' sha256 '9d7edb32d02ab9bd9749a5bde8756595ea4cfcb1da02ca11c30fb591d4c1ed85' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb index 959caaa08..2ff4cca1e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb @@ -1,4 +1,4 @@ -test_cask 'container-pkg' do +cask 'container-pkg' do version '1.2.3' sha256 '611c50c8a2a2098951d2cd0fd54787ed81b92cd97b4b08bd7cba17f1e1d8e40b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb index 7186577a2..33ea670d1 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb @@ -1,4 +1,4 @@ -test_cask 'container-rar' do +cask 'container-rar' do version '1.2.3' sha256 '419af7864c0e1f125515c49b08bd22e0f7de39f5285897c440fe03c714871763' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb index 3a0faad97..5715795a7 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb @@ -1,4 +1,4 @@ -test_cask 'container-sit' do +cask 'container-sit' do version '1.2.3' sha256 '0d21a64dce625044345c8ecca888e5439feaf254dac7f884917028a744f93cf3' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb index 58e1d82fd..e32931c89 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb @@ -1,4 +1,4 @@ -test_cask 'container-tar-gz' do +cask 'container-tar-gz' do version '1.2.3' sha256 'fab685fabf73d5a9382581ce8698fce9408f5feaa49fa10d9bc6c510493300f5' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb index 35e01d0a8..82a751d5d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb @@ -1,4 +1,4 @@ -test_cask 'container-xar' do +cask 'container-xar' do version '1.2.3' sha256 '5bb8e09a6fc630ebeaf266b1fd2d15e2ae7d32d7e4da6668a8093426fa1ba509' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb index b27e908ae..3f844af04 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb @@ -1,4 +1,4 @@ -test_cask 'container-xz' do +cask 'container-xz' do version '1.2.3' sha256 '839263f474edde1d54a9101606e6f0dc9d963acc93f6dcc5af8d10ebc3187c02' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb index 475fb055f..a1844a9c9 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb @@ -1,3 +1,3 @@ -test_cask 'generic-artifact-absolute-target' do +cask 'generic-artifact-absolute-target' do artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app" end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb index f7657dbb5..a3e65caab 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb @@ -1,3 +1,3 @@ -test_cask 'generic-artifact-no-target' do +cask 'generic-artifact-no-target' do artifact 'Caffeine.app' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb index f97441751..eb521e35a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb @@ -1,3 +1,3 @@ -test_cask 'generic-artifact-relative-target' do +cask 'generic-artifact-relative-target' do artifact 'Caffeine.app', target: 'Caffeine.app' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb index aac00f495..2804da7c3 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-sha256' do +cask 'invalid-sha256' do version '1.2.3' sha256 'not a valid shasum' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb index db2621074..37634f619 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-appcast-multiple' do +cask 'invalid-appcast-multiple' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb index b4c11b1be..7b51ffb53 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-appcast-url' do +cask 'invalid-appcast-url' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb index d39d124b0..b066139ce 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-conflicts-with-key' do +cask 'invalid-conflicts-with-key' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb index b0c919a9b..b21912a6e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-depends-on-arch-value' do +cask 'invalid-depends-on-arch-value' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb index 05304e806..24a912893 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-depends-on-key' do +cask 'invalid-depends-on-key' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb index 183dd5d91..723ceacbb 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-depends-on-macos-bad-release' do +cask 'invalid-depends-on-macos-bad-release' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb index b1f763d76..689e24b67 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-depends-on-macos-conflicting-forms' do +cask 'invalid-depends-on-macos-conflicting-forms' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb index eefd3ac40..5c3faec35 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-depends-on-x11-value' do +cask 'invalid-depends-on-x11-value' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb index bf14d372b..baf124b7a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-conflicting-keys' do +cask 'invalid-gpg-conflicting-keys' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb index 626e02a47..386593b06 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-key-id' do +cask 'invalid-gpg-key-id' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb index 77d41ed6b..4108380d2 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-key-url' do +cask 'invalid-gpg-key-url' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb index 460bcd532..3375801c9 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-missing-key' do +cask 'invalid-gpg-missing-key' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb index 8abc89486..b420f74d5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-multiple-stanzas' do +cask 'invalid-gpg-multiple-stanzas' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb index f1abc9225..40f6a9dae 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-parameter' do +cask 'invalid-gpg-parameter' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb index 1b9e7362f..43cc27b08 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-signature-url' do +cask 'invalid-gpg-signature-url' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb index 266047617..a369ef875 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-gpg-type' do +cask 'invalid-gpg-type' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb index a8159c979..c8c613767 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb @@ -1,4 +1,4 @@ -test_cask => 'invalid-header-format' do +cask => 'invalid-header-format' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb index 2b8ad5619..af15a13ef 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-header-token-mismatch-this-text-does-not-belong' do +cask 'invalid-header-token-mismatch-this-text-does-not-belong' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb index 47851c0e0..7e37e61df 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-header-version' do +cask 'invalid-header-version' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb index 84510ac24..5a0ccadf6 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-stage-only-conflict' do +cask 'invalid-stage-only-conflict' do version '2.61' sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb index d4e5ff4a9..5170a9c0f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-two-homepage' do +cask 'invalid-two-homepage' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb index 49e470788..f548400a4 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-two-url' do +cask 'invalid-two-url' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb index c9fe37772..fbffa8a1e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb @@ -1,4 +1,4 @@ -test_cask 'invalid-two-version' do +cask 'invalid-two-version' do version '1.2.3' version '2.0' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb index 2be9b4397..934d22463 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb @@ -1,4 +1,4 @@ -test_cask 'local-caffeine' do +cask 'local-caffeine' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb index f5244d0a5..6709ac12e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb @@ -1,4 +1,4 @@ -test_cask 'local-transmission' do +cask 'local-transmission' do version '2.61' sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb index 5e1886a57..907b1375f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb @@ -1,4 +1,4 @@ -test_cask 'missing-checksum' do +cask 'missing-checksum' do version '1.2.3' url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb index ff924541d..cf06d6c33 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb @@ -1,4 +1,4 @@ -test_cask 'missing-homepage' do +cask 'missing-homepage' do version '1.2.3' url 'http://localhost/something.dmg' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb index a5265b379..0801f4abb 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb @@ -1,4 +1,4 @@ -test_cask 'missing-name' do +cask 'missing-name' do version '1.2.3' url 'http://localhost/something.dmg' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb index 7f8027907..e6e6d9d20 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb @@ -1,4 +1,4 @@ -test_cask 'missing-sha256' do +cask 'missing-sha256' do version '1.2.3' url 'http://localhost/something.dmg' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb index 1b3e76b9c..0bfaec332 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb @@ -1,4 +1,4 @@ -test_cask 'missing-url' do +cask 'missing-url' do version '1.2.3' homepage 'http://example.com' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb index da2160bce..88e13d8bb 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb @@ -1,4 +1,4 @@ -test_cask 'missing-version' do +cask 'missing-version' do url 'http://localhost/something.dmg' homepage 'http://example.com' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb index 619c7a5fb..2f4e30dc1 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb @@ -1,4 +1,4 @@ -test_cask 'naked-executable' do +cask 'naked-executable' do version '1.2.3' sha256 '306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb index 526c7414a..6061f7bff 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb @@ -1,4 +1,4 @@ -test_cask 'nested-app' do +cask 'nested-app' do version '1.2.3' sha256 '1866dfa833b123bb8fe7fa7185ebf24d28d300d0643d75798bc23730af734216' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb index d9ba354f5..1e06c6168 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb @@ -1,4 +1,4 @@ -test_cask 'no-checksum' do +cask 'no-checksum' do version '1.2.3' sha256 :no_check diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb index ee557b1e4..3bafa171d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb @@ -1,4 +1,4 @@ -test_cask 'no-dsl-version' do +cask 'no-dsl-version' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb index da6ff0fcd..7e60fc179 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb @@ -1,4 +1,4 @@ -test_cask 'osdn-correct-url-format' do +cask 'osdn-correct-url-format' do version '1.2.3' url 'http://user.dl.osdn.jp/something/id/Something-1.2.3.dmg' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb index 8400159a1..68b4ecd4c 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb @@ -1,4 +1,4 @@ -test_cask 'osdn-incorrect-url-format' do +cask 'osdn-incorrect-url-format' do version '1.2.3' url 'http://osdn.jp/projects/something/files/Something-1.2.3.dmg/download' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb index b97764071..0bf3ee9b5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb @@ -1,4 +1,4 @@ -test_cask 'sha256-for-empty-string' do +cask 'sha256-for-empty-string' do version '1.2.3' sha256 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb index 41ef73500..439eb8998 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb @@ -1,4 +1,4 @@ -test_cask 'sourceforge-correct-url-format' do +cask 'sourceforge-correct-url-format' do version '1.2.3' url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb index 27b5490b7..39ac52414 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb @@ -1,4 +1,4 @@ -test_cask 'sourceforge-incorrect-url-format' do +cask 'sourceforge-incorrect-url-format' do version '1.2.3' url 'http://sourceforge.net/projects/something/files/Something-1.2.3.dmg/download' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb index d9546c5e1..07b068f70 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb @@ -1,4 +1,4 @@ -test_cask 'sourceforge-version-latest-correct-url-format' do +cask 'sourceforge-version-latest-correct-url-format' do version :latest url 'https://sourceforge.net/projects/something/files/latest/download' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb index b52b5d3d2..941e2084f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb @@ -1,4 +1,4 @@ -test_cask 'stage-only' do +cask 'stage-only' do version '2.61' sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb index afc8387c7..3e2c76e67 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb @@ -1,4 +1,4 @@ -test_cask 'test-opera-mail' do +cask 'test-opera-mail' do version '1.0' sha256 'afd192e308f8ea8ddb3d426fd6663d97078570417ee78b8e1fa15f515ae3d677' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb index ec32828f7..7ca0157d9 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb @@ -1,4 +1,4 @@ -test_cask 'test-opera' do +cask 'test-opera' do version '19.0.1326.47' sha256 '7b91f20ab754f7b3fef8dc346e0393917e11676b74c8f577408841619f76040a' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb index 3b4723f45..6bd090c28 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb @@ -1,4 +1,4 @@ -test_cask 'version-latest-string' do +cask 'version-latest-string' do version 'latest' sha256 :no_check end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb index 884ddff90..040cfc76e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb @@ -1,4 +1,4 @@ -test_cask 'version-latest-with-checksum' do +cask 'version-latest-with-checksum' do version :latest sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb index 1aa7bc8f7..4c1c9897a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb @@ -1,4 +1,4 @@ -test_cask 'with-accessibility-access' do +cask 'with-accessibility-access' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb index b75ff320c..7a6d75a9c 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb @@ -1,4 +1,4 @@ -test_cask 'with-alt-target' do +cask 'with-alt-target' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb index f99f7a93c..fc57e5e65 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb @@ -1,4 +1,4 @@ -test_cask 'with-appcast' do +cask 'with-appcast' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb index d8cede7aa..38be2e772 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb @@ -1,4 +1,4 @@ -test_cask 'with-binary' do +cask 'with-binary' do version '1.2.3' sha256 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb index 30d3a49b3..d5d90114a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb @@ -1,4 +1,4 @@ -test_cask 'with-caveats' do +cask 'with-caveats' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb index 1871efab3..640a3bbb3 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb @@ -1,4 +1,4 @@ -test_cask 'with-choices' do +cask 'with-choices' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb index d8a3836b8..e3c666834 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb @@ -1,4 +1,4 @@ -test_cask 'with-conditional-caveats' do +cask 'with-conditional-caveats' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb index a20d932ba..ab3631743 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb @@ -1,4 +1,4 @@ -test_cask 'with-conflicts-with' do +cask 'with-conflicts-with' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb index e0c4e3fa7..9fe0d043b 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-arch' do +cask 'with-depends-on-arch' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb index 327fc4000..3a90295e5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-cask-cyclic-helper' do +cask 'with-depends-on-cask-cyclic-helper' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb index f74d860bf..776351568 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-cask-cyclic' do +cask 'with-depends-on-cask-cyclic' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb index bb69b7506..74e1c2747 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-cask-multiple' do +cask 'with-depends-on-cask-multiple' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb index 05a180560..52daec865 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-cask' do +cask 'with-depends-on-cask' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb index c99d2dee1..07d7bb86a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-formula-multiple' do +cask 'with-depends-on-formula-multiple' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb index b0339e68c..ac980f890 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-formula' do +cask 'with-depends-on-formula' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb index cae16704c..7fb1a9016 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-macos-array' do +cask 'with-depends-on-macos-array' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb index 7f14dd84f..1483bcf74 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-macos-comparison' do +cask 'with-depends-on-macos-comparison' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb index ecefff362..483d75814 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-macos-failure' do +cask 'with-depends-on-macos-failure' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb index 6e370d46a..887771fe2 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-macos-string' do +cask 'with-depends-on-macos-string' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb index 7f11b6e64..e5aa05d23 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-macos-symbol' do +cask 'with-depends-on-macos-symbol' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb index fc84f2daa..d5107edc5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-x11-false' do +cask 'with-depends-on-x11-false' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb index b1a7bad2b..bcb781637 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb @@ -1,4 +1,4 @@ -test_cask 'with-depends-on-x11' do +cask 'with-depends-on-x11' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb index c16343c4b..15f0319c5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb @@ -1,4 +1,4 @@ -test_cask :v1 => 'with-dsl-version' do +cask :v1 => 'with-dsl-version' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb index 107c6cbe2..5987bbfe6 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb @@ -1,4 +1,4 @@ -test_cask 'with-embedded-binary' do +cask 'with-embedded-binary' do version '1.2.3' sha256 'fe052d3e77d92676775fd916ddb8942e72a565b844ea7f6d055474c99bb4e47b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb index a7d347fb5..f7f1ddc22 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb @@ -1,4 +1,4 @@ -test_cask 'with-generic-artifact-no-target' do +cask 'with-generic-artifact-no-target' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb index e718b994b..d6ce0ce8d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb @@ -1,4 +1,4 @@ -test_cask 'with-generic-artifact' do +cask 'with-generic-artifact' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb index 6aa735e1f..fc0c9ddfc 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb @@ -1,4 +1,4 @@ -test_cask 'with-gpg-key-url' do +cask 'with-gpg-key-url' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb index 1f7042515..e07546b94 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb @@ -1,4 +1,4 @@ -test_cask 'with-gpg' do +cask 'with-gpg' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb index d1105b50e..b0ad0c626 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb @@ -1,4 +1,4 @@ -test_cask 'with-installable' do +cask 'with-installable' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb index 92e2e09df..a857b6900 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb @@ -1,4 +1,4 @@ -test_cask 'with-installer-manual' do +cask 'with-installer-manual' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb index 5e98eab48..b32d131e0 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb @@ -1,4 +1,4 @@ -test_cask 'with-installer-script' do +cask 'with-installer-script' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb index 837627119..505e9f5a7 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb @@ -1,4 +1,4 @@ -test_cask 'with-macosx-dir' do +cask 'with-macosx-dir' do version '1.2.3' sha256 '5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb index 8bb42c447..d86d47126 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb @@ -1,4 +1,4 @@ -test_cask 'with-pkgutil-zap' do +cask 'with-pkgutil-zap' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb index c36151d52..88158e10d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb @@ -1,4 +1,4 @@ -test_cask 'with-suite' do +cask 'with-suite' do version '1.2.3' sha256 'd95dcc12d4e5be0bc3cb9793c4b7e7f69a25f0b3c7418494b0c883957e6eeae4' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb index 8eb68d88a..3963d7790 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb @@ -1,4 +1,4 @@ -test_cask 'with-two-apps-correct' do +cask 'with-two-apps-correct' do version '1.2.3' sha256 '3178fbfd1ea5d87a2a0662a4eb599ebc9a03888e73f37538d9f3f6ee69d2368e' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb index 6bd316dfe..c3ca473bd 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb @@ -1,4 +1,4 @@ -test_cask 'with-two-apps-incorrect' do +cask 'with-two-apps-incorrect' do version '1.2.3' sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb index 202423691..879e6e4ce 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb @@ -1,4 +1,4 @@ -test_cask 'with-two-apps-subdir' do +cask 'with-two-apps-subdir' do version '1.2.3' sha256 'd687c22a21c02bd8f07da9302c8292b93a04df9a929e3f04d09aea6c76f75c65' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb index 203f18405..cba51f18f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-delete' do +cask 'with-uninstall-delete' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb index a26abab1c..a9cec5b97 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-early-script' do +cask 'with-uninstall-early-script' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb index fa54c7e1f..9b27a1f36 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-kext' do +cask 'with-uninstall-kext' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb index 51ad45a09..e5aa2b2d7 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-launchctl' do +cask 'with-uninstall-launchctl' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb index 26dca6f1a..46f1f9704 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-login-item' do +cask 'with-uninstall-login-item' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb index db77a460b..00157322d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-pkgutil' do +cask 'with-uninstall-pkgutil' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb index 19337b18a..7f9515578 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-quit' do +cask 'with-uninstall-quit' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb index 88142ea71..252d81994 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-rmdir' do +cask 'with-uninstall-rmdir' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb index d2e0d6167..3e2dd0bb9 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-script' do +cask 'with-uninstall-script' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb index cc32b888a..850055c3c 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-signal' do +cask 'with-uninstall-signal' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb index 4fe58a19a..171780bb7 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb @@ -1,4 +1,4 @@ -test_cask 'with-uninstall-trash' do +cask 'with-uninstall-trash' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb index c76a9acb0..a0ab83fc2 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-delete' do +cask 'with-zap-delete' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb index d35c1809e..9375d2cc7 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-early-script' do +cask 'with-zap-early-script' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb index 463fe8133..e9c29f619 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-kext' do +cask 'with-zap-kext' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb index aab285672..6d17ccfb0 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-launchctl' do +cask 'with-zap-launchctl' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb index d7ba9a65b..2715892ef 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-login-item' do +cask 'with-zap-login-item' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb index 17a667000..c7f08b76d 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-pkgutil' do +cask 'with-zap-pkgutil' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb index 21f824ae9..4e4ab3a85 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-quit' do +cask 'with-zap-quit' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb index eac02ad0e..02139b3b0 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-rmdir' do +cask 'with-zap-rmdir' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb index f8646a267..5e033301a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-script' do +cask 'with-zap-script' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb index 5accd8337..47870cf05 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-signal' do +cask 'with-zap-signal' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb index aef4e0eab..8f4e91d67 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap-trash' do +cask 'with-zap-trash' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb index 056c90671..275516fba 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb @@ -1,4 +1,4 @@ -test_cask 'with-zap' do +cask 'with-zap' do version '1.2.3' sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' -- cgit v1.2.3 From 0802ad734f20c4e8507a1423513ef08301ea19d0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 3 Feb 2017 22:00:28 +0100 Subject: Simplify `CaskLoader`. --- Library/Homebrew/cask/lib/hbc/cask_loader.rb | 9 ++------- Library/Homebrew/compat/hbc/cask_loader.rb | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb index 63660fcd0..3fe02d7e1 100644 --- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb +++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb @@ -32,17 +32,12 @@ module Hbc end def cask(header_token, &block) - @klass = Cask - build_cask(header_token, &block) - end - - def build_cask(header_token, &block) raise CaskTokenDoesNotMatchError.new(@token, header_token) unless @token == header_token if @path.nil? - @klass.new(@token, &block) + Cask.new(@token, &block) else - @klass.new(@token, sourcefile_path: @path, &block) + Cask.new(@token, sourcefile_path: @path, &block) end end end diff --git a/Library/Homebrew/compat/hbc/cask_loader.rb b/Library/Homebrew/compat/hbc/cask_loader.rb index e7f3a4aac..a7c84e3ce 100644 --- a/Library/Homebrew/compat/hbc/cask_loader.rb +++ b/Library/Homebrew/compat/hbc/cask_loader.rb @@ -1,7 +1,7 @@ module CaskLoaderCompatibilityLayer private - def build_cask(header_token, &block) + def cask(header_token, &block) if header_token.is_a?(Hash) && header_token.key?(:v1) odeprecated %q("cask :v1 => 'token'"), %q("cask 'token'") header_token = header_token[:v1] -- cgit v1.2.3 From 22a37b2f5d3a57ec5732b0dcc8bb0474b4a47700 Mon Sep 17 00:00:00 2001 From: Thomas Maurer Date: Sat, 4 Feb 2017 13:20:00 +0100 Subject: Add failing reinstall test with invalid install option --- Library/Homebrew/test/reinstall_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/test/reinstall_test.rb b/Library/Homebrew/test/reinstall_test.rb index 613c06188..2906983c3 100644 --- a/Library/Homebrew/test/reinstall_test.rb +++ b/Library/Homebrew/test/reinstall_test.rb @@ -12,4 +12,13 @@ class IntegrationCommandTestReinstall < IntegrationCommandTestCase cmd("reinstall", "testball") assert foo_dir.exist? end + + def test_reinstall_with_invalid_option + setup_test_formula "testball" + + cmd("install", "testball", "--with-foo") + + assert_match "testball: this formula has no --with-fo option so it will be ignored!", + cmd("reinstall", "testball", "--with-fo") + end end -- cgit v1.2.3 From 6594650eb1c37170e7d70e7e9c75b48d154e38a9 Mon Sep 17 00:00:00 2001 From: Thomas Maurer Date: Sat, 4 Feb 2017 18:10:37 +0100 Subject: Pass invalid option names to formula installer This is the same that happens in the command 'install'. By passing the invalid option names, we enable the formula installer to output warnings if necessary. --- Library/Homebrew/cmd/reinstall.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 2eb2840a5..586405909 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -25,19 +25,21 @@ module Homebrew backup keg end - options = BuildOptions.new(Options.create(ARGV.flags_only), f.options).used_options + build_options = BuildOptions.new(Options.create(ARGV.flags_only), f.options) + options = build_options.used_options options |= f.build.used_options options &= f.options fi = FormulaInstaller.new(f) - fi.options = options - fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) - fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? - fi.force_bottle = ARGV.force_bottle? - fi.interactive = ARGV.interactive? - fi.git = ARGV.git? - fi.verbose = ARGV.verbose? - fi.debug = ARGV.debug? + fi.options = options + fi.invalid_option_names = build_options.invalid_option_names + fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) + fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? + fi.force_bottle = ARGV.force_bottle? + fi.interactive = ARGV.interactive? + fi.git = ARGV.git? + fi.verbose = ARGV.verbose? + fi.debug = ARGV.debug? fi.prelude oh1 "Reinstalling #{f.full_name} #{options.to_a.join " "}" -- cgit v1.2.3 From fc712b0089dbb4e6ebeb3f5bc846b00a62029f69 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 4 Feb 2017 20:24:29 +0100 Subject: Make descriptions a bit clearer. --- Library/Homebrew/cask/lib/hbc/pkg.rb | 4 ++-- Library/Homebrew/cask/test/cask/pkg_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb index 497a7b6dd..39252b48a 100644 --- a/Library/Homebrew/cask/lib/hbc/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/pkg.rb @@ -98,8 +98,8 @@ module Hbc end end - # Some pkgs (microsoft office for one) leave files (generally nibs) but - # report them as directories. We remove these as files instead. + # Some pkgs incorrectly report files (generally nibs) + # as directories; we remove these as files instead. def _delete_broken_file_dir(path) return unless path.file? && !path.symlink? @command.run!("/bin/rm", args: ["-f", "--", path], sudo: true) diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb index b99d49ddd..a52c90a0e 100644 --- a/Library/Homebrew/cask/test/cask/pkg_test.rb +++ b/Library/Homebrew/cask/test/cask/pkg_test.rb @@ -68,11 +68,11 @@ describe Hbc::Pkg do fake_dir.must_be :exist? end - it "chokes on directories that are really files" do + it "cleans files incorrectly reported as directories" do pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) fake_dir = Pathname(Dir.mktmpdir) - fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } + fake_file = fake_dir.join("ima_file_pretending_to_be_a_dir").tap { |path| FileUtils.touch(path) } pkg.stubs(:pkgutil_bom_specials).returns([]) pkg.stubs(:pkgutil_bom_files).returns([]) -- cgit v1.2.3 From d22cfd3866257abb9c3ade46c6c34f341cf70514 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 4 Feb 2017 20:24:45 +0100 Subject: Always use `Pathname.new` in `pkg_test.rb`. --- Library/Homebrew/cask/test/cask/pkg_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb index a52c90a0e..ac43f9e63 100644 --- a/Library/Homebrew/cask/test/cask/pkg_test.rb +++ b/Library/Homebrew/cask/test/cask/pkg_test.rb @@ -5,13 +5,13 @@ describe Hbc::Pkg do it "removes files and dirs referenced by the pkg" do pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - some_files = Array.new(3) { Pathname(Tempfile.new("testfile").path) } + some_files = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } pkg.stubs(:pkgutil_bom_files).returns some_files - some_specials = Array.new(3) { Pathname(Tempfile.new("testfile").path) } + some_specials = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } pkg.stubs(:pkgutil_bom_specials).returns some_specials - some_dirs = Array.new(3) { Pathname(Dir.mktmpdir) } + some_dirs = Array.new(3) { Pathname.new(Dir.mktmpdir) } pkg.stubs(:pkgutil_bom_dirs).returns some_dirs pkg.stubs(:forget) @@ -50,7 +50,7 @@ describe Hbc::Pkg do it "cleans broken symlinks, but leaves AOK symlinks" do pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - fake_dir = Pathname(Dir.mktmpdir) + fake_dir = Pathname.new(Dir.mktmpdir) fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) } @@ -71,7 +71,7 @@ describe Hbc::Pkg do it "cleans files incorrectly reported as directories" do pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - fake_dir = Pathname(Dir.mktmpdir) + fake_dir = Pathname.new(Dir.mktmpdir) fake_file = fake_dir.join("ima_file_pretending_to_be_a_dir").tap { |path| FileUtils.touch(path) } pkg.stubs(:pkgutil_bom_specials).returns([]) @@ -88,7 +88,7 @@ describe Hbc::Pkg do it "snags permissions on ornery dirs, but returns them afterwords" do pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - fake_dir = Pathname(Dir.mktmpdir) + fake_dir = Pathname.new(Dir.mktmpdir) fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) } -- cgit v1.2.3 From 324988e7a5d7d4735cf5f96ea17ae1491d0f801e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 25 Jan 2017 00:36:38 +0100 Subject: Simplify `brew cask doctor`. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 112 +++++----------------------- 1 file changed, 20 insertions(+), 92 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 84d8e1ebc..3618f0734 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -2,23 +2,13 @@ module Hbc class CLI class Doctor < Base def self.run - ohai "macOS Release:", render_with_none_as_error(MacOS.full_version) - ohai "Hardware Architecture:", render_with_none_as_error("#{Hardware::CPU.type}-#{Hardware::CPU.bits}") - ohai "Ruby Version:", render_with_none_as_error("#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}") - ohai "Ruby Path:", render_with_none_as_error(RbConfig.ruby) - # TODO: consider removing most Homebrew constants from doctor output - ohai "Homebrew Version:", render_with_none_as_error(homebrew_version) - ohai "Homebrew Executable Path:", render_with_none_as_error(HOMEBREW_BREW_FILE) - ohai "Homebrew Cellar Path:", render_with_none_as_error(homebrew_cellar) - ohai "Homebrew Repository Path:", render_with_none_as_error(HOMEBREW_REPOSITORY) - ohai "Homebrew Origin:", render_with_none_as_error(homebrew_origin) - ohai "Homebrew-Cask Version:", render_with_none_as_error(Hbc.full_version) + ohai "Homebrew-Cask Version:", Hbc.full_version ohai "Homebrew-Cask Install Location:", render_install_location ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom) ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads - ohai "Homebrew-Cask Default Tap Path:", render_tap_paths(Hbc.default_tap.path) - ohai "Homebrew-Cask Alternate Cask Taps:", render_tap_paths(alt_taps) - ohai "Homebrew-Cask Default Tap Cask Count:", render_with_none_as_error(default_cask_count) + ohai "Homebrew-Cask Taps:" + puts render_taps(Hbc.default_tap) + puts render_taps(*alt_taps) ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH) ohai "Contents of $RUBYLIB Environment Variable:", render_env_var("RUBYLIB") ohai "Contents of $RUBYOPT Environment Variable:", render_env_var("RUBYOPT") @@ -33,69 +23,6 @@ module Hbc ohai "Contents of Locale Environment Variables:", render_with_none(locale_variables) end - def self.alt_taps - Tap.select { |t| t.cask_dir && t != Hbc.default_tap } - .map(&:path) - end - - def self.default_cask_count - Hbc.default_tap.cask_files.count - rescue StandardError - "0 #{error_string "Error reading #{Hbc.default_tap.path}"}" - end - - def self.homebrew_origin - homebrew_origin = notfound_string - begin - Dir.chdir(HOMEBREW_REPOSITORY) do - homebrew_origin = SystemCommand.run("/usr/bin/git", - args: %w[config --get remote.origin.url], - print_stderr: false).stdout.strip - end - if homebrew_origin !~ /\S/ - homebrew_origin = "#{none_string} #{error_string}" - elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z} - homebrew_origin.concat " #{error_string "warning: nonstandard origin"}" - end - rescue StandardError - homebrew_origin = error_string "Not Found - Error running git" - end - homebrew_origin - end - - def self.homebrew_cellar - homebrew_constants("cellar") - end - - def self.homebrew_version - homebrew_constants("version") - end - - def self.homebrew_taps - Tap::TAP_DIRECTORY - end - - def self.homebrew_constants(name) - @homebrew_constants ||= {} - return @homebrew_constants[name] if @homebrew_constants.key?(name) - @homebrew_constants[name] = notfound_string - begin - @homebrew_constants[name] = SystemCommand.run!(HOMEBREW_BREW_FILE, - args: ["--#{name}"], - print_stderr: false) - .stdout - .strip - if @homebrew_constants[name] !~ /\S/ - @homebrew_constants[name] = "#{none_string} #{error_string}" - end - path = Pathname.new(@homebrew_constants[name]) - @homebrew_constants[name] = path if path.exist? - rescue StandardError - @homebrew_constants[name] = error_string "Not Found - Error running brew" - end - @homebrew_constants[name] - end - def self.locale_variables ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q(#{v}="#{ENV[v]}") }.sort.join("\n") end @@ -108,10 +35,6 @@ module Hbc /phinze/ end - def self.notfound_string - Formatter.error("Not Found - Unknown Error") - end - def self.error_string(string = "Error") Formatter.error("(#{string})") end @@ -121,20 +44,25 @@ module Hbc none_string end - def self.render_with_none_as_error(string) - return string if !string.nil? && string.respond_to?(:to_s) && !string.to_s.empty? - "#{none_string} #{error_string}" + def self.alt_taps + Tap.select { |t| t.cask_dir && t != Hbc.default_tap } + end + + def self.cask_count_for_tap(tap) + count = tap.cask_files.count + "#{count} #{count == 1 ? "cask" : "casks"}" + rescue StandardError + "0 #{error_string "error reading #{tap.path}"}" end - def self.render_tap_paths(paths) - paths = [paths] unless paths.respond_to?(:each) - paths.collect do |dir| - if dir.nil? || dir.to_s.empty? + def self.render_taps(*taps) + taps.collect do |tap| + if tap.path.nil? || tap.path.to_s.empty? none_string - elsif dir.to_s.match(legacy_tap_pattern) - dir.to_s.concat(" #{error_string "Warning: legacy tap path"}") + elsif tap.path.to_s.match(legacy_tap_pattern) + tap.path.to_s.concat(" #{error_string "Warning: legacy tap path"}") else - dir.to_s + "#{tap.path} (#{cask_count_for_tap(tap)})" end end end @@ -151,7 +79,7 @@ module Hbc # where "doctor" is needed is precisely the situation where such # things are less dependable. def self.render_install_location - locations = Dir.glob(Pathname.new(homebrew_cellar).join("brew-cask", "*")).reverse + locations = Dir.glob(HOMEBREW_CELLAR.join("brew-cask", "*")).reverse if locations.empty? none_string else -- cgit v1.2.3 From 7d312e4ccadd1852b0ae956e19248eea7ec13696 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 08:25:17 +0100 Subject: Remove legacy tap pattern. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 3618f0734..cba3ba0e6 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -31,10 +31,6 @@ module Hbc "" end - def self.legacy_tap_pattern - /phinze/ - end - def self.error_string(string = "Error") Formatter.error("(#{string})") end @@ -59,8 +55,6 @@ module Hbc taps.collect do |tap| if tap.path.nil? || tap.path.to_s.empty? none_string - elsif tap.path.to_s.match(legacy_tap_pattern) - tap.path.to_s.concat(" #{error_string "Warning: legacy tap path"}") else "#{tap.path} (#{cask_count_for_tap(tap)})" end -- cgit v1.2.3 From f0337a318320bebe56de1b07b406cd8fbca9c8a5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 26 Jan 2017 08:54:52 +0100 Subject: Simplify output of environment variables. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index cba3ba0e6..0fa08be8a 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -10,21 +10,22 @@ module Hbc puts render_taps(Hbc.default_tap) puts render_taps(*alt_taps) ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH) - ohai "Contents of $RUBYLIB Environment Variable:", render_env_var("RUBYLIB") - ohai "Contents of $RUBYOPT Environment Variable:", render_env_var("RUBYOPT") - ohai "Contents of $RUBYPATH Environment Variable:", render_env_var("RUBYPATH") - ohai "Contents of $RBENV_VERSION Environment Variable:", render_env_var("RBENV_VERSION") - ohai "Contents of $CHRUBY_VERSION Environment Variable:", render_env_var("CHRUBY_VERSION") - ohai "Contents of $GEM_HOME Environment Variable:", render_env_var("GEM_HOME") - ohai "Contents of $GEM_PATH Environment Variable:", render_env_var("GEM_PATH") - ohai "Contents of $BUNDLE_PATH Environment Variable:", render_env_var("BUNDLE_PATH") - ohai "Contents of $PATH Environment Variable:", render_env_var("PATH") - ohai "Contents of $SHELL Environment Variable:", render_env_var("SHELL") - ohai "Contents of Locale Environment Variables:", render_with_none(locale_variables) + ohai "Environment Variables:" + render_env_var("RUBYLIB") + render_env_var("RUBYOPT") + render_env_var("RUBYPATH") + render_env_var("RBENV_VERSION") + render_env_var("CHRUBY_VERSION") + render_env_var("GEM_HOME") + render_env_var("GEM_PATH") + render_env_var("BUNDLE_PATH") + render_env_var("PATH") + render_env_var("SHELL") + locale_variables end def self.locale_variables - ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q(#{v}="#{ENV[v]}") }.sort.join("\n") + ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort.each(&method(:render_env_var)) end def self.none_string @@ -63,9 +64,8 @@ module Hbc def self.render_env_var(var) if ENV.key?(var) - %Q(#{var}="#{ENV[var]}") - else - none_string + var = %Q(#{var}="#{ENV[var]}") + puts var.gsub(ENV["HOME"], "~") end end -- cgit v1.2.3 From b54c3d618e8c2704eb9930776c883f0052ecc9db Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 4 Feb 2017 21:52:04 +0100 Subject: Add `user_tilde` method to shorten/anonymize output. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 0fa08be8a..7b777abbb 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -65,10 +65,14 @@ module Hbc def self.render_env_var(var) if ENV.key?(var) var = %Q(#{var}="#{ENV[var]}") - puts var.gsub(ENV["HOME"], "~") + puts user_tilde(var) end end + def self.user_tilde(path) + path.gsub(ENV["HOME"], "~") + end + # This could be done by calling into Homebrew, but the situation # where "doctor" is needed is precisely the situation where such # things are less dependable. @@ -84,7 +88,7 @@ module Hbc end def self.render_staging_location(path) - path = Pathname.new(path) + path = Pathname.new(user_tilde(path.to_s)) if !path.exist? "#{path} #{error_string "error: path does not exist"}}" elsif !path.writable? @@ -95,6 +99,7 @@ module Hbc end def self.render_load_path(paths) + paths.map(&method(:user_tilde)) return "#{none_string} #{error_string}" if [*paths].empty? paths end -- cgit v1.2.3 From 46e051b1c2ed44ce4db151da9a09a1870c485334 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 4 Feb 2017 21:53:02 +0100 Subject: Simplify cache output. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 7b777abbb..acf584bfd 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -106,13 +106,11 @@ module Hbc def self.render_cached_downloads cleanup = CLI::Cleanup.default - files = cleanup.cache_files - count = files.count + count = cleanup.cache_files.count size = cleanup.disk_cleanup_size - size_msg = "#{number_readable(count)} files, #{disk_usage_readable(size)}" - warn_msg = error_string('warning: run "brew cask cleanup"') - size_msg << " #{warn_msg}" if count > 0 - [Hbc.cache, size_msg] + msg = user_tilde(Hbc.cache.to_s) + msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero? + msg end def self.help -- cgit v1.2.3 From d8eab8c2114f8f89decb4293283ec747f82f9d08 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 4 Feb 2017 21:53:35 +0100 Subject: Simplify rendering of environment variables. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 38 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index acf584bfd..598c9eee1 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -7,25 +7,28 @@ module Hbc ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom) ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads ohai "Homebrew-Cask Taps:" - puts render_taps(Hbc.default_tap) - puts render_taps(*alt_taps) + puts render_taps(Hbc.default_tap, *alt_taps) ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH) ohai "Environment Variables:" - render_env_var("RUBYLIB") - render_env_var("RUBYOPT") - render_env_var("RUBYPATH") - render_env_var("RBENV_VERSION") - render_env_var("CHRUBY_VERSION") - render_env_var("GEM_HOME") - render_env_var("GEM_PATH") - render_env_var("BUNDLE_PATH") - render_env_var("PATH") - render_env_var("SHELL") - locale_variables + + environment_variables = [ + "RUBYLIB", + "RUBYOPT", + "RUBYPATH", + "RBENV_VERSION", + "CHRUBY_VERSION", + "GEM_HOME", + "GEM_PATH", + "BUNDLE_PATH", + "PATH", + "SHELL", + ] + + (locale_variables + environment_variables).sort.each(&method(:render_env_var)) end def self.locale_variables - ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort.each(&method(:render_env_var)) + ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort end def self.none_string @@ -63,10 +66,9 @@ module Hbc end def self.render_env_var(var) - if ENV.key?(var) - var = %Q(#{var}="#{ENV[var]}") - puts user_tilde(var) - end + return unless ENV.key?(var) + var = %Q(#{var}="#{ENV[var]}") + puts user_tilde(var) end def self.user_tilde(path) -- cgit v1.2.3 From d02a4d9e51e69280532533b2cfa7e1e5513edc4c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 06:48:08 +0100 Subject: Fix test for `brew cask doctor`. --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 12 ++++++------ Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index 598c9eee1..6b2f4caab 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -2,14 +2,14 @@ module Hbc class CLI class Doctor < Base def self.run - ohai "Homebrew-Cask Version:", Hbc.full_version - ohai "Homebrew-Cask Install Location:", render_install_location - ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom) - ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads + ohai "Homebrew-Cask Version", Hbc.full_version + ohai "Homebrew-Cask Install Location", render_install_location + ohai "Homebrew-Cask Staging Location", render_staging_location(Hbc.caskroom) + ohai "Homebrew-Cask Cached Downloads", render_cached_downloads ohai "Homebrew-Cask Taps:" puts render_taps(Hbc.default_tap, *alt_taps) - ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH) - ohai "Environment Variables:" + ohai "Contents of $LOAD_PATH", render_load_path($LOAD_PATH) + ohai "Environment Variables" environment_variables = [ "RUBYLIB", diff --git a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb index 38f8b50ac..ff1cf5706 100644 --- a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb @@ -4,7 +4,7 @@ describe Hbc::CLI::Doctor do it "displays some nice info about the environment" do expect { Hbc::CLI::Doctor.run - }.to output(/\A==> macOS Release:/).to_stdout + }.to output(/\A==> Homebrew-Cask Version/).to_stdout end it "raises an exception when arguments are given" do -- cgit v1.2.3 From 8113a9fed9fe6dcd41f6a382cb19e61c0abe2887 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 06:55:42 +0100 Subject: Remove XIP support. --- Library/Homebrew/cask/lib/hbc/container.rb | 2 -- Library/Homebrew/cask/lib/hbc/container/xip.rb | 29 -------------------------- 2 files changed, 31 deletions(-) delete mode 100644 Library/Homebrew/cask/lib/hbc/container/xip.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb index e31fbc8fb..fc7246f3d 100644 --- a/Library/Homebrew/cask/lib/hbc/container.rb +++ b/Library/Homebrew/cask/lib/hbc/container.rb @@ -16,7 +16,6 @@ require "hbc/container/tar" require "hbc/container/ttf" require "hbc/container/rar" require "hbc/container/xar" -require "hbc/container/xip" require "hbc/container/xz" require "hbc/container/zip" @@ -34,7 +33,6 @@ module Hbc Sit, Rar, Zip, - Xip, # needs to be before xar as this is a cpio inside a gzip inside a xar Xar, # need to be before tar as tar can also list xar Tar, # or compressed tar (bzip2/gzip/lzma/xz) Bzip2, # pure bzip2 diff --git a/Library/Homebrew/cask/lib/hbc/container/xip.rb b/Library/Homebrew/cask/lib/hbc/container/xip.rb deleted file mode 100644 index 982402e4e..000000000 --- a/Library/Homebrew/cask/lib/hbc/container/xip.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "tmpdir" - -module Hbc - class Container - class Xip < Base - def self.me?(criteria) - criteria.magic_number(/^xar!/n) && - IO.popen(["/usr/bin/xar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| io.read =~ /\AContent\nMetadata\n\Z/ } - end - - def extract - Dir.mktmpdir do |unpack_dir| - begin - ohai "Verifying signature for #{@path.basename}" - @command.run!("/usr/sbin/pkgutil", args: ["--check-signature", @path]) - rescue - raise "Signature check failed." - end - - @command.run!("/usr/bin/xar", args: ["-x", "-f", @path, "Content", "-C", unpack_dir]) - - Dir.chdir(@cask.staged_path) do - @command.run!("/usr/bin/cpio", args: ["--quiet", "-i", "-I", Pathname(unpack_dir).join("Content")]) - end - end - end - end - end -end -- cgit v1.2.3 From e1ea7bb721ec6d315058c0da285acd38cfc62b9f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 07:47:54 +0100 Subject: Refactor Cask `Artifact`s. --- Library/Homebrew/cask/lib/hbc/artifact/base.rb | 4 ---- Library/Homebrew/cask/lib/hbc/artifact/installer.rb | 14 -------------- .../cask/lib/hbc/artifact/nested_container.rb | 4 ---- Library/Homebrew/cask/lib/hbc/artifact/pkg.rb | 4 ---- Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb | 8 -------- .../Homebrew/cask/lib/hbc/artifact/uninstall_base.rb | 6 +----- Library/Homebrew/cask/lib/hbc/artifact/zap.rb | 11 +---------- Library/Homebrew/cask/lib/hbc/installer.rb | 15 ++++++++++----- Library/Homebrew/cask/test/cask/artifact/pkg_test.rb | 10 ---------- .../cask/test/cask/artifact/uninstall_test.rb | 20 ++------------------ Library/Homebrew/cask/test/cask/artifact/zap_test.rb | 20 ++------------------ 11 files changed, 16 insertions(+), 100 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/artifact/base.rb b/Library/Homebrew/cask/lib/hbc/artifact/base.rb index b53c13f08..d925ff340 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/base.rb @@ -27,10 +27,6 @@ module Hbc attr_reader :force - def zap_phase - odebug "Nothing to do. The #{self.class.artifact_name} artifact has no zap phase." - end - # TODO: this sort of logic would make more sense in dsl.rb, or a # constructor called from dsl.rb, so long as that isn't slow. def self.read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb index b64b00fe3..55e8d38c0 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb @@ -3,16 +3,6 @@ require "hbc/artifact/base" module Hbc module Artifact class Installer < Base - # TODO: for backward compatibility, removeme - def install - install_phase - end - - # TODO: for backward compatibility, removeme - def uninstall - uninstall_phase - end - def install_phase @cask.artifacts[self.class.artifact_dsl_key].each do |artifact| if artifact.manual @@ -36,10 +26,6 @@ module Hbc end end end - - def uninstall_phase - odebug "Nothing to do. The #{self.class.artifact_dsl_key} artifact has no uninstall phase." - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb index 107640797..45f23fe37 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb @@ -7,10 +7,6 @@ module Hbc @cask.artifacts[:nested_container].each { |container| extract(container) } end - def uninstall_phase - # no need to take action; is removed after extraction - end - def extract(container_relative_path) source = @cask.staged_path.join(container_relative_path) container = Container.for_path(source, @command) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb index 0569d2a86..6d6362d46 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb @@ -36,10 +36,6 @@ module Hbc @cask.artifacts[:pkg].each { |pkg_description| run_installer(pkg_description) } end - def uninstall_phase - # Do nothing. Must be handled explicitly by a separate :uninstall stanza. - end - def run_installer(pkg_description) load_pkg_description pkg_description ohai "Running installer for #{@cask}; your password may be necessary." diff --git a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb index 594c5bef9..1122c1d02 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb @@ -6,14 +6,6 @@ module Hbc def self.artifact_dsl_key :stage_only end - - def install_phase - # do nothing - end - - def uninstall_phase - # do nothing - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index ccb06a9ab..e18e9c311 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -54,15 +54,11 @@ module Hbc path_strings - undeletable end - def install_phase - odebug "Nothing to do. The uninstall artifact has no install phase." - end - def uninstall_phase dispatch_uninstall_directives end - def dispatch_uninstall_directives(expand_tilde = true) + def dispatch_uninstall_directives(expand_tilde: true) directives_set = @cask.artifacts[stanza] ohai "Running #{stanza} process for #{@cask}; your password may be necessary" diff --git a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb index 503ea35c4..b31e2ef11 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb @@ -3,17 +3,8 @@ require "hbc/artifact/uninstall_base" module Hbc module Artifact class Zap < UninstallBase - def install_phase - odebug "Nothing to do. The zap artifact has no install phase." - end - def uninstall_phase - odebug "Nothing to do. The zap artifact has no uninstall phase." - end - - def zap_phase - expand_tilde = true - dispatch_uninstall_directives(expand_tilde) + dispatch_uninstall_directives(expand_tilde: true) end end end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 465011735..28f67e5fd 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -140,15 +140,18 @@ module Hbc odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| + artifact = artifact.new(@cask, options) + next unless artifact.respond_to?(:install_phase) odebug "Installing artifact of class #{artifact}" - artifact.new(@cask, options).install_phase + artifact.install_phase already_installed_artifacts.unshift(artifact) end rescue StandardError => e begin already_installed_artifacts.each do |artifact| + next unless artifact.respond_to?(:uninstall_phase) odebug "Reverting installation of artifact of class #{artifact}" - artifact.new(@cask, options).uninstall_phase + artifact.uninstall_phase end ensure purge_versioned_files @@ -319,9 +322,11 @@ module Hbc artifacts = Artifact.for_cask(@cask) odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| - odebug "Un-installing artifact of class #{artifact}" options = { command: @command, force: force } - artifact.new(@cask, options).uninstall_phase + artifact = artifact.new(@cask, options) + next unless artifact.respond_to?(:uninstall_phase) + odebug "Un-installing artifact of class #{artifact}" + artifact.uninstall_phase end end @@ -330,7 +335,7 @@ module Hbc uninstall_artifacts if Artifact::Zap.me?(@cask) ohai "Dispatching zap stanza" - Artifact::Zap.new(@cask, command: @command).zap_phase + Artifact::Zap.new(@cask, command: @command).uninstall_phase else opoo "No zap stanza present for Cask '#{@cask}'" end diff --git a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb index a77fb0a07..b054290ce 100644 --- a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb @@ -21,16 +21,6 @@ describe Hbc::Artifact::Pkg do end end - describe "uninstall_phase" do - it "does nothing, because the uninstall_phase method is a no-op" do - pkg = Hbc::Artifact::Pkg.new(@cask, - command: Hbc::FakeSystemCommand) - shutup do - pkg.uninstall_phase - end - end - end - describe "choices" do before do @cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb index 3fb679196..464cad345 100644 --- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb @@ -13,28 +13,12 @@ describe Hbc::Artifact::Uninstall do end end - describe "install_phase" do - it "does nothing, because the install_phase method is a no-op" do - shutup do - uninstall_artifact.install_phase - end - end - end - - describe "zap_phase" do - it "does nothing, because the zap_phase method is a no-op" do - shutup do - uninstall_artifact.zap_phase - end - end - end - describe "uninstall_phase" do - subject do + subject { shutup do uninstall_artifact.uninstall_phase end - end + } describe "when using launchctl" do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") } diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb index 0ebd9b304..ea546728b 100644 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb @@ -14,28 +14,12 @@ describe Hbc::Artifact::Zap do end end - describe "install_phase" do - it "does nothing, because the install_phase method is a no-op" do - shutup do - zap_artifact.install_phase - end - end - end - describe "uninstall_phase" do - it "does nothing, because the uninstall_phase method is a no-op" do + subject { shutup do zap_artifact.uninstall_phase end - end - end - - describe "zap_phase" do - subject do - shutup do - zap_artifact.zap_phase - end - end + } describe "when using launchctl" do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") } -- cgit v1.2.3 From 1f5cf4fd40fc3528e700a421afc9a128c159cac9 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Wed, 18 Jan 2017 22:37:11 +0530 Subject: Update docs and manpages to include --fix option --- Library/Homebrew/dev-cmd/audit.rb | 4 ++-- Library/Homebrew/rubocops/bottle_block_cop.rb | 32 +++++++-------------------- 2 files changed, 10 insertions(+), 26 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index c2d6aeaed..5ad12d4b6 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -5,9 +5,9 @@ #: If no are provided, all of them are checked. #: #: If `--strict` is passed, additional checks are run, including RuboCop -#: style checks and custom cop checks. +#: style checks. #: -#: If `--fix` is passed, style violations and custom cop violations will be +#: If `--fix` is passed, style violations will be #: automatically fixed using RuboCop's `--auto-correct` feature. #: #: If `--online` is passed, additional slower checks that require a network diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb index 6b699ab5e..e16672683 100644 --- a/Library/Homebrew/rubocops/bottle_block_cop.rb +++ b/Library/Homebrew/rubocops/bottle_block_cop.rb @@ -9,42 +9,26 @@ module RuboCop method, _args, body = *node _keyword, method_name = *method - return unless method_name.equal?(:bottle) && revision?(body) - add_offense(node, :expression) + return unless method_name == :bottle + check_revision?(body) end private def autocorrect(node) lambda do |corrector| - # Check for revision - _method, _args, body = *node - if revision?(body) - replace_revision(corrector, node) - end + correction = node.source.sub("revision", "rebuild") + corrector.insert_before(node.source_range, correction) + corrector.remove(node.source_range) end end - def revision?(body) + def check_revision?(body) body.children.each do |method_call_node| _receiver, method_name, _args = *method_call_node - if method_name == :revision - return true - end + next unless method_name == :revision + add_offense(method_call_node, :expression) end - false - end - - def replace_revision(corrector, node) - new_source = "" - node.source.each_line do |line| - if line =~ /\A\s*revision/ - line = line.sub("revision", "rebuild") - end - new_source << line - end - corrector.insert_before(node.source_range, new_source) - corrector.remove(node.source_range) end end end -- cgit v1.2.3 From 73df50459590ea6f5736393158dddf82affd7fde Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 6 Feb 2017 10:30:32 +0000 Subject: official_taps: games is deprecated. --- Library/Homebrew/official_taps.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index 024dd2a20..35295c1e8 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -3,7 +3,6 @@ OFFICIAL_TAPS = %w[ dupes emacs fuse - games nginx php science -- cgit v1.2.3 From ba2ec8abcc0f4a33852da4bb58af975d604569d5 Mon Sep 17 00:00:00 2001 From: Fabian Mettler Date: Mon, 6 Feb 2017 14:22:17 +0100 Subject: Fix: Documentation of --only in tests cmd This pull request fixes the documentation for the —only flag of the tests cmd. --- Library/Homebrew/dev-cmd/tests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 05bdda8d2..9d93fc9e8 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -1,4 +1,4 @@ -#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`] [`--seed` ] [`--trace`] [`--online`] [`--official-cmd-taps`]: +#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`] [`--seed` ] [`--trace`] [`--online`] [`--official-cmd-taps`]: #: Run Homebrew's unit and integration tests. require "fileutils" -- cgit v1.2.3 From 4e7062a9ce7331dcf9f6f03d03da764b743477b6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 08:51:25 +0100 Subject: Use `expect` syntax in `installer_test`. --- Library/Homebrew/cask/test/cask/installer_test.rb | 169 ++++++++++------------ 1 file changed, 74 insertions(+), 95 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb index b26c28847..17629dce2 100644 --- a/Library/Homebrew/cask/test/cask/installer_test.rb +++ b/Library/Homebrew/cask/test/cask/installer_test.rb @@ -13,10 +13,8 @@ describe Hbc::Installer do Hbc::Installer.new(caffeine).install end - dest_path = Hbc.caskroom.join("local-caffeine", caffeine.version) - dest_path.must_be :directory? - application = Hbc.appdir.join("Caffeine.app") - application.must_be :directory? + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).must_be :directory? + expect(Hbc.appdir.join("Caffeine.app")).must_be :directory? end it "works with dmg-based Casks" do @@ -26,10 +24,8 @@ describe Hbc::Installer do Hbc::Installer.new(asset).install end - dest_path = Hbc.caskroom.join("container-dmg", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container") - file.must_be :file? + expect(Hbc.caskroom.join("container-dmg", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with tar-gz-based Casks" do @@ -39,10 +35,8 @@ describe Hbc::Installer do Hbc::Installer.new(asset).install end - dest_path = Hbc.caskroom.join("container-tar-gz", asset.version) - dest_path.must_be :directory? - application = Hbc.appdir.join("container") - application.must_be :file? + expect(Hbc.caskroom.join("container-tar-gz", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with cab-based Casks" do @@ -55,10 +49,8 @@ describe Hbc::Installer do end end - dest_path = Hbc.caskroom.join("container-cab", asset.version) - dest_path.must_be :directory? - application = Hbc.appdir.join("container") - application.must_be :file? + expect(Hbc.caskroom.join("container-cab", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with Adobe AIR-based Casks" do @@ -69,10 +61,8 @@ describe Hbc::Installer do Hbc::Installer.new(asset).install end - dest_path = Hbc.caskroom.join("container-air", asset.version) - dest_path.must_be :directory? - application = Hbc.appdir.join("container.app") - application.must_be :directory? + expect(Hbc.caskroom.join("container-air", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container.app")).must_be :directory? end it "works with 7z-based Casks" do @@ -85,10 +75,8 @@ describe Hbc::Installer do end end - dest_path = Hbc.caskroom.join("container-7z", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container") - file.must_be :file? + expect(Hbc.caskroom.join("container-7z", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with xar-based Casks" do @@ -98,10 +86,8 @@ describe Hbc::Installer do Hbc::Installer.new(asset).install end - dest_path = Hbc.caskroom.join("container-xar", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container") - file.must_be :file? + expect(Hbc.caskroom.join("container-xar", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with Stuffit-based Casks" do @@ -114,10 +100,8 @@ describe Hbc::Installer do end end - dest_path = Hbc.caskroom.join("container-sit", asset.version) - dest_path.must_be :directory? - application = Hbc.appdir.join("container") - application.must_be :file? + expect(Hbc.caskroom.join("container-sit", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with RAR-based Casks" do @@ -130,10 +114,8 @@ describe Hbc::Installer do end end - dest_path = Hbc.caskroom.join("container-rar", asset.version) - dest_path.must_be :directory? - application = Hbc.appdir.join("container") - application.must_be :file? + expect(Hbc.caskroom.join("container-rar", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with pure bzip2-based Casks" do @@ -143,10 +125,8 @@ describe Hbc::Installer do Hbc::Installer.new(asset).install end - dest_path = Hbc.caskroom.join("container-bzip2", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container-bzip2--#{asset.version}") - file.must_be :file? + expect(Hbc.caskroom.join("container-bzip2", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).must_be :file? end it "works with pure gzip-based Casks" do @@ -156,10 +136,8 @@ describe Hbc::Installer do Hbc::Installer.new(asset).install end - dest_path = Hbc.caskroom.join("container-gzip", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container") - file.must_be :file? + expect(Hbc.caskroom.join("container-gzip", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container")).must_be :file? end it "works with pure xz-based Casks" do @@ -172,10 +150,8 @@ describe Hbc::Installer do end end - dest_path = Hbc.caskroom.join("container-xz", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container-xz--#{asset.version}") - file.must_be :file? + expect(Hbc.caskroom.join("container-xz", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container-xz--#{asset.version}")).must_be :file? end it "works with lzma-based Casks" do @@ -188,15 +164,13 @@ describe Hbc::Installer do end end - dest_path = Hbc.caskroom.join("container-lzma", asset.version) - dest_path.must_be :directory? - file = Hbc.appdir.join("container-lzma--#{asset.version}") - file.must_be :file? + expect(Hbc.caskroom.join("container-lzma", asset.version)).must_be :directory? + expect(Hbc.appdir.join("container-lzma--#{asset.version}")).must_be :file? end it "blows up on a bad checksum" do bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") - lambda { + expect { shutup do Hbc::Installer.new(bad_checksum).install end @@ -205,7 +179,7 @@ describe Hbc::Installer do it "blows up on a missing checksum" do missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") - lambda { + expect { shutup do Hbc::Installer.new(missing_checksum).install end @@ -219,12 +193,12 @@ describe Hbc::Installer do Hbc::Installer.new(no_checksum).install end - no_checksum.must_be :installed? + expect(no_checksum).must_be :installed? end it "fails to install if sha256 :no_check is used with --require-sha" do no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") - lambda { + expect { Hbc::Installer.new(no_checksum, require_sha: true).install }.must_raise(Hbc::CaskNoShasumError) end @@ -236,23 +210,27 @@ describe Hbc::Installer do Hbc::Installer.new(no_checksum, require_sha: true, force: true).install end - no_checksum.must_be :installed? + expect(no_checksum).must_be :installed? end it "prints caveats if they're present" do with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb") - lambda { + + expect { Hbc::Installer.new(with_caveats).install }.must_output(/Here are some things you might want to know/) - with_caveats.must_be :installed? + + expect(with_caveats).must_be :installed? end it "prints installer :manual instructions when present" do with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") - lambda { + + expect { Hbc::Installer.new(with_installer_manual).install }.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/) - with_installer_manual.must_be :installed? + + expect(with_installer_manual).must_be :installed? end it "does not extract __MACOSX directories from zips" do @@ -262,54 +240,60 @@ describe Hbc::Installer do Hbc::Installer.new(with_macosx_dir).install end - with_macosx_dir.staged_path.join("__MACOSX").wont_be :directory? + expect(with_macosx_dir.staged_path.join("__MACOSX")).wont_be :directory? end it "installer method raises an exception when already-installed Casks which auto-update are attempted" do - auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - auto_updates.installed?.must_equal false - installer = Hbc::Installer.new(auto_updates) + with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") + + expect(with_auto_updates).wont_be :installed? + + installer = Hbc::Installer.new(with_auto_updates) shutup do installer.install end - lambda { + expect { installer.install }.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError) end it "allows already-installed Casks which auto-update to be installed if force is provided" do - auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - auto_updates.installed?.must_equal false + with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") + + expect(with_auto_updates).wont_be :installed? shutup do - Hbc::Installer.new(auto_updates).install + Hbc::Installer.new(with_auto_updates).install end shutup do - Hbc::Installer.new(auto_updates, force: true).install + Hbc::Installer.new(with_auto_updates, force: true).install end # wont_raise end # unlike the CLI, the internal interface throws exception on double-install it "installer method raises an exception when already-installed Casks are attempted" do transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - transmission.installed?.must_equal false + + expect(transmission).wont_be :installed? + installer = Hbc::Installer.new(transmission) shutup do installer.install end - lambda { + expect { installer.install }.must_raise(Hbc::CaskAlreadyInstalledError) end it "allows already-installed Casks to be installed if force is provided" do transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - transmission.installed?.must_equal false + + expect(transmission).wont_be :installed? shutup do Hbc::Installer.new(transmission).install @@ -327,9 +311,7 @@ describe Hbc::Installer do Hbc::Installer.new(naked_pkg).install end - dest_path = Hbc.caskroom.join("container-pkg", naked_pkg.version) - pkg = dest_path.join("container.pkg") - pkg.must_be :file? + expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).must_be :file? end it "works properly with an overridden container :type" do @@ -339,9 +321,7 @@ describe Hbc::Installer do Hbc::Installer.new(naked_executable).install end - dest_path = Hbc.caskroom.join("naked-executable", naked_executable.version) - executable = dest_path.join("naked_executable") - executable.must_be :file? + expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).must_be :file? end it "works fine with a nested container" do @@ -351,8 +331,7 @@ describe Hbc::Installer do Hbc::Installer.new(nested_app).install end - dest_path = Hbc.appdir.join("MyNestedApp.app") - dest_path.must_be :directory? + expect(Hbc.appdir.join("MyNestedApp.app")).must_be :directory? end it "generates and finds a timestamped metadata directory for an installed Cask" do @@ -363,8 +342,8 @@ describe Hbc::Installer do end m_path = caffeine.metadata_path(:now, true) - caffeine.metadata_path(:now, false).must_equal(m_path) - caffeine.metadata_path(:latest).must_equal(m_path) + expect(caffeine.metadata_path(:now, false)).must_equal(m_path) + expect(caffeine.metadata_path(:latest)).must_equal(m_path) end it "generates and finds a metadata subdirectory for an installed Cask" do @@ -376,8 +355,8 @@ describe Hbc::Installer do subdir_name = "Casks" m_subdir = caffeine.metadata_subdir(subdir_name, :now, true) - caffeine.metadata_subdir(subdir_name, :now, false).must_equal(m_subdir) - caffeine.metadata_subdir(subdir_name, :latest).must_equal(m_subdir) + expect(caffeine.metadata_subdir(subdir_name, :now, false)).must_equal(m_subdir) + expect(caffeine.metadata_subdir(subdir_name, :latest)).must_equal(m_subdir) end end @@ -391,9 +370,9 @@ describe Hbc::Installer do installer.uninstall end - Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app").wont_be :directory? - Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory? - Hbc.caskroom.join("local-caffeine").wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine")).wont_be :directory? end it "uninstalls all versions if force is set" do @@ -404,19 +383,19 @@ describe Hbc::Installer do Hbc::Installer.new(caffeine).install end - Hbc.caskroom.join("local-caffeine", caffeine.version).must_be :directory? - Hbc.caskroom.join("local-caffeine", mutated_version).wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).must_be :directory? + expect(Hbc.caskroom.join("local-caffeine", mutated_version)).wont_be :directory? FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version)) - Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory? - Hbc.caskroom.join("local-caffeine", mutated_version).must_be :directory? + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine", mutated_version)).must_be :directory? shutup do Hbc::Installer.new(caffeine, force: true).uninstall end - Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory? - Hbc.caskroom.join("local-caffeine", mutated_version).wont_be :directory? - Hbc.caskroom.join("local-caffeine").wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine", mutated_version)).wont_be :directory? + expect(Hbc.caskroom.join("local-caffeine")).wont_be :directory? end end end -- cgit v1.2.3 From e18a17460771c4a77af904b216aa2f9434763ca3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 22:40:14 +0100 Subject: Simplify check for `:stage_only`. --- Library/Homebrew/cask/lib/hbc/dsl.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index c62873665..4707ae76a 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -270,14 +270,17 @@ module Hbc ORDINARY_ARTIFACT_TYPES.each do |type| define_method(type) do |*args| - if type == :stage_only && args != [true] - raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true") - end - artifacts[type] << args - if artifacts.key?(:stage_only) && artifacts.keys.count > 1 && - !(artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty? - raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact") + if type == :stage_only + if args != [true] + raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true") + end + + unless (artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty? + raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact") + end end + + artifacts[type].add(args) end end -- cgit v1.2.3 From 4a4a162223f015abd6bb78d0dc268157526686f8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 23:27:35 +0100 Subject: Let `Artifact::for_cask` return artifact instances. --- Library/Homebrew/cask/lib/hbc/artifact.rb | 10 +++++----- Library/Homebrew/cask/lib/hbc/cli/list.rb | 2 +- Library/Homebrew/cask/lib/hbc/installer.rb | 14 +++++--------- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact.rb index 8b4babdf6..49346d7cc 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact.rb @@ -56,12 +56,12 @@ module Hbc ] end - def self.for_cask(cask) + def self.for_cask(cask, command: SystemCommand, force: false) odebug "Determining which artifacts are present in Cask #{cask}" - artifacts.select do |artifact| - odebug "Checking for artifact class #{artifact}" - artifact.me?(cask) - end + + artifacts + .select { |klass| klass.me?(cask) } + .map { |klass| klass.new(cask, command: command, force: force) } end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 4094b3d38..e100fbd83 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -55,7 +55,7 @@ module Hbc def self.list_artifacts(cask) Artifact.for_cask(cask).each do |artifact| - summary = artifact.new(cask).summary + summary = artifact.summary ohai summary[:english_description], summary[:contents] unless summary.empty? end end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 28f67e5fd..776a3acd2 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -133,16 +133,14 @@ module Hbc def install_artifacts already_installed_artifacts = [] - options = { command: @command, force: force } odebug "Installing artifacts" - artifacts = Artifact.for_cask(@cask) + artifacts = Artifact.for_cask(@cask, command: @command, force: force) odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| - artifact = artifact.new(@cask, options) next unless artifact.respond_to?(:install_phase) - odebug "Installing artifact of class #{artifact}" + odebug "Installing artifact of class #{artifact.class}" artifact.install_phase already_installed_artifacts.unshift(artifact) end @@ -150,7 +148,7 @@ module Hbc begin already_installed_artifacts.each do |artifact| next unless artifact.respond_to?(:uninstall_phase) - odebug "Reverting installation of artifact of class #{artifact}" + odebug "Reverting installation of artifact of class #{artifact.class}" artifact.uninstall_phase end ensure @@ -319,13 +317,11 @@ module Hbc def uninstall_artifacts odebug "Un-installing artifacts" - artifacts = Artifact.for_cask(@cask) + artifacts = Artifact.for_cask(@cask, command: @command, force: force) odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| - options = { command: @command, force: force } - artifact = artifact.new(@cask, options) next unless artifact.respond_to?(:uninstall_phase) - odebug "Un-installing artifact of class #{artifact}" + odebug "Un-installing artifact of class #{artifact.class}" artifact.uninstall_phase end end -- cgit v1.2.3 From ac4969c3314641c8b5202ae67e2287f6b5bbb664 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Feb 2017 23:29:42 +0100 Subject: Convert `self.artifacts` to `TYPES`. --- Library/Homebrew/cask/lib/hbc/artifact.rb | 56 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact.rb index 49346d7cc..b155a125a 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact.rb @@ -27,39 +27,37 @@ module Hbc module Artifact # NOTE: order is important here, since we want to extract nested containers # before we handle any other artifacts - def self.artifacts - [ - PreflightBlock, - NestedContainer, - Installer, - App, - Suite, - Artifact, # generic 'artifact' stanza - Colorpicker, - Pkg, - Prefpane, - Qlplugin, - Dictionary, - Font, - Service, - StageOnly, - Binary, - InputMethod, - InternetPlugin, - AudioUnitPlugin, - VstPlugin, - Vst3Plugin, - ScreenSaver, - Uninstall, - PostflightBlock, - Zap, - ] - end + TYPES = [ + PreflightBlock, + NestedContainer, + Installer, + App, + Suite, + Artifact, # generic 'artifact' stanza + Colorpicker, + Pkg, + Prefpane, + Qlplugin, + Dictionary, + Font, + Service, + StageOnly, + Binary, + InputMethod, + InternetPlugin, + AudioUnitPlugin, + VstPlugin, + Vst3Plugin, + ScreenSaver, + Uninstall, + PostflightBlock, + Zap, + ].freeze def self.for_cask(cask, command: SystemCommand, force: false) odebug "Determining which artifacts are present in Cask #{cask}" - artifacts + TYPES .select { |klass| klass.me?(cask) } .map { |klass| klass.new(cask, command: command, force: force) } end -- cgit v1.2.3 From 11ebfdafb227ae36559f65c6bd098172301e82f0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 7 Feb 2017 00:19:58 +0000 Subject: audit: enforce https for github.com urls --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index b5dc4ecb1..7a5d38afe 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1343,6 +1343,7 @@ class ResourceAuditor %r{^http://(?:[^/]*\.)?bintray\.com/}, %r{^http://tools\.ietf\.org/}, %r{^http://launchpad\.net/}, + %r{^http://github\.com/}, %r{^http://bitbucket\.org/}, %r{^http://anonscm\.debian\.org/}, %r{^http://cpan\.metacpan\.org/}, -- cgit v1.2.3 From 6cd36428505b1b3548b1e15fe7e0a850b2e2aeaa Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 07:14:28 +0100 Subject: Create custom matchers for “valid symlink”. --- Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb | 4 ++-- Library/Homebrew/cask/spec/spec_helper.rb | 1 + Library/Homebrew/cask/spec/support/file_helper.rb | 8 -------- Library/Homebrew/cask/spec/support/file_matchers.rb | 9 +++++++++ Library/Homebrew/cask/test/cask/artifact/suite_test.rb | 2 +- Library/Homebrew/cask/test/test_helper.rb | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 Library/Homebrew/cask/spec/support/file_helper.rb create mode 100644 Library/Homebrew/cask/spec/support/file_matchers.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb index 95ac2b5f5..b606aba1b 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb @@ -20,7 +20,7 @@ describe Hbc::Artifact::Binary do shutup do Hbc::Artifact::Binary.new(cask).install_phase end - expect(FileHelper.valid_alias?(expected_path)).to be true + expect(expected_path).to be_a_valid_symlink end it "avoids clobbering an existing binary by linking over it" do @@ -82,7 +82,7 @@ describe Hbc::Artifact::Binary do Hbc::Artifact::Binary.new(cask).install_phase end - expect(FileHelper.valid_alias?(expected_path)).to be true + expect(expected_path).to be_a_valid_symlink end end end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index eefee3d60..548691f19 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -34,4 +34,5 @@ end RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) + config.include(FileMatchers) end diff --git a/Library/Homebrew/cask/spec/support/file_helper.rb b/Library/Homebrew/cask/spec/support/file_helper.rb deleted file mode 100644 index abe7b2618..000000000 --- a/Library/Homebrew/cask/spec/support/file_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module FileHelper - module_function - - def valid_alias?(candidate) - return false unless candidate.symlink? - candidate.readlink.exist? - end -end diff --git a/Library/Homebrew/cask/spec/support/file_matchers.rb b/Library/Homebrew/cask/spec/support/file_matchers.rb new file mode 100644 index 000000000..d3e62f45a --- /dev/null +++ b/Library/Homebrew/cask/spec/support/file_matchers.rb @@ -0,0 +1,9 @@ +module FileMatchers + extend RSpec::Matchers::DSL + + matcher :be_a_valid_symlink do + match do |path| + path.symlink? && path.readlink.exist? + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb index 0584dcbeb..6259baa4b 100644 --- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb @@ -20,7 +20,7 @@ describe Hbc::Artifact::Suite do end target_path.must_be :directory? - TestHelper.valid_alias?(target_path).must_equal false + TestHelper.valid_symlink?(target_path).must_equal false source_path.wont_be :exist? end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 71ce5752e..f600a1c5c 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -58,7 +58,7 @@ class TestHelper "file://" + local_binary_path(name) end - def self.valid_alias?(candidate) + def self.valid_symlink?(candidate) return false unless candidate.symlink? candidate.readlink.exist? end -- cgit v1.2.3 From 1281a3f94bd5286a446ac8f7288d44a9025ca60e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 07:17:17 +0100 Subject: Remove `kernel_at_exit_hacks.rb`. --- Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb b/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb deleted file mode 100644 index b5c84869b..000000000 --- a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Kernel - alias real_at_exit at_exit - - def at_exit(&block) - real_at_exit(&block) unless ENV["DISABLE_AT_EXIT"] - end - - def with_disabled_at_exit - ENV["DISABLE_AT_EXIT"] = "1" - yield - ENV.delete("DISABLE_AT_EXIT") - end -end -- cgit v1.2.3 From 9c623a273b967b8554ff5bd9b8debc2cf4c0cbd9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 07:24:41 +0100 Subject: Remove `Sha256Helper`. --- Library/Homebrew/cask/spec/cask/audit_spec.rb | 3 +-- Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb | 8 +++----- Library/Homebrew/cask/spec/support/sha256_helper.rb | 8 -------- 3 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 Library/Homebrew/cask/spec/support/sha256_helper.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb index 193b58fd6..9eb9f0136 100644 --- a/Library/Homebrew/cask/spec/cask/audit_spec.rb +++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb @@ -1,6 +1,5 @@ describe Hbc::Audit do include AuditMatchers - include Sha256Helper let(:cask) { instance_double(Hbc::Cask) } let(:download) { false } @@ -178,7 +177,7 @@ describe Hbc::Audit do end context "when appcast checkpoint is out of date" do - let(:actual_checkpoint) { random_sha256 } + let(:actual_checkpoint) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" } it { is_expected.to warn_with(mismatch_msg) } it { should_not warn_with(curl_error_msg) } end diff --git a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb index a379dafb9..d803c566d 100644 --- a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb +++ b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb @@ -1,6 +1,4 @@ describe Hbc::Verify::Checksum do - include Sha256Helper - let(:cask) { double("cask") } let(:downloaded_path) { double("downloaded_path") } let(:verification) { described_class.new(cask, downloaded_path) } @@ -35,7 +33,7 @@ describe Hbc::Verify::Checksum do end context "sha256 is a valid shasum" do - let(:sha256) { random_sha256 } + let(:sha256) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" } it { is_expected.to be true } end @@ -44,7 +42,7 @@ describe Hbc::Verify::Checksum do describe "#verify" do subject { verification.verify } - let(:computed) { random_sha256 } + let(:computed) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" } before do allow(verification).to receive(:computed).and_return(computed) @@ -67,7 +65,7 @@ describe Hbc::Verify::Checksum do end context "sha256 does not match computed" do - let(:sha256) { random_sha256 } + let(:sha256) { "d3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33f" } it "raises an error" do expect { subject }.to raise_error(Hbc::CaskSha256MismatchError) diff --git a/Library/Homebrew/cask/spec/support/sha256_helper.rb b/Library/Homebrew/cask/spec/support/sha256_helper.rb deleted file mode 100644 index 14f2a2519..000000000 --- a/Library/Homebrew/cask/spec/support/sha256_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -require"digest" - -module Sha256Helper - def random_sha256 - seed = "--#{rand(10_000)}--#{Time.now}--" - Digest::SHA2.hexdigest(seed) - end -end -- cgit v1.2.3 From 79280826f5c8faa82c623a2fb3bb797a75a5d94a Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 8 Feb 2017 00:58:20 -0800 Subject: pull: fix false positives for nonstandard bump subjects when untapped If the formula's tap isn't tapped yet when running `brew pull`, a false positive occurs for the nonstandard bump subject check, and a bogus warning is printed, which claims the bump subject should refer to the old version not the new version. --- Library/Homebrew/dev-cmd/pull.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 8771788e4..c2342d39c 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -376,7 +376,7 @@ module Homebrew subject_strs << "remove stable" formula_name_str += ":" # just for cosmetics else - subject_strs << formula.version.to_s + subject_strs << new[:stable] end end if old[:devel] != new[:devel] @@ -387,7 +387,7 @@ module Homebrew formula_name_str += ":" # just for cosmetics end else - subject_strs << "#{formula.devel.version} (devel)" + subject_strs << "#{new[:devel]} (devel)" end end subject = subject_strs.empty? ? nil : "#{formula_name_str} #{subject_strs.join(", ")}" -- cgit v1.2.3 From 956daf37a0de03f5ffddc35bb85efcd33ee407da Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 17:15:36 +0100 Subject: Use `Open3` for integration tests instead of manually forking. --- Library/Homebrew/keg.rb | 4 ++ Library/Homebrew/test/bottle_test.rb | 2 +- Library/Homebrew/test/options_test.rb | 2 +- .../helper/integration_command_test_case.rb | 71 ++++++++-------------- 4 files changed, 30 insertions(+), 49 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 837968615..f743612ea 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -217,6 +217,10 @@ class Keg true end + def require_relocation? + # no-op + end + def linked? linked_keg_record.symlink? && linked_keg_record.directory? && diff --git a/Library/Homebrew/test/bottle_test.rb b/Library/Homebrew/test/bottle_test.rb index c10746e09..7981ccf79 100644 --- a/Library/Homebrew/test/bottle_test.rb +++ b/Library/Homebrew/test/bottle_test.rb @@ -14,7 +14,7 @@ class IntegrationCommandTestBottle < IntegrationCommandTestCase FileUtils.ln_s "not-exist", "symlink" end assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, - cmd_output("bottle", "--no-rebuild", "testball")) + cmd("bottle", "--no-rebuild", "testball")) ensure FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"] end diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb index f38ec4415..09ea14180 100644 --- a/Library/Homebrew/test/options_test.rb +++ b/Library/Homebrew/test/options_test.rb @@ -9,7 +9,7 @@ class IntegrationCommandTestOptions < IntegrationCommandTestCase EOS assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", - cmd_output("options", "testball").chomp + cmd("options", "testball").chomp end end diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index a36b56691..45e73757a 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -3,6 +3,7 @@ require "fileutils" require "pathname" require "formula" require "test/support/helper/test_case" +require "open3" class IntegrationCommandTestCase < Homebrew::TestCase def setup @@ -28,57 +29,34 @@ class IntegrationCommandTestCase < Homebrew::TestCase end def cmd_output(*args) - # 1.8-compatible way of writing def cmd_output(*args, **env) env = args.last.is_a?(Hash) ? args.pop : {} - cmd_args = %W[ - -W0 - -I#{HOMEBREW_LIBRARY_PATH}/test/support/lib - -I#{HOMEBREW_LIBRARY_PATH} - -rconfig + + env.merge!( + "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", + "HOMEBREW_INTEGRATION_TEST" => cmd_id_from_args(args), + "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, + "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"] + ) + + ruby_args = [ + "-W0", + "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", + "-I", HOMEBREW_LIBRARY_PATH.to_s, + "-rconfig" ] - if ENV["HOMEBREW_TESTS_COVERAGE"] - # This is needed only because we currently use a patched version of - # simplecov, and gems installed through git are not available without - # requiring bundler/setup first. See also the comment in test/Gemfile. - # Remove this line when we'll switch back to a stable simplecov release. - cmd_args << "-rbundler/setup" - cmd_args << "-rsimplecov" - end - cmd_args << "-rtest/support/helper/integration_mocks" - cmd_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - cmd_args += args - developer = ENV["HOMEBREW_DEVELOPER"] - Bundler.with_original_env do - ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew" - ENV["HOMEBREW_INTEGRATION_TEST"] = cmd_id_from_args(args) - ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR - ENV["HOMEBREW_DEVELOPER"] = developer - env.each_pair do |k, v| - ENV[k] = v - end + ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] + ruby_args << "-rtest/support/helper/integration_mocks" + ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - read, write = IO.pipe - begin - pid = fork do - read.close - $stdout.reopen(write) - $stderr.reopen(write) - write.close - exec RUBY_PATH, *cmd_args - end - write.close - read.read.chomp - ensure - Process.wait(pid) - read.close - end + Bundler.with_original_env do + output, status = Open3.capture2e(env, RUBY_PATH, *ruby_args, *args) + [output.chomp, status] end end def cmd(*args) - output = cmd_output(*args) - status = $?.exitstatus - assert_equal 0, status, <<-EOS.undent + output, status = cmd_output(*args) + assert status.success?, <<-EOS.undent `brew #{args.join " "}` exited with non-zero status! #{output} EOS @@ -86,9 +64,8 @@ class IntegrationCommandTestCase < Homebrew::TestCase end def cmd_fail(*args) - output = cmd_output(*args) - status = $?.exitstatus - refute_equal 0, status, <<-EOS.undent + output, status = cmd_output(*args) + refute status.success?, <<-EOS.undent `brew #{args.join " "}` exited with zero status! #{output} EOS -- cgit v1.2.3 From cedc46c64b1a7e37c4e9f2c8c990ae65608b3086 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 18:40:20 +0100 Subject: Use `false` instead of `# no-op`. --- Library/Homebrew/keg.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index f743612ea..fa42cc83a 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -218,7 +218,7 @@ class Keg end def require_relocation? - # no-op + false end def linked? -- cgit v1.2.3 From 31c51108ce43ae97f6b8c061be90ccc1a567010b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 19:01:46 +0100 Subject: Use explicit checks instead of custom matcher. --- Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb | 6 ++++-- Library/Homebrew/cask/spec/spec_helper.rb | 1 - Library/Homebrew/cask/spec/support/file_matchers.rb | 9 --------- 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 Library/Homebrew/cask/spec/support/file_matchers.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb index b606aba1b..c27dcc8f0 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb @@ -20,7 +20,8 @@ describe Hbc::Artifact::Binary do shutup do Hbc::Artifact::Binary.new(cask).install_phase end - expect(expected_path).to be_a_valid_symlink + expect(expected_path).to be_a_symlink + expect(expected_path.readlink).to exist end it "avoids clobbering an existing binary by linking over it" do @@ -82,7 +83,8 @@ describe Hbc::Artifact::Binary do Hbc::Artifact::Binary.new(cask).install_phase end - expect(expected_path).to be_a_valid_symlink + expect(expected_path).to be_a_symlink + expect(expected_path.readlink).to exist end end end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 548691f19..eefee3d60 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -34,5 +34,4 @@ end RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) - config.include(FileMatchers) end diff --git a/Library/Homebrew/cask/spec/support/file_matchers.rb b/Library/Homebrew/cask/spec/support/file_matchers.rb deleted file mode 100644 index d3e62f45a..000000000 --- a/Library/Homebrew/cask/spec/support/file_matchers.rb +++ /dev/null @@ -1,9 +0,0 @@ -module FileMatchers - extend RSpec::Matchers::DSL - - matcher :be_a_valid_symlink do - match do |path| - path.symlink? && path.readlink.exist? - end - end -end -- cgit v1.2.3 From 486fa0bf193fab23a1c1836ba4dc6bd5c1c05df9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 10 Feb 2017 07:49:21 +0100 Subject: Fix `uninstall` also running `zap`. --- Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb | 3 +++ Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb | 4 ---- Library/Homebrew/cask/lib/hbc/artifact/zap.rb | 2 +- Library/Homebrew/cask/lib/hbc/installer.rb | 2 +- Library/Homebrew/cask/test/cask/artifact/zap_test.rb | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb index 8b5603064..5a3dc098d 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb @@ -3,6 +3,9 @@ require "hbc/artifact/uninstall_base" module Hbc module Artifact class Uninstall < UninstallBase + def uninstall_phase + dispatch_uninstall_directives + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index e18e9c311..ce2b1f51a 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -54,10 +54,6 @@ module Hbc path_strings - undeletable end - def uninstall_phase - dispatch_uninstall_directives - end - def dispatch_uninstall_directives(expand_tilde: true) directives_set = @cask.artifacts[stanza] ohai "Running #{stanza} process for #{@cask}; your password may be necessary" diff --git a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb index b31e2ef11..7793e5772 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb @@ -3,7 +3,7 @@ require "hbc/artifact/uninstall_base" module Hbc module Artifact class Zap < UninstallBase - def uninstall_phase + def zap_phase dispatch_uninstall_directives(expand_tilde: true) end end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 776a3acd2..cafc9d8b9 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -331,7 +331,7 @@ module Hbc uninstall_artifacts if Artifact::Zap.me?(@cask) ohai "Dispatching zap stanza" - Artifact::Zap.new(@cask, command: @command).uninstall_phase + Artifact::Zap.new(@cask, command: @command).zap_phase else opoo "No zap stanza present for Cask '#{@cask}'" end diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb index ea546728b..37a65f863 100644 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb @@ -14,10 +14,10 @@ describe Hbc::Artifact::Zap do end end - describe "uninstall_phase" do + describe "#zap_phase" do subject { shutup do - zap_artifact.uninstall_phase + zap_artifact.zap_phase end } -- cgit v1.2.3 From 2af49064563a238baea79f68bfaec080c2bfd636 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 10 Feb 2017 08:00:43 +0100 Subject: Add test to ensure `Zap` does not have an `uninstall_phase`. --- .../spec/cask/artifact/uninstall_no_zap_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb new file mode 100644 index 000000000..3150b50be --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb @@ -0,0 +1,21 @@ +require "spec_helper" + +describe Hbc::Artifact::Zap do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + + let(:zap_artifact) { + Hbc::Artifact::Zap.new(cask) + } + + before do + shutup do + InstallHelper.install_without_artifacts(cask) + end + end + + describe "#uninstall_phase" do + subject { zap_artifact } + + it { is_expected.not_to respond_to(:uninstall_phase) } + end +end -- cgit v1.2.3 From 455369b10c270bc6e11a1a007d109da3027e4205 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 31 Dec 2016 13:39:30 +0100 Subject: Display message when running `brew cask _stanza` without arguments. --- Library/Homebrew/cask/lib/hbc/cli.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 2b2211877..73ab121d2 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -152,7 +152,7 @@ module Hbc Hbc.default_tap.install unless Hbc.default_tap.installed? Hbc.init if should_init?(command) run_command(command, *rest) - rescue CaskError, CaskSha256MismatchError => e + rescue CaskError, CaskSha256MismatchError, ArgumentError => e msg = e.message msg << e.backtrace.join("\n") if Hbc.debug onoe msg diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 105e946d7..c54db8795 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -44,13 +44,15 @@ module Hbc :stage_only, :nested_container, :uninstall, - :postflight, - :uninstall_postflight, :preflight, + :postflight, + :uninstall_preflight, :uninstall_postflight, ] def self.run(*args) + raise ArgumentError, "No stanza given." if args.empty? + table = args.include? "--table" quiet = args.include? "--quiet" format = :to_yaml if args.include? "--yaml" -- cgit v1.2.3 From 03253a8d8b66b49eb6b6a7edd4ed353bcbf3a238 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 5 Feb 2017 18:03:11 +0100 Subject: audit: enforce https://*.sourceforge.io/ homepages Ref: https://sourceforge.net/blog/introducing-https-for-project-websites/ --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ Library/Homebrew/test/audit_test.rb | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index b5dc4ecb1..d10ff51f4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -584,6 +584,10 @@ class FormulaAuditor problem "Please use https:// for #{homepage}" end + if homepage =~ %r{^http://([^/]*)\.(sf|sourceforge)\.net(/|$)} + problem "#{homepage} should be `https://#{$1}.sourceforge.io/`" + end + # There's an auto-redirect here, but this mistake is incredibly common too. # Only applies to the homepage and subdomains for now, not the FTP URLs. if homepage =~ %r{^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org} diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index 60cf27610..b1ccb1e10 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -431,6 +431,9 @@ class FormulaAuditorTests < Homebrew::TestCase "corge" => "http://savannah.nongnu.org/corge", "grault" => "http://grault.github.io/", "garply" => "http://www.gnome.org/garply", + "sf1" => "http://foo.sourceforge.net/", + "sf2" => "http://foo.sourceforge.net", + "sf3" => "http://foo.sf.net/", "waldo" => "http://www.gnu.org/waldo", } @@ -455,6 +458,8 @@ class FormulaAuditorTests < Homebrew::TestCase end elsif homepage =~ %r{https:\/\/code\.google\.com} assert_match "#{homepage} should end with a slash", fa.problems.first + elsif homepage =~ /foo\.(sf|sourceforge)\.net/ + assert_match "#{homepage} should be `https://foo.sourceforge.io/`", fa.problems.first else assert_match "Please use https:// for #{homepage}", fa.problems.first end -- cgit v1.2.3 From fe0b68a5ad76bc3a91518f54a97bdd7a9144eda5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 07:50:42 +0100 Subject: Convert `Plist` test to spec. --- Library/Homebrew/cask/spec/plist/parser_spec.rb | 75 +++++++++++++++++++++++++ Library/Homebrew/cask/test/plist/parser_test.rb | 65 --------------------- 2 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 Library/Homebrew/cask/spec/plist/parser_spec.rb delete mode 100644 Library/Homebrew/cask/test/plist/parser_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/plist/parser_spec.rb b/Library/Homebrew/cask/spec/plist/parser_spec.rb new file mode 100644 index 000000000..9d4a59fdc --- /dev/null +++ b/Library/Homebrew/cask/spec/plist/parser_spec.rb @@ -0,0 +1,75 @@ +require "spec_helper" + +describe Plist do + subject { described_class.parse_xml(input) } + + describe "::parse_xml" do + context "given a hdiutil output as input" do + let(:input) { + <<-EOS.undent + + + + + system-entities + + + content-hint + Apple_partition_map + dev-entry + /dev/disk3s1 + potentially-mountable + + unmapped-content-hint + Apple_partition_map + + + content-hint + Apple_partition_scheme + dev-entry + /dev/disk3 + potentially-mountable + + unmapped-content-hint + Apple_partition_scheme + + + content-hint + Apple_HFS + dev-entry + /dev/disk3s2 + mount-point + /private/tmp/dmg.BhfS2g + potentially-mountable + + unmapped-content-hint + Apple_HFS + volume-kind + hfs + + + + + EOS + } + + it "successfully parses it" do + expect(subject.keys).to eq(["system-entities"]) + expect(subject["system-entities"].length).to eq(3) + expect(subject["system-entities"].map { |e| e["dev-entry"] }).to eq( + %w[ + /dev/disk3s1 + /dev/disk3 + /dev/disk3s2 + ] + ) + end + end + + context "given an empty input" do + let(:input) { "" } + + it { is_expected.to be_nil } + end + end +end diff --git a/Library/Homebrew/cask/test/plist/parser_test.rb b/Library/Homebrew/cask/test/plist/parser_test.rb deleted file mode 100644 index 7f844e377..000000000 --- a/Library/Homebrew/cask/test/plist/parser_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require "test_helper" - -describe Plist do - it "parses some hdiutil output okay" do - hdiutil_output = <<-EOS.undent - - - - - system-entities - - - content-hint - Apple_partition_map - dev-entry - /dev/disk3s1 - potentially-mountable - - unmapped-content-hint - Apple_partition_map - - - content-hint - Apple_partition_scheme - dev-entry - /dev/disk3 - potentially-mountable - - unmapped-content-hint - Apple_partition_scheme - - - content-hint - Apple_HFS - dev-entry - /dev/disk3s2 - mount-point - /private/tmp/dmg.BhfS2g - potentially-mountable - - unmapped-content-hint - Apple_HFS - volume-kind - hfs - - - - - EOS - - parsed = Plist.parse_xml(hdiutil_output) - - parsed.keys.must_equal ["system-entities"] - parsed["system-entities"].length.must_equal 3 - parsed["system-entities"].map { |e| e["dev-entry"] }.must_equal %w[ - /dev/disk3s1 - /dev/disk3 - /dev/disk3s2 - ] - end - - it "does not choke on empty input" do - Plist.parse_xml("").must_equal {} - end -end -- cgit v1.2.3 From c8d164412d924e8412bc26a653397edba53693fd Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 07:58:02 +0100 Subject: Convert `Hbc::UrlChecker` test to spec. --- .../Homebrew/cask/spec/cask/url_checker_spec.rb | 44 +++++++++++++++++++ .../Homebrew/cask/test/cask/url_checker_test.rb | 51 ---------------------- 2 files changed, 44 insertions(+), 51 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/url_checker_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/url_checker_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/url_checker_spec.rb b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb new file mode 100644 index 000000000..3b46bc587 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb @@ -0,0 +1,44 @@ +require "spec_helper" + +describe Hbc::UrlChecker do + describe "request processing" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:checker) { Hbc::UrlChecker.new(cask) } + + before(:each) do + allow(Hbc::Fetcher).to receive(:head).and_return(response) + checker.run + end + + context "with an empty response" do + let(:response) { "" } + + it "adds an error" do + expect(checker.errors).to include("timeout while requesting #{cask.url}") + end + end + + context "with a valid http response" do + let(:response) { + <<-EOS.undent + HTTP/1.1 200 OK + Content-Type: application/x-apple-diskimage + ETag: "b4208f3e84967be4b078ecaa03fba941" + Content-Length: 23726161 + Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT + EOS + } + + it "properly populates the response code and headers" do + expect(checker.errors).to be_empty + expect(checker.response_status).to eq("HTTP/1.1 200 OK") + expect(checker.headers).to eq( + "Content-Type" => "application/x-apple-diskimage", + "ETag" => '"b4208f3e84967be4b078ecaa03fba941"', + "Content-Length" => "23726161", + "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT" + ) + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/url_checker_test.rb b/Library/Homebrew/cask/test/cask/url_checker_test.rb deleted file mode 100644 index afd4532dd..000000000 --- a/Library/Homebrew/cask/test/cask/url_checker_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require "test_helper" - -describe Hbc::UrlChecker do - describe "request processing" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } - let(:checker) { Hbc::UrlChecker.new(cask) } - let(:with_stubbed_fetcher) { - lambda { |&block| - Hbc::Fetcher.stub(:head, response) do - checker.run - instance_eval(&block) - end - } - } - - describe "with an empty response" do - let(:response) { "" } - - it "adds an error" do - with_stubbed_fetcher.call do - expect(checker.errors).must_include("timeout while requesting #{cask.url}") - end - end - end - - describe "with a valid http response" do - let(:response) { - <<-EOS.undent - HTTP/1.1 200 OK - Content-Type: application/x-apple-diskimage - ETag: "b4208f3e84967be4b078ecaa03fba941" - Content-Length: 23726161 - Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT - EOS - } - - it "properly populates the response code and headers" do - with_stubbed_fetcher.call do - expect(checker.errors).must_be_empty - expect(checker.response_status).must_equal("HTTP/1.1 200 OK") - expect(checker.headers).must_equal( - "Content-Type" => "application/x-apple-diskimage", - "ETag" => '"b4208f3e84967be4b078ecaa03fba941"', - "Content-Length" => "23726161", - "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT" - ) - end - end - end - end -end -- cgit v1.2.3 From 99bf7ba77164e01544c6f189a53365c6b078f3f5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 08:29:41 +0100 Subject: Cleanup after each spec example. --- Library/Homebrew/cask/spec/cask/scopes_spec.rb | 28 +++++++++----------------- Library/Homebrew/cask/spec/spec_helper.rb | 6 ++++++ 2 files changed, 16 insertions(+), 18 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/scopes_spec.rb b/Library/Homebrew/cask/spec/cask/scopes_spec.rb index 12c1a697f..abf4b6401 100644 --- a/Library/Homebrew/cask/spec/cask/scopes_spec.rb +++ b/Library/Homebrew/cask/spec/cask/scopes_spec.rb @@ -1,39 +1,31 @@ describe Hbc::Scopes do describe "installed" do - let(:fake_caskroom) { Pathname(Dir.mktmpdir) } - - before do - allow(Hbc).to receive(:caskroom) { fake_caskroom } - end - - after do - fake_caskroom.rmtree - end - it "returns a list installed Casks by loading Casks for all the dirs that exist in the caskroom" do allow(Hbc).to receive(:load) { |token| "loaded-#{token}" } - fake_caskroom.join("cask-bar").mkdir - fake_caskroom.join("cask-foo").mkdir + Hbc.caskroom.join("cask-bar").mkpath + Hbc.caskroom.join("cask-foo").mkpath installed_casks = Hbc.installed expect(Hbc).to have_received(:load).with("cask-bar") expect(Hbc).to have_received(:load).with("cask-foo") - expect(installed_casks).to eq(%w[ - loaded-cask-bar - loaded-cask-foo - ]) + expect(installed_casks).to eq( + %w[ + loaded-cask-bar + loaded-cask-foo + ] + ) end it "optimizes performance by resolving to a fully qualified path before calling Hbc.load" do - fake_tapped_cask_dir = Pathname(Dir.mktmpdir).join("Casks") + fake_tapped_cask_dir = Pathname.new(Dir.mktmpdir).join("Casks") absolute_path_to_cask = fake_tapped_cask_dir.join("some-cask.rb") allow(Hbc).to receive(:load) allow(Hbc).to receive(:all_tapped_cask_dirs) { [fake_tapped_cask_dir] } - fake_caskroom.join("some-cask").mkdir + Hbc.caskroom.join("some-cask").mkdir fake_tapped_cask_dir.mkdir FileUtils.touch(absolute_path_to_cask) diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index eefee3d60..dc9edec3d 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -34,4 +34,10 @@ end RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) + config.after(:each) do + FileUtils.rm_rf [ + Hbc.appdir.children, + Hbc.caskroom.children, + ] + end end -- cgit v1.2.3 From fe2829a5d2df373bd2353530e84e4d228efb9d97 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 08:30:33 +0100 Subject: Convert `depends_on` test to spec. --- Library/Homebrew/cask/spec/cask/depends_on_spec.rb | 92 +++++++++++++++++ Library/Homebrew/cask/test/cask/depends_on_test.rb | 113 --------------------- 2 files changed, 92 insertions(+), 113 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/depends_on_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/depends_on_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/depends_on_spec.rb b/Library/Homebrew/cask/spec/cask/depends_on_spec.rb new file mode 100644 index 000000000..078a2bce7 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/depends_on_spec.rb @@ -0,0 +1,92 @@ +require "spec_helper" + +# TODO: this test should be named after the corresponding class, once +# that class is abstracted from installer.rb +describe "Satisfy Dependencies and Requirements" do + subject { + lambda do + shutup do + Hbc::Installer.new(cask).install + end + end + } + + describe "depends_on cask" do + context "when depends_on cask is cyclic" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb") } + it { is_expected.to raise_error(Hbc::CaskCyclicCaskDependencyError) } + end + + context do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") } + let(:dependency) { Hbc.load(cask.depends_on.cask.first) } + + it "installs the dependency of a Cask and the Cask itself" do + expect(subject).not_to raise_error + expect(cask).to be_installed + expect(dependency).to be_installed + end + end + end + + describe "depends_on macos" do + context "given an array" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb") } + it { is_expected.not_to raise_error } + end + + context "given a comparisson" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb") } + it { is_expected.not_to raise_error } + end + + context "given a string" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") } + it { is_expected.not_to raise_error } + end + + context "given a symbol" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb") } + it { is_expected.not_to raise_error } + end + + context "when not satisfied" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb") } + it { is_expected.to raise_error(Hbc::CaskError) } + end + end + + describe "depends_on arch" do + context "when satisfied" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") } + it { is_expected.not_to raise_error } + end + end + + describe "depends_on x11" do + before(:each) do + allow(MacOS::X11).to receive(:installed?).and_return(x11_installed) + end + + context "when satisfied" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") } + let(:x11_installed) { true } + + it { is_expected.not_to raise_error } + end + + context "when not satisfied" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") } + let(:x11_installed) { false } + + it { is_expected.to raise_error(Hbc::CaskX11DependencyError) } + end + + context "when depends_on x11: false" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb") } + let(:x11_installed) { false } + + it { is_expected.not_to raise_error } + end + end +end diff --git a/Library/Homebrew/cask/test/cask/depends_on_test.rb b/Library/Homebrew/cask/test/cask/depends_on_test.rb deleted file mode 100644 index 1ec85b520..000000000 --- a/Library/Homebrew/cask/test/cask/depends_on_test.rb +++ /dev/null @@ -1,113 +0,0 @@ -require "test_helper" - -# TODO: this test should be named after the corresponding class, once -# that class is abstracted from installer.rb -describe "Satisfy Dependencies and Requirements" do - # TODO: test that depends_on formula invokes Homebrew - # - # describe "depends_on formula" do - # it "" do - # end - # end - # - - describe "depends_on cask" do - it "raises an exception when depends_on cask is cyclic" do - dep_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb") - lambda { - shutup do - Hbc::Installer.new(dep_cask).install - end - }.must_raise(Hbc::CaskCyclicCaskDependencyError) - end - - it "installs the dependency of a Cask and the Cask itself" do - csk = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") - dependency = Hbc.load(csk.depends_on.cask.first) - shutup do - Hbc::Installer.new(csk).install - end - - csk.must_be :installed? - dependency.must_be :installed? - end - end - - describe "depends_on macos" do - it "understands depends_on macos: " do - macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb") - shutup do - Hbc::Installer.new(macos_cask).install - end - end - - it "understands depends_on macos: " do - macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb") - shutup do - Hbc::Installer.new(macos_cask).install - end - end - - it "understands depends_on macos: " do - macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") - shutup do - Hbc::Installer.new(macos_cask).install - end - end - - it "understands depends_on macos: " do - macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb") - shutup do - Hbc::Installer.new(macos_cask).install - end - end - - it "raises an exception when depends_on macos is not satisfied" do - macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb") - lambda { - shutup do - Hbc::Installer.new(macos_cask).install - end - }.must_raise(Hbc::CaskError) - end - end - - describe "depends_on arch" do - it "succeeds when depends_on arch is satisfied" do - arch_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") - shutup do - Hbc::Installer.new(arch_cask).install - end - end - end - - describe "depends_on x11" do - it "succeeds when depends_on x11 is satisfied" do - x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") - MacOS::X11.stubs(:installed?).returns(true) - shutup do - Hbc::Installer.new(x11_cask).install - end - end - - it "raises an exception when depends_on x11 is not satisfied" do - x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") - MacOS::X11.stubs(:installed?).returns(false) - lambda { - shutup do - Hbc::Installer.new(x11_cask).install - end - }.must_raise(Hbc::CaskX11DependencyError) - end - - it "never raises when depends_on x11: false" do - x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb") - MacOS::X11.stubs(:installed?).returns(false) - lambda do - shutup do - Hbc::Installer.new(x11_cask).install - end - end # won't raise - end - end -end -- cgit v1.2.3 From af8b91746c8ee67cc5c050fdd4182089171dd0ab Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 08:54:20 +0100 Subject: Convert Accessibility test to spec. --- .../Homebrew/cask/spec/cask/accessibility_spec.rb | 82 ++++++++++++++++++++++ .../Homebrew/cask/test/cask/accessibility_test.rb | 77 -------------------- 2 files changed, 82 insertions(+), 77 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/accessibility_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/accessibility_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/accessibility_spec.rb b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb new file mode 100644 index 000000000..8787a2c6d --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb @@ -0,0 +1,82 @@ +require "spec_helper" + +# TODO: this test should be named after the corresponding class, once +# that class is abstracted from installer.rb. +describe "Accessibility Access" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") } + let(:fake_system_command) { class_double(Hbc::SystemCommand) } + let(:installer) { Hbc::Installer.new(cask, command: fake_system_command) } + + before(:each) do + allow(MacOS).to receive(:version).and_return(MacOS::Version.new(macos_version)) + allow(installer).to receive(:bundle_identifier).and_return("com.example.BasicCask") + end + + context "on MacOS 10.8 and below" do + let(:macos_version) { "10.8" } + + it "can enable accessibility access in macOS releases prior to Mavericks" do + expect(fake_system_command).to receive(:run!).with( + "/usr/bin/touch", + args: [Hbc.pre_mavericks_accessibility_dotfile], + sudo: true + ) + + shutup do + installer.enable_accessibility_access + end + end + + it "warns about disabling accessibility access on old macOS releases" do + expect { + installer.disable_accessibility_access + }.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr + end + end + + context "on MacOS 10.9" do + let(:macos_version) { "10.9" } + + it "can enable accessibility access" do + expect(fake_system_command).to receive(:run!).with( + "/usr/bin/sqlite3", + args: [Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"], + sudo: true + ) + + shutup do + installer.enable_accessibility_access + end + end + + it "can disable accessibility access" do + expect(fake_system_command).to receive(:run!).with( + "/usr/bin/sqlite3", + args: [Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"], + sudo: true + ) + + shutup do + installer.disable_accessibility_access + end + end + end + + context "on MacOS 10.12 and above" do + let(:macos_version) { "10.12" } + + it "warns about enabling accessibility access on new macOS releases" do + expect { + expect { + installer.enable_accessibility_access + }.to output.to_stdout + }.to output(/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./).to_stderr + end + + it "warns about disabling accessibility access on new macOS releases" do + expect { + installer.disable_accessibility_access + }.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr + end + end +end diff --git a/Library/Homebrew/cask/test/cask/accessibility_test.rb b/Library/Homebrew/cask/test/cask/accessibility_test.rb deleted file mode 100644 index 657629469..000000000 --- a/Library/Homebrew/cask/test/cask/accessibility_test.rb +++ /dev/null @@ -1,77 +0,0 @@ -require "test_helper" - -# TODO: this test should be named after the corresponding class, once -# that class is abstracted from installer.rb. -describe "Accessibility Access" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") } - let(:with_fake_command) { { command: Hbc::FakeSystemCommand } } - let(:installer) { Hbc::Installer.new(cask, with_fake_command) } - - describe "install" do - it "can enable accessibility access" do - MacOS.stub :version, MacOS::Version.new("10.9") do - installer.stub :bundle_identifier, "com.example.BasicCask" do - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"] - ) - shutup do - installer.enable_accessibility_access - end - end - end - end - - it "can enable accessibility access in macOS releases prior to Mavericks" do - MacOS.stub :version, MacOS::Version.new("10.8") do - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/bin/touch", Hbc.pre_mavericks_accessibility_dotfile] - ) - shutup do - installer.enable_accessibility_access - end - end - end - - it "warns about enabling accessibility access on new macOS releases" do - MacOS.stub :version, MacOS::Version.new("10.12") do - installer.stub :bundle_identifier, "com.example.BasicCask" do - capture_io { installer.enable_accessibility_access }[1] - .must_match("Warning: Accessibility access cannot be enabled automatically on this version of macOS.") - end - end - end - end - - describe "uninstall" do - it "can disable accessibility access" do - MacOS.stub :version, MacOS::Version.new("10.9") do - installer.stub :bundle_identifier, "com.example.BasicCask" do - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"] - ) - shutup do - installer.disable_accessibility_access - end - end - end - end - - it "warns about disabling accessibility access on old macOS releases" do - MacOS.stub :version, MacOS::Version.new("10.8") do - installer.stub :bundle_identifier, "com.example.BasicCask" do - capture_io { installer.disable_accessibility_access }[1] - .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") - end - end - end - - it "warns about disabling accessibility access on new macOS releases" do - MacOS.stub :version, MacOS::Version.new("10.12") do - installer.stub :bundle_identifier, "com.example.BasicCask" do - capture_io { installer.disable_accessibility_access }[1] - .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.") - end - end - end - end -end -- cgit v1.2.3 From 17fd7d6ebbfcddeb0be7f504600d69f32343dd86 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 09:18:48 +0100 Subject: Convert `staged` test to spec. --- Library/Homebrew/cask/spec/cask/staged_spec.rb | 18 ++++++++++++++++++ Library/Homebrew/cask/test/cask/staged_test.rb | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/staged_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/staged_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/staged_spec.rb b/Library/Homebrew/cask/spec/cask/staged_spec.rb new file mode 100644 index 000000000..10f1cbb47 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/staged_spec.rb @@ -0,0 +1,18 @@ +require "spec_helper" + +# TODO: this test should be named after the corresponding class, once +# that class is abstracted from installer.rb. It makes little sense +# to be invoking bundle_identifier off of the installer instance. +describe "Operations on staged Casks" do + describe "bundle ID" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } + let(:installer) { Hbc::Installer.new(cask) } + it "fetches the bundle ID from a staged cask" do + shutup do + installer.install + end + + expect(installer.bundle_identifier).to eq("org.m0k.transmission") + end + end +end diff --git a/Library/Homebrew/cask/test/cask/staged_test.rb b/Library/Homebrew/cask/test/cask/staged_test.rb deleted file mode 100644 index 2b601a6ae..000000000 --- a/Library/Homebrew/cask/test/cask/staged_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "test_helper" - -# TODO: this test should be named after the corresponding class, once -# that class is abstracted from installer.rb. It makes little sense -# to be invoking bundle_identifier off of the installer instance. -describe "Operations on staged Casks" do - describe "bundle ID" do - it "fetches the bundle ID from a staged cask" do - transmission_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - tr_installer = Hbc::Installer.new(transmission_cask) - - shutup do - tr_installer.install - end - tr_installer.bundle_identifier.must_equal("org.m0k.transmission") - end - end -end -- cgit v1.2.3 From d9d15d3670fa9f425f852feac0868ca2ace8f813 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 09:58:38 +0100 Subject: Convert `Pkg` test to spec. --- Library/Homebrew/cask/spec/cask/pkg_spec.rb | 114 ++++++++++++++++++++++++++++ Library/Homebrew/cask/spec/spec_helper.rb | 8 ++ Library/Homebrew/cask/test/cask/pkg_test.rb | 111 --------------------------- 3 files changed, 122 insertions(+), 111 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/pkg_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/pkg_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/pkg_spec.rb new file mode 100644 index 000000000..2f0ba0839 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/pkg_spec.rb @@ -0,0 +1,114 @@ +require "spec_helper" + +describe Hbc::Pkg do + describe "uninstall" do + let(:fake_system_command) { Hbc::NeverSudoSystemCommand } + let(:empty_response) { double(stdout: "") } + let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) } + + it "removes files and dirs referenced by the pkg" do + some_files = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } + allow(pkg).to receive(:pkgutil_bom_files).and_return(some_files) + + some_specials = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } + allow(pkg).to receive(:pkgutil_bom_specials).and_return(some_specials) + + some_dirs = Array.new(3) { Pathname.new(Dir.mktmpdir) } + allow(pkg).to receive(:pkgutil_bom_dirs).and_return(some_dirs) + + allow(pkg).to receive(:forget) + + pkg.uninstall + + some_files.each do |file| + expect(file).not_to exist + end + + some_dirs.each do |dir| + expect(dir).not_to exist + end + end + + context "pkgutil" do + let(:fake_system_command) { class_double(Hbc::SystemCommand) } + + it "forgets the pkg" do + allow(fake_system_command).to receive(:run!).with( + "/usr/sbin/pkgutil", + args: ["--only-files", "--files", "my.fake.pkg"] + ).and_return(empty_response) + + allow(fake_system_command).to receive(:run!).with( + "/usr/sbin/pkgutil", + args: ["--only-dirs", "--files", "my.fake.pkg"] + ).and_return(empty_response) + + allow(fake_system_command).to receive(:run!).with( + "/usr/sbin/pkgutil", + args: ["--files", "my.fake.pkg"] + ).and_return(empty_response) + + expect(fake_system_command).to receive(:run!).with( + "/usr/sbin/pkgutil", + args: ["--forget", "my.fake.pkg"], + sudo: true + ) + + pkg.uninstall + end + end + + it "removes broken symlinks" do + fake_dir = Pathname.new(Dir.mktmpdir) + fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } + + intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) } + broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") } + + allow(pkg).to receive(:pkgutil_bom_specials).and_return([]) + allow(pkg).to receive(:pkgutil_bom_files).and_return([]) + allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_dir]) + allow(pkg).to receive(:forget) + + pkg.uninstall + + expect(intact_symlink).to exist + expect(broken_symlink).not_to exist + expect(fake_dir).to exist + end + + it "removes files incorrectly reportes as directories" do + fake_dir = Pathname.new(Dir.mktmpdir) + fake_file = fake_dir.join("ima_file_pretending_to_be_a_dir").tap { |path| FileUtils.touch(path) } + + allow(pkg).to receive(:pkgutil_bom_specials).and_return([]) + allow(pkg).to receive(:pkgutil_bom_files).and_return([]) + allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_file, fake_dir]) + allow(pkg).to receive(:forget) + + pkg.uninstall + + expect(fake_file).not_to exist + expect(fake_dir).not_to exist + end + + it "snags permissions on ornery dirs, but returns them afterwards" do + fake_dir = Pathname.new(Dir.mktmpdir) + fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) } + fake_dir.chmod(0000) + + allow(pkg).to receive(:pkgutil_bom_specials).and_return([]) + allow(pkg).to receive(:pkgutil_bom_files).and_return([fake_file]) + allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_dir]) + allow(pkg).to receive(:forget) + + shutup do + pkg.uninstall + end + + expect(fake_dir).to be_a_directory + expect(fake_file).not_to be_a_file + expect((fake_dir.stat.mode % 01000).to_s(8)).to eq("0") + end + end +end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index dc9edec3d..d9f29c828 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -41,3 +41,11 @@ RSpec.configure do |config| ] end end + +module Hbc + class NeverSudoSystemCommand < SystemCommand + def self.run(command, options = {}) + super(command, options.merge(sudo: false)) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb deleted file mode 100644 index ac43f9e63..000000000 --- a/Library/Homebrew/cask/test/cask/pkg_test.rb +++ /dev/null @@ -1,111 +0,0 @@ -require "test_helper" - -describe Hbc::Pkg do - describe "uninstall" do - it "removes files and dirs referenced by the pkg" do - pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - - some_files = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } - pkg.stubs(:pkgutil_bom_files).returns some_files - - some_specials = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) } - pkg.stubs(:pkgutil_bom_specials).returns some_specials - - some_dirs = Array.new(3) { Pathname.new(Dir.mktmpdir) } - pkg.stubs(:pkgutil_bom_dirs).returns some_dirs - - pkg.stubs(:forget) - - pkg.uninstall - - some_files.each do |file| - file.wont_be :exist? - end - - some_dirs.each do |dir| - dir.wont_be :exist? - end - end - - it "forgets the pkg" do - pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::FakeSystemCommand) - - Hbc::FakeSystemCommand.stubs_command( - ["/usr/sbin/pkgutil", "--only-files", "--files", "my.fake.pkg"] - ) - Hbc::FakeSystemCommand.stubs_command( - ["/usr/sbin/pkgutil", "--only-dirs", "--files", "my.fake.pkg"] - ) - Hbc::FakeSystemCommand.stubs_command( - ["/usr/sbin/pkgutil", "--files", "my.fake.pkg"] - ) - - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/pkgutil", "--forget", "my.fake.pkg"] - ) - - pkg.uninstall - end - - it "cleans broken symlinks, but leaves AOK symlinks" do - pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - - fake_dir = Pathname.new(Dir.mktmpdir) - fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } - - intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) } - broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") } - - pkg.stubs(:pkgutil_bom_specials).returns([]) - pkg.stubs(:pkgutil_bom_files).returns([]) - pkg.stubs(:pkgutil_bom_dirs).returns([fake_dir]) - pkg.stubs(:forget) - - pkg.uninstall - - intact_symlink.must_be :exist? - broken_symlink.wont_be :exist? - fake_dir.must_be :exist? - end - - it "cleans files incorrectly reported as directories" do - pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - - fake_dir = Pathname.new(Dir.mktmpdir) - fake_file = fake_dir.join("ima_file_pretending_to_be_a_dir").tap { |path| FileUtils.touch(path) } - - pkg.stubs(:pkgutil_bom_specials).returns([]) - pkg.stubs(:pkgutil_bom_files).returns([]) - pkg.stubs(:pkgutil_bom_dirs).returns([fake_file, fake_dir]) - pkg.stubs(:forget) - - pkg.uninstall - - fake_file.wont_be :exist? - fake_dir.wont_be :exist? - end - - it "snags permissions on ornery dirs, but returns them afterwords" do - pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand) - - fake_dir = Pathname.new(Dir.mktmpdir) - - fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) } - - fake_dir.chmod(0000) - - pkg.stubs(:pkgutil_bom_specials).returns([]) - pkg.stubs(:pkgutil_bom_files).returns([fake_file]) - pkg.stubs(:pkgutil_bom_dirs).returns([fake_dir]) - pkg.stubs(:forget) - - shutup do - pkg.uninstall - end - - fake_dir.must_be :directory? - fake_file.wont_be :file? - (fake_dir.stat.mode % 01000).to_s(8).must_equal "0" - end - end -end -- cgit v1.2.3 From 8155d27e5c11f9d0adfbb6c911d1c5d6b479aa53 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 10:09:00 +0100 Subject: Convert Pre/PostflightBlock test to spec. --- .../spec/cask/artifact/postflight_block_spec.rb | 41 ++++++++++++++++++++++ .../spec/cask/artifact/preflight_block_spec.rb | 41 ++++++++++++++++++++++ .../test/cask/artifact/postflight_block_test.rb | 41 ---------------------- .../test/cask/artifact/preflight_block_test.rb | 41 ---------------------- 4 files changed, 82 insertions(+), 82 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb create mode 100644 Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb new file mode 100644 index 000000000..6f58afb2a --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb @@ -0,0 +1,41 @@ +require "spec_helper" + +describe Hbc::Artifact::PostflightBlock do + describe "install_phase" do + it "calls the specified block after installing, passing a Cask mini-dsl" do + called = false + yielded_arg = nil + + cask = Hbc::Cask.new("with-postflight") do + postflight do |c| + called = true + yielded_arg = c + end + end + + described_class.new(cask).install_phase + + expect(called).to be true + expect(yielded_arg).to be_kind_of(Hbc::DSL::Postflight) + end + end + + describe "uninstall_phase" do + it "calls the specified block after uninstalling, passing a Cask mini-dsl" do + called = false + yielded_arg = nil + + cask = Hbc::Cask.new("with-uninstall-postflight") do + uninstall_postflight do |c| + called = true + yielded_arg = c + end + end + + described_class.new(cask).uninstall_phase + + expect(called).to be true + expect(yielded_arg).to be_kind_of(Hbc::DSL::UninstallPostflight) + end + end +end diff --git a/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb new file mode 100644 index 000000000..ac5313bca --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb @@ -0,0 +1,41 @@ +require "spec_helper" + +describe Hbc::Artifact::PreflightBlock do + describe "install_phase" do + it "calls the specified block before installing, passing a Cask mini-dsl" do + called = false + yielded_arg = nil + + cask = Hbc::Cask.new("with-preflight") do + preflight do |c| + called = true + yielded_arg = c + end + end + + described_class.new(cask).install_phase + + expect(called).to be true + expect(yielded_arg).to be_kind_of Hbc::DSL::Preflight + end + end + + describe "uninstall_phase" do + it "calls the specified block before uninstalling, passing a Cask mini-dsl" do + called = false + yielded_arg = nil + + cask = Hbc::Cask.new("with-uninstall-preflight") do + uninstall_preflight do |c| + called = true + yielded_arg = c + end + end + + described_class.new(cask).uninstall_phase + + expect(called).to be true + expect(yielded_arg).to be_kind_of Hbc::DSL::UninstallPreflight + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb b/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb deleted file mode 100644 index 47dcdd905..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::PostflightBlock do - describe "install_phase" do - it "calls the specified block after installing, passing a Cask mini-dsl" do - called = false - yielded_arg = nil - - cask = Hbc::Cask.new("with-postflight") do - postflight do |c| - called = true - yielded_arg = c - end - end - - Hbc::Artifact::PostflightBlock.new(cask).install_phase - - called.must_equal true - yielded_arg.must_be_kind_of Hbc::DSL::Postflight - end - end - - describe "uninstall_phase" do - it "calls the specified block after uninstalling, passing a Cask mini-dsl" do - called = false - yielded_arg = nil - - cask = Hbc::Cask.new("with-uninstall-postflight") do - uninstall_postflight do |c| - called = true - yielded_arg = c - end - end - - Hbc::Artifact::PostflightBlock.new(cask).uninstall_phase - - called.must_equal true - yielded_arg.must_be_kind_of Hbc::DSL::UninstallPostflight - end - end -end diff --git a/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb b/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb deleted file mode 100644 index 440b1db3a..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::PreflightBlock do - describe "install_phase" do - it "calls the specified block before installing, passing a Cask mini-dsl" do - called = false - yielded_arg = nil - - cask = Hbc::Cask.new("with-preflight") do - preflight do |c| - called = true - yielded_arg = c - end - end - - Hbc::Artifact::PreflightBlock.new(cask).install_phase - - called.must_equal true - yielded_arg.must_be_kind_of Hbc::DSL::Preflight - end - end - - describe "uninstall_phase" do - it "calls the specified block before uninstalling, passing a Cask mini-dsl" do - called = false - yielded_arg = nil - - cask = Hbc::Cask.new("with-uninstall-preflight") do - uninstall_preflight do |c| - called = true - yielded_arg = c - end - end - - Hbc::Artifact::PreflightBlock.new(cask).uninstall_phase - - called.must_equal true - yielded_arg.must_be_kind_of Hbc::DSL::UninstallPreflight - end - end -end -- cgit v1.2.3 From d8e515004c68b82532401a26ae0d6a4f27844d91 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 10:45:25 +0100 Subject: Convert DSL test to spec. --- Library/Homebrew/cask/spec/cask/dsl_spec.rb | 548 ++++++++++++++++++++++++++++ Library/Homebrew/cask/test/cask/dsl_test.rb | 479 ------------------------ 2 files changed, 548 insertions(+), 479 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/dsl_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/dsl_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/dsl_spec.rb b/Library/Homebrew/cask/spec/cask/dsl_spec.rb new file mode 100644 index 000000000..99525cc20 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl_spec.rb @@ -0,0 +1,548 @@ +require "spec_helper" + +describe Hbc::DSL do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") } + let(:token) { "basic-cask" } + + context "stanzas" do + it "lets you set url, homepage, and version" do + expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") + expect(cask.homepage).to eq("http://example.com/") + expect(cask.version.to_s).to eq("1.2.3") + end + end + + describe "when a Cask includes an unknown method" do + let(:attempt_unknown_method) { + lambda do + Hbc::Cask.new("unexpected-method-cask") do + future_feature :not_yet_on_your_machine + end + end + } + + it "prints a warning that it has encountered an unexpected method" do + expected = Regexp.compile(<<-EOS.undent.lines.map(&:chomp).join("")) + (?m) + Warning: + .* + Unexpected method 'future_feature' called on Cask unexpected-method-cask\\. + .* + https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md + .* + https://github.com/caskroom/homebrew-cask#reporting-bugs + EOS + + expect { + expect(attempt_unknown_method).not_to output.to_stdout + }.to output(expected).to_stderr + end + + it "will simply warn, not throw an exception" do + expect { + shutup do + attempt_unknown_method.call + end + }.not_to raise_error + end + end + + describe "header line" do + context "when invalid" do + let(:token) { "invalid/invalid-header-format" } + it "raises an error" do + expect { cask }.to raise_error(SyntaxError) + end + end + + context "when token does not match the file name" do + let(:token) { "invalid/invalid-header-token-mismatch" } + + it "raises an error" do + expect { + cask + }.to raise_error(Hbc::CaskTokenDoesNotMatchError, /Bad header line:.*does not match file name/) + end + end + + context "when it contains no DSL version" do + let(:token) { "no-dsl-version" } + + it "does not require a DSL version in the header" do + expect(cask.token).to eq("no-dsl-version") + expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") + expect(cask.homepage).to eq("http://example.com/") + expect(cask.version.to_s).to eq("1.2.3") + end + end + + context "when it contains a deprecated DSL version" do + let(:token) { "with-dsl-version" } + + it "may use deprecated DSL version hash syntax" do + allow(ENV).to receive(:[]).with("HOMEBREW_DEVELOPER").and_return(nil) + + shutup do + expect(cask.token).to eq("with-dsl-version") + expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") + expect(cask.homepage).to eq("http://example.com/") + expect(cask.version.to_s).to eq("1.2.3") + end + end + end + end + + describe "name stanza" do + it "lets you set the full name via a name stanza" do + cask = Hbc::Cask.new("name-cask") do + name "Proper Name" + end + + expect(cask.name).to eq([ + "Proper Name", + ]) + end + + it "Accepts an array value to the name stanza" do + cask = Hbc::Cask.new("array-name-cask") do + name ["Proper Name", "Alternate Name"] + end + + expect(cask.name).to eq([ + "Proper Name", + "Alternate Name", + ]) + end + + it "Accepts multiple name stanzas" do + cask = Hbc::Cask.new("multi-name-cask") do + name "Proper Name" + name "Alternate Name" + end + + expect(cask.name).to eq([ + "Proper Name", + "Alternate Name", + ]) + end + end + + describe "sha256 stanza" do + it "lets you set checksum via sha256" do + cask = Hbc::Cask.new("checksum-cask") do + sha256 "imasha2" + end + + expect(cask.sha256).to eq("imasha2") + end + end + + describe "language stanza" do + it "allows multilingual casks" do + cask = lambda do + Hbc::Cask.new("cask-with-apps") do + language "zh" do + sha256 "abc123" + "zh-CN" + end + + language "en-US", default: true do + sha256 "xyz789" + "en-US" + end + + url "https://example.org/#{language}.zip" + end + end + + allow(MacOS).to receive(:languages).and_return(["zh"]) + expect(cask.call.language).to eq("zh-CN") + expect(cask.call.sha256).to eq("abc123") + expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip") + + allow(MacOS).to receive(:languages).and_return(["zh-XX"]) + expect(cask.call.language).to eq("zh-CN") + expect(cask.call.sha256).to eq("abc123") + expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip") + + allow(MacOS).to receive(:languages).and_return(["en"]) + expect(cask.call.language).to eq("en-US") + expect(cask.call.sha256).to eq("xyz789") + expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip") + + allow(MacOS).to receive(:languages).and_return(["xx-XX"]) + expect(cask.call.language).to eq("en-US") + expect(cask.call.sha256).to eq("xyz789") + expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip") + + allow(MacOS).to receive(:languages).and_return(["xx-XX", "zh", "en"]) + expect(cask.call.language).to eq("zh-CN") + expect(cask.call.sha256).to eq("abc123") + expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip") + + allow(MacOS).to receive(:languages).and_return(["xx-XX", "en-US", "zh"]) + expect(cask.call.language).to eq("en-US") + expect(cask.call.sha256).to eq("xyz789") + expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip") + end + end + + describe "app stanza" do + it "allows you to specify app stanzas" do + cask = Hbc::Cask.new("cask-with-apps") do + app "Foo.app" + app "Bar.app" + end + + expect(Array(cask.artifacts[:app])).to eq([["Foo.app"], ["Bar.app"]]) + end + + it "allow app stanzas to be empty" do + cask = Hbc::Cask.new("cask-with-no-apps") + expect(Array(cask.artifacts[:app])).to eq([]) + end + end + + describe "caveats stanza" do + it "allows caveats to be specified via a method define" do + cask = Hbc::Cask.new("plain-cask") + + expect(cask.caveats).to be_empty + + cask = Hbc::Cask.new("cask-with-caveats") do + def caveats; <<-EOS.undent + When you install this Cask, you probably want to know this. + EOS + end + end + + expect(cask.caveats).to eq("When you install this Cask, you probably want to know this.\n") + end + end + + describe "pkg stanza" do + it "allows installable pkgs to be specified" do + cask = Hbc::Cask.new("cask-with-pkgs") do + pkg "Foo.pkg" + pkg "Bar.pkg" + end + + expect(Array(cask.artifacts[:pkg])).to eq([["Foo.pkg"], ["Bar.pkg"]]) + end + end + + describe "url stanza" do + let(:token) { "invalid/invalid-two-url" } + + it "prevents defining multiple urls" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'url' stanza may only appear once/) + end + end + + describe "homepage stanza" do + let(:token) { "invalid/invalid-two-homepage" } + + it "prevents defining multiple homepages" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'homepage' stanza may only appear once/) + end + end + + describe "version stanza" do + let(:token) { "invalid/invalid-two-version" } + it "prevents defining multiple versions" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'version' stanza may only appear once/) + end + end + + describe "appcast stanza" do + let(:token) { "with-appcast" } + + it "allows appcasts to be specified" do + expect(cask.appcast.to_s).to match(/^http/) + end + + context "when multiple appcasts are defined" do + let(:token) { "invalid/invalid-appcast-multiple" } + + it "raises an error" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'appcast' stanza may only appear once/) + end + end + + context "when appcast URL is invalid" do + let(:token) { "invalid/invalid-appcast-url" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + end + + describe "GPG stanza" do + context "valid" do + let(:token) { "with-gpg" } + + it "is allowed to be specified" do + expect(cask.gpg.to_s).to match(/\S/) + end + end + + context "with :key_url" do + let(:token) { "with-gpg-key-url" } + it "is allowed to be specified" do + expect(cask.gpg.to_s).to match(/\S/) + end + end + + context "specifying mmultiple times" do + let(:token) { "invalid/invalid-gpg-multiple-stanzas" } + + it "is not allowed" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza may only appear once/) + end + end + + context "missing GPG key parameters" do + let(:token) { "invalid/invalid-gpg-missing-key" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza must include exactly one/) + end + end + + context "conflicting GPG key parameters" do + let(:token) { "invalid/invalid-gpg-conflicting-keys" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza must include exactly one/) + end + end + + context "invalid GPG signature URLs" do + let(:token) { "invalid/invalid-gpg-signature-url" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + + context "invalid GPG key URLs" do + let(:token) { "invalid/invalid-gpg-key-url" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + + context "invalid GPG key IDs" do + let(:token) { "invalid/invalid-gpg-key-id" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + + context "GPG parameter is unknown" do + let(:token) { "invalid/invalid-gpg-parameter" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + end + + describe "depends_on stanza" do + let(:token) { "invalid/invalid-depends-on-key" } + + it "refuses to load with an invalid depends_on key" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + + describe "depends_on formula" do + context "with one Formula" do + let(:token) { "with-depends-on-formula" } + + it "allows depends_on formula to be specified" do + expect(cask.depends_on.formula).not_to be nil + end + end + + context "with multiple Formulae" do + let(:token) { "with-depends-on-formula-multiple" } + + it "allows multiple depends_on formula to be specified" do + expect(cask.depends_on.formula).not_to be nil + end + end + end + + describe "depends_on cask" do + context "specifying one" do + let(:token) { "with-depends-on-cask" } + it "is allowed" do + expect(cask.depends_on.cask).not_to be nil + end + end + + context "specifying multiple" do + let(:token) { "with-depends-on-cask-multiple" } + + it "is allowed" do + expect(cask.depends_on.cask).not_to be nil + end + end + end + + describe "depends_on macos" do + context "valid" do + let(:token) { "with-depends-on-macos-string" } + + it "allows depends_on macos to be specified" do + expect(cask.depends_on.macos).not_to be nil + end + end + + context "invalid depends_on macos value" do + let(:token) { "invalid/invalid-depends-on-macos-bad-release" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + + context "conflicting depends_on macos forms" do + let(:token) { "invalid/invalid-depends-on-macos-conflicting-forms" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + end + + describe "depends_on arch" do + context "valid" do + let(:token) { "with-depends-on-arch" } + + it "is allowed to be specified" do + expect(cask.depends_on.arch).not_to be nil + end + end + + context "invalid depends_on arch value" do + let(:token) { "invalid/invalid-depends-on-arch-value" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + end + + describe "depends_on x11" do + context "valid" do + let(:token) { "with-depends-on-x11" } + + it "is allowed to be specified" do + expect(cask.depends_on.x11).not_to be nil + end + end + + context "invalid depends_on x11 value" do + let(:token) { "invalid/invalid-depends-on-x11-value" } + + it "refuses to load" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + end + + describe "conflicts_with stanza" do + context "valid" do + let(:token) { "with-conflicts-with" } + + it "allows conflicts_with stanza to be specified" do + expect(cask.conflicts_with.formula).not_to be nil + end + end + + context "invalid conflicts_with key" do + let(:token) { "invalid/invalid-conflicts-with-key" } + + it "refuses to load invalid conflicts_with key" do + expect { cask }.to raise_error(Hbc::CaskInvalidError) + end + end + end + + describe "installer stanza" do + context "script" do + let(:token) { "with-installer-script" } + + it "allows installer script to be specified" do + expect(cask.artifacts[:installer].first.script[:executable]).to eq("/usr/bin/true") + expect(cask.artifacts[:installer].first.script[:args]).to eq(["--flag"]) + expect(cask.artifacts[:installer].to_a[1].script[:executable]).to eq("/usr/bin/false") + expect(cask.artifacts[:installer].to_a[1].script[:args]).to eq(["--flag"]) + end + end + + context "manual" do + let(:token) { "with-installer-manual" } + + it "allows installer manual to be specified" do + expect(cask.artifacts[:installer].first.manual).to eq("Caffeine.app") + end + end + end + + describe "stage_only stanza" do + context "when there is no other activatable artifact" do + let(:token) { "stage-only" } + + it "allows stage_only stanza to be specified" do + expect(cask.artifacts[:stage_only].first).to eq([true]) + end + end + + context "when there is are activatable artifacts" do + let(:token) { "invalid/invalid-stage-only-conflict" } + + it "prevents specifying stage_only" do + expect { cask }.to raise_error(Hbc::CaskInvalidError, /'stage_only' must be the only activatable artifact/) + end + end + end + + describe "auto_updates stanza" do + let(:token) { "auto-updates" } + + it "allows auto_updates stanza to be specified" do + expect(cask.auto_updates).to be true + end + end + + describe "appdir" do + context "interpolation of the appdir in stanzas" do + let(:token) { "appdir-interpolation" } + + it "is allowed" do + expect(cask.artifacts[:binary].first).to eq(["#{Hbc.appdir}/some/path"]) + end + end + + it "does not include a trailing slash" do + begin + original_appdir = Hbc.appdir + Hbc.appdir = "#{original_appdir}/" + + cask = Hbc::Cask.new("appdir-trailing-slash") do + binary "#{appdir}/some/path" + end + + expect(cask.artifacts[:binary].first).to eq(["#{original_appdir}/some/path"]) + ensure + Hbc.appdir = original_appdir + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb deleted file mode 100644 index cdd06a836..000000000 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ /dev/null @@ -1,479 +0,0 @@ -require "test_helper" - -describe Hbc::DSL do - it "lets you set url, homepage, and version" do - test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") - test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" - test_cask.homepage.must_equal "http://example.com/" - test_cask.version.to_s.must_equal "1.2.3" - end - - describe "when a Cask includes an unknown method" do - attempt_unknown_method = nil - - before do - attempt_unknown_method = lambda do - Hbc::Cask.new("unexpected-method-cask") do - future_feature :not_yet_on_your_machine - end - end - end - - it "prints a warning that it has encountered an unexpected method" do - expected = Regexp.compile(<<-EOS.undent.lines.map(&:chomp).join("")) - (?m) - Warning: - .* - Unexpected method 'future_feature' called on Cask unexpected-method-cask\\. - .* - https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md - .* - https://github.com/caskroom/homebrew-cask#reporting-bugs - EOS - - attempt_unknown_method.must_output nil, expected - end - - it "will simply warn, not throw an exception" do - begin - shutup do - attempt_unknown_method.call - end - rescue StandardError => e - flunk("Wanted unexpected method to simply warn, but got exception #{e}") - end - end - end - - describe "header line" do - it "requires a valid header format" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-header-format.rb") - }.must_raise(SyntaxError) - end - - it "requires the header token to match the file name" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-header-token-mismatch.rb") - }.must_raise(Hbc::CaskTokenDoesNotMatchError) - err.message.must_include "Bad header line:" - err.message.must_include "does not match file name" - end - - it "does not require a DSL version in the header" do - test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-dsl-version.rb") - test_cask.token.must_equal "no-dsl-version" - test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" - test_cask.homepage.must_equal "http://example.com/" - test_cask.version.to_s.must_equal "1.2.3" - end - - it "may use deprecated DSL version hash syntax" do - stub = proc do |arg| - arg == "HOMEBREW_DEVELOPER" ? nil : ENV[arg] - end - - ENV.stub :[], stub do - shutup do - test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-dsl-version.rb") - test_cask.token.must_equal "with-dsl-version" - test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg" - test_cask.homepage.must_equal "http://example.com/" - test_cask.version.to_s.must_equal "1.2.3" - end - end - end - end - - describe "name stanza" do - it "lets you set the full name via a name stanza" do - cask = Hbc::Cask.new("name-cask") do - name "Proper Name" - end - - cask.name.must_equal [ - "Proper Name", - ] - end - - it "Accepts an array value to the name stanza" do - cask = Hbc::Cask.new("array-name-cask") do - name ["Proper Name", "Alternate Name"] - end - - cask.name.must_equal [ - "Proper Name", - "Alternate Name", - ] - end - - it "Accepts multiple name stanzas" do - cask = Hbc::Cask.new("multi-name-cask") do - name "Proper Name" - name "Alternate Name" - end - - cask.name.must_equal [ - "Proper Name", - "Alternate Name", - ] - end - end - - describe "sha256 stanza" do - it "lets you set checksum via sha256" do - cask = Hbc::Cask.new("checksum-cask") do - sha256 "imasha2" - end - - cask.sha256.must_equal "imasha2" - end - end - - describe "language stanza" do - it "allows multilingual casks" do - cask = lambda do - Hbc::Cask.new("cask-with-apps") do - language "zh" do - sha256 "abc123" - "zh-CN" - end - - language "en-US", default: true do - sha256 "xyz789" - "en-US" - end - - url "https://example.org/#{language}.zip" - end - end - - MacOS.stub :languages, ["zh"] do - cask.call.language.must_equal "zh-CN" - cask.call.sha256.must_equal "abc123" - cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip" - end - - MacOS.stub :languages, ["zh-XX"] do - cask.call.language.must_equal "zh-CN" - cask.call.sha256.must_equal "abc123" - cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip" - end - - MacOS.stub :languages, ["en"] do - cask.call.language.must_equal "en-US" - cask.call.sha256.must_equal "xyz789" - cask.call.url.to_s.must_equal "https://example.org/en-US.zip" - end - - MacOS.stub :languages, ["xx-XX"] do - cask.call.language.must_equal "en-US" - cask.call.sha256.must_equal "xyz789" - cask.call.url.to_s.must_equal "https://example.org/en-US.zip" - end - - MacOS.stub :languages, ["xx-XX", "zh", "en"] do - cask.call.language.must_equal "zh-CN" - cask.call.sha256.must_equal "abc123" - cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip" - end - - MacOS.stub :languages, ["xx-XX", "en-US", "zh"] do - cask.call.language.must_equal "en-US" - cask.call.sha256.must_equal "xyz789" - cask.call.url.to_s.must_equal "https://example.org/en-US.zip" - end - end - end - - describe "app stanza" do - it "allows you to specify app stanzas" do - cask = Hbc::Cask.new("cask-with-apps") do - app "Foo.app" - app "Bar.app" - end - - Array(cask.artifacts[:app]).must_equal [["Foo.app"], ["Bar.app"]] - end - - it "allow app stanzas to be empty" do - cask = Hbc::Cask.new("cask-with-no-apps") - Array(cask.artifacts[:app]).must_equal %w[] - end - end - - describe "caveats stanza" do - it "allows caveats to be specified via a method define" do - cask = Hbc::Cask.new("plain-cask") - - cask.caveats.must_be :empty? - - cask = Hbc::Cask.new("cask-with-caveats") do - def caveats; <<-EOS.undent - When you install this Cask, you probably want to know this. - EOS - end - end - - cask.caveats.must_equal "When you install this Cask, you probably want to know this.\n" - end - end - - describe "pkg stanza" do - it "allows installable pkgs to be specified" do - cask = Hbc::Cask.new("cask-with-pkgs") do - pkg "Foo.pkg" - pkg "Bar.pkg" - end - - Array(cask.artifacts[:pkg]).must_equal [["Foo.pkg"], ["Bar.pkg"]] - end - end - - describe "url stanza" do - it "prevents defining multiple urls" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-url.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'url' stanza may only appear once" - end - end - - describe "homepage stanza" do - it "prevents defining multiple homepages" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-homepage.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'homepage' stanza may only appear once" - end - end - - describe "version stanza" do - it "prevents defining multiple versions" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-version.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'version' stanza may only appear once" - end - end - - describe "appcast stanza" do - it "allows appcasts to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-appcast.rb") - cask.appcast.to_s.must_match(/^http/) - end - - it "prevents defining multiple appcasts" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-appcast-multiple.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'appcast' stanza may only appear once" - end - - it "refuses to load invalid appcast URLs" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-appcast-url.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "gpg stanza" do - it "allows gpg stanza to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-gpg.rb") - cask.gpg.to_s.must_match(/\S/) - end - - it "allows gpg stanza to be specified with :key_url" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-gpg-key-url.rb") - cask.gpg.to_s.must_match(/\S/) - end - - it "prevents specifying gpg stanza multiple times" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'gpg' stanza may only appear once" - end - - it "prevents missing gpg key parameters" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-missing-key.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'gpg' stanza must include exactly one" - end - - it "prevents conflicting gpg key parameters" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-conflicting-keys.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'gpg' stanza must include exactly one" - end - - it "refuses to load invalid gpg signature URLs" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-signature-url.rb") - }.must_raise(Hbc::CaskInvalidError) - end - - it "refuses to load invalid gpg key URLs" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-key-url.rb") - }.must_raise(Hbc::CaskInvalidError) - end - - it "refuses to load invalid gpg key IDs" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-key-id.rb") - }.must_raise(Hbc::CaskInvalidError) - end - - it "refuses to load if gpg parameter is unknown" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-parameter.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "depends_on stanza" do - it "refuses to load with an invalid depends_on key" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-key.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "depends_on formula" do - it "allows depends_on formula to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-formula.rb") - cask.depends_on.formula.wont_be_nil - end - - it "allows multiple depends_on formula to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-formula-multiple.rb") - cask.depends_on.formula.wont_be_nil - end - end - - describe "depends_on cask" do - it "allows depends_on cask to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") - cask.depends_on.cask.wont_be_nil - end - - it "allows multiple depends_on cask to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb") - cask.depends_on.cask.wont_be_nil - end - end - - describe "depends_on macos" do - it "allows depends_on macos to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") - cask.depends_on.macos.wont_be_nil - end - it "refuses to load with an invalid depends_on macos value" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb") - }.must_raise(Hbc::CaskInvalidError) - end - it "refuses to load with conflicting depends_on macos forms" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "depends_on arch" do - it "allows depends_on arch to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") - cask.depends_on.arch.wont_be_nil - end - it "refuses to load with an invalid depends_on arch value" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-arch-value.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "depends_on x11" do - it "allows depends_on x11 to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") - cask.depends_on.x11.wont_be_nil - end - it "refuses to load with an invalid depends_on x11 value" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-x11-value.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "conflicts_with stanza" do - it "allows conflicts_with stanza to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-conflicts-with.rb") - cask.conflicts_with.formula.wont_be_nil - end - - it "refuses to load invalid conflicts_with key" do - lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-conflicts-with-key.rb") - }.must_raise(Hbc::CaskInvalidError) - end - end - - describe "installer stanza" do - it "allows installer script to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-script.rb") - cask.artifacts[:installer].first.script[:executable].must_equal "/usr/bin/true" - cask.artifacts[:installer].first.script[:args].must_equal ["--flag"] - cask.artifacts[:installer].to_a[1].script[:executable].must_equal "/usr/bin/false" - cask.artifacts[:installer].to_a[1].script[:args].must_equal ["--flag"] - end - it "allows installer manual to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") - cask.artifacts[:installer].first.manual.must_equal "Caffeine.app" - end - end - - describe "stage_only stanza" do - it "allows stage_only stanza to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/stage-only.rb") - cask.artifacts[:stage_only].first.must_equal [true] - end - - it "prevents specifying stage_only with other activatables" do - err = lambda { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-stage-only-conflict.rb") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'stage_only' must be the only activatable artifact" - end - end - - describe "auto_updates stanza" do - it "allows auto_updates stanza to be specified" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - cask.auto_updates.must_equal true - end - end - - describe "appdir" do - it "allows interpolation of the appdir value in stanzas" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/appdir-interpolation.rb") - cask.artifacts[:binary].first.must_equal ["#{Hbc.appdir}/some/path"] - end - - it "does not include a trailing slash" do - original_appdir = Hbc.appdir - Hbc.appdir = "#{original_appdir}/" - - begin - cask = Hbc::Cask.new("appdir-trailing-slash") do - binary "#{appdir}/some/path" - end - - cask.artifacts[:binary].first.must_equal ["#{original_appdir}/some/path"] - ensure - Hbc.appdir = original_appdir - end - end - end -end -- cgit v1.2.3 From d197e79d35c121fbd79491886cf6d13b8037faef Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 11:52:20 +0100 Subject: Convert `Installer` test to spec. --- Library/Homebrew/cask/spec/cask/installer_spec.rb | 398 +++++++++++++++++++++ Library/Homebrew/cask/test/cask/installer_test.rb | 401 ---------------------- 2 files changed, 398 insertions(+), 401 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/installer_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/installer_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/installer_spec.rb b/Library/Homebrew/cask/spec/cask/installer_spec.rb new file mode 100644 index 000000000..c0148c387 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/installer_spec.rb @@ -0,0 +1,398 @@ +require "spec_helper" + +describe Hbc::Installer do + describe "install" do + let(:empty_depends_on_stub) { + double(formula: [], cask: [], macos: nil, arch: nil, x11: nil) + } + + it "downloads and installs a nice fresh Cask" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + + shutup do + Hbc::Installer.new(caffeine).install + end + + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory + expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory + end + + it "works with dmg-based Casks" do + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb") + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with tar-gz-based Casks" do + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb") + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with cab-based Casks" do + skip("cabextract not installed") if which("cabextract").nil? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-cab.rb") + + allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-cab", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with Adobe AIR-based Casks" do + skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-air.rb") + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-air", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container.app")).to be_a_directory + end + + it "works with 7z-based Casks" do + skip("unar not installed") if which("unar").nil? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-7z.rb") + + allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-7z", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with xar-based Casks" do + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb") + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with Stuffit-based Casks" do + skip("unar not installed") if which("unar").nil? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-sit.rb") + + allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-sit", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with RAR-based Casks" do + skip("unar not installed") if which("unar").nil? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-rar.rb") + + allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-rar", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with pure bzip2-based Casks" do + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb") + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).to be_a_file + end + + it "works with pure gzip-based Casks" do + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb") + + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container")).to be_a_file + end + + it "works with pure xz-based Casks" do + skip("unxz not installed") if which("unxz").nil? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xz.rb") + + allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-xz", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container-xz--#{asset.version}")).to be_a_file + end + + it "works with lzma-based Casks" do + skip("unlzma not installed") if which("unlzma").nil? + asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-lzma.rb") + + allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub) + shutup do + Hbc::Installer.new(asset).install + end + + expect(Hbc.caskroom.join("container-lzma", asset.version)).to be_a_directory + expect(Hbc.appdir.join("container-lzma--#{asset.version}")).to be_a_file + end + + it "blows up on a bad checksum" do + bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") + expect { + shutup do + Hbc::Installer.new(bad_checksum).install + end + }.to raise_error(Hbc::CaskSha256MismatchError) + end + + it "blows up on a missing checksum" do + missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") + expect { + shutup do + Hbc::Installer.new(missing_checksum).install + end + }.to raise_error(Hbc::CaskSha256MissingError) + end + + it "installs fine if sha256 :no_check is used" do + no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + + shutup do + Hbc::Installer.new(no_checksum).install + end + + expect(no_checksum).to be_installed + end + + it "fails to install if sha256 :no_check is used with --require-sha" do + no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + expect { + Hbc::Installer.new(no_checksum, require_sha: true).install + }.to raise_error(Hbc::CaskNoShasumError) + end + + it "installs fine if sha256 :no_check is used with --require-sha and --force" do + no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + + shutup do + Hbc::Installer.new(no_checksum, require_sha: true, force: true).install + end + + expect(no_checksum).to be_installed + end + + it "prints caveats if they're present" do + with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb") + + expect { + Hbc::Installer.new(with_caveats).install + }.to output(/Here are some things you might want to know/).to_stdout + + expect(with_caveats).to be_installed + end + + it "prints installer :manual instructions when present" do + with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") + + expect { + Hbc::Installer.new(with_installer_manual).install + }.to output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/).to_stdout + + expect(with_installer_manual).to be_installed + end + + it "does not extract __MACOSX directories from zips" do + with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb") + + shutup do + Hbc::Installer.new(with_macosx_dir).install + end + + expect(with_macosx_dir.staged_path.join("__MACOSX")).not_to be_a_directory + end + + it "installer method raises an exception when already-installed Casks which auto-update are attempted" do + with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") + + expect(with_auto_updates).not_to be_installed + + installer = Hbc::Installer.new(with_auto_updates) + + shutup do + installer.install + end + + expect { + installer.install + }.to raise_error(Hbc::CaskAlreadyInstalledAutoUpdatesError) + end + + it "allows already-installed Casks which auto-update to be installed if force is provided" do + with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") + + expect(with_auto_updates).not_to be_installed + + shutup do + Hbc::Installer.new(with_auto_updates).install + end + + expect { + shutup do + Hbc::Installer.new(with_auto_updates, force: true).install + end + }.not_to raise_error + end + + # unlike the CLI, the internal interface throws exception on double-install + it "installer method raises an exception when already-installed Casks are attempted" do + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + + expect(transmission).not_to be_installed + + installer = Hbc::Installer.new(transmission) + + shutup do + installer.install + end + + expect { + installer.install + }.to raise_error(Hbc::CaskAlreadyInstalledError) + end + + it "allows already-installed Casks to be installed if force is provided" do + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + + expect(transmission).not_to be_installed + + shutup do + Hbc::Installer.new(transmission).install + end + + shutup do + Hbc::Installer.new(transmission, force: true).install + end # wont_raise + end + + it "works naked-pkg-based Casks" do + naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb") + + shutup do + Hbc::Installer.new(naked_pkg).install + end + + expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file + end + + it "works properly with an overridden container :type" do + naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb") + + shutup do + Hbc::Installer.new(naked_executable).install + end + + expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file + end + + it "works fine with a nested container" do + nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb") + + shutup do + Hbc::Installer.new(nested_app).install + end + + expect(Hbc.appdir.join("MyNestedApp.app")).to be_a_directory + end + + it "generates and finds a timestamped metadata directory for an installed Cask" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + + shutup do + Hbc::Installer.new(caffeine).install + end + + m_path = caffeine.metadata_path(:now, true) + expect(caffeine.metadata_path(:now, false)).to eq(m_path) + expect(caffeine.metadata_path(:latest)).to eq(m_path) + end + + it "generates and finds a metadata subdirectory for an installed Cask" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + + shutup do + Hbc::Installer.new(caffeine).install + end + + subdir_name = "Casks" + m_subdir = caffeine.metadata_subdir(subdir_name, :now, true) + expect(caffeine.metadata_subdir(subdir_name, :now, false)).to eq(m_subdir) + expect(caffeine.metadata_subdir(subdir_name, :latest)).to eq(m_subdir) + end + end + + describe "uninstall" do + it "fully uninstalls a Cask" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + installer = Hbc::Installer.new(caffeine) + + shutup do + installer.install + installer.uninstall + end + + expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory + expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory + end + + it "uninstalls all versions if force is set" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + mutated_version = caffeine.version + ".1" + + shutup do + Hbc::Installer.new(caffeine).install + end + + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory + expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory + FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version)) + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory + expect(Hbc.caskroom.join("local-caffeine", mutated_version)).to be_a_directory + + shutup do + Hbc::Installer.new(caffeine, force: true).uninstall + end + + expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory + expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory + expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory + end + end +end diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb deleted file mode 100644 index 17629dce2..000000000 --- a/Library/Homebrew/cask/test/cask/installer_test.rb +++ /dev/null @@ -1,401 +0,0 @@ -require "test_helper" - -describe Hbc::Installer do - describe "install" do - let(:empty_depends_on_stub) { - stub(formula: [], cask: [], macos: nil, arch: nil, x11: nil) - } - - it "downloads and installs a nice fresh Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - - shutup do - Hbc::Installer.new(caffeine).install - end - - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).must_be :directory? - expect(Hbc.appdir.join("Caffeine.app")).must_be :directory? - end - - it "works with dmg-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb") - - shutup do - Hbc::Installer.new(asset).install - end - - expect(Hbc.caskroom.join("container-dmg", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with tar-gz-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb") - - shutup do - Hbc::Installer.new(asset).install - end - - expect(Hbc.caskroom.join("container-tar-gz", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with cab-based Casks" do - skip("cabextract not installed") if which("cabextract").nil? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-cab.rb") - - asset.stub :depends_on, empty_depends_on_stub do - shutup do - Hbc::Installer.new(asset).install - end - end - - expect(Hbc.caskroom.join("container-cab", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with Adobe AIR-based Casks" do - skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-air.rb") - - shutup do - Hbc::Installer.new(asset).install - end - - expect(Hbc.caskroom.join("container-air", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container.app")).must_be :directory? - end - - it "works with 7z-based Casks" do - skip("unar not installed") if which("unar").nil? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-7z.rb") - - asset.stub :depends_on, empty_depends_on_stub do - shutup do - Hbc::Installer.new(asset).install - end - end - - expect(Hbc.caskroom.join("container-7z", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with xar-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb") - - shutup do - Hbc::Installer.new(asset).install - end - - expect(Hbc.caskroom.join("container-xar", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with Stuffit-based Casks" do - skip("unar not installed") if which("unar").nil? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-sit.rb") - - asset.stub :depends_on, empty_depends_on_stub do - shutup do - Hbc::Installer.new(asset).install - end - end - - expect(Hbc.caskroom.join("container-sit", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with RAR-based Casks" do - skip("unar not installed") if which("unar").nil? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-rar.rb") - - asset.stub :depends_on, empty_depends_on_stub do - shutup do - Hbc::Installer.new(asset).install - end - end - - expect(Hbc.caskroom.join("container-rar", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with pure bzip2-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb") - - shutup do - Hbc::Installer.new(asset).install - end - - expect(Hbc.caskroom.join("container-bzip2", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).must_be :file? - end - - it "works with pure gzip-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb") - - shutup do - Hbc::Installer.new(asset).install - end - - expect(Hbc.caskroom.join("container-gzip", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container")).must_be :file? - end - - it "works with pure xz-based Casks" do - skip("unxz not installed") if which("unxz").nil? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xz.rb") - - asset.stub :depends_on, empty_depends_on_stub do - shutup do - Hbc::Installer.new(asset).install - end - end - - expect(Hbc.caskroom.join("container-xz", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container-xz--#{asset.version}")).must_be :file? - end - - it "works with lzma-based Casks" do - skip("unlzma not installed") if which("unlzma").nil? - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-lzma.rb") - - asset.stub :depends_on, empty_depends_on_stub do - shutup do - Hbc::Installer.new(asset).install - end - end - - expect(Hbc.caskroom.join("container-lzma", asset.version)).must_be :directory? - expect(Hbc.appdir.join("container-lzma--#{asset.version}")).must_be :file? - end - - it "blows up on a bad checksum" do - bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") - expect { - shutup do - Hbc::Installer.new(bad_checksum).install - end - }.must_raise(Hbc::CaskSha256MismatchError) - end - - it "blows up on a missing checksum" do - missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") - expect { - shutup do - Hbc::Installer.new(missing_checksum).install - end - }.must_raise(Hbc::CaskSha256MissingError) - end - - it "installs fine if sha256 :no_check is used" do - no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") - - shutup do - Hbc::Installer.new(no_checksum).install - end - - expect(no_checksum).must_be :installed? - end - - it "fails to install if sha256 :no_check is used with --require-sha" do - no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") - expect { - Hbc::Installer.new(no_checksum, require_sha: true).install - }.must_raise(Hbc::CaskNoShasumError) - end - - it "installs fine if sha256 :no_check is used with --require-sha and --force" do - no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") - - shutup do - Hbc::Installer.new(no_checksum, require_sha: true, force: true).install - end - - expect(no_checksum).must_be :installed? - end - - it "prints caveats if they're present" do - with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb") - - expect { - Hbc::Installer.new(with_caveats).install - }.must_output(/Here are some things you might want to know/) - - expect(with_caveats).must_be :installed? - end - - it "prints installer :manual instructions when present" do - with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") - - expect { - Hbc::Installer.new(with_installer_manual).install - }.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/) - - expect(with_installer_manual).must_be :installed? - end - - it "does not extract __MACOSX directories from zips" do - with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb") - - shutup do - Hbc::Installer.new(with_macosx_dir).install - end - - expect(with_macosx_dir.staged_path.join("__MACOSX")).wont_be :directory? - end - - it "installer method raises an exception when already-installed Casks which auto-update are attempted" do - with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - - expect(with_auto_updates).wont_be :installed? - - installer = Hbc::Installer.new(with_auto_updates) - - shutup do - installer.install - end - - expect { - installer.install - }.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError) - end - - it "allows already-installed Casks which auto-update to be installed if force is provided" do - with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - - expect(with_auto_updates).wont_be :installed? - - shutup do - Hbc::Installer.new(with_auto_updates).install - end - - shutup do - Hbc::Installer.new(with_auto_updates, force: true).install - end # wont_raise - end - - # unlike the CLI, the internal interface throws exception on double-install - it "installer method raises an exception when already-installed Casks are attempted" do - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - - expect(transmission).wont_be :installed? - - installer = Hbc::Installer.new(transmission) - - shutup do - installer.install - end - - expect { - installer.install - }.must_raise(Hbc::CaskAlreadyInstalledError) - end - - it "allows already-installed Casks to be installed if force is provided" do - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - - expect(transmission).wont_be :installed? - - shutup do - Hbc::Installer.new(transmission).install - end - - shutup do - Hbc::Installer.new(transmission, force: true).install - end # wont_raise - end - - it "works naked-pkg-based Casks" do - naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb") - - shutup do - Hbc::Installer.new(naked_pkg).install - end - - expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).must_be :file? - end - - it "works properly with an overridden container :type" do - naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb") - - shutup do - Hbc::Installer.new(naked_executable).install - end - - expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).must_be :file? - end - - it "works fine with a nested container" do - nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb") - - shutup do - Hbc::Installer.new(nested_app).install - end - - expect(Hbc.appdir.join("MyNestedApp.app")).must_be :directory? - end - - it "generates and finds a timestamped metadata directory for an installed Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - - shutup do - Hbc::Installer.new(caffeine).install - end - - m_path = caffeine.metadata_path(:now, true) - expect(caffeine.metadata_path(:now, false)).must_equal(m_path) - expect(caffeine.metadata_path(:latest)).must_equal(m_path) - end - - it "generates and finds a metadata subdirectory for an installed Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - - shutup do - Hbc::Installer.new(caffeine).install - end - - subdir_name = "Casks" - m_subdir = caffeine.metadata_subdir(subdir_name, :now, true) - expect(caffeine.metadata_subdir(subdir_name, :now, false)).must_equal(m_subdir) - expect(caffeine.metadata_subdir(subdir_name, :latest)).must_equal(m_subdir) - end - end - - describe "uninstall" do - it "fully uninstalls a Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - installer = Hbc::Installer.new(caffeine) - - shutup do - installer.install - installer.uninstall - end - - expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).wont_be :directory? - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory? - expect(Hbc.caskroom.join("local-caffeine")).wont_be :directory? - end - - it "uninstalls all versions if force is set" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - mutated_version = caffeine.version + ".1" - - shutup do - Hbc::Installer.new(caffeine).install - end - - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).must_be :directory? - expect(Hbc.caskroom.join("local-caffeine", mutated_version)).wont_be :directory? - FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version)) - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory? - expect(Hbc.caskroom.join("local-caffeine", mutated_version)).must_be :directory? - - shutup do - Hbc::Installer.new(caffeine, force: true).uninstall - end - - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory? - expect(Hbc.caskroom.join("local-caffeine", mutated_version)).wont_be :directory? - expect(Hbc.caskroom.join("local-caffeine")).wont_be :directory? - end - end -end -- cgit v1.2.3 From 9e31b51cb0f14ca8e9491de90248532fc44f123f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 11:58:34 +0100 Subject: Convert Audit test to spec. --- Library/Homebrew/cask/spec/cask/cli/audit_spec.rb | 61 +++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/audit_test.rb | 64 ----------------------- 2 files changed, 61 insertions(+), 64 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/audit_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/audit_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb new file mode 100644 index 000000000..b520a88df --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb @@ -0,0 +1,61 @@ +require "spec_helper" + +describe Hbc::CLI::Audit do + let(:auditor) { double } + let(:cask) { double } + + describe "selection of Casks to audit" do + it "audits all Casks if no tokens are given" do + allow(Hbc).to receive(:all).and_return([cask, cask]) + + expect(auditor).to receive(:audit).twice + + run_audit([], auditor) + end + + it "audits specified Casks if tokens are given" do + cask_token = "nice-app" + expect(Hbc).to receive(:load).with(cask_token).and_return(cask) + + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + + run_audit([cask_token], auditor) + end + end + + describe "rules for downloading a Cask" do + it "does not download the Cask per default" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + + run_audit(["casktoken"], auditor) + end + + it "download a Cask if --download flag is set" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: true, check_token_conflicts: false) + + run_audit(["casktoken", "--download"], auditor) + end + end + + describe "rules for checking token conflicts" do + it "does not check for token conflicts per default" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false) + + run_audit(["casktoken"], auditor) + end + + it "checks for token conflicts if --token-conflicts flag is set" do + allow(Hbc).to receive(:load).and_return(cask) + expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: true) + + run_audit(["casktoken", "--token-conflicts"], auditor) + end + end + + def run_audit(args, auditor) + Hbc::CLI::Audit.new(args, auditor).run + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/audit_test.rb b/Library/Homebrew/cask/test/cask/cli/audit_test.rb deleted file mode 100644 index 89a7d140a..000000000 --- a/Library/Homebrew/cask/test/cask/cli/audit_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Audit do - let(:auditor) { mock } - let(:cask) { mock } - - describe "selection of Casks to audit" do - it "audits all Casks if no tokens are given" do - Hbc.stub :all, [cask, cask] do - auditor.expects(:audit).times(2) - - run_audit([], auditor) - end - end - - it "audits specified Casks if tokens are given" do - cask_token = "nice-app" - Hbc.expects(:load).with(cask_token).returns(cask) - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - - run_audit([cask_token], auditor) - end - end - - describe "rules for downloading a Cask" do - it "does not download the Cask per default" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - - run_audit(["casktoken"], auditor) - end - end - - it "download a Cask if --download flag is set" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: true, check_token_conflicts: false) - - run_audit(["casktoken", "--download"], auditor) - end - end - end - - describe "rules for checking token conflicts" do - it "does not check for token conflicts per default" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false) - - run_audit(["casktoken"], auditor) - end - end - - it "checks for token conflicts if --token-conflicts flag is set" do - Hbc.stub :load, cask do - auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: true) - - run_audit(["casktoken", "--token-conflicts"], auditor) - end - end - end - - def run_audit(args, auditor) - Hbc::CLI::Audit.new(args, auditor).run - end -end -- cgit v1.2.3 From 2ade29a5cf5df84ed9fb7dcf429c59c3e084a6a1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:01:03 +0100 Subject: Convert Cat test to spec. --- Library/Homebrew/cask/spec/cask/cli/cat_spec.rb | 59 +++++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/cat_test.rb | 59 ------------------------- 2 files changed, 59 insertions(+), 59 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/cat_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/cat_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb b/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb new file mode 100644 index 000000000..7517c1b5c --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb @@ -0,0 +1,59 @@ +require "spec_helper" + +describe Hbc::CLI::Cat do + describe "given a basic Cask" do + let(:expected_output) { + <<-EOS.undent + cask 'basic-cask' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url 'http://example.com/TestCask.dmg' + homepage 'http://example.com/' + + app 'TestCask.app' + end + EOS + } + + it "displays the Cask file content about the specified Cask" do + expect { + Hbc::CLI::Cat.run("basic-cask") + }.to output(expected_output).to_stdout + end + + it "throws away additional Cask arguments and uses the first" do + expect { + Hbc::CLI::Cat.run("basic-cask", "local-caffeine") + }.to output(expected_output).to_stdout + end + + it "throws away stray options" do + expect { + Hbc::CLI::Cat.run("--notavalidoption", "basic-cask") + }.to output(expected_output).to_stdout + end + end + + it "raises an exception when the Cask does not exist" do + expect { + Hbc::CLI::Cat.run("notacask") + }.to raise_error(Hbc::CaskUnavailableError) + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Cat.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Cat.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/cat_test.rb b/Library/Homebrew/cask/test/cask/cli/cat_test.rb deleted file mode 100644 index 2eca9cfe9..000000000 --- a/Library/Homebrew/cask/test/cask/cli/cat_test.rb +++ /dev/null @@ -1,59 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Cat do - describe "given a basic Cask" do - before do - @expected_output = <<-EOS.undent - cask 'basic-cask' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url 'http://example.com/TestCask.dmg' - homepage 'http://example.com/' - - app 'TestCask.app' - end - EOS - end - - it "displays the Cask file content about the specified Cask" do - lambda { - Hbc::CLI::Cat.run("basic-cask") - }.must_output(@expected_output) - end - - it "throws away additional Cask arguments and uses the first" do - lambda { - Hbc::CLI::Cat.run("basic-cask", "local-caffeine") - }.must_output(@expected_output) - end - - it "throws away stray options" do - lambda { - Hbc::CLI::Cat.run("--notavalidoption", "basic-cask") - }.must_output(@expected_output) - end - end - - it "raises an exception when the Cask does not exist" do - lambda { - Hbc::CLI::Cat.run("notacask") - }.must_raise Hbc::CaskUnavailableError - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Cat.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Cat.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From dcb206dd1ef1be09f75774c0f86692ad3e31c679 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:05:42 +0100 Subject: Convert Create test to spec. --- Library/Homebrew/cask/spec/cask/cli/create_spec.rb | 100 +++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/create_test.rb | 100 --------------------- 2 files changed, 100 insertions(+), 100 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/create_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/create_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/create_spec.rb b/Library/Homebrew/cask/spec/cask/cli/create_spec.rb new file mode 100644 index 000000000..e3d484d87 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/create_spec.rb @@ -0,0 +1,100 @@ +require "spec_helper" + +# monkeypatch for testing +module Hbc + class CLI + class Create + def self.exec_editor(*command) + editor_commands << command + end + + def self.reset! + @editor_commands = [] + end + + def self.editor_commands + @editor_commands ||= [] + end + end + end +end + +describe Hbc::CLI::Create do + before(:each) do + Hbc::CLI::Create.reset! + end + + after(:each) do + %w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask| + path = Hbc.path(cask) + path.delete if path.exist? + end + end + + it "opens the editor for the specified Cask" do + Hbc::CLI::Create.run("new-cask") + expect(Hbc::CLI::Create.editor_commands).to eq [ + [Hbc.path("new-cask")], + ] + end + + it "drops a template down for the specified Cask" do + Hbc::CLI::Create.run("new-cask") + template = File.read(Hbc.path("new-cask")) + expect(template).to eq <<-EOS.undent + cask 'new-cask' do + version '' + sha256 '' + + url 'https://' + name '' + homepage '' + + app '' + end + EOS + end + + it "throws away additional Cask arguments and uses the first" do + Hbc::CLI::Create.run("additional-cask", "another-cask") + expect(Hbc::CLI::Create.editor_commands).to eq [ + [Hbc.path("additional-cask")], + ] + end + + it "throws away stray options" do + Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask") + expect(Hbc::CLI::Create.editor_commands).to eq [ + [Hbc.path("yet-another-cask")], + ] + end + + it "raises an exception when the Cask already exists" do + expect { + Hbc::CLI::Create.run("basic-cask") + }.to raise_error(Hbc::CaskAlreadyCreatedError) + end + + it "allows creating Casks that are substrings of existing Casks" do + Hbc::CLI::Create.run("local-caff") + expect(Hbc::CLI::Create.editor_commands).to eq [ + [Hbc.path("local-caff")], + ] + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Create.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Create.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/create_test.rb b/Library/Homebrew/cask/test/cask/cli/create_test.rb deleted file mode 100644 index f09c91e8e..000000000 --- a/Library/Homebrew/cask/test/cask/cli/create_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -require "test_helper" - -# monkeypatch for testing -module Hbc - class CLI - class Create - def self.exec_editor(*command) - editor_commands << command - end - - def self.reset! - @editor_commands = [] - end - - def self.editor_commands - @editor_commands ||= [] - end - end - end -end - -describe Hbc::CLI::Create do - before do - Hbc::CLI::Create.reset! - end - - after do - %w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask| - path = Hbc.path(cask) - path.delete if path.exist? - end - end - - it "opens the editor for the specified Cask" do - Hbc::CLI::Create.run("new-cask") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("new-cask")], - ] - end - - it "drops a template down for the specified Cask" do - Hbc::CLI::Create.run("new-cask") - template = File.read(Hbc.path("new-cask")) - template.must_equal <<-EOS.undent - cask 'new-cask' do - version '' - sha256 '' - - url 'https://' - name '' - homepage '' - - app '' - end - EOS - end - - it "throws away additional Cask arguments and uses the first" do - Hbc::CLI::Create.run("additional-cask", "another-cask") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("additional-cask")], - ] - end - - it "throws away stray options" do - Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("yet-another-cask")], - ] - end - - it "raises an exception when the Cask already exists" do - lambda { - Hbc::CLI::Create.run("basic-cask") - }.must_raise Hbc::CaskAlreadyCreatedError - end - - it "allows creating Casks that are substrings of existing Casks" do - Hbc::CLI::Create.run("local-caff") - Hbc::CLI::Create.editor_commands.must_equal [ - [Hbc.path("local-caff")], - ] - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Create.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Create.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From 3ef51dba055700ecca9a4f10e1fe0e714b7f9889 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:11:04 +0100 Subject: Convert Edit test to spec. --- Library/Homebrew/cask/spec/cask/cli/edit_spec.rb | 62 ++++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/edit_test.rb | 62 ------------------------ 2 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/edit_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/edit_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb b/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb new file mode 100644 index 000000000..5ddf27a48 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb @@ -0,0 +1,62 @@ +require "spec_helper" + +# monkeypatch for testing +module Hbc + class CLI + class Edit + def self.exec_editor(*command) + editor_commands << command + end + + def self.reset! + @editor_commands = [] + end + + def self.editor_commands + @editor_commands ||= [] + end + end + end +end + +describe Hbc::CLI::Edit do + before(:each) do + Hbc::CLI::Edit.reset! + end + + it "opens the editor for the specified Cask" do + Hbc::CLI::Edit.run("local-caffeine") + expect(Hbc::CLI::Edit.editor_commands).to eq [ + [Hbc.path("local-caffeine")], + ] + end + + it "throws away additional arguments and uses the first" do + Hbc::CLI::Edit.run("local-caffeine", "local-transmission") + expect(Hbc::CLI::Edit.editor_commands).to eq [ + [Hbc.path("local-caffeine")], + ] + end + + it "raises an exception when the Cask doesnt exist" do + expect { + Hbc::CLI::Edit.run("notacask") + }.to raise_error(Hbc::CaskUnavailableError) + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Edit.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Edit.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/edit_test.rb b/Library/Homebrew/cask/test/cask/cli/edit_test.rb deleted file mode 100644 index 6eb2289c0..000000000 --- a/Library/Homebrew/cask/test/cask/cli/edit_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -require "test_helper" - -# monkeypatch for testing -module Hbc - class CLI - class Edit - def self.exec_editor(*command) - editor_commands << command - end - - def self.reset! - @editor_commands = [] - end - - def self.editor_commands - @editor_commands ||= [] - end - end - end -end - -describe Hbc::CLI::Edit do - before do - Hbc::CLI::Edit.reset! - end - - it "opens the editor for the specified Cask" do - Hbc::CLI::Edit.run("alfred") - Hbc::CLI::Edit.editor_commands.must_equal [ - [Hbc.path("alfred")], - ] - end - - it "throws away additional arguments and uses the first" do - Hbc::CLI::Edit.run("adium", "alfred") - Hbc::CLI::Edit.editor_commands.must_equal [ - [Hbc.path("adium")], - ] - end - - it "raises an exception when the Cask doesnt exist" do - lambda { - Hbc::CLI::Edit.run("notacask") - }.must_raise Hbc::CaskUnavailableError - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Edit.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Edit.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From e637eb414e880559695a71b3fc1efbc7104ee64e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:12:52 +0100 Subject: Convert Fetch test to spec. --- Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb | 77 ++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/fetch_test.rb | 78 ----------------------- 2 files changed, 77 insertions(+), 78 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/fetch_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb b/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb new file mode 100644 index 000000000..bb8133453 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb @@ -0,0 +1,77 @@ +require "spec_helper" + +describe Hbc::CLI::Fetch do + let(:local_transmission) { + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + } + + let(:local_caffeine) { + Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + } + + it "allows download the installer of a Cask" do + shutup do + Hbc::CLI::Fetch.run("local-transmission", "local-caffeine") + end + expect(Hbc::CurlDownloadStrategy.new(local_transmission).cached_location).to exist + expect(Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location).to exist + end + + it "prevents double fetch (without nuking existing installation)" do + download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) + + shutup do + Hbc::Download.new(local_transmission).perform + end + old_ctime = File.stat(download_stategy.cached_location).ctime + + shutup do + Hbc::CLI::Fetch.run("local-transmission") + end + new_ctime = File.stat(download_stategy.cached_location).ctime + + expect(old_ctime.to_i).to eq(new_ctime.to_i) + end + + it "allows double fetch with --force" do + shutup do + Hbc::Download.new(local_transmission).perform + end + + download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) + old_ctime = File.stat(download_stategy.cached_location).ctime + sleep(1) + + shutup do + Hbc::CLI::Fetch.run("local-transmission", "--force") + end + download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) + new_ctime = File.stat(download_stategy.cached_location).ctime + + expect(new_ctime.to_i).to be > old_ctime.to_i + end + + it "properly handles Casks that are not present" do + expect { + shutup do + Hbc::CLI::Fetch.run("notacask") + end + }.to raise_error(Hbc::CaskUnavailableError) + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Fetch.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Fetch.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb b/Library/Homebrew/cask/test/cask/cli/fetch_test.rb deleted file mode 100644 index 8dd7e0ebf..000000000 --- a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb +++ /dev/null @@ -1,78 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Fetch do - let(:local_transmission) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - } - - let(:local_caffeine) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - } - - it "allows download the installer of a Cask" do - shutup do - Hbc::CLI::Fetch.run("local-transmission", "local-caffeine") - end - Hbc::CurlDownloadStrategy.new(local_transmission).cached_location.must_be :exist? - Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location.must_be :exist? - end - - it "prevents double fetch (without nuking existing installation)" do - download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) - - shutup do - Hbc::Download.new(local_transmission).perform - end - old_ctime = File.stat(download_stategy.cached_location).ctime - - shutup do - Hbc::CLI::Fetch.run("local-transmission") - end - new_ctime = File.stat(download_stategy.cached_location).ctime - - old_ctime.to_i.must_equal new_ctime.to_i - end - - it "allows double fetch with --force" do - shutup do - Hbc::Download.new(local_transmission).perform - end - - download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) - old_ctime = File.stat(download_stategy.cached_location).ctime - sleep(1) - - shutup do - Hbc::CLI::Fetch.run("local-transmission", "--force") - end - download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission) - new_ctime = File.stat(download_stategy.cached_location).ctime - - # new_ctime.to_i.must_be :>, old_ctime.to_i - new_ctime.to_i.must_be :>, old_ctime.to_i - end - - it "properly handles Casks that are not present" do - lambda { - shutup do - Hbc::CLI::Fetch.run("notacask") - end - }.must_raise Hbc::CaskUnavailableError - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Fetch.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Fetch.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From 0daf01681268dd19ee5d154e484b3d97832f9ec9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:15:34 +0100 Subject: Convert Home test to spec. --- Library/Homebrew/cask/spec/cask/cli/home_spec.rb | 48 ++++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/home_test.rb | 48 ------------------------ 2 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/home_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/home_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/home_spec.rb b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb new file mode 100644 index 000000000..a2b49b433 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb @@ -0,0 +1,48 @@ +require "spec_helper" + +# monkeypatch for testing +module Hbc + class CLI + class Home + def self.system(*command) + system_commands << command + end + + def self.reset! + @system_commands = [] + end + + def self.system_commands + @system_commands ||= [] + end + end + end +end + +describe Hbc::CLI::Home do + before do + Hbc::CLI::Home.reset! + end + + it "opens the homepage for the specified Cask" do + Hbc::CLI::Home.run("local-caffeine") + expect(Hbc::CLI::Home.system_commands).to eq [ + ["/usr/bin/open", "--", "http://example.com/local-caffeine"], + ] + end + + it "works for multiple Casks" do + Hbc::CLI::Home.run("local-caffeine", "local-transmission") + expect(Hbc::CLI::Home.system_commands).to eq [ + ["/usr/bin/open", "--", "http://example.com/local-caffeine"], + ["/usr/bin/open", "--", "http://example.com/local-transmission"], + ] + end + + it "opens the project page when no Cask is specified" do + Hbc::CLI::Home.run + expect(Hbc::CLI::Home.system_commands).to eq [ + ["/usr/bin/open", "--", "http://caskroom.io/"], + ] + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/home_test.rb b/Library/Homebrew/cask/test/cask/cli/home_test.rb deleted file mode 100644 index 67bcb024a..000000000 --- a/Library/Homebrew/cask/test/cask/cli/home_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require "test_helper" - -# monkeypatch for testing -module Hbc - class CLI - class Home - def self.system(*command) - system_commands << command - end - - def self.reset! - @system_commands = [] - end - - def self.system_commands - @system_commands ||= [] - end - end - end -end - -describe Hbc::CLI::Home do - before do - Hbc::CLI::Home.reset! - end - - it "opens the homepage for the specified Cask" do - Hbc::CLI::Home.run("alfred") - Hbc::CLI::Home.system_commands.must_equal [ - ["/usr/bin/open", "--", "https://www.alfredapp.com/"], - ] - end - - it "works for multiple Casks" do - Hbc::CLI::Home.run("alfred", "adium") - Hbc::CLI::Home.system_commands.must_equal [ - ["/usr/bin/open", "--", "https://www.alfredapp.com/"], - ["/usr/bin/open", "--", "https://www.adium.im/"], - ] - end - - it "opens the project page when no Cask is specified" do - Hbc::CLI::Home.run - Hbc::CLI::Home.system_commands.must_equal [ - ["/usr/bin/open", "--", "http://caskroom.io/"], - ] - end -end -- cgit v1.2.3 From 9d36734e40c064efc48a58d28da9b23c9158dedc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:19:51 +0100 Subject: Convert Info test to spec. --- Library/Homebrew/cask/spec/cask/cli/info_spec.rb | 110 +++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/info_test.rb | 110 ----------------------- 2 files changed, 110 insertions(+), 110 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/info_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/info_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/info_spec.rb b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb new file mode 100644 index 000000000..6977f81c3 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb @@ -0,0 +1,110 @@ +require "spec_helper" + +describe Hbc::CLI::Info do + it "displays some nice info about the specified Cask" do + expect { + Hbc::CLI::Info.run("local-caffeine") + }.to output(<<-EOS.undent).to_stdout + local-caffeine: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + EOS + end + + describe "given multiple Casks" do + let(:expected_output) { + <<-EOS.undent + local-caffeine: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + local-transmission: 2.61 + http://example.com/local-transmission + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb + ==> Name + None + ==> Artifacts + Transmission.app (app) + EOS + } + + it "displays the info" do + expect { + Hbc::CLI::Info.run("local-caffeine", "local-transmission") + }.to output(expected_output).to_stdout + end + + it "throws away stray options" do + expect { + Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission") + }.to output(expected_output).to_stdout + end + end + + it "should print caveats if the Cask provided one" do + expect { + Hbc::CLI::Info.run("with-caveats") + }.to output(<<-EOS.undent).to_stdout + with-caveats: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + ==> Caveats + Here are some things you might want to know. + + Cask token: with-caveats + + Custom text via puts followed by DSL-generated text: + To use with-caveats, you may need to add the /custom/path/bin directory + to your PATH environment variable, eg (for bash shell): + + export PATH=/custom/path/bin:"$PATH" + + EOS + end + + it 'should not print "Caveats" section divider if the caveats block has no output' do + expect { + Hbc::CLI::Info.run("with-conditional-caveats") + }.to output(<<-EOS.undent).to_stdout + with-conditional-caveats: 1.2.3 + http://example.com/local-caffeine + Not installed + From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb + ==> Name + None + ==> Artifacts + Caffeine.app (app) + EOS + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Info.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Info.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/info_test.rb b/Library/Homebrew/cask/test/cask/cli/info_test.rb deleted file mode 100644 index 767a594e8..000000000 --- a/Library/Homebrew/cask/test/cask/cli/info_test.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Info do - it "displays some nice info about the specified Cask" do - lambda { - Hbc::CLI::Info.run("local-caffeine") - }.must_output <<-EOS.undent - local-caffeine: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - EOS - end - - describe "given multiple Casks" do - before do - @expected_output = <<-EOS.undent - local-caffeine: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - local-transmission: 2.61 - http://example.com/local-transmission - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-transmission.rb - ==> Name - None - ==> Artifacts - Transmission.app (app) - EOS - end - - it "displays the info" do - lambda { - Hbc::CLI::Info.run("local-caffeine", "local-transmission") - }.must_output(@expected_output) - end - - it "throws away stray options" do - lambda { - Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission") - }.must_output(@expected_output) - end - end - - it "should print caveats if the Cask provided one" do - lambda { - Hbc::CLI::Info.run("with-caveats") - }.must_output <<-EOS.undent - with-caveats: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-caveats.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - ==> Caveats - Here are some things you might want to know. - - Cask token: with-caveats - - Custom text via puts followed by DSL-generated text: - To use with-caveats, you may need to add the /custom/path/bin directory - to your PATH environment variable, eg (for bash shell): - - export PATH=/custom/path/bin:"$PATH" - - EOS - end - - it 'should not print "Caveats" section divider if the caveats block has no output' do - lambda { - Hbc::CLI::Info.run("with-conditional-caveats") - }.must_output <<-EOS.undent - with-conditional-caveats: 1.2.3 - http://example.com/local-caffeine - Not installed - From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-conditional-caveats.rb - ==> Name - None - ==> Artifacts - Caffeine.app (app) - EOS - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Info.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Info.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From cd4705b7bca5f266907ea6424d721190617edbcd Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:29:33 +0100 Subject: Convert Install test to spec. --- .../Homebrew/cask/spec/cask/cli/install_spec.rb | 109 +++++++++++++++++++++ Library/Homebrew/cask/spec/spec_helper.rb | 3 + .../Homebrew/cask/test/cask/cli/install_test.rb | 107 -------------------- 3 files changed, 112 insertions(+), 107 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/install_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/install_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/install_spec.rb b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb new file mode 100644 index 000000000..07aa78aa3 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb @@ -0,0 +1,109 @@ +require "spec_helper" + +describe Hbc::CLI::Install do + it "allows staging and activation of multiple Casks at once" do + shutup do + Hbc::CLI::Install.run("local-transmission", "local-caffeine") + end + + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + expect(Hbc.appdir.join("Transmission.app")).to be_a_directory + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).to be_installed + expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory + end + + it "skips double install (without nuking existing installation)" do + shutup do + Hbc::CLI::Install.run("local-transmission") + end + shutup do + Hbc::CLI::Install.run("local-transmission") + end + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + end + + it "prints a warning message on double install" do + shutup do + Hbc::CLI::Install.run("local-transmission") + end + + expect { + Hbc::CLI::Install.run("local-transmission", "") + }.to output(/Warning: A Cask for local-transmission is already installed./).to_stderr + end + + it "allows double install with --force" do + shutup do + Hbc::CLI::Install.run("local-transmission") + end + + expect { + expect { + Hbc::CLI::Install.run("local-transmission", "--force") + }.to output(/It seems there is already an App at.*overwriting\./).to_stderr + }.to output(/local-transmission was successfully installed!/).to_stdout + end + + it "skips dependencies with --skip-cask-deps" do + shutup do + Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps") + end + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")).to be_installed + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).not_to be_installed + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed + end + + it "properly handles Casks that are not present" do + expect { + shutup do + Hbc::CLI::Install.run("notacask") + end + }.to raise_error(Hbc::CaskError) + end + + it "returns a suggestion for a misspelled Cask" do + expect { + begin + Hbc::CLI::Install.run("googlechrome") + rescue Hbc::CaskError + nil + end + }.to output(/No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/).to_stderr + end + + it "returns multiple suggestions for a Cask fragment" do + expect { + begin + Hbc::CLI::Install.run("google") + rescue Hbc::CaskError + nil + end + }.to output(/No available Cask for google\. Did you mean one of:\ngoogle/).to_stderr + end + + describe "when no Cask is specified" do + with_options = lambda do |options| + it "raises an exception" do + expect { + Hbc::CLI::Install.run(*options) + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "without options" do + with_options.call([]) + end + + describe "with --force" do + with_options.call(["--force"]) + end + + describe "with --skip-cask-deps" do + with_options.call(["--skip-cask-deps"]) + end + + describe "with an invalid option" do + with_options.call(["--notavalidoption"]) + end + end +end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index d9f29c828..059d13a3a 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -31,6 +31,9 @@ Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path end +# pretend that the caskroom/cask Tap is installed +FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path + RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) diff --git a/Library/Homebrew/cask/test/cask/cli/install_test.rb b/Library/Homebrew/cask/test/cask/cli/install_test.rb deleted file mode 100644 index d47d55a50..000000000 --- a/Library/Homebrew/cask/test/cask/cli/install_test.rb +++ /dev/null @@ -1,107 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Install do - it "allows staging and activation of multiple Casks at once" do - shutup do - Hbc::CLI::Install.run("local-transmission", "local-caffeine") - end - - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? - Hbc.appdir.join("Transmission.app").must_be :directory? - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb").must_be :installed? - Hbc.appdir.join("Caffeine.app").must_be :directory? - end - - it "skips double install (without nuking existing installation)" do - shutup do - Hbc::CLI::Install.run("local-transmission") - end - shutup do - Hbc::CLI::Install.run("local-transmission") - end - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? - end - - it "prints a warning message on double install" do - shutup do - Hbc::CLI::Install.run("local-transmission") - end - - lambda { - Hbc::CLI::Install.run("local-transmission", "") - }.must_output nil, /Warning: A Cask for local-transmission is already installed./ - end - - it "allows double install with --force" do - shutup do - Hbc::CLI::Install.run("local-transmission") - end - - lambda { - Hbc::CLI::Install.run("local-transmission", "--force") - }.must_output(/local-transmission was successfully installed!/) - end - - it "skips dependencies with --skip-cask-deps" do - shutup do - Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps") - end - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb").must_be :installed? - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb").wont_be :installed? - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").wont_be :installed? - end - - it "properly handles Casks that are not present" do - lambda { - shutup do - Hbc::CLI::Install.run("notacask") - end - }.must_raise Hbc::CaskError - end - - it "returns a suggestion for a misspelled Cask" do - lambda { - begin - Hbc::CLI::Install.run("googlechrome") - rescue Hbc::CaskError - nil - end - }.must_output(nil, /No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/) - end - - it "returns multiple suggestions for a Cask fragment" do - lambda { - begin - Hbc::CLI::Install.run("google") - rescue Hbc::CaskError - nil - end - }.must_output(nil, /No available Cask for google\. Did you mean one of:\ngoogle/) - end - - describe "when no Cask is specified" do - with_options = lambda do |options| - it "raises an exception" do - lambda { - Hbc::CLI::Install.run(*options) - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "without options" do - with_options.call([]) - end - - describe "with --force" do - with_options.call(["--force"]) - end - - describe "with --skip-cask-deps" do - with_options.call(["--skip-cask-deps"]) - end - - describe "with an invalid option" do - with_options.call(["--notavalidoption"]) - end - end -end -- cgit v1.2.3 From bcaa13b7507afaf7f957a2d815884a8263461d31 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 12:37:45 +0100 Subject: Convert List test to spec. --- Library/Homebrew/cask/spec/cask/cli/list_spec.rb | 84 +++++++++++++++++++++ .../Homebrew/cask/spec/support/install_helper.rb | 38 +++++++++- Library/Homebrew/cask/test/cask/cli/list_test.rb | 88 ---------------------- 3 files changed, 119 insertions(+), 91 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/list_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/list_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/list_spec.rb b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb new file mode 100644 index 000000000..49c06c521 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb @@ -0,0 +1,84 @@ +require "spec_helper" + +describe Hbc::CLI::List do + it "lists the installed Casks in a pretty fashion" do + casks = %w[local-caffeine local-transmission].map { |c| Hbc.load(c) } + + casks.each do |c| + InstallHelper.install_with_caskfile(c) + end + + expect { + Hbc::CLI::List.run + }.to output(<<-EOS.undent).to_stdout + local-caffeine + local-transmission + EOS + end + + describe "lists versions" do + let(:casks) { ["local-caffeine", "local-transmission"] } + let(:expected_output) { + <<-EOS.undent + local-caffeine 1.2.3 + local-transmission 2.61 + EOS + } + + before(:each) do + casks.map(&Hbc.method(:load)).each(&InstallHelper.method(:install_with_caskfile)) + end + + it "of all installed Casks" do + expect { + Hbc::CLI::List.run("--versions") + }.to output(expected_output).to_stdout + end + + it "of given Casks" do + expect { + Hbc::CLI::List.run("--versions", "local-caffeine", "local-transmission") + }.to output(expected_output).to_stdout + end + end + + describe "when Casks have been renamed" do + let(:caskroom_path) { Hbc.caskroom.join("ive-been-renamed") } + let(:staged_path) { caskroom_path.join("latest") } + + before do + staged_path.mkpath + end + + it "lists installed Casks without backing ruby files (due to renames or otherwise)" do + expect { + Hbc::CLI::List.run + }.to output(<<-EOS.undent).to_stdout + ive-been-renamed (!) + EOS + end + end + + describe "given a set of installed Casks" do + let(:caffeine) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } + let(:transmission) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } + let(:casks) { [caffeine, transmission] } + + it "lists the installed files for those Casks" do + casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile)) + + shutup do + Hbc::Artifact::App.new(transmission).install_phase + end + + expect { + Hbc::CLI::List.run("local-transmission", "local-caffeine") + }.to output(<<-EOS.undent).to_stdout + ==> Apps + #{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv}) + ==> Apps + Missing App: #{Hbc.appdir.join("Caffeine.app")} + EOS + end + end +end diff --git a/Library/Homebrew/cask/spec/support/install_helper.rb b/Library/Homebrew/cask/spec/support/install_helper.rb index c8023c66b..d91b9ea57 100644 --- a/Library/Homebrew/cask/spec/support/install_helper.rb +++ b/Library/Homebrew/cask/spec/support/install_helper.rb @@ -1,10 +1,42 @@ module InstallHelper - class << self - def install_without_artifacts(cask) - Hbc::Installer.new(cask).tap do |i| + module_function + + require "test/support/helper/shutup" + extend Test::Helper::Shutup + + def self.install_without_artifacts(cask) + Hbc::Installer.new(cask).tap do |i| + shutup do i.download i.extract_primary_container end end end + + def self.install_without_artifacts_with_caskfile(cask) + Hbc::Installer.new(cask).tap do |i| + shutup do + i.download + i.extract_primary_container + i.save_caskfile + end + end + end + + def install_without_artifacts(cask) + Hbc::Installer.new(cask).tap do |i| + shutup do + i.download + i.extract_primary_container + end + end + end + + def install_with_caskfile(cask) + Hbc::Installer.new(cask).tap do |i| + shutup do + i.save_caskfile + end + end + end end diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/test/cask/cli/list_test.rb deleted file mode 100644 index 9acf37efe..000000000 --- a/Library/Homebrew/cask/test/cask/cli/list_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::List do - it "lists the installed Casks in a pretty fashion" do - casks = %w[local-caffeine local-transmission].map { |c| Hbc.load(c) } - - casks.each do |c| - TestHelper.install_with_caskfile(c) - end - - lambda { - Hbc::CLI::List.run - }.must_output <<-EOS.undent - local-caffeine - local-transmission - EOS - end - - describe "lists versions" do - let(:casks) { ["local-caffeine", "local-transmission"] } - let(:output) { - <<-EOS.undent - local-caffeine 1.2.3 - local-transmission 2.61 - EOS - } - - before(:each) do - casks.map(&Hbc.method(:load)).each(&TestHelper.method(:install_with_caskfile)) - end - - it "of all installed Casks" do - lambda { - Hbc::CLI::List.run("--versions") - }.must_output(output) - end - - it "of given Casks" do - lambda { - Hbc::CLI::List.run("--versions", "local-caffeine", "local-transmission") - }.must_output(output) - end - end - - describe "when Casks have been renamed" do - let(:caskroom_path) { Hbc.caskroom.join("ive-been-renamed") } - let(:staged_path) { caskroom_path.join("latest") } - - before do - staged_path.mkpath - end - - after do - caskroom_path.rmtree - end - - it "lists installed Casks without backing ruby files (due to renames or otherwise)" do - lambda { - Hbc::CLI::List.run - }.must_output <<-EOS.undent - ive-been-renamed (!) - EOS - end - end - - describe "given a set of installed Casks" do - let(:caffeine) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } - let(:transmission) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } - let(:casks) { [caffeine, transmission] } - - it "lists the installed files for those Casks" do - casks.each(&TestHelper.method(:install_without_artifacts_with_caskfile)) - - shutup do - Hbc::Artifact::App.new(transmission).install_phase - end - - lambda { - Hbc::CLI::List.run("local-transmission", "local-caffeine") - }.must_output <<-EOS.undent - ==> Apps - #{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv}) - ==> Apps - Missing App: #{Hbc.appdir.join("Caffeine.app")} - EOS - end - end -end -- cgit v1.2.3 From 7b2d8ed4b3a1a71da59b1aa1859e844c37ba24c2 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:25:10 +0100 Subject: Convert Options test to spec. --- .../Homebrew/cask/spec/cask/cli/options_spec.rb | 140 ++++++++++++++++++++ Library/Homebrew/cask/spec/spec_helper.rb | 32 ++++- .../Homebrew/cask/test/cask/cli/options_test.rb | 144 --------------------- 3 files changed, 167 insertions(+), 149 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/options_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/options_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/options_spec.rb b/Library/Homebrew/cask/spec/cask/cli/options_spec.rb new file mode 100644 index 000000000..a4381213a --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/options_spec.rb @@ -0,0 +1,140 @@ +require "spec_helper" + +describe Hbc::CLI do + it "supports setting the appdir" do + Hbc::CLI.process_options %w[help --appdir=/some/path/foo] + + expect(Hbc.appdir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the appdir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.appdir).to eq(Pathname.new("/some/path/bar")) + end + + it "supports setting the prefpanedir" do + Hbc::CLI.process_options %w[help --prefpanedir=/some/path/foo] + + expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the prefpanedir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/bar")) + end + + it "supports setting the qlplugindir" do + Hbc::CLI.process_options %w[help --qlplugindir=/some/path/foo] + + expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the qlplugindir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/bar")) + end + + it "supports setting the colorpickerdir" do + Hbc::CLI.process_options %w[help --colorpickerdir=/some/path/foo] + + expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the colorpickerdir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/bar")) + end + + it "supports setting the dictionarydir" do + Hbc::CLI.process_options %w[help --dictionarydir=/some/path/foo] + + expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the dictionarydir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/bar")) + end + + it "supports setting the fontdir" do + Hbc::CLI.process_options %w[help --fontdir=/some/path/foo] + + expect(Hbc.fontdir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the fontdir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.fontdir).to eq(Pathname.new("/some/path/bar")) + end + + it "supports setting the servicedir" do + Hbc::CLI.process_options %w[help --servicedir=/some/path/foo] + + expect(Hbc.servicedir).to eq(Pathname.new("/some/path/foo")) + end + + it "supports setting the servicedir from ENV" do + ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar" + + Hbc::CLI.process_options %w[help] + + expect(Hbc.servicedir).to eq(Pathname.new("/some/path/bar")) + end + + it "allows additional options to be passed through" do + rest = Hbc::CLI.process_options %w[edit foo --create --appdir=/some/path/qux] + + expect(Hbc.appdir).to eq(Pathname.new("/some/path/qux")) + expect(rest).to eq(%w[edit foo --create]) + end + + describe "when a mandatory argument is missing" do + it "shows a user-friendly error message" do + expect { + Hbc::CLI.process_options %w[install -f] + }.to raise_error(Hbc::CaskError) + end + end + + describe "given an ambiguous option" do + it "shows a user-friendly error message" do + expect { + Hbc::CLI.process_options %w[edit -c] + }.to raise_error(Hbc::CaskError) + end + end + + describe "--debug" do + it "sets the Cask debug method to true" do + Hbc::CLI.process_options %w[help --debug] + expect(Hbc.debug).to be true + Hbc.debug = false + end + end + + describe "--help" do + it "sets the Cask help method to true" do + Hbc::CLI.process_options %w[foo --help] + expect(Hbc.help).to be true + Hbc.help = false + end + end +end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 059d13a3a..13ed746b5 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -37,11 +37,33 @@ FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "h RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) - config.after(:each) do - FileUtils.rm_rf [ - Hbc.appdir.children, - Hbc.caskroom.children, - ] + config.around(:each) do |example| + begin + @__appdir = Hbc.appdir + @__caskroom = Hbc.caskroom + @__prefpanedir = Hbc.prefpanedir + @__qlplugindir = Hbc.qlplugindir + @__servicedir = Hbc.servicedir + + @__argv = ARGV.dup + @__env = ENV.to_hash # dup doesn't work on ENV + + example.run + ensure + ARGV.replace(@__argv) + ENV.replace(@__env) + + Hbc.appdir = @__appdir + Hbc.caskroom = @__caskroom + Hbc.prefpanedir = @__prefpanedir + Hbc.qlplugindir = @__qlplugindir + Hbc.servicedir = @__servicedir + + FileUtils.rm_rf [ + Hbc.appdir.children, + Hbc.caskroom.children, + ] + end end end diff --git a/Library/Homebrew/cask/test/cask/cli/options_test.rb b/Library/Homebrew/cask/test/cask/cli/options_test.rb deleted file mode 100644 index d49e7827b..000000000 --- a/Library/Homebrew/cask/test/cask/cli/options_test.rb +++ /dev/null @@ -1,144 +0,0 @@ -require "test_helper" - -describe Hbc::CLI do - it "supports setting the appdir" do - Hbc::CLI.process_options %w[help --appdir=/some/path/foo] - - Hbc.appdir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the appdir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.appdir.must_equal Pathname("/some/path/bar") - end - - it "supports setting the prefpanedir" do - Hbc::CLI.process_options %w[help --prefpanedir=/some/path/foo] - - Hbc.prefpanedir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the prefpanedir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.prefpanedir.must_equal Pathname("/some/path/bar") - end - - it "supports setting the qlplugindir" do - Hbc::CLI.process_options %w[help --qlplugindir=/some/path/foo] - - Hbc.qlplugindir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the qlplugindir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.qlplugindir.must_equal Pathname("/some/path/bar") - end - - it "supports setting the colorpickerdir" do - Hbc::CLI.process_options %w[help --colorpickerdir=/some/path/foo] - - Hbc.colorpickerdir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the colorpickerdir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.colorpickerdir.must_equal Pathname("/some/path/bar") - end - - it "supports setting the dictionarydir" do - Hbc::CLI.process_options %w[help --dictionarydir=/some/path/foo] - - Hbc.dictionarydir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the dictionarydir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.dictionarydir.must_equal Pathname("/some/path/bar") - end - - it "supports setting the fontdir" do - Hbc::CLI.process_options %w[help --fontdir=/some/path/foo] - - Hbc.fontdir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the fontdir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.fontdir.must_equal Pathname("/some/path/bar") - end - - it "supports setting the servicedir" do - Hbc::CLI.process_options %w[help --servicedir=/some/path/foo] - - Hbc.servicedir.must_equal Pathname("/some/path/foo") - end - - it "supports setting the servicedir from ENV" do - ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar" - - Hbc::CLI.process_options %w[help] - - Hbc.servicedir.must_equal Pathname("/some/path/bar") - end - - it "allows additional options to be passed through" do - rest = Hbc::CLI.process_options %w[edit foo --create --appdir=/some/path/qux] - - Hbc.appdir.must_equal Pathname("/some/path/qux") - rest.must_equal %w[edit foo --create] - end - - describe "when a mandatory argument is missing" do - it "shows a user-friendly error message" do - lambda { - Hbc::CLI.process_options %w[install -f] - }.must_raise Hbc::CaskError - end - end - - describe "given an ambiguous option" do - it "shows a user-friendly error message" do - lambda { - Hbc::CLI.process_options %w[edit -c] - }.must_raise Hbc::CaskError - end - end - - describe "--debug" do - it "sets the Cask debug method to true" do - Hbc::CLI.process_options %w[help --debug] - Hbc.debug.must_equal true - Hbc.debug = false - end - end - - describe "--help" do - it "sets the Cask help method to true" do - Hbc::CLI.process_options %w[foo --help] - Hbc.help.must_equal true - Hbc.help = false - end - end - - after do - ENV["HOMEBREW_CASK_OPTS"] = nil - end -end -- cgit v1.2.3 From 20b77dfdcc4332f1d21e39571e1bbc7eefc6d4dd Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:29:46 +0100 Subject: Convert Reinstall test to spec. --- .../Homebrew/cask/spec/cask/cli/reinstall_spec.rb | 24 ++++++++++++++++++++++ .../Homebrew/cask/test/cask/cli/reinstall_test.rb | 24 ---------------------- 2 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/reinstall_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb new file mode 100644 index 000000000..df83c53e2 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb @@ -0,0 +1,24 @@ +require "spec_helper" + +describe Hbc::CLI::Reinstall do + it "allows reinstalling a Cask" do + shutup do + Hbc::CLI::Install.run("local-transmission") + end + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + + shutup do + Hbc::CLI::Reinstall.run("local-transmission") + end + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + end + + it "allows reinstalling a non installed Cask" do + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed + + shutup do + Hbc::CLI::Reinstall.run("local-transmission") + end + expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb b/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb deleted file mode 100644 index d34a2c6bb..000000000 --- a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Reinstall do - it "allows reinstalling a Cask" do - shutup do - Hbc::CLI::Install.run("local-transmission") - end - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? - - shutup do - Hbc::CLI::Reinstall.run("local-transmission") - end - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? - end - - it "allows reinstalling a non installed Cask" do - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").wont_be :installed? - - shutup do - Hbc::CLI::Reinstall.run("local-transmission") - end - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed? - end -end -- cgit v1.2.3 From 82e6070ca045001eab7aec0ba9b85dbca48615f8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:34:26 +0100 Subject: Convert Search test to spec. --- Library/Homebrew/cask/spec/cask/cli/search_spec.rb | 61 ++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/search_test.rb | 59 --------------------- 2 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/search_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/search_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/search_spec.rb b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb new file mode 100644 index 000000000..fe669dd3e --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb @@ -0,0 +1,61 @@ +require "spec_helper" + +describe Hbc::CLI::Search do + it "lists the available Casks that match the search term" do + expect { + Hbc::CLI::Search.run("photoshop") + }.to output(<<-EOS.undent).to_stdout + ==> Partial matches + adobe-photoshop-cc + adobe-photoshop-lightroom + EOS + end + + it "shows that there are no Casks matching a search term that did not result in anything" do + expect { + Hbc::CLI::Search.run("foo-bar-baz") + }.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout + end + + it "lists all available Casks with no search term" do + expect { + Hbc::CLI::Search.run + }.to output(/google-chrome/).to_stdout + end + + it "ignores hyphens in search terms" do + expect { + Hbc::CLI::Search.run("goo-gle-chrome") + }.to output(/google-chrome/).to_stdout + end + + it "ignores hyphens in Cask tokens" do + expect { + Hbc::CLI::Search.run("googlechrome") + }.to output(/google-chrome/).to_stdout + end + + it "accepts multiple arguments" do + expect { + Hbc::CLI::Search.run("google chrome") + }.to output(/google-chrome/).to_stdout + end + + it "accepts a regexp argument" do + expect { + Hbc::CLI::Search.run("/^google-c[a-z]rome$/") + }.to output("==> Regexp matches\ngoogle-chrome\n").to_stdout + end + + it "Returns both exact and partial matches" do + expect { + Hbc::CLI::Search.run("mnemosyne") + }.to output(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/).to_stdout + end + + it "does not search the Tap name" do + expect { + Hbc::CLI::Search.run("caskroom") + }.to output(/^No Cask found for "caskroom"\.\n/).to_stdout + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/search_test.rb b/Library/Homebrew/cask/test/cask/cli/search_test.rb deleted file mode 100644 index 6eb6badb9..000000000 --- a/Library/Homebrew/cask/test/cask/cli/search_test.rb +++ /dev/null @@ -1,59 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Search do - it "lists the available Casks that match the search term" do - lambda { - Hbc::CLI::Search.run("photoshop") - }.must_output <<-EOS.undent - ==> Partial matches - adobe-photoshop-cc - adobe-photoshop-lightroom - EOS - end - - it "shows that there are no Casks matching a search term that did not result in anything" do - lambda { - Hbc::CLI::Search.run("foo-bar-baz") - }.must_output("No Cask found for \"foo-bar-baz\".\n") - end - - it "lists all available Casks with no search term" do - out = capture_io { Hbc::CLI::Search.run }[0] - out.must_match(/google-chrome/) - out.length.must_be :>, 1000 - end - - it "ignores hyphens in search terms" do - out = capture_io { Hbc::CLI::Search.run("goo-gle-chrome") }[0] - out.must_match(/google-chrome/) - out.length.must_be :<, 100 - end - - it "ignores hyphens in Cask tokens" do - out = capture_io { Hbc::CLI::Search.run("googlechrome") }[0] - out.must_match(/google-chrome/) - out.length.must_be :<, 100 - end - - it "accepts multiple arguments" do - out = capture_io { Hbc::CLI::Search.run("google chrome") }[0] - out.must_match(/google-chrome/) - out.length.must_be :<, 100 - end - - it "accepts a regexp argument" do - lambda { - Hbc::CLI::Search.run("/^google-c[a-z]rome$/") - }.must_output "==> Regexp matches\ngoogle-chrome\n" - end - - it "Returns both exact and partial matches" do - out = capture_io { Hbc::CLI::Search.run("mnemosyne") }[0] - out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/) - end - - it "does not search the Tap name" do - out = capture_io { Hbc::CLI::Search.run("caskroom") }[0] - out.must_match(/^No Cask found for "caskroom"\.\n/) - end -end -- cgit v1.2.3 From 3d031420404506223d047fc509e53df4cc9185d9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:40:31 +0100 Subject: Convert Uninstall test to spec. --- .../Homebrew/cask/spec/cask/cli/uninstall_spec.rb | 144 +++++++++++++++++++ .../Homebrew/cask/test/cask/cli/uninstall_test.rb | 154 --------------------- 2 files changed, 144 insertions(+), 154 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/uninstall_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb new file mode 100644 index 000000000..be0aa31b6 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb @@ -0,0 +1,144 @@ +require "spec_helper" + +describe Hbc::CLI::Uninstall do + it "shows an error when a bad Cask is provided" do + expect { + Hbc::CLI::Uninstall.run("notacask") + }.to raise_error(Hbc::CaskUnavailableError) + end + + it "shows an error when a Cask is provided that's not installed" do + expect { + Hbc::CLI::Uninstall.run("anvil") + }.to raise_error(Hbc::CaskNotInstalledError) + end + + it "tries anyway on a non-present Cask when --force is given" do + expect { + Hbc::CLI::Uninstall.run("anvil", "--force") + }.not_to raise_error + end + + it "can uninstall and unlink multiple Casks at once" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + + shutup do + Hbc::Installer.new(caffeine).install + Hbc::Installer.new(transmission).install + end + + expect(caffeine).to be_installed + expect(transmission).to be_installed + + shutup do + Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission") + end + + expect(caffeine).not_to be_installed + expect(Hbc.appdir.join("Transmission.app")).not_to exist + expect(transmission).not_to be_installed + expect(Hbc.appdir.join("Caffeine.app")).not_to exist + end + + describe "when multiple versions of a cask are installed" do + let(:token) { "versioned-cask" } + let(:first_installed_version) { "1.2.3" } + let(:last_installed_version) { "4.5.6" } + let(:timestamped_versions) { + [ + [first_installed_version, "123000"], + [last_installed_version, "456000"], + ] + } + let(:caskroom_path) { Hbc.caskroom.join(token).tap(&:mkpath) } + + before(:each) do + timestamped_versions.each do |timestamped_version| + caskroom_path.join(".metadata", *timestamped_version, "Casks").tap(&:mkpath) + .join("#{token}.rb").open("w") do |caskfile| + caskfile.puts <<-EOS.undent + cask '#{token}' do + version '#{timestamped_version[0]}' + end + EOS + end + caskroom_path.join(timestamped_version[0]).mkpath + end + end + + it "uninstalls one version at a time" do + shutup do + Hbc::CLI::Uninstall.run("versioned-cask") + end + + expect(caskroom_path.join(first_installed_version)).to exist + expect(caskroom_path.join(last_installed_version)).not_to exist + expect(caskroom_path).to exist + + shutup do + Hbc::CLI::Uninstall.run("versioned-cask") + end + + expect(caskroom_path.join(first_installed_version)).not_to exist + expect(caskroom_path).not_to exist + end + + it "displays a message when versions remain installed" do + expect { + expect { + Hbc::CLI::Uninstall.run("versioned-cask") + }.not_to output.to_stderr + }.to output(/#{token} #{first_installed_version} is still installed./).to_stdout + end + end + + describe "when Casks in Taps have been renamed or removed" do + let(:app) { Hbc.appdir.join("ive-been-renamed.app") } + let(:caskroom_path) { Hbc.caskroom.join("ive-been-renamed").tap(&:mkpath) } + let(:saved_caskfile) { caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb") } + + before do + app.tap(&:mkpath) + .join("Contents").tap(&:mkpath) + .join("Info.plist").tap(&FileUtils.method(:touch)) + + caskroom_path.mkpath + + saved_caskfile.dirname.mkpath + + IO.write saved_caskfile, <<-EOS.undent + cask 'ive-been-renamed' do + version :latest + + app 'ive-been-renamed.app' + end + EOS + end + + it "can still uninstall those Casks" do + shutup do + Hbc::CLI::Uninstall.run("ive-been-renamed") + end + + expect(app).not_to exist + expect(caskroom_path).not_to exist + end + end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Uninstall.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Uninstall.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb b/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb deleted file mode 100644 index 540909be3..000000000 --- a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb +++ /dev/null @@ -1,154 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Uninstall do - it "shows an error when a bad Cask is provided" do - lambda { - Hbc::CLI::Uninstall.run("notacask") - }.must_raise Hbc::CaskUnavailableError - end - - it "shows an error when a Cask is provided that's not installed" do - lambda { - Hbc::CLI::Uninstall.run("anvil") - }.must_raise Hbc::CaskNotInstalledError - end - - it "tries anyway on a non-present Cask when --force is given" do - lambda do - Hbc::CLI::Uninstall.run("anvil", "--force") - end # wont_raise - end - - it "can uninstall and unlink multiple Casks at once" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - - shutup do - Hbc::Installer.new(caffeine).install - Hbc::Installer.new(transmission).install - end - - caffeine.must_be :installed? - transmission.must_be :installed? - - shutup do - Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission") - end - - caffeine.wont_be :installed? - Hbc.appdir.join("Transmission.app").wont_be :exist? - transmission.wont_be :installed? - Hbc.appdir.join("Caffeine.app").wont_be :exist? - end - - describe "when multiple versions of a cask are installed" do - let(:token) { "versioned-cask" } - let(:first_installed_version) { "1.2.3" } - let(:last_installed_version) { "4.5.6" } - let(:timestamped_versions) { - [ - [first_installed_version, "123000"], - [last_installed_version, "456000"], - ] - } - let(:caskroom_path) { Hbc.caskroom.join(token).tap(&:mkpath) } - - before(:each) do - timestamped_versions.each do |timestamped_version| - caskroom_path.join(".metadata", *timestamped_version, "Casks").tap(&:mkpath) - .join("#{token}.rb").open("w") do |caskfile| - caskfile.puts <<-EOS.undent - cask '#{token}' do - version '#{timestamped_version[0]}' - end - EOS - end - caskroom_path.join(timestamped_version[0]).mkpath - end - end - - after(:each) do - caskroom_path.rmtree if caskroom_path.exist? - end - - it "uninstalls one version at a time" do - shutup do - Hbc::CLI::Uninstall.run("versioned-cask") - end - - caskroom_path.join(first_installed_version).must_be :exist? - caskroom_path.join(last_installed_version).wont_be :exist? - caskroom_path.must_be :exist? - - shutup do - Hbc::CLI::Uninstall.run("versioned-cask") - end - - caskroom_path.join(first_installed_version).wont_be :exist? - caskroom_path.wont_be :exist? - end - - it "displays a message when versions remain installed" do - out, err = capture_io do - Hbc::CLI::Uninstall.run("versioned-cask") - end - - out.must_match(/#{token} #{first_installed_version} is still installed./) - err.must_be :empty? - end - end - - describe "when Casks in Taps have been renamed or removed" do - let(:app) { Hbc.appdir.join("ive-been-renamed.app") } - let(:caskroom_path) { Hbc.caskroom.join("ive-been-renamed").tap(&:mkpath) } - let(:saved_caskfile) { caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb") } - - before do - app.tap(&:mkpath) - .join("Contents").tap(&:mkpath) - .join("Info.plist").tap(&FileUtils.method(:touch)) - - caskroom_path.mkpath - - saved_caskfile.dirname.mkpath - - IO.write saved_caskfile, <<-EOS.undent - cask 'ive-been-renamed' do - version :latest - - app 'ive-been-renamed.app' - end - EOS - end - - after do - app.rmtree if app.exist? - caskroom_path.rmtree if caskroom_path.exist? - end - - it "can still uninstall those Casks" do - shutup do - Hbc::CLI::Uninstall.run("ive-been-renamed") - end - - app.wont_be :exist? - caskroom_path.wont_be :exist? - end - end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Uninstall.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Uninstall.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From 32565eb96efcda28f4c255afc4e25467b8560379 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:41:40 +0100 Subject: Convert Version test to spec. --- Library/Homebrew/cask/spec/cask/cli/version_spec.rb | 11 +++++++++++ Library/Homebrew/cask/test/cask/cli/version_test.rb | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/version_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/version_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/version_spec.rb b/Library/Homebrew/cask/spec/cask/cli/version_spec.rb new file mode 100644 index 000000000..e6fcf4850 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/version_spec.rb @@ -0,0 +1,11 @@ +require "spec_helper" + +describe "brew cask --version" do + it "respects the --version argument" do + expect { + expect { + Hbc::CLI::NullCommand.new("--version").run + }.not_to output.to_stderr + }.to output(Hbc.full_version).to_stdout + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/version_test.rb b/Library/Homebrew/cask/test/cask/cli/version_test.rb deleted file mode 100644 index 60e6d22ae..000000000 --- a/Library/Homebrew/cask/test/cask/cli/version_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "test_helper" - -describe "brew cask --version" do - it "respects the --version argument" do - lambda { - Hbc::CLI::NullCommand.new("--version").run - }.must_output Hbc.full_version - end -end -- cgit v1.2.3 From 787860c1bd228c849ab311e57a5042c1cb5162e2 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:44:28 +0100 Subject: Convert Zap test to spec. --- Library/Homebrew/cask/spec/cask/cli/zap_spec.rb | 75 +++++++++++++++++++++++++ Library/Homebrew/cask/test/cask/cli/zap_test.rb | 75 ------------------------- 2 files changed, 75 insertions(+), 75 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/cli/zap_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/cli/zap_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb b/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb new file mode 100644 index 000000000..d26114567 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb @@ -0,0 +1,75 @@ +require "spec_helper" + +describe Hbc::CLI::Zap do + it "shows an error when a bad Cask is provided" do + expect { + Hbc::CLI::Zap.run("notacask") + }.to raise_error(Hbc::CaskUnavailableError) + end + + it "can zap and unlink multiple Casks at once" do + caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + + shutup do + Hbc::Installer.new(caffeine).install + Hbc::Installer.new(transmission).install + end + + expect(caffeine).to be_installed + expect(transmission).to be_installed + + shutup do + Hbc::CLI::Zap.run("--notavalidoption", + "local-caffeine", "local-transmission") + end + + expect(caffeine).not_to be_installed + expect(Hbc.appdir.join("Caffeine.app")).not_to be_a_symlink + expect(transmission).not_to be_installed + expect(Hbc.appdir.join("Transmission.app")).not_to be_a_symlink + end + + # TODO: Explicit test that both zap and uninstall directives get dispatched. + # The above tests that implicitly. + # + # it "dispatches both uninstall and zap stanzas" do + # with_zap = Hbc.load('with-zap') + # + # shutup do + # Hbc::Installer.new(with_zap).install + # end + # + # with_zap.must_be :installed? + # + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1') + # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit']) + # + # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) + # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', + # Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path]) + # + # shutup do + # Hbc::CLI::Zap.run('with-zap') + # end + # with_zap.wont_be :installed? + # end + + describe "when no Cask is specified" do + it "raises an exception" do + expect { + Hbc::CLI::Zap.run + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end + + describe "when no Cask is specified, but an invalid option" do + it "raises an exception" do + expect { + Hbc::CLI::Zap.run("--notavalidoption") + }.to raise_error(Hbc::CaskUnspecifiedError) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/cli/zap_test.rb b/Library/Homebrew/cask/test/cask/cli/zap_test.rb deleted file mode 100644 index 0f2aa4f8e..000000000 --- a/Library/Homebrew/cask/test/cask/cli/zap_test.rb +++ /dev/null @@ -1,75 +0,0 @@ -require "test_helper" - -describe Hbc::CLI::Zap do - it "shows an error when a bad Cask is provided" do - lambda { - Hbc::CLI::Zap.run("notacask") - }.must_raise Hbc::CaskUnavailableError - end - - it "can zap and unlink multiple Casks at once" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - - shutup do - Hbc::Installer.new(caffeine).install - Hbc::Installer.new(transmission).install - end - - caffeine.must_be :installed? - transmission.must_be :installed? - - shutup do - Hbc::CLI::Zap.run("--notavalidoption", - "local-caffeine", "local-transmission") - end - - caffeine.wont_be :installed? - Hbc.appdir.join("Transmission.app").wont_be :symlink? - transmission.wont_be :installed? - Hbc.appdir.join("Caffeine.app").wont_be :symlink? - end - - # TODO: Explicit test that both zap and uninstall directives get dispatched. - # The above tests that implicitly. - # - # it "dispatches both uninstall and zap stanzas" do - # with_zap = Hbc.load('with-zap') - # - # shutup do - # Hbc::Installer.new(with_zap).install - # end - # - # with_zap.must_be :installed? - # - # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1') - # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit']) - # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1') - # Hbc::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit']) - # - # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please']) - # Hbc::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', - # Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path]) - # - # shutup do - # Hbc::CLI::Zap.run('with-zap') - # end - # with_zap.wont_be :installed? - # end - - describe "when no Cask is specified" do - it "raises an exception" do - lambda { - Hbc::CLI::Zap.run - }.must_raise Hbc::CaskUnspecifiedError - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - lambda { - Hbc::CLI::Zap.run("--notavalidoption") - }.must_raise Hbc::CaskUnspecifiedError - end - end -end -- cgit v1.2.3 From 75609f7212c9e992eec22554abb3fb5540e62d96 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 13:57:11 +0100 Subject: Convert alt target test to spec. --- .../cask/spec/cask/artifact/alt_target_spec.rb | 79 +++++++++++++++++++++ .../cask/test/cask/artifact/alt_target_test.rb | 81 ---------------------- 2 files changed, 79 insertions(+), 81 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb new file mode 100644 index 000000000..9a57a9878 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb @@ -0,0 +1,79 @@ +require "spec_helper" + +describe Hbc::Artifact::App do + describe "activate to alternate target" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") } + + let(:install_phase) { + -> { Hbc::Artifact::App.new(cask).install_phase } + } + + let(:source_path) { cask.staged_path.join("Caffeine.app") } + let(:target_path) { Hbc.appdir.join("AnotherName.app") } + + before do + InstallHelper.install_without_artifacts(cask) + end + + it "installs the given apps using the proper target directory" do + expect(source_path).to be_a_directory + expect(target_path).not_to exist + + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(source_path).not_to exist + end + + describe "when app is in a subdirectory" do + let(:cask) { + Hbc::Cask.new("subdir") do + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage "http://example.com/local-caffeine" + version "1.2.3" + sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" + app "subdir/Caffeine.app", target: "AnotherName.app" + end + } + + it "installs the given apps using the proper target directory" do + appsubdir = cask.staged_path.join("subdir").tap(&:mkpath) + FileUtils.mv(source_path, appsubdir) + + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(appsubdir.join("Caffeine.app")).not_to exist + end + end + + it "only uses apps when they are specified" do + staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app") + FileUtils.cp_r source_path, staged_app_copy + + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(source_path).not_to exist + + expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist + expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory + end + + it "avoids clobbering an existing app by moving over it" do + target_path.mkpath + + expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") + + expect(source_path).to be_a_directory + expect(target_path).to be_a_directory + expect(File.identical?(source_path, target_path)).to be false + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb b/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb deleted file mode 100644 index 06c76f337..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::App do - describe "activate to alternate target" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") } - - let(:install_phase) { - -> { Hbc::Artifact::App.new(cask).install_phase } - } - - let(:source_path) { cask.staged_path.join("Caffeine.app") } - let(:target_path) { Hbc.appdir.join("AnotherName.app") } - - before do - TestHelper.install_without_artifacts(cask) - end - - it "installs the given apps using the proper target directory" do - source_path.must_be :directory? - target_path.wont_be :exist? - - shutup do - install_phase.call - end - - target_path.must_be :directory? - source_path.wont_be :exist? - end - - describe "when app is in a subdirectory" do - let(:cask) { - Hbc::Cask.new("subdir") do - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage "http://example.com/local-caffeine" - version "1.2.3" - sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" - app "subdir/Caffeine.app", target: "AnotherName.app" - end - } - - it "installs the given apps using the proper target directory" do - appsubdir = cask.staged_path.join("subdir").tap(&:mkpath) - FileUtils.mv(source_path, appsubdir) - - shutup do - install_phase.call - end - - target_path.must_be :directory? - appsubdir.join("Caffeine.app").wont_be :exist? - end - end - - it "only uses apps when they are specified" do - staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app") - FileUtils.cp_r source_path, staged_app_copy - - shutup do - install_phase.call - end - - target_path.must_be :directory? - source_path.wont_be :exist? - - Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist? - cask.staged_path.join("Caffeine Deluxe.app").must_be :directory? - end - - it "avoids clobbering an existing app by moving over it" do - target_path.mkpath - - err = install_phase.must_raise(Hbc::CaskError) - - err.message.must_equal("It seems there is already an App at '#{target_path}'.") - - source_path.must_be :directory? - target_path.must_be :directory? - File.identical?(source_path, target_path).must_equal false - end - end -end -- cgit v1.2.3 From 20e85cc96feaa4cb4a9ddac64758297aa2bff728 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 14:23:18 +0100 Subject: Convert App test to spec. --- .../Homebrew/cask/spec/cask/artifact/app_spec.rb | 245 +++++++++++++++++++ .../Homebrew/cask/test/cask/artifact/app_test.rb | 260 --------------------- 2 files changed, 245 insertions(+), 260 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/app_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/app_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb new file mode 100644 index 000000000..b3877f000 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb @@ -0,0 +1,245 @@ +require "spec_helper" + +describe Hbc::Artifact::App do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } + let(:command) { Hbc::SystemCommand } + let(:force) { false } + let(:app) { Hbc::Artifact::App.new(cask, command: command, force: force) } + + let(:source_path) { cask.staged_path.join("Caffeine.app") } + let(:target_path) { Hbc.appdir.join("Caffeine.app") } + + let(:install_phase) { -> { app.install_phase } } + let(:uninstall_phase) { -> { app.uninstall_phase } } + + before(:each) do + InstallHelper.install_without_artifacts(cask) + end + + describe "install_phase" do + it "installs the given app using the proper target directory" do + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(source_path).not_to exist + end + + describe "when app is in a subdirectory" do + let(:cask) { + Hbc::Cask.new("subdir") do + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" + homepage "http://example.com/local-caffeine" + version "1.2.3" + sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" + app "subdir/Caffeine.app" + end + } + + it "installs the given app using the proper target directory" do + appsubdir = cask.staged_path.join("subdir").tap(&:mkpath) + FileUtils.mv(source_path, appsubdir) + + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(appsubdir.join("Caffeine.app")).not_to exist + end + end + + it "only uses apps when they are specified" do + staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app") + FileUtils.cp_r source_path, staged_app_copy + + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(source_path).not_to exist + + expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist + expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist + end + + describe "when the target already exists" do + before(:each) do + target_path.mkpath + end + + it "avoids clobbering an existing app" do + expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") + + expect(source_path).to be_a_directory + expect(target_path).to be_a_directory + expect(File.identical?(source_path, target_path)).to be false + + contents_path = target_path.join("Contents/Info.plist") + expect(contents_path).not_to exist + end + + describe "given the force option" do + let(:force) { true } + + before(:each) do + allow(Hbc::Utils).to receive(:current_user).and_return("fake_user") + end + + describe "target is both writable and user-owned" do + it "overwrites the existing app" do + stdout = <<-EOS.undent + ==> Removing App: '#{target_path}' + ==> Moving App 'Caffeine.app' to '#{target_path}' + EOS + + stderr = <<-EOS.undent + Warning: It seems there is already an App at '#{target_path}'; overwriting. + EOS + + expect { + expect(install_phase).to output(stdout).to_stdout + }.to output(stderr).to_stderr + + expect(source_path).not_to exist + expect(target_path).to be_a_directory + + contents_path = target_path.join("Contents/Info.plist") + expect(contents_path).to exist + end + end + + describe "target is user-owned but contains read-only files" do + before(:each) do + system "/usr/bin/touch", "--", "#{target_path}/foo" + system "/bin/chmod", "--", "0555", target_path + end + + it "overwrites the existing app" do + expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "--", "u+rwx", target_path], must_succeed: false) + .and_call_original + expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "-N", target_path], must_succeed: false) + .and_call_original + expect(command).to receive(:run).with("/usr/bin/chflags", args: ["-R", "--", "000", target_path], must_succeed: false) + .and_call_original + + stdout = <<-EOS.undent + ==> Removing App: '#{target_path}' + ==> Moving App 'Caffeine.app' to '#{target_path}' + EOS + + stderr = <<-EOS.undent + Warning: It seems there is already an App at '#{target_path}'; overwriting. + EOS + + expect { + expect(install_phase).to output(stdout).to_stdout + }.to output(stderr).to_stderr + + expect(source_path).not_to exist + expect(target_path).to be_a_directory + + contents_path = target_path.join("Contents/Info.plist") + expect(contents_path).to exist + end + + after(:each) do + system "/bin/chmod", "--", "0755", target_path + end + end + end + end + + describe "when the target is a broken symlink" do + let(:deleted_path) { cask.staged_path.join("Deleted.app") } + + before(:each) do + deleted_path.mkdir + File.symlink(deleted_path, target_path) + deleted_path.rmdir + end + + it "leaves the target alone" do + expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.") + expect(target_path).to be_a_symlink + end + + describe "given the force option" do + let(:force) { true } + + it "overwrites the existing app" do + stdout = <<-EOS.undent + ==> Removing App: '#{target_path}' + ==> Moving App 'Caffeine.app' to '#{target_path}' + EOS + + stderr = <<-EOS.undent + Warning: It seems there is already an App at '#{target_path}'; overwriting. + EOS + + expect { + expect(install_phase).to output(stdout).to_stdout + }.to output(stderr).to_stderr + + expect(source_path).not_to exist + expect(target_path).to be_a_directory + + contents_path = target_path.join("Contents/Info.plist") + expect(contents_path).to exist + end + end + end + + it "gives a warning if the source doesn't exist" do + source_path.rmtree + + message = "It seems the App source is not there: '#{source_path}'" + + expect(install_phase).to raise_error(Hbc::CaskError, message) + end + end + + describe "uninstall_phase" do + it "deletes managed apps" do + shutup do + install_phase.call + end + + expect(target_path).to exist + + shutup do + uninstall_phase.call + end + + expect(target_path).not_to exist + end + end + + describe "summary" do + let(:description) { app.summary[:english_description] } + let(:contents) { app.summary[:contents] } + + it "returns the correct english_description" do + expect(description).to eq("Apps") + end + + describe "app is correctly installed" do + it "returns the path to the app" do + shutup do + install_phase.call + end + + expect(contents).to eq(["#{target_path} (#{target_path.abv})"]) + end + end + + describe "app is missing" do + it "returns a warning and the supposed path to the app" do + expect(contents.size).to eq(1) + expect(contents[0]).to match(/.*Missing App.*: #{target_path}/) + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/app_test.rb b/Library/Homebrew/cask/test/cask/artifact/app_test.rb deleted file mode 100644 index 1403a34a9..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/app_test.rb +++ /dev/null @@ -1,260 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::App do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } - let(:command) { Hbc::SystemCommand } - let(:force) { false } - let(:app) { Hbc::Artifact::App.new(cask, command: command, force: force) } - - let(:source_path) { cask.staged_path.join("Caffeine.app") } - let(:target_path) { Hbc.appdir.join("Caffeine.app") } - - let(:install_phase) { -> { app.install_phase } } - let(:uninstall_phase) { -> { app.uninstall_phase } } - - before do - TestHelper.install_without_artifacts(cask) - end - - describe "install_phase" do - it "installs the given app using the proper target directory" do - shutup do - install_phase.call - end - - target_path.must_be :directory? - source_path.wont_be :exist? - end - - describe "when app is in a subdirectory" do - let(:cask) { - Hbc::Cask.new("subdir") do - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage "http://example.com/local-caffeine" - version "1.2.3" - sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" - app "subdir/Caffeine.app" - end - } - - it "installs the given app using the proper target directory" do - appsubdir = cask.staged_path.join("subdir").tap(&:mkpath) - FileUtils.mv(source_path, appsubdir) - - shutup do - install_phase.call - end - - target_path.must_be :directory? - appsubdir.join("Caffeine.app").wont_be :exist? - end - end - - it "only uses apps when they are specified" do - staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app") - FileUtils.cp_r source_path, staged_app_copy - - shutup do - install_phase.call - end - - target_path.must_be :directory? - source_path.wont_be :exist? - - Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist? - cask.staged_path.join("Caffeine Deluxe.app").must_be :exist? - end - - describe "when the target already exists" do - before do - target_path.mkpath - end - - it "avoids clobbering an existing app" do - err = install_phase.must_raise(Hbc::CaskError) - - err.message.must_equal("It seems there is already an App at '#{target_path}'.") - - source_path.must_be :directory? - target_path.must_be :directory? - File.identical?(source_path, target_path).must_equal false - - contents_path = target_path.join("Contents/Info.plist") - contents_path.wont_be :exist? - end - - describe "given the force option" do - let(:force) { true } - - before do - Hbc::Utils.stubs(current_user: "fake_user") - end - - describe "target is both writable and user-owned" do - it "overwrites the existing app" do - stdout = <<-EOS.undent - ==> Removing App: '#{target_path}' - ==> Moving App 'Caffeine.app' to '#{target_path}' - EOS - - stderr = <<-EOS.undent - Warning: It seems there is already an App at '#{target_path}'; overwriting. - EOS - - install_phase.must_output(stdout, stderr) - - source_path.wont_be :exist? - target_path.must_be :directory? - - contents_path = target_path.join("Contents/Info.plist") - contents_path.must_be :exist? - end - end - - describe "target is user-owned but contains read-only files" do - let(:command) { Hbc::FakeSystemCommand } - - let(:chmod_cmd) { - ["/bin/chmod", "-R", "--", "u+rwx", target_path] - } - - let(:chmod_n_cmd) { - ["/bin/chmod", "-R", "-N", target_path] - } - - let(:chflags_cmd) { - ["/usr/bin/chflags", "-R", "--", "000", target_path] - } - - before do - system "/usr/bin/touch", "--", "#{target_path}/foo" - system "/bin/chmod", "--", "0555", target_path - end - - it "overwrites the existing app" do - command.expect_and_pass_through(chflags_cmd) - command.expect_and_pass_through(chmod_cmd) - command.expect_and_pass_through(chmod_n_cmd) - - stdout = <<-EOS.undent - ==> Removing App: '#{target_path}' - ==> Moving App 'Caffeine.app' to '#{target_path}' - EOS - - stderr = <<-EOS.undent - Warning: It seems there is already an App at '#{target_path}'; overwriting. - EOS - - install_phase.must_output(stdout, stderr) - - source_path.wont_be :exist? - target_path.must_be :directory? - - contents_path = target_path.join("Contents/Info.plist") - contents_path.must_be :exist? - end - - after do - system "/bin/chmod", "--", "0755", target_path - end - end - end - end - - describe "when the target is a broken symlink" do - let(:deleted_path) { cask.staged_path.join("Deleted.app") } - - before do - deleted_path.mkdir - File.symlink(deleted_path, target_path) - deleted_path.rmdir - end - - it "leaves the target alone" do - err = install_phase.must_raise(Hbc::CaskError) - - err.message.must_equal("It seems there is already an App at '#{target_path}'.") - - File.symlink?(target_path).must_equal true - end - - describe "given the force option" do - let(:force) { true } - - it "overwrites the existing app" do - stdout = <<-EOS.undent - ==> Removing App: '#{target_path}' - ==> Moving App 'Caffeine.app' to '#{target_path}' - EOS - - stderr = <<-EOS.undent - Warning: It seems there is already an App at '#{target_path}'; overwriting. - EOS - - install_phase.must_output(stdout, stderr) - - source_path.wont_be :exist? - target_path.must_be :directory? - - contents_path = target_path.join("Contents/Info.plist") - contents_path.must_be :exist? - end - end - end - - it "gives a warning if the source doesn't exist" do - source_path.rmtree - - message = "It seems the App source is not there: '#{source_path}'" - - error = install_phase.must_raise(Hbc::CaskError) - error.message.must_equal message - end - end - - describe "uninstall_phase" do - before do - shutup do - install_phase.call - end - end - - it "deletes managed apps" do - target_path.must_be :exist? - - shutup do - uninstall_phase.call - end - - target_path.wont_be :exist? - end - end - - describe "summary" do - let(:description) { app.summary[:english_description] } - let(:contents) { app.summary[:contents] } - - it "returns the correct english_description" do - description.must_equal "Apps" - end - - describe "app is correctly installed" do - before do - shutup do - install_phase.call - end - end - - it "returns the path to the app" do - contents.must_equal ["#{target_path} (#{target_path.abv})"] - end - end - - describe "app is missing" do - it "returns a warning and the supposed path to the app" do - contents.size.must_equal 1 - contents[0].must_match(/.*Missing App.*: #{target_path}/) - end - end - end -end -- cgit v1.2.3 From 24d50599410dacbb36decfc957a5933e19d6a205 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 14:25:50 +0100 Subject: Convert generic artifact test to spec. --- .../spec/cask/artifact/generic_artifact_spec.rb | 47 ++++++++++++++++++++++ .../test/cask/artifact/generic_artifact_test.rb | 47 ---------------------- 2 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb new file mode 100644 index 000000000..7d9128c0e --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb @@ -0,0 +1,47 @@ +require "spec_helper" + +describe Hbc::Artifact::Artifact do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } + + let(:install_phase) { + -> { Hbc::Artifact::Artifact.new(cask).install_phase } + } + + let(:source_path) { cask.staged_path.join("Caffeine.app") } + let(:target_path) { Hbc.appdir.join("Caffeine.app") } + + before do + InstallHelper.install_without_artifacts(cask) + end + + describe "with no target" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") } + + it "fails to install with no target" do + expect(install_phase).to raise_error(Hbc::CaskInvalidError) + end + end + + it "moves the artifact to the proper directory" do + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(source_path).not_to exist + end + + it "avoids clobbering an existing artifact" do + target_path.mkpath + + expect { + shutup do + install_phase.call + end + }.to raise_error(Hbc::CaskError) + + expect(source_path).to be_a_directory + expect(target_path).to be_a_directory + expect(File.identical?(source_path, target_path)).to be false + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb b/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb deleted file mode 100644 index 21584b92a..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Artifact do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } - - let(:install_phase) { - -> { Hbc::Artifact::Artifact.new(cask).install_phase } - } - - let(:source_path) { cask.staged_path.join("Caffeine.app") } - let(:target_path) { Hbc.appdir.join("Caffeine.app") } - - before do - TestHelper.install_without_artifacts(cask) - end - - describe "with no target" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") } - - it "fails to install with no target" do - install_phase.must_raise Hbc::CaskInvalidError - end - end - - it "moves the artifact to the proper directory" do - shutup do - install_phase.call - end - - target_path.must_be :directory? - source_path.wont_be :exist? - end - - it "avoids clobbering an existing artifact" do - target_path.mkpath - - assert_raises Hbc::CaskError do - shutup do - install_phase.call - end - end - - source_path.must_be :directory? - target_path.must_be :directory? - File.identical?(source_path, target_path).must_equal false - end -end -- cgit v1.2.3 From 3db8cdf8613694a26051e0ee291f931a7ca00ae3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 14:28:18 +0100 Subject: Convert NestedContainer test to spec. --- .../cask/spec/cask/artifact/nested_container_spec.rb | 17 +++++++++++++++++ .../cask/test/cask/artifact/nested_container_test.rb | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb new file mode 100644 index 000000000..31a1cb5eb --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb @@ -0,0 +1,17 @@ +require "spec_helper" + +describe Hbc::Artifact::NestedContainer do + describe "install" do + it "extracts the specified paths as containers" do + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c| + InstallHelper.install_without_artifacts(c) + end + + shutup do + Hbc::Artifact::NestedContainer.new(cask).install_phase + end + + expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb b/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb deleted file mode 100644 index 4d7ceaaa0..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::NestedContainer do - describe "install" do - it "extracts the specified paths as containers" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c| - TestHelper.install_without_artifacts(c) - end - - shutup do - Hbc::Artifact::NestedContainer.new(cask).install_phase - end - - cask.staged_path.join("MyNestedApp.app").must_be :directory? - end - end -end -- cgit v1.2.3 From e5e8f545b72f4a8849a915dfba1acce5f39ef3ab Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 8 Feb 2017 14:37:40 +0100 Subject: Convert Artifact::Pkg test to spec. --- .../Homebrew/cask/spec/cask/artifact/pkg_spec.rb | 71 ++++++++++++++++++++++ .../Homebrew/cask/test/cask/artifact/pkg_test.rb | 64 ------------------- 2 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/pkg_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb new file mode 100644 index 000000000..d4d69ea66 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb @@ -0,0 +1,71 @@ +require "spec_helper" + +describe Hbc::Artifact::Pkg do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + let(:fake_system_command) { class_double(Hbc::SystemCommand) } + + before(:each) do + shutup do + InstallHelper.install_without_artifacts(cask) + end + end + + describe "install_phase" do + it "runs the system installer on the specified pkgs" do + pkg = Hbc::Artifact::Pkg.new(cask, command: fake_system_command) + + expect(fake_system_command).to receive(:run!).with( + "/usr/sbin/installer", + args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"], + sudo: true, + print_stdout: true + ) + + shutup do + pkg.install_phase + end + end + end + + describe "choices" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") } + + it "passes the choice changes xml to the system installer" do + pkg = Hbc::Artifact::Pkg.new(cask, command: fake_system_command) + + file = double(path: Pathname.new("/tmp/choices.xml")) + + expect(file).to receive(:write).with(<<-EOS.undent) + + + + + \t + \t\tattributeSetting + \t\t1 + \t\tchoiceAttribute + \t\tselected + \t\tchoiceIdentifier + \t\tchoice1 + \t + + + EOS + + expect(file).to receive(:close) + expect(file).to receive(:unlink) + expect(Tempfile).to receive(:open).and_yield(file) + + expect(fake_system_command).to receive(:run!).with( + "/usr/sbin/installer", + args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", cask.staged_path.join("/tmp/choices.xml")], + sudo: true, + print_stdout: true + ) + + shutup do + pkg.install_phase + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb deleted file mode 100644 index b054290ce..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Pkg do - before do - @cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") - shutup do - TestHelper.install_without_artifacts(@cask) - end - end - - describe "install_phase" do - it "runs the system installer on the specified pkgs" do - pkg = Hbc::Artifact::Pkg.new(@cask, - command: Hbc::FakeSystemCommand) - - Hbc::FakeSystemCommand.expects_command(["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", @cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"]) - - shutup do - pkg.install_phase - end - end - end - - describe "choices" do - before do - @cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") - shutup do - TestHelper.install_without_artifacts(@cask) - end - end - - it "passes the choice changes xml to the system installer" do - pkg = Hbc::Artifact::Pkg.new(@cask, command: Hbc::FakeSystemCommand) - - file = mock - file.expects(:write).with <<-EOS.undent - - - - - \t - \t\tattributeSetting - \t\t1 - \t\tchoiceAttribute - \t\tselected - \t\tchoiceIdentifier - \t\tchoice1 - \t - - - EOS - file.stubs path: Pathname.new("/tmp/choices.xml") - file.expects(:close) - file.expects(:unlink) - Tempfile.expects(:open).yields file - - Hbc::FakeSystemCommand.expects_command(["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", @cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", @cask.staged_path.join("/tmp/choices.xml")]) - - shutup do - pkg.install_phase - end - end - end -end -- cgit v1.2.3 From c431758f2dff931b69b16ab412dabacbe77380c0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:04:07 +0100 Subject: Convert Zap test to spec. --- .../Homebrew/cask/spec/cask/artifact/zap_spec.rb | 319 +++++++++++++++++++++ .../cask/spec/support/fake_system_command.rb | 77 +++++ .../Homebrew/cask/test/cask/artifact/zap_test.rb | 319 --------------------- 3 files changed, 396 insertions(+), 319 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb create mode 100644 Library/Homebrew/cask/spec/support/fake_system_command.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/zap_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb new file mode 100644 index 000000000..bd14cd6de --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb @@ -0,0 +1,319 @@ +require "spec_helper" + +# TODO: test that zap removes an alternate version of the same Cask +describe Hbc::Artifact::Zap do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + + let(:zap_artifact) { + Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand) + } + + before(:each) do + shutup do + InstallHelper.install_without_artifacts(cask) + end + end + + describe "#zap_phase" do + subject { + shutup do + zap_artifact.zap_phase + end + } + + context "when using launchctl" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") } + let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] } + let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] } + let(:unknown_response) { "launchctl list returned unknown response\n" } + let(:service_info) { + <<-EOS.undent + { + "LimitLoadToSessionType" = "Aqua"; + "Label" = "my.fancy.package.service"; + "TimeOut" = 30; + "OnDemand" = true; + "LastExitStatus" = 0; + "ProgramArguments" = ( + "argument"; + ); + }; + EOS + } + + context "when launchctl job is owned by user" do + it "can zap" do + Hbc::FakeSystemCommand.stubs_command( + launchctl_list_cmd, + service_info + ) + + Hbc::FakeSystemCommand.stubs_command( + sudo(launchctl_list_cmd), + unknown_response + ) + + Hbc::FakeSystemCommand.expects_command(launchctl_remove_cmd) + + subject + end + end + + describe "when launchctl job is owned by system" do + it "can zap" do + Hbc::FakeSystemCommand.stubs_command( + launchctl_list_cmd, + unknown_response + ) + + Hbc::FakeSystemCommand.stubs_command( + sudo(launchctl_list_cmd), + service_info + ) + + Hbc::FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) + + subject + end + end + end + + context "when using pkgutil" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-pkgutil.rb") } + let(:main_pkg_id) { "my.fancy.package.main" } + let(:agent_pkg_id) { "my.fancy.package.agent" } + let(:main_files) { + %w[ + fancy/bin/fancy.exe + fancy/var/fancy.data + ] + } + let(:main_dirs) { + %w[ + fancy + fancy/bin + fancy/var + ] + } + let(:agent_files) { + %w[ + fancy/agent/fancy-agent.exe + fancy/agent/fancy-agent.pid + fancy/agent/fancy-agent.log + ] + } + let(:agent_dirs) { + %w[ + fancy + fancy/agent + ] + } + let(:pkg_info_plist) { + <<-EOS.undent + + + + + install-location + tmp + volume + / + + + EOS + } + + it "can zap" do + Hbc::FakeSystemCommand.stubs_command( + %w[/usr/sbin/pkgutil --pkgs=my.fancy.package.*], + "#{main_pkg_id}\n#{agent_pkg_id}" + ) + + [ + [main_pkg_id, main_files, main_dirs], + [agent_pkg_id, agent_files, agent_dirs], + ].each do |pkg_id, pkg_files, pkg_dirs| + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --only-files --files #{pkg_id}], + pkg_files.join("\n") + ) + + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --only-dirs --files #{pkg_id}], + pkg_dirs.join("\n") + ) + + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --files #{pkg_id}], + (pkg_files + pkg_dirs).join("\n") + ) + + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --pkg-info-plist #{pkg_id}], + pkg_info_plist + ) + + Hbc::FakeSystemCommand.expects_command(sudo(%W[/usr/sbin/pkgutil --forget #{pkg_id}])) + + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }) + ) + end + + subject + end + end + + context "when using kext" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-kext.rb") } + let(:kext_id) { "my.fancy.package.kernelextension" } + + it "can zap" do + Hbc::FakeSystemCommand.stubs_command( + sudo(%W[/usr/sbin/kextstat -l -b #{kext_id}]), "loaded" + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(%W[/sbin/kextunload -b #{kext_id}]) + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(%W[/usr/sbin/kextfind -b #{kext_id}]), "/Library/Extensions/FancyPackage.kext\n" + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]) + ) + + subject + end + end + + context "when using quit" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-quit.rb") } + let(:bundle_id) { "my.fancy.package.app" } + let(:quit_application_script) { + %Q(tell application id "#{bundle_id}" to quit) + } + + it "can zap" do + Hbc::FakeSystemCommand.stubs_command( + %w[/bin/launchctl list], "999\t0\t#{bundle_id}\n" + ) + + Hbc::FakeSystemCommand.stubs_command( + %w[/bin/launchctl list] + ) + + subject + end + end + + context "when using signal" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-signal.rb") } + let(:bundle_id) { "my.fancy.package.app" } + let(:signals) { %w[TERM KILL] } + let(:unix_pids) { [12_345, 67_890] } + + it "can zap" do + Hbc::FakeSystemCommand.stubs_command( + %w[/bin/launchctl list], unix_pids.map { |pid| [pid, 0, bundle_id].join("\t") }.join("\n") + ) + + signals.each do |signal| + expect(Process).to receive(:kill).with(signal, *unix_pids) + end + + subject + end + end + + context "when using delete" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-delete.rb") } + + it "can zap" do + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -rf --], + Pathname.new("/permissible/absolute/path"), + Pathname.new("~/permissible/path/with/tilde").expand_path) + ) + + subject + end + end + + context "when using trash" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-trash.rb") } + + it "can zap" do + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -rf --], + Pathname.new("/permissible/absolute/path"), + Pathname.new("~/permissible/path/with/tilde").expand_path) + ) + + subject + end + end + + context "when using rmdir" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") } + let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } + + it "can zap" do + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")) + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rmdir --], dir_pathname) + ) + + subject + end + end + + context "when using script" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-script.rb") } + let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } + + it "can zap" do + Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) + + Hbc::FakeSystemCommand.expects_command( + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + ) + + subject + end + end + + context "when using early_script" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-early-script.rb") } + let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } + + it "can zap" do + Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) + + Hbc::FakeSystemCommand.expects_command( + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + ) + + subject + end + end + + context "when using login_item" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-login-item.rb") } + + it "can zap" do + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/osascript", "-e", 'tell application "System Events" to delete every login ' \ + 'item whose name is "Fancy"'] + ) + + subject + end + end + end +end diff --git a/Library/Homebrew/cask/spec/support/fake_system_command.rb b/Library/Homebrew/cask/spec/support/fake_system_command.rb new file mode 100644 index 000000000..b9390d482 --- /dev/null +++ b/Library/Homebrew/cask/spec/support/fake_system_command.rb @@ -0,0 +1,77 @@ +def sudo(*args) + %w[/usr/bin/sudo -E --] + args.flatten +end + +module Hbc + class FakeSystemCommand + def self.responses + @responses ||= {} + end + + def self.expectations + @expectations ||= {} + end + + def self.system_calls + @system_calls ||= Hash.new(0) + end + + def self.clear + @responses = nil + @expectations = nil + @system_calls = nil + end + + def self.stubs_command(command, response = "") + responses[command] = response + end + + def self.expects_command(command, response = "", times = 1) + stubs_command(command, response) + expectations[command] = times + end + + def self.expect_and_pass_through(command, times = 1) + pass_through = ->(cmd, opts) { Hbc::SystemCommand.run(cmd, opts) } + expects_command(command, pass_through, times) + end + + def self.verify_expectations! + expectations.each do |command, times| + unless system_calls[command] == times + raise("expected #{command.inspect} to be run #{times} times, but got #{system_calls[command]}") + end + end + end + + def self.run(command_string, options = {}) + command = Hbc::SystemCommand.new(command_string, options).command + puts command + unless responses.key?(command) + raise("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}") + end + system_calls[command] += 1 + + response = responses[command] + if response.respond_to?(:call) + response.call(command_string, options) + else + Hbc::SystemCommand::Result.new(command, response, "", 0) + end + end + + def self.run!(command, options = {}) + run(command, options.merge(must_succeed: true)) + end + end +end + +RSpec.configure do |config| + config.after(:each) do + begin + Hbc::FakeSystemCommand.verify_expectations! + ensure + Hbc::FakeSystemCommand.clear + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb deleted file mode 100644 index 37a65f863..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ /dev/null @@ -1,319 +0,0 @@ -require "test_helper" - -# TODO: test that zap removes an alternate version of the same Cask -describe Hbc::Artifact::Zap do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } - - let(:zap_artifact) { - Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand) - } - - before do - shutup do - TestHelper.install_without_artifacts(cask) - end - end - - describe "#zap_phase" do - subject { - shutup do - zap_artifact.zap_phase - end - } - - describe "when using launchctl" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") } - let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] } - let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] } - let(:unknown_response) { "launchctl list returned unknown response\n" } - let(:service_info) { - <<-EOS.undent - { - "LimitLoadToSessionType" = "Aqua"; - "Label" = "my.fancy.package.service"; - "TimeOut" = 30; - "OnDemand" = true; - "LastExitStatus" = 0; - "ProgramArguments" = ( - "argument"; - ); - }; - EOS - } - - describe "when launchctl job is owned by user" do - it "can zap" do - Hbc::FakeSystemCommand.stubs_command( - launchctl_list_cmd, - service_info - ) - - Hbc::FakeSystemCommand.stubs_command( - sudo(launchctl_list_cmd), - unknown_response - ) - - Hbc::FakeSystemCommand.expects_command(launchctl_remove_cmd) - - subject - end - end - - describe "when launchctl job is owned by system" do - it "can zap" do - Hbc::FakeSystemCommand.stubs_command( - launchctl_list_cmd, - unknown_response - ) - - Hbc::FakeSystemCommand.stubs_command( - sudo(launchctl_list_cmd), - service_info - ) - - Hbc::FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) - - subject - end - end - end - - describe "when using pkgutil" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-pkgutil.rb") } - let(:main_pkg_id) { "my.fancy.package.main" } - let(:agent_pkg_id) { "my.fancy.package.agent" } - let(:main_files) { - %w[ - fancy/bin/fancy.exe - fancy/var/fancy.data - ] - } - let(:main_dirs) { - %w[ - fancy - fancy/bin - fancy/var - ] - } - let(:agent_files) { - %w[ - fancy/agent/fancy-agent.exe - fancy/agent/fancy-agent.pid - fancy/agent/fancy-agent.log - ] - } - let(:agent_dirs) { - %w[ - fancy - fancy/agent - ] - } - let(:pkg_info_plist) { - <<-EOS.undent - - - - - install-location - tmp - volume - / - - - EOS - } - - it "can zap" do - Hbc::FakeSystemCommand.stubs_command( - %w[/usr/sbin/pkgutil --pkgs=my.fancy.package.*], - "#{main_pkg_id}\n#{agent_pkg_id}" - ) - - [ - [main_pkg_id, main_files, main_dirs], - [agent_pkg_id, agent_files, agent_dirs], - ].each do |pkg_id, pkg_files, pkg_dirs| - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --only-files --files #{pkg_id}], - pkg_files.join("\n") - ) - - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --only-dirs --files #{pkg_id}], - pkg_dirs.join("\n") - ) - - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --files #{pkg_id}], - (pkg_files + pkg_dirs).join("\n") - ) - - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --pkg-info-plist #{pkg_id}], - pkg_info_plist - ) - - Hbc::FakeSystemCommand.expects_command(sudo(%W[/usr/sbin/pkgutil --forget #{pkg_id}])) - - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }) - ) - end - - subject - end - end - - describe "when using kext" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-kext.rb") } - let(:kext_id) { "my.fancy.package.kernelextension" } - - it "can zap" do - Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/sbin/kextstat -l -b #{kext_id}]), "loaded" - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(%W[/sbin/kextunload -b #{kext_id}]) - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(%W[/usr/sbin/kextfind -b #{kext_id}]), "/Library/Extensions/FancyPackage.kext\n" - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]) - ) - - subject - end - end - - describe "when using quit" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-quit.rb") } - let(:bundle_id) { "my.fancy.package.app" } - let(:quit_application_script) { - %Q(tell application id "#{bundle_id}" to quit) - } - - it "can zap" do - Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list], "999\t0\t#{bundle_id}\n" - ) - - Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list] - ) - - subject - end - end - - describe "when using signal" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-signal.rb") } - let(:bundle_id) { "my.fancy.package.app" } - let(:signals) { %w[TERM KILL] } - let(:unix_pids) { [12_345, 67_890] } - - it "can zap" do - Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list], unix_pids.map { |pid| [pid, 0, bundle_id].join("\t") }.join("\n") - ) - - signals.each do |signal| - Process.expects(:kill).with(signal, *unix_pids) - end - - subject - end - end - - describe "when using delete" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-delete.rb") } - - it "can zap" do - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) - ) - - subject - end - end - - describe "when using trash" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-trash.rb") } - - it "can zap" do - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) - ) - - subject - end - end - - describe "when using rmdir" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") } - let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } - - it "can zap" do - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")) - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rmdir --], dir_pathname) - ) - - subject - end - end - - describe "when using script" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-script.rb") } - let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - - it "can zap" do - Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) - - Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") - ) - - subject - end - end - - describe "when using early_script" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-early-script.rb") } - let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - - it "can zap" do - Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) - - Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") - ) - - subject - end - end - - describe "when using login_item" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-login-item.rb") } - - it "can zap" do - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/osascript", "-e", 'tell application "System Events" to delete every login ' \ - 'item whose name is "Fancy"'] - ) - - subject - end - end - end -end -- cgit v1.2.3 From ed197c6f82e8f8aafa07a98f60ddf6bf64964884 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:19:24 +0100 Subject: Convert Suite test to spec. --- .../Homebrew/cask/spec/cask/artifact/suite_spec.rb | 49 ++++++++++++++++++++++ .../Homebrew/cask/test/cask/artifact/suite_test.rb | 48 --------------------- 2 files changed, 49 insertions(+), 48 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/suite_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb new file mode 100644 index 000000000..79ca0546c --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb @@ -0,0 +1,49 @@ +require "spec_helper" + +describe Hbc::Artifact::Suite do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") } + + let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } } + + let(:target_path) { Hbc.appdir.join("Caffeine") } + let(:source_path) { cask.staged_path.join("Caffeine") } + + before(:each) do + InstallHelper.install_without_artifacts(cask) + end + + it "moves the suite to the proper directory" do + skip("flaky test") # FIXME + + shutup do + install_phase.call + end + + expect(target_path).to be_a_directory + expect(target_path).to be_a_symlink + expect(target_path.readlink).to exist + expect(source_path).not_to exist + end + + it "creates a suite containing the expected app" do + shutup do + install_phase.call + end + + expect(target_path.join("Caffeine.app")).to exist + end + + it "avoids clobbering an existing suite by moving over it" do + target_path.mkpath + + expect { + shutup do + install_phase.call + end + }.to raise_error(Hbc::CaskError) + + expect(source_path).to be_a_directory + expect(target_path).to be_a_directory + expect(File.identical?(source_path, target_path)).to be false + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb deleted file mode 100644 index 6259baa4b..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Suite do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") } - - let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } } - - let(:target_path) { Hbc.appdir.join("Caffeine") } - let(:source_path) { cask.staged_path.join("Caffeine") } - - before do - TestHelper.install_without_artifacts(cask) - end - - it "moves the suite to the proper directory" do - skip("flaky test") - - shutup do - install_phase.call - end - - target_path.must_be :directory? - TestHelper.valid_symlink?(target_path).must_equal false - source_path.wont_be :exist? - end - - it "creates a suite containing the expected app" do - shutup do - install_phase.call - end - - target_path.join("Caffeine.app").must_be :exist? - end - - it "avoids clobbering an existing suite by moving over it" do - target_path.mkpath - - assert_raises Hbc::CaskError do - shutup do - install_phase.call - end - end - - source_path.must_be :directory? - target_path.must_be :directory? - File.identical?(source_path, target_path).must_equal false - end -end -- cgit v1.2.3 From 1647b9d97a744de066ff87cccf59fbb6fe278680 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:26:28 +0100 Subject: Convert two apps correct test to spec. --- .../spec/cask/artifact/two_apps_correct_spec.rb | 93 +++++++++++++++++++++ .../test/cask/artifact/two_apps_correct_test.rb | 97 ---------------------- 2 files changed, 93 insertions(+), 97 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb new file mode 100644 index 000000000..7fa44dbce --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb @@ -0,0 +1,93 @@ +require "spec_helper" + +describe Hbc::Artifact::App do + describe "multiple apps" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") } + + let(:install_phase) { + -> { Hbc::Artifact::App.new(cask).install_phase } + } + + let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") } + let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") } + + let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") } + let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") } + + before(:each) do + InstallHelper.install_without_artifacts(cask) + end + + it "installs both apps using the proper target directory" do + shutup do + install_phase.call + end + + expect(target_path_mini).to be_a_directory + expect(source_path_mini).not_to exist + + expect(target_path_pro).to be_a_directory + expect(source_path_pro).not_to exist + end + + describe "when apps are in a subdirectory" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") } + + it "installs both apps using the proper target directory" do + shutup do + install_phase.call + end + + expect(target_path_mini).to be_a_directory + expect(source_path_mini).not_to exist + + expect(target_path_pro).to be_a_directory + expect(source_path_pro).not_to exist + end + end + + it "only uses apps when they are specified" do + FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app") + + shutup do + install_phase.call + end + + expect(target_path_mini).to be_a_directory + expect(source_path_mini).not_to exist + + expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist + expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist + end + + describe "avoids clobbering an existing app" do + it "when the first app of two already exists" do + target_path_mini.mkpath + + expect { + expect(install_phase).to output(<<-EOS.undent).to_stdout + ==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}' + EOS + }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path_mini}'.") + + expect(source_path_mini).to be_a_directory + expect(target_path_mini).to be_a_directory + expect(File.identical?(source_path_mini, target_path_mini)).to be false + end + + it "when the second app of two already exists" do + target_path_pro.mkpath + + expect { + expect(install_phase).to output(<<-EOS.undent).to_stdout + ==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}' + EOS + }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path_pro}'.") + + expect(source_path_pro).to be_a_directory + expect(target_path_pro).to be_a_directory + expect(File.identical?(source_path_pro, target_path_pro)).to be false + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb deleted file mode 100644 index c6ad9db47..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb +++ /dev/null @@ -1,97 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::App do - describe "multiple apps" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") } - - let(:install_phase) { - -> { Hbc::Artifact::App.new(cask).install_phase } - } - - let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") } - let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") } - - let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") } - let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") } - - before do - TestHelper.install_without_artifacts(cask) - end - - it "installs both apps using the proper target directory" do - shutup do - install_phase.call - end - - target_path_mini.must_be :directory? - source_path_mini.wont_be :exist? - - target_path_pro.must_be :directory? - source_path_pro.wont_be :exist? - end - - describe "when apps are in a subdirectory" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") } - - it "installs both apps using the proper target directory" do - shutup do - install_phase.call - end - - target_path_mini.must_be :directory? - source_path_mini.wont_be :exist? - - target_path_pro.must_be :directory? - source_path_pro.wont_be :exist? - end - end - - it "only uses apps when they are specified" do - FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app") - - shutup do - install_phase.call - end - - target_path_mini.must_be :directory? - source_path_mini.wont_be :exist? - - Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist? - cask.staged_path.join("Caffeine Deluxe.app").must_be :exist? - end - - describe "avoids clobbering an existing app" do - it "when the first app of two already exists" do - target_path_mini.mkpath - - err = assert_raises Hbc::CaskError do - install_phase.must_output <<-EOS.undent - ==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}' - EOS - end - - err.message.must_equal("It seems there is already an App at '#{target_path_mini}'.") - - source_path_mini.must_be :directory? - target_path_mini.must_be :directory? - File.identical?(source_path_mini, target_path_mini).must_equal false - end - - it "when the second app of two already exists" do - target_path_pro.mkpath - - err = assert_raises Hbc::CaskError do - install_phase.must_output <<-EOS.undent - ==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}' - EOS - end - - err.message.must_equal("It seems there is already an App at '#{target_path_pro}'.") - - source_path_pro.must_be :directory? - target_path_pro.must_be :directory? - File.identical?(source_path_pro, target_path_pro).must_equal false - end - end - end -end -- cgit v1.2.3 From 2cecf98023ee39fc14f7c5f236b1969e2e6855b1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:26:57 +0100 Subject: Convert two apps incorrect test to spec. --- .../cask/spec/cask/artifact/two_apps_incorrect_spec.rb | 11 +++++++++++ .../cask/test/cask/artifact/two_apps_incorrect_test.rb | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb new file mode 100644 index 000000000..0aa38d910 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb @@ -0,0 +1,11 @@ +require "spec_helper" + +describe Hbc::Artifact::App do + # FIXME: Doesn't actually raise because the `app` stanza is not evaluated on load. + # it "must raise" do + # lambda { + # Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-incorrect.rb") + # }.must_raise + # # TODO: later give the user a nice exception for this case and check for it here + # end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb deleted file mode 100644 index a79fc6378..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::App do - # FIXME: Doesn't actually raise because the `app` stanza is not evaluated on load. - # it "must raise" do - # lambda { - # Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-incorrect.rb") - # }.must_raise - # # TODO: later give the user a nice exception for this case and check for it here - # end -end -- cgit v1.2.3 From 4de74bf744ff3006da32bf592735718fec9798d6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:29:53 +0100 Subject: Convert uninstall test to spec. --- .../cask/spec/cask/artifact/uninstall_spec.rb | 318 +++++++++++++++++++++ .../cask/test/cask/artifact/uninstall_test.rb | 318 --------------------- 2 files changed, 318 insertions(+), 318 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb new file mode 100644 index 000000000..008e2ad2a --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb @@ -0,0 +1,318 @@ +require "spec_helper" + +describe Hbc::Artifact::Uninstall do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + + let(:uninstall_artifact) { + Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand) + } + + before(:each) do + shutup do + InstallHelper.install_without_artifacts(cask) + end + end + + describe "uninstall_phase" do + subject { + shutup do + uninstall_artifact.uninstall_phase + end + } + + context "when using launchctl" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") } + let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] } + let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] } + let(:unknown_response) { "launchctl list returned unknown response\n" } + let(:service_info) { + <<-EOS.undent + { + "LimitLoadToSessionType" = "Aqua"; + "Label" = "my.fancy.package.service"; + "TimeOut" = 30; + "OnDemand" = true; + "LastExitStatus" = 0; + "ProgramArguments" = ( + "argument"; + ); + }; + EOS + } + + context "when launchctl job is owned by user" do + it "can uninstall" do + Hbc::FakeSystemCommand.stubs_command( + launchctl_list_cmd, + service_info + ) + + Hbc::FakeSystemCommand.stubs_command( + sudo(launchctl_list_cmd), + unknown_response + ) + + Hbc::FakeSystemCommand.expects_command(launchctl_remove_cmd) + + subject + end + end + + context "when launchctl job is owned by system" do + it "can uninstall" do + Hbc::FakeSystemCommand.stubs_command( + launchctl_list_cmd, + unknown_response + ) + + Hbc::FakeSystemCommand.stubs_command( + sudo(launchctl_list_cmd), + service_info + ) + + Hbc::FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) + + subject + end + end + end + + context "when using pkgutil" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-pkgutil.rb") } + let(:main_pkg_id) { "my.fancy.package.main" } + let(:agent_pkg_id) { "my.fancy.package.agent" } + let(:main_files) { + %w[ + fancy/bin/fancy.exe + fancy/var/fancy.data + ] + } + let(:main_dirs) { + %w[ + fancy + fancy/bin + fancy/var + ] + } + let(:agent_files) { + %w[ + fancy/agent/fancy-agent.exe + fancy/agent/fancy-agent.pid + fancy/agent/fancy-agent.log + ] + } + let(:agent_dirs) { + %w[ + fancy + fancy/agent + ] + } + let(:pkg_info_plist) { + <<-EOS.undent + + + + + install-location + tmp + volume + / + + + EOS + } + + it "can uninstall" do + Hbc::FakeSystemCommand.stubs_command( + %w[/usr/sbin/pkgutil --pkgs=my.fancy.package.*], + "#{main_pkg_id}\n#{agent_pkg_id}" + ) + + [ + [main_pkg_id, main_files, main_dirs], + [agent_pkg_id, agent_files, agent_dirs], + ].each do |pkg_id, pkg_files, pkg_dirs| + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --only-files --files #{pkg_id}], + pkg_files.join("\n") + ) + + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --only-dirs --files #{pkg_id}], + pkg_dirs.join("\n") + ) + + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --files #{pkg_id}], + (pkg_files + pkg_dirs).join("\n") + ) + + Hbc::FakeSystemCommand.stubs_command( + %W[/usr/sbin/pkgutil --pkg-info-plist #{pkg_id}], + pkg_info_plist + ) + + Hbc::FakeSystemCommand.expects_command(sudo(%W[/usr/sbin/pkgutil --forget #{pkg_id}])) + + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }) + ) + end + + subject + end + end + + context "when using kext" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-kext.rb") } + let(:kext_id) { "my.fancy.package.kernelextension" } + + it "can uninstall" do + Hbc::FakeSystemCommand.stubs_command( + sudo(%W[/usr/sbin/kextstat -l -b #{kext_id}]), "loaded" + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(%W[/sbin/kextunload -b #{kext_id}]) + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(%W[/usr/sbin/kextfind -b #{kext_id}]), "/Library/Extensions/FancyPackage.kext\n" + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]) + ) + + subject + end + end + + context "when using quit" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-quit.rb") } + let(:bundle_id) { "my.fancy.package.app" } + let(:quit_application_script) { + %Q(tell application id "#{bundle_id}" to quit) + } + + it "can uninstall" do + Hbc::FakeSystemCommand.stubs_command( + %w[/bin/launchctl list], "999\t0\t#{bundle_id}\n" + ) + + Hbc::FakeSystemCommand.stubs_command( + %w[/bin/launchctl list] + ) + + subject + end + end + + context "when using signal" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-signal.rb") } + let(:bundle_id) { "my.fancy.package.app" } + let(:signals) { %w[TERM KILL] } + let(:unix_pids) { [12_345, 67_890] } + + it "can uninstall" do + Hbc::FakeSystemCommand.stubs_command( + %w[/bin/launchctl list], unix_pids.map { |pid| [pid, 0, bundle_id].join("\t") }.join("\n") + ) + + signals.each do |signal| + expect(Process).to receive(:kill).with(signal, *unix_pids) + end + + subject + end + end + + context "when using delete" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-delete.rb") } + + it "can uninstall" do + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -rf --], + Pathname.new("/permissible/absolute/path"), + Pathname.new("~/permissible/path/with/tilde").expand_path) + ) + + subject + end + end + + context "when using trash" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-trash.rb") } + + it "can uninstall" do + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -rf --], + Pathname.new("/permissible/absolute/path"), + Pathname.new("~/permissible/path/with/tilde").expand_path) + ) + + subject + end + end + + context "when using rmdir" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") } + let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } + + it "can uninstall" do + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")) + ) + + Hbc::FakeSystemCommand.expects_command( + sudo(%w[/bin/rmdir --], dir_pathname) + ) + + subject + end + end + + context "when using script" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script.rb") } + let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } + + it "can uninstall" do + Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) + + Hbc::FakeSystemCommand.expects_command( + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + ) + + subject + end + end + + context "when using early_script" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-early-script.rb") } + let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } + + it "can uninstall" do + Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) + + Hbc::FakeSystemCommand.expects_command( + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + ) + + subject + end + end + + context "when using login_item" do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-login-item.rb") } + + it "can uninstall" do + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/osascript", "-e", 'tell application "System Events" to delete every login ' \ + 'item whose name is "Fancy"'] + ) + + subject + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb deleted file mode 100644 index 464cad345..000000000 --- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb +++ /dev/null @@ -1,318 +0,0 @@ -require "test_helper" - -describe Hbc::Artifact::Uninstall do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } - - let(:uninstall_artifact) { - Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand) - } - - before do - shutup do - TestHelper.install_without_artifacts(cask) - end - end - - describe "uninstall_phase" do - subject { - shutup do - uninstall_artifact.uninstall_phase - end - } - - describe "when using launchctl" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") } - let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] } - let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] } - let(:unknown_response) { "launchctl list returned unknown response\n" } - let(:service_info) { - <<-EOS.undent - { - "LimitLoadToSessionType" = "Aqua"; - "Label" = "my.fancy.package.service"; - "TimeOut" = 30; - "OnDemand" = true; - "LastExitStatus" = 0; - "ProgramArguments" = ( - "argument"; - ); - }; - EOS - } - - describe "when launchctl job is owned by user" do - it "can uninstall" do - Hbc::FakeSystemCommand.stubs_command( - launchctl_list_cmd, - service_info - ) - - Hbc::FakeSystemCommand.stubs_command( - sudo(launchctl_list_cmd), - unknown_response - ) - - Hbc::FakeSystemCommand.expects_command(launchctl_remove_cmd) - - subject - end - end - - describe "when launchctl job is owned by system" do - it "can uninstall" do - Hbc::FakeSystemCommand.stubs_command( - launchctl_list_cmd, - unknown_response - ) - - Hbc::FakeSystemCommand.stubs_command( - sudo(launchctl_list_cmd), - service_info - ) - - Hbc::FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) - - subject - end - end - end - - describe "when using pkgutil" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-pkgutil.rb") } - let(:main_pkg_id) { "my.fancy.package.main" } - let(:agent_pkg_id) { "my.fancy.package.agent" } - let(:main_files) { - %w[ - fancy/bin/fancy.exe - fancy/var/fancy.data - ] - } - let(:main_dirs) { - %w[ - fancy - fancy/bin - fancy/var - ] - } - let(:agent_files) { - %w[ - fancy/agent/fancy-agent.exe - fancy/agent/fancy-agent.pid - fancy/agent/fancy-agent.log - ] - } - let(:agent_dirs) { - %w[ - fancy - fancy/agent - ] - } - let(:pkg_info_plist) { - <<-EOS.undent - - - - - install-location - tmp - volume - / - - - EOS - } - - it "can uninstall" do - Hbc::FakeSystemCommand.stubs_command( - %w[/usr/sbin/pkgutil --pkgs=my.fancy.package.*], - "#{main_pkg_id}\n#{agent_pkg_id}" - ) - - [ - [main_pkg_id, main_files, main_dirs], - [agent_pkg_id, agent_files, agent_dirs], - ].each do |pkg_id, pkg_files, pkg_dirs| - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --only-files --files #{pkg_id}], - pkg_files.join("\n") - ) - - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --only-dirs --files #{pkg_id}], - pkg_dirs.join("\n") - ) - - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --files #{pkg_id}], - (pkg_files + pkg_dirs).join("\n") - ) - - Hbc::FakeSystemCommand.stubs_command( - %W[/usr/sbin/pkgutil --pkg-info-plist #{pkg_id}], - pkg_info_plist - ) - - Hbc::FakeSystemCommand.expects_command(sudo(%W[/usr/sbin/pkgutil --forget #{pkg_id}])) - - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }) - ) - end - - subject - end - end - - describe "when using kext" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-kext.rb") } - let(:kext_id) { "my.fancy.package.kernelextension" } - - it "can uninstall" do - Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/sbin/kextstat -l -b #{kext_id}]), "loaded" - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(%W[/sbin/kextunload -b #{kext_id}]) - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(%W[/usr/sbin/kextfind -b #{kext_id}]), "/Library/Extensions/FancyPackage.kext\n" - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]) - ) - - subject - end - end - - describe "when using quit" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-quit.rb") } - let(:bundle_id) { "my.fancy.package.app" } - let(:quit_application_script) { - %Q(tell application id "#{bundle_id}" to quit) - } - - it "can uninstall" do - Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list], "999\t0\t#{bundle_id}\n" - ) - - Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list] - ) - - subject - end - end - - describe "when using signal" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-signal.rb") } - let(:bundle_id) { "my.fancy.package.app" } - let(:signals) { %w[TERM KILL] } - let(:unix_pids) { [12_345, 67_890] } - - it "can uninstall" do - Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list], unix_pids.map { |pid| [pid, 0, bundle_id].join("\t") }.join("\n") - ) - - signals.each do |signal| - Process.expects(:kill).with(signal, *unix_pids) - end - - subject - end - end - - describe "when using delete" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-delete.rb") } - - it "can uninstall" do - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) - ) - - subject - end - end - - describe "when using trash" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-trash.rb") } - - it "can uninstall" do - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) - ) - - subject - end - end - - describe "when using rmdir" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") } - let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } - - it "can uninstall" do - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")) - ) - - Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rmdir --], dir_pathname) - ) - - subject - end - end - - describe "when using script" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script.rb") } - let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - - it "can uninstall" do - Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) - - Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") - ) - - subject - end - end - - describe "when using early_script" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-early-script.rb") } - let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - - it "can uninstall" do - Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) - - Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") - ) - - subject - end - end - - describe "when using login_item" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-login-item.rb") } - - it "can uninstall" do - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/osascript", "-e", 'tell application "System Events" to delete every login ' \ - 'item whose name is "Fancy"'] - ) - - subject - end - end - end -end -- cgit v1.2.3 From 92e2e7a21665aad705d76b90735aed854b7a09f5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:31:55 +0100 Subject: Convert DMG test to spec. --- .../Homebrew/cask/spec/cask/container/dmg_spec.rb | 22 ++++++++++++++++++++++ .../Homebrew/cask/test/cask/container/dmg_test.rb | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/container/dmg_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/container/dmg_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb new file mode 100644 index 000000000..af42d89b1 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb @@ -0,0 +1,22 @@ +require "spec_helper" + +describe Hbc::Container::Dmg do + describe "#mount!" do + it "does not store nil mounts for dmgs with extra data" do + transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + + dmg = Hbc::Container::Dmg.new( + transmission, + Pathname(transmission.url.path), + Hbc::SystemCommand + ) + + begin + dmg.mount! + expect(dmg.mounts).not_to include nil + ensure + dmg.eject! + end + end + end +end diff --git a/Library/Homebrew/cask/test/cask/container/dmg_test.rb b/Library/Homebrew/cask/test/cask/container/dmg_test.rb deleted file mode 100644 index 67161c580..000000000 --- a/Library/Homebrew/cask/test/cask/container/dmg_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require "test_helper" - -describe Hbc::Container::Dmg do - describe "mount!" do - it "does not store nil mounts for dmgs with extra data" do - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") - - dmg = Hbc::Container::Dmg.new( - transmission, - Pathname(transmission.url.path), - Hbc::SystemCommand - ) - - begin - dmg.mount! - dmg.mounts.wont_include nil - ensure - dmg.eject! - end - end - end -end -- cgit v1.2.3 From 59668d27108c34499ae8d00dd9354dc57a112de0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:34:35 +0100 Subject: Convert naked test to spec. --- .../cask/spec/cask/container/naked_spec.rb | 25 ++++++++++++++++++++++ .../cask/test/cask/container/naked_test.rb | 20 ----------------- 2 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/container/naked_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/container/naked_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/container/naked_spec.rb b/Library/Homebrew/cask/spec/cask/container/naked_spec.rb new file mode 100644 index 000000000..ee4102eca --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/container/naked_spec.rb @@ -0,0 +1,25 @@ +require "spec_helper" + +describe Hbc::Container::Naked do + it "saves files with spaces in them from uris with encoded spaces" do + cask = Hbc::Cask.new("spacey") do + url "http://example.com/kevin%20spacey.pkg" + version "1.2" + end + + path = "/tmp/downloads/kevin-spacey-1.2.pkg" + expected_destination = cask.staged_path.join("kevin spacey.pkg") + expected_command = ["/usr/bin/ditto", "--", path, expected_destination] + Hbc::FakeSystemCommand.stubs_command(expected_command) + + container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand) + + expect { + shutup do + container.extract + end + }.not_to raise_error + + expect(Hbc::FakeSystemCommand.system_calls[expected_command]).to eq(1) + end +end diff --git a/Library/Homebrew/cask/test/cask/container/naked_test.rb b/Library/Homebrew/cask/test/cask/container/naked_test.rb deleted file mode 100644 index d40c16de5..000000000 --- a/Library/Homebrew/cask/test/cask/container/naked_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "test_helper" - -describe Hbc::Container::Naked do - it "saves files with spaces in them from uris with encoded spaces" do - cask = Hbc::Cask.new("spacey") do - url "http://example.com/kevin%20spacey.pkg" - version "1.2" - end - - path = "/tmp/downloads/kevin-spacey-1.2.pkg" - expected_destination = cask.staged_path.join("kevin spacey.pkg") - expected_command = ["/usr/bin/ditto", "--", path, expected_destination] - Hbc::FakeSystemCommand.stubs_command(expected_command) - - container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand) - container.extract - - Hbc::FakeSystemCommand.system_calls[expected_command].must_equal 1 - end -end -- cgit v1.2.3 From ba61d3ca6ba6ee4d8553d7f3df1b0de88806a6fe Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:49:12 +0100 Subject: Convert caveats test to spec. --- .../Homebrew/cask/spec/cask/dsl/caveats_spec.rb | 10 ++++++++++ Library/Homebrew/cask/spec/spec_helper.rb | 2 +- .../cask/spec/support/shared_examples/dsl_base.rb | 23 ++++++++++++++++++++++ .../Homebrew/cask/test/cask/dsl/caveats_test.rb | 10 ---------- .../cask/test/support/shared_examples/dsl_base.rb | 23 ---------------------- Library/Homebrew/cask/test/test_helper.rb | 1 - 6 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb create mode 100644 Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb delete mode 100644 Library/Homebrew/cask/test/cask/dsl/caveats_test.rb delete mode 100644 Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb new file mode 100644 index 000000000..777491d66 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb @@ -0,0 +1,10 @@ +require "spec_helper" + +describe Hbc::DSL::Caveats do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:dsl) { Hbc::DSL::Caveats.new(cask) } + + it_behaves_like Hbc::DSL::Base + + # TODO: add tests for Caveats DSL methods +end diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 13ed746b5..0a7327b08 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -17,7 +17,7 @@ $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) require "test/support/helper/shutup" -Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require)) +Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "**", "*.rb")).each(&method(:require)) require "hbc" diff --git a/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb new file mode 100644 index 000000000..400ff40f6 --- /dev/null +++ b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb @@ -0,0 +1,23 @@ +require "hbc/dsl/base" + +shared_examples Hbc::DSL::Base do + it "supports the token method" do + expect(dsl.token).to eq(cask.token) + end + + it "supports the version method" do + expect(dsl.version).to eq(cask.version) + end + + it "supports the caskroom_path method" do + expect(dsl.caskroom_path).to eq(cask.caskroom_path) + end + + it "supports the staged_path method" do + expect(dsl.staged_path).to eq(cask.staged_path) + end + + it "supports the appdir method" do + expect(dsl.appdir).to eq(cask.appdir) + end +end diff --git a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb b/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb deleted file mode 100644 index 37845e7c3..000000000 --- a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "test_helper" - -describe Hbc::DSL::Caveats do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } - let(:dsl) { Hbc::DSL::Caveats.new(cask) } - - it_behaves_like Hbc::DSL::Base - - # TODO: add tests for Caveats DSL methods -end diff --git a/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb deleted file mode 100644 index 28115bb4b..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "test_helper" - -shared_examples_for Hbc::DSL::Base do - it "supports the token method" do - dsl.token.must_equal cask.token - end - - it "supports the version method" do - dsl.version.must_equal cask.version - end - - it "supports the caskroom_path method" do - dsl.caskroom_path.must_equal cask.caskroom_path - end - - it "supports the staged_path method" do - dsl.staged_path.must_equal cask.staged_path - end - - it "supports the appdir method" do - dsl.appdir.must_equal cask.appdir - end -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index f600a1c5c..57b468d0f 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -93,7 +93,6 @@ end # Extend MiniTest API with support for RSpec-style shared examples require "support/shared_examples" -require "support/shared_examples/dsl_base.rb" require "support/shared_examples/staged.rb" require "support/fake_dirs" -- cgit v1.2.3 From e7c943b561cc9c0bfc1d0923783e5dbf729bc076 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:57:53 +0100 Subject: Convert postflight test to spec. --- .../Homebrew/cask/spec/cask/dsl/postflight_spec.rb | 12 ++ .../cask/spec/support/shared_examples/staged.rb | 143 +++++++++++++++++++++ .../Homebrew/cask/test/cask/dsl/postflight_test.rb | 12 -- .../cask/test/support/shared_examples/staged.rb | 109 ---------------- Library/Homebrew/cask/test/test_helper.rb | 1 - 5 files changed, 155 insertions(+), 122 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb create mode 100644 Library/Homebrew/cask/spec/support/shared_examples/staged.rb delete mode 100644 Library/Homebrew/cask/test/cask/dsl/postflight_test.rb delete mode 100644 Library/Homebrew/cask/test/support/shared_examples/staged.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb new file mode 100644 index 000000000..116a7c8a8 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb @@ -0,0 +1,12 @@ +require "spec_helper" + +describe Hbc::DSL::Postflight do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) } + + it_behaves_like Hbc::DSL::Base + + it_behaves_like Hbc::Staged do + let(:staged) { dsl } + end +end diff --git a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb new file mode 100644 index 000000000..f791696ac --- /dev/null +++ b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb @@ -0,0 +1,143 @@ +require "spec_helper" + +require "hbc/staged" + +shared_examples Hbc::Staged do + let(:fake_pathname_exists) { + fake_pathname = Pathname.new("/path/to/file/that/exists") + allow(fake_pathname).to receive(:exist?).and_return(true) + allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname) + fake_pathname + } + + let(:fake_pathname_does_not_exist) { + fake_pathname = Pathname.new("/path/to/file/that/does/not/exist") + allow(fake_pathname).to receive(:exist?).and_return(false) + allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname) + fake_pathname + } + + it "can run system commands with list-form arguments" do + Hbc::FakeSystemCommand.expects_command( + ["echo", "homebrew-cask", "rocks!"] + ) + + shutup do + staged.system_command("echo", args: ["homebrew-cask", "rocks!"]) + end + end + + it "can get the Info.plist file for the primary app" do + expect(staged.info_plist_file.to_s).to include Hbc.appdir.join("TestCask.app/Contents/Info.plist") + end + + it "can execute commands on the Info.plist file" do + allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask") + + Hbc::FakeSystemCommand.expects_command( + ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file] + ) + + shutup do + staged.plist_exec("Print CFBundleIdentifier") + end + end + + it "can set a key in the Info.plist file" do + allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask") + + Hbc::FakeSystemCommand.expects_command( + ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file] + ) + + shutup do + staged.plist_set(":JVMOptions:JVMVersion", "1.6+") + end + end + + it "can set the permissions of a file" do + fake_pathname = fake_pathname_exists + allow(staged).to receive(:Pathname).and_return(fake_pathname) + + Hbc::FakeSystemCommand.expects_command( + ["/bin/chmod", "-R", "--", "777", fake_pathname] + ) + + shutup do + staged.set_permissions(fake_pathname.to_s, "777") + end + end + + it "can set the permissions of multiple files" do + fake_pathname = fake_pathname_exists + allow(staged).to receive(:Pathname).and_return(fake_pathname) + + Hbc::FakeSystemCommand.expects_command( + ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] + ) + + shutup do + staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777") + end + end + + it "cannot set the permissions of a file that does not exist" do + fake_pathname = fake_pathname_does_not_exist + allow(staged).to receive(:Pathname).and_return(fake_pathname) + staged.set_permissions(fake_pathname.to_s, "777") + end + + it "can set the ownership of a file" do + fake_pathname = fake_pathname_exists + + allow(staged).to receive(:current_user).and_return("fake_user") + allow(staged).to receive(:Pathname).and_return(fake_pathname) + + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname] + ) + + shutup do + staged.set_ownership(fake_pathname.to_s) + end + end + + it "can set the ownership of multiple files" do + fake_pathname = fake_pathname_exists + + allow(staged).to receive(:current_user).and_return("fake_user") + allow(staged).to receive(:Pathname).and_return(fake_pathname) + + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname] + ) + + shutup do + staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s]) + end + end + + it "can set the ownership of a file with a different user and group" do + fake_pathname = fake_pathname_exists + + allow(staged).to receive(:Pathname).and_return(fake_pathname) + + Hbc::FakeSystemCommand.expects_command( + ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname] + ) + + shutup do + staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group") + end + end + + it "cannot set the ownership of a file that does not exist" do + allow(staged).to receive(:current_user).and_return("fake_user") + fake_pathname = fake_pathname_does_not_exist + allow(staged).to receive(:Pathname).and_return(fake_pathname) + + shutup do + staged.set_ownership(fake_pathname.to_s) + end + end +end diff --git a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb deleted file mode 100644 index b5b38102d..000000000 --- a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "test_helper" - -describe Hbc::DSL::Postflight do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } - let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) } - - it_behaves_like Hbc::DSL::Base - - it_behaves_like Hbc::Staged do - let(:staged) { dsl } - end -end diff --git a/Library/Homebrew/cask/test/support/shared_examples/staged.rb b/Library/Homebrew/cask/test/support/shared_examples/staged.rb deleted file mode 100644 index 95e75726e..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples/staged.rb +++ /dev/null @@ -1,109 +0,0 @@ -require "test_helper" - -shared_examples_for Hbc::Staged do - let(:fake_pathname_exists) { - fake_pathname = Pathname("/path/to/file/that/exists") - fake_pathname.stubs(exist?: true, expand_path: fake_pathname) - fake_pathname - } - - let(:fake_pathname_does_not_exist) { - fake_pathname = Pathname("/path/to/file/that/does/not/exist") - fake_pathname.stubs(exist?: false, expand_path: fake_pathname) - fake_pathname - } - - it "can run system commands with list-form arguments" do - Hbc::FakeSystemCommand.expects_command( - ["echo", "homebrew-cask", "rocks!"] - ) - staged.system_command("echo", args: ["homebrew-cask", "rocks!"]) - end - - it "can get the Info.plist file for the primary app" do - staged.info_plist_file.to_s.must_include Hbc.appdir.join("TestCask.app/Contents/Info.plist") - end - - it "can execute commands on the Info.plist file" do - staged.stubs(bundle_identifier: "com.example.BasicCask") - - Hbc::FakeSystemCommand.expects_command( - ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file] - ) - staged.plist_exec("Print CFBundleIdentifier") - end - - it "can set a key in the Info.plist file" do - staged.stubs(bundle_identifier: "com.example.BasicCask") - - Hbc::FakeSystemCommand.expects_command( - ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file] - ) - staged.plist_set(":JVMOptions:JVMVersion", "1.6+") - end - - it "can set the permissions of a file" do - fake_pathname = fake_pathname_exists - staged.stubs(Pathname: fake_pathname) - - Hbc::FakeSystemCommand.expects_command( - ["/bin/chmod", "-R", "--", "777", fake_pathname] - ) - staged.set_permissions(fake_pathname.to_s, "777") - end - - it "can set the permissions of multiple files" do - fake_pathname = fake_pathname_exists - staged.stubs(:Pathname).returns(fake_pathname) - - Hbc::FakeSystemCommand.expects_command( - ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] - ) - staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777") - end - - it "cannot set the permissions of a file that does not exist" do - fake_pathname = fake_pathname_does_not_exist - staged.stubs(Pathname: fake_pathname) - staged.set_permissions(fake_pathname.to_s, "777") - end - - it "can set the ownership of a file" do - staged.stubs(current_user: "fake_user") - fake_pathname = fake_pathname_exists - staged.stubs(Pathname: fake_pathname) - - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname] - ) - staged.set_ownership(fake_pathname.to_s) - end - - it "can set the ownership of multiple files" do - staged.stubs(current_user: "fake_user") - fake_pathname = fake_pathname_exists - staged.stubs(Pathname: fake_pathname) - - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname] - ) - staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s]) - end - - it "can set the ownership of a file with a different user and group" do - fake_pathname = fake_pathname_exists - staged.stubs(Pathname: fake_pathname) - - Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname] - ) - staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group") - end - - it "cannot set the ownership of a file that does not exist" do - staged.stubs(current_user: "fake_user") - fake_pathname = fake_pathname_does_not_exist - staged.stubs(Pathname: fake_pathname) - staged.set_ownership(fake_pathname.to_s) - end -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 57b468d0f..a4bb9af0f 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -93,7 +93,6 @@ end # Extend MiniTest API with support for RSpec-style shared examples require "support/shared_examples" -require "support/shared_examples/staged.rb" require "support/fake_dirs" require "support/fake_system_command" -- cgit v1.2.3 From 451e7c3aebf77be1d353712d202e2e915b8962f0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:58:57 +0100 Subject: Convert preflight test to spec. --- Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb | 12 ++++++++++++ Library/Homebrew/cask/test/cask/dsl/preflight_test.rb | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/dsl/preflight_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb new file mode 100644 index 000000000..90d2634db --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb @@ -0,0 +1,12 @@ +require "spec_helper" + +describe Hbc::DSL::Preflight do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) } + + it_behaves_like Hbc::DSL::Base + + it_behaves_like Hbc::Staged do + let(:staged) { dsl } + end +end diff --git a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb deleted file mode 100644 index 555be7ed9..000000000 --- a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "test_helper" - -describe Hbc::DSL::Preflight do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } - let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) } - - it_behaves_like Hbc::DSL::Base - - it_behaves_like Hbc::Staged do - let(:staged) { dsl } - end -end -- cgit v1.2.3 From 0a4bc0e3b4526dacf2045b12741c1359b43607bc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 03:59:53 +0100 Subject: Convert uninstall_postflight test to spec. --- Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb | 8 ++++++++ Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb new file mode 100644 index 000000000..4b7dd7557 --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb @@ -0,0 +1,8 @@ +require "spec_helper" + +describe Hbc::DSL::UninstallPostflight do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) } + + it_behaves_like Hbc::DSL::Base +end diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb deleted file mode 100644 index ae4db979e..000000000 --- a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "test_helper" - -describe Hbc::DSL::UninstallPostflight do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } - let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) } - - it_behaves_like Hbc::DSL::Base -end -- cgit v1.2.3 From b0dc2da97be49968350dfbe39858ca9e1ef06e29 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 04:00:42 +0100 Subject: Convert uninstall_preflight test to spec. --- .../Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb | 12 ++++++++++++ .../Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb delete mode 100644 Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb new file mode 100644 index 000000000..a4930e99e --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb @@ -0,0 +1,12 @@ +require "spec_helper" + +describe Hbc::DSL::UninstallPreflight do + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) } + + it_behaves_like Hbc::DSL::Base + + it_behaves_like Hbc::Staged do + let(:staged) { dsl } + end +end diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb b/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb deleted file mode 100644 index f964b0098..000000000 --- a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "test_helper" - -describe Hbc::DSL::UninstallPreflight do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } - let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) } - - it_behaves_like Hbc::DSL::Base - - it_behaves_like Hbc::Staged do - let(:staged) { dsl } - end -end -- cgit v1.2.3 From 6154182b13642de41125403d3be9959814d0afc3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 04:06:56 +0100 Subject: Remove syntax test. --- Library/Homebrew/cask/test/syntax_test.rb | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Library/Homebrew/cask/test/syntax_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/test/syntax_test.rb b/Library/Homebrew/cask/test/syntax_test.rb deleted file mode 100644 index 0ea832bde..000000000 --- a/Library/Homebrew/cask/test/syntax_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "test_helper" - -describe "Syntax check" do - project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../")) - backend_files = Dir[project_root.join("**", "*.rb")].reject { |f| f.match %r{/vendor/|/Casks/} } - interpreter = RUBY_PATH - flags = %w[-c] - flags.unshift "--disable-all" - backend_files.each do |file| - it "#{file} is valid Ruby" do - args = flags + ["--", file] - shutup do - raise SyntaxError, "#{file} failed syntax check" unless system(interpreter, *args) - end - end - end -end -- cgit v1.2.3 From a616fab5bf84d9e2a07610666cf148444c04b3c4 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 04:15:57 +0100 Subject: Convert cask test to spec. --- Library/Homebrew/cask/spec/cask/cask_spec.rb | 69 +++++++++++++++++++++++++++ Library/Homebrew/cask/test/cask_test.rb | 71 ---------------------------- 2 files changed, 69 insertions(+), 71 deletions(-) delete mode 100644 Library/Homebrew/cask/test/cask_test.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cask_spec.rb b/Library/Homebrew/cask/spec/cask/cask_spec.rb index d470c6ec3..32f3d8258 100644 --- a/Library/Homebrew/cask/spec/cask/cask_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cask_spec.rb @@ -20,4 +20,73 @@ describe Hbc::Cask do end end end + + describe "load" do + let(:hbc_relative_tap_path) { "../../Taps/caskroom/homebrew-cask" } + + it "returns an instance of the Cask for the given token" do + c = Hbc.load("adium") + expect(c).to be_kind_of(Hbc::Cask) + expect(c.token).to eq("adium") + end + + it "returns an instance of the Cask from a specific file location" do + location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") + c = Hbc.load(location) + expect(c).to be_kind_of(Hbc::Cask) + expect(c.token).to eq("dia") + end + + it "returns an instance of the Cask from a url" do + url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb") + c = shutup do + Hbc.load(url) + end + expect(c).to be_kind_of(Hbc::Cask) + expect(c.token).to eq("dia") + end + + it "raises an error when failing to download a Cask from a url" do + expect { + url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb") + shutup do + Hbc.load(url) + end + }.to raise_error(Hbc::CaskUnavailableError) + end + + it "returns an instance of the Cask from a relative file location" do + c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb") + expect(c).to be_kind_of(Hbc::Cask) + expect(c.token).to eq("bbedit") + end + + it "uses exact match when loading by token" do + expect(Hbc.load("test-opera").token).to eq("test-opera") + expect(Hbc.load("test-opera-mail").token).to eq("test-opera-mail") + end + + it "raises an error when attempting to load a Cask that doesn't exist" do + expect { + Hbc.load("notacask") + }.to raise_error(Hbc::CaskUnavailableError) + end + end + + describe "all_tokens" do + it "returns a token for every Cask" do + all_cask_tokens = Hbc.all_tokens + expect(all_cask_tokens.count).to be > 20 + all_cask_tokens.each { |token| expect(token).to be_kind_of(String) } + end + end + + describe "metadata" do + it "proposes a versioned metadata directory name for each instance" do + cask_token = "adium" + c = Hbc.load(cask_token) + metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version) + expect(c.metadata_versioned_container_path.to_s).to eq(metadata_path.to_s) + end + end end diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb deleted file mode 100644 index d3abda274..000000000 --- a/Library/Homebrew/cask/test/cask_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -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") - c.must_be_kind_of(Hbc::Cask) - c.token.must_equal("adium") - end - - it "returns an instance of the Cask from a specific file location" do - 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(hbc_relative_tap_path + "/Casks/dia.rb") - c = shutup do - Hbc.load(url) - end - c.must_be_kind_of(Hbc::Cask) - c.token.must_equal("dia") - end - - it "raises an error when failing to download a Cask from a url" do - lambda { - url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb") - shutup do - Hbc.load(url) - end - }.must_raise(Hbc::CaskUnavailableError) - end - - it "returns an instance of the Cask from a relative file location" do - c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb") - c.must_be_kind_of(Hbc::Cask) - c.token.must_equal("bbedit") - end - - it "uses exact match when loading by token" do - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera.rb").token.must_equal("test-opera") - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera-mail.rb").token.must_equal("test-opera-mail") - end - - it "raises an error when attempting to load a Cask that doesn't exist" do - lambda { - Hbc.load("notacask") - }.must_raise(Hbc::CaskUnavailableError) - end - end - - describe "all_tokens" do - it "returns a token for every Cask" do - all_cask_tokens = Hbc.all_tokens - all_cask_tokens.count.must_be :>, 20 - all_cask_tokens.each { |token| token.must_be_kind_of String } - end - end - - describe "metadata" do - it "proposes a versioned metadata directory name for each instance" do - cask_token = "adium" - c = Hbc.load(cask_token) - metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version) - c.metadata_versioned_container_path.to_s.must_equal(metadata_path.to_s) - end - end -end -- cgit v1.2.3 From a9e538efbdb0532e9236400434c9970e0cdfd8fc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 04:17:14 +0100 Subject: Move NeverSudoSystemCommand to separate file. --- Library/Homebrew/cask/spec/spec_helper.rb | 8 -------- Library/Homebrew/cask/spec/support/never_sudo_system_command.rb | 9 +++++++++ Library/Homebrew/cask/test/support/never_sudo_system_command.rb | 7 ------- 3 files changed, 9 insertions(+), 15 deletions(-) create mode 100644 Library/Homebrew/cask/spec/support/never_sudo_system_command.rb delete mode 100644 Library/Homebrew/cask/test/support/never_sudo_system_command.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 0a7327b08..8b0720e86 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -66,11 +66,3 @@ RSpec.configure do |config| end end end - -module Hbc - class NeverSudoSystemCommand < SystemCommand - def self.run(command, options = {}) - super(command, options.merge(sudo: false)) - end - end -end diff --git a/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb b/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb new file mode 100644 index 000000000..eb8b677f2 --- /dev/null +++ b/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb @@ -0,0 +1,9 @@ +require "hbc/system_command" + +module Hbc + class NeverSudoSystemCommand < SystemCommand + def self.run(command, options = {}) + super(command, options.merge(sudo: false)) + end + end +end diff --git a/Library/Homebrew/cask/test/support/never_sudo_system_command.rb b/Library/Homebrew/cask/test/support/never_sudo_system_command.rb deleted file mode 100644 index 8a370df44..000000000 --- a/Library/Homebrew/cask/test/support/never_sudo_system_command.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Hbc - class NeverSudoSystemCommand < SystemCommand - def self.run(command, options = {}) - super(command, options.merge(sudo: false)) - end - end -end -- cgit v1.2.3 From b9de5c04908bbbe2e2c30fff57b1301e17082202 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 04:37:24 +0100 Subject: Simplify spec helper. --- Library/Homebrew/cask/spec/spec_helper.rb | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 8b0720e86..ea6a87f41 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -34,16 +34,26 @@ end # pretend that the caskroom/cask Tap is installed FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path +HOMEBREW_CASK_DIRS = [ + :appdir, + :caskroom, + :prefpanedir, + :qlplugindir, + :servicedir, + :binarydir, +].freeze + RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) config.around(:each) do |example| begin - @__appdir = Hbc.appdir - @__caskroom = Hbc.caskroom - @__prefpanedir = Hbc.prefpanedir - @__qlplugindir = Hbc.qlplugindir - @__servicedir = Hbc.servicedir + @__dirs = HOMEBREW_CASK_DIRS.map { |dir| + Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path| + path.mkpath + Hbc.public_send("#{dir}=", path) + } + } @__argv = ARGV.dup @__env = ENV.to_hash # dup doesn't work on ENV @@ -53,16 +63,7 @@ RSpec.configure do |config| ARGV.replace(@__argv) ENV.replace(@__env) - Hbc.appdir = @__appdir - Hbc.caskroom = @__caskroom - Hbc.prefpanedir = @__prefpanedir - Hbc.qlplugindir = @__qlplugindir - Hbc.servicedir = @__servicedir - - FileUtils.rm_rf [ - Hbc.appdir.children, - Hbc.caskroom.children, - ] + FileUtils.rm_rf @__dirs.map(&:children) end end end -- cgit v1.2.3 From 31b9dc28e3105d9164fb28d7e29985ba1f1775eb Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 9 Feb 2017 04:39:53 +0100 Subject: Remove cask test directory. --- Library/Homebrew/cask/cmd/brew-cask-tests.rb | 31 ++----- Library/Homebrew/cask/spec/upload_coverage.rb | 6 ++ Library/Homebrew/cask/test/support/cleanup.rb | 10 -- Library/Homebrew/cask/test/support/fake_dirs.rb | 31 ------- .../cask/test/support/fake_system_command.rb | 77 ---------------- .../Homebrew/cask/test/support/shared_examples.rb | 25 ----- Library/Homebrew/cask/test/test_helper.rb | 102 --------------------- Library/Homebrew/cask/test/upload_coverage.rb | 6 -- 8 files changed, 16 insertions(+), 272 deletions(-) create mode 100755 Library/Homebrew/cask/spec/upload_coverage.rb delete mode 100644 Library/Homebrew/cask/test/support/cleanup.rb delete mode 100644 Library/Homebrew/cask/test/support/fake_dirs.rb delete mode 100644 Library/Homebrew/cask/test/support/fake_system_command.rb delete mode 100644 Library/Homebrew/cask/test/support/shared_examples.rb delete mode 100644 Library/Homebrew/cask/test/test_helper.rb delete mode 100755 Library/Homebrew/cask/test/upload_coverage.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index bdcabd4dc..b27bc2fe7 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -21,36 +21,25 @@ cask_root.cd do system "bundle", "install" end - rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest") - minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec") - if ARGV.flag?("--coverage") ENV["HOMEBREW_TESTS_COVERAGE"] = "1" upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"] end - failed = false - - if rspec - run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[ - --color - --require spec_helper - --format progress - --format ParallelTests::RSpec::RuntimeLogger - --out tmp/parallel_runtime_rspec.log - ] - failed ||= !$CHILD_STATUS.success? - end + run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[ + --color + --require spec_helper + --format progress + --format ParallelTests::RSpec::RuntimeLogger + --out tmp/parallel_runtime_rspec.log + ] - if minitest - run_tests "parallel_test", Dir["test/**/*_test.rb"] - failed ||= !$CHILD_STATUS.success? + unless $CHILD_STATUS.success? + Homebrew.failed = true end - Homebrew.failed = failed - if upload_coverage puts "Submitting Codecov coverage..." - system "bundle", "exec", "test/upload_coverage.rb" + system "bundle", "exec", "spec/upload_coverage.rb" end end diff --git a/Library/Homebrew/cask/spec/upload_coverage.rb b/Library/Homebrew/cask/spec/upload_coverage.rb new file mode 100755 index 000000000..06d38157d --- /dev/null +++ b/Library/Homebrew/cask/spec/upload_coverage.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require "simplecov" +require "codecov" + +formatter = SimpleCov::Formatter::Codecov.new +formatter.format SimpleCov::ResultMerger.merged_result diff --git a/Library/Homebrew/cask/test/support/cleanup.rb b/Library/Homebrew/cask/test/support/cleanup.rb deleted file mode 100644 index c31a74be2..000000000 --- a/Library/Homebrew/cask/test/support/cleanup.rb +++ /dev/null @@ -1,10 +0,0 @@ -module MiniTest - class Spec - def after_teardown - super - Hbc.installed.each do |cask| - Hbc::Installer.new(cask).purge_versioned_files - end - end - end -end diff --git a/Library/Homebrew/cask/test/support/fake_dirs.rb b/Library/Homebrew/cask/test/support/fake_dirs.rb deleted file mode 100644 index ea7acc685..000000000 --- a/Library/Homebrew/cask/test/support/fake_dirs.rb +++ /dev/null @@ -1,31 +0,0 @@ -# wire in a set of fake link dirs per-test -module FakeDirHooks - DIRS = [:appdir, :qlplugindir, :binarydir].freeze - - def before_setup - super - - @canned_dirs = {} - - DIRS.each do |dir_name| - dir = HOMEBREW_PREFIX.join("#{dir_name}-#{Time.now.to_i}-#{rand(1024)}") - dir.mkpath - Hbc.send("#{dir_name}=", dir) - @canned_dirs[:dir_name] = dir - end - end - - def after_teardown - super - - @canned_dirs.each_value do |dir| - dir.rmtree if dir.exist? - end - end -end - -module MiniTest - class Spec - include FakeDirHooks - end -end diff --git a/Library/Homebrew/cask/test/support/fake_system_command.rb b/Library/Homebrew/cask/test/support/fake_system_command.rb deleted file mode 100644 index 97efd0761..000000000 --- a/Library/Homebrew/cask/test/support/fake_system_command.rb +++ /dev/null @@ -1,77 +0,0 @@ -module Hbc - class FakeSystemCommand - def self.responses - @responses ||= {} - end - - def self.expectations - @expectations ||= {} - end - - def self.system_calls - @system_calls ||= Hash.new(0) - end - - def self.clear - @responses = nil - @expectations = nil - @system_calls = nil - end - - def self.stubs_command(command, response = "") - responses[command] = response - end - - def self.expects_command(command, response = "", times = 1) - stubs_command(command, response) - expectations[command] = times - end - - def self.expect_and_pass_through(command, times = 1) - pass_through = ->(cmd, opts) { Hbc::SystemCommand.run(cmd, opts) } - expects_command(command, pass_through, times) - end - - def self.verify_expectations! - expectations.each do |command, times| - unless system_calls[command] == times - raise("expected #{command.inspect} to be run #{times} times, but got #{system_calls[command]}") - end - end - end - - def self.run(command_string, options = {}) - command = Hbc::SystemCommand.new(command_string, options).command - unless responses.key?(command) - raise("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}") - end - system_calls[command] += 1 - - response = responses[command] - if response.respond_to?(:call) - response.call(command_string, options) - else - Hbc::SystemCommand::Result.new(command, response, "", 0) - end - end - - def self.run!(command, options = {}) - run(command, options.merge(must_succeed: true)) - end - end -end - -module FakeSystemCommandHooks - def after_teardown - super - Hbc::FakeSystemCommand.verify_expectations! - ensure - Hbc::FakeSystemCommand.clear - end -end - -module MiniTest - class Spec - include FakeSystemCommandHooks - end -end diff --git a/Library/Homebrew/cask/test/support/shared_examples.rb b/Library/Homebrew/cask/test/support/shared_examples.rb deleted file mode 100644 index 594ca81c1..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Adapted from https://gist.github.com/jodosha/1560208 -MiniTest::Spec.class_eval do - def self.shared_examples - @shared_examples ||= {} - end -end - -module MiniTest - class Spec - module SharedExamples - def shared_examples_for(desc, &block) - MiniTest::Spec.shared_examples[desc] = block - end - - def it_behaves_like(desc, *args, &block) - instance_exec(*args, &MiniTest::Spec.shared_examples[desc]) - instance_eval(&block) if block_given? - end - end - end -end - -Object.class_eval do - include(MiniTest::Spec::SharedExamples) -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb deleted file mode 100644 index a4bb9af0f..000000000 --- a/Library/Homebrew/cask/test/test_helper.rb +++ /dev/null @@ -1,102 +0,0 @@ -require "bundler" -require "bundler/setup" -require "pathname" - -require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] - -# 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/test/support/lib")) - -require "global" - -# add Homebrew-Cask to load path -$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) - -require "test/support/helper/shutup" -include Test::Helper::Shutup - -def sudo(*args) - %w[/usr/bin/sudo -E --] + args.flatten -end - -# must be called after testing_env so at_exit hooks are in proper order -require "minitest/autorun" -require "minitest/reporters" -Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true) - -require "parallel_tests/test/runtime_logger" - -# Force mocha to patch MiniTest since we have both loaded thanks to homebrew's testing_env -require "mocha/api" -require "mocha/integration/mini_test" -Mocha::Integration::MiniTest.activate - -# our baby -require "hbc" - -# create and override default directories -Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) -Hbc.cache.mkpath -Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) -Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap| - # link test casks - FileUtils.mkdir_p tap.path.dirname - FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path -end - -# pretend that the caskroom/cask Tap is installed -FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path - -class TestHelper - # helpers for test Casks to reference local files easily - def self.local_binary_path(name) - File.expand_path(File.join(File.dirname(__FILE__), "support", "binaries", name)) - end - - def self.local_binary_url(name) - "file://" + local_binary_path(name) - end - - def self.valid_symlink?(candidate) - return false unless candidate.symlink? - candidate.readlink.exist? - end - - def self.install_without_artifacts(cask) - Hbc::Installer.new(cask).tap do |i| - shutup do - i.download - i.extract_primary_container - end - end - end - - def self.install_with_caskfile(cask) - Hbc::Installer.new(cask).tap do |i| - shutup do - i.save_caskfile - end - end - end - - def self.install_without_artifacts_with_caskfile(cask) - Hbc::Installer.new(cask).tap do |i| - shutup do - i.download - i.extract_primary_container - i.save_caskfile - end - end - end -end - -# Extend MiniTest API with support for RSpec-style shared examples -require "support/shared_examples" - -require "support/fake_dirs" -require "support/fake_system_command" -require "support/cleanup" -require "support/never_sudo_system_command" -require "tmpdir" -require "tempfile" diff --git a/Library/Homebrew/cask/test/upload_coverage.rb b/Library/Homebrew/cask/test/upload_coverage.rb deleted file mode 100755 index 06d38157d..000000000 --- a/Library/Homebrew/cask/test/upload_coverage.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -require "simplecov" -require "codecov" - -formatter = SimpleCov::Formatter::Codecov.new -formatter.format SimpleCov::ResultMerger.merged_result -- cgit v1.2.3 From f457c6ab327b0520c61021437b87be0cedc5f770 Mon Sep 17 00:00:00 2001 From: Danielle Tomlinson Date: Fri, 10 Feb 2017 22:59:44 +0100 Subject: diagnostic: Add CircleCI to Env check --- Library/Homebrew/extend/os/mac/diagnostic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 6d30cd294..3e0c1d04d 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -53,8 +53,8 @@ module Homebrew return unless MacOS::Xcode.installed? return unless MacOS::Xcode.outdated? - # Travis CI images are going to end up outdated so don't complain. - return if ENV["TRAVIS"] + # CI images are going to end up outdated so don't complain. + return if ENV["TRAVIS"] || ENV["CIRCLECI"] message = <<-EOS.undent Your Xcode (#{MacOS::Xcode.version}) is outdated. -- cgit v1.2.3 From 67bdeb463a58a4e0936ed769583e98cba24ad43f Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Fri, 10 Feb 2017 19:28:40 -0800 Subject: Revert "Use `Open3` for integration tests instead of manually forking." --- Library/Homebrew/keg.rb | 4 -- Library/Homebrew/test/bottle_test.rb | 2 +- Library/Homebrew/test/options_test.rb | 2 +- .../helper/integration_command_test_case.rb | 71 ++++++++++++++-------- 4 files changed, 49 insertions(+), 30 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index fa42cc83a..837968615 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -217,10 +217,6 @@ class Keg true end - def require_relocation? - false - end - def linked? linked_keg_record.symlink? && linked_keg_record.directory? && diff --git a/Library/Homebrew/test/bottle_test.rb b/Library/Homebrew/test/bottle_test.rb index 7981ccf79..c10746e09 100644 --- a/Library/Homebrew/test/bottle_test.rb +++ b/Library/Homebrew/test/bottle_test.rb @@ -14,7 +14,7 @@ class IntegrationCommandTestBottle < IntegrationCommandTestCase FileUtils.ln_s "not-exist", "symlink" end assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, - cmd("bottle", "--no-rebuild", "testball")) + cmd_output("bottle", "--no-rebuild", "testball")) ensure FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"] end diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb index 09ea14180..f38ec4415 100644 --- a/Library/Homebrew/test/options_test.rb +++ b/Library/Homebrew/test/options_test.rb @@ -9,7 +9,7 @@ class IntegrationCommandTestOptions < IntegrationCommandTestCase EOS assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", - cmd("options", "testball").chomp + cmd_output("options", "testball").chomp end end diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index 45e73757a..a36b56691 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -3,7 +3,6 @@ require "fileutils" require "pathname" require "formula" require "test/support/helper/test_case" -require "open3" class IntegrationCommandTestCase < Homebrew::TestCase def setup @@ -29,34 +28,57 @@ class IntegrationCommandTestCase < Homebrew::TestCase end def cmd_output(*args) + # 1.8-compatible way of writing def cmd_output(*args, **env) env = args.last.is_a?(Hash) ? args.pop : {} - - env.merge!( - "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", - "HOMEBREW_INTEGRATION_TEST" => cmd_id_from_args(args), - "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, - "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"] - ) - - ruby_args = [ - "-W0", - "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", - "-I", HOMEBREW_LIBRARY_PATH.to_s, - "-rconfig" + cmd_args = %W[ + -W0 + -I#{HOMEBREW_LIBRARY_PATH}/test/support/lib + -I#{HOMEBREW_LIBRARY_PATH} + -rconfig ] - ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] - ruby_args << "-rtest/support/helper/integration_mocks" - ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - + if ENV["HOMEBREW_TESTS_COVERAGE"] + # This is needed only because we currently use a patched version of + # simplecov, and gems installed through git are not available without + # requiring bundler/setup first. See also the comment in test/Gemfile. + # Remove this line when we'll switch back to a stable simplecov release. + cmd_args << "-rbundler/setup" + cmd_args << "-rsimplecov" + end + cmd_args << "-rtest/support/helper/integration_mocks" + cmd_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s + cmd_args += args + developer = ENV["HOMEBREW_DEVELOPER"] Bundler.with_original_env do - output, status = Open3.capture2e(env, RUBY_PATH, *ruby_args, *args) - [output.chomp, status] + ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew" + ENV["HOMEBREW_INTEGRATION_TEST"] = cmd_id_from_args(args) + ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR + ENV["HOMEBREW_DEVELOPER"] = developer + env.each_pair do |k, v| + ENV[k] = v + end + + read, write = IO.pipe + begin + pid = fork do + read.close + $stdout.reopen(write) + $stderr.reopen(write) + write.close + exec RUBY_PATH, *cmd_args + end + write.close + read.read.chomp + ensure + Process.wait(pid) + read.close + end end end def cmd(*args) - output, status = cmd_output(*args) - assert status.success?, <<-EOS.undent + output = cmd_output(*args) + status = $?.exitstatus + assert_equal 0, status, <<-EOS.undent `brew #{args.join " "}` exited with non-zero status! #{output} EOS @@ -64,8 +86,9 @@ class IntegrationCommandTestCase < Homebrew::TestCase end def cmd_fail(*args) - output, status = cmd_output(*args) - refute status.success?, <<-EOS.undent + output = cmd_output(*args) + status = $?.exitstatus + refute_equal 0, status, <<-EOS.undent `brew #{args.join " "}` exited with zero status! #{output} EOS -- cgit v1.2.3 From 9d96a5c512f45cb7cf68626a7ce6963e2573a589 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 13:42:11 +0100 Subject: Use `Open3` for integration tests instead of manually forking. --- Library/Homebrew/test/bottle_test.rb | 2 +- Library/Homebrew/test/options_test.rb | 2 +- .../helper/integration_command_test_case.rb | 71 ++++++++-------------- 3 files changed, 26 insertions(+), 49 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/bottle_test.rb b/Library/Homebrew/test/bottle_test.rb index c10746e09..7981ccf79 100644 --- a/Library/Homebrew/test/bottle_test.rb +++ b/Library/Homebrew/test/bottle_test.rb @@ -14,7 +14,7 @@ class IntegrationCommandTestBottle < IntegrationCommandTestCase FileUtils.ln_s "not-exist", "symlink" end assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, - cmd_output("bottle", "--no-rebuild", "testball")) + cmd("bottle", "--no-rebuild", "testball")) ensure FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"] end diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb index f38ec4415..09ea14180 100644 --- a/Library/Homebrew/test/options_test.rb +++ b/Library/Homebrew/test/options_test.rb @@ -9,7 +9,7 @@ class IntegrationCommandTestOptions < IntegrationCommandTestCase EOS assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", - cmd_output("options", "testball").chomp + cmd("options", "testball").chomp end end diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index a36b56691..45e73757a 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -3,6 +3,7 @@ require "fileutils" require "pathname" require "formula" require "test/support/helper/test_case" +require "open3" class IntegrationCommandTestCase < Homebrew::TestCase def setup @@ -28,57 +29,34 @@ class IntegrationCommandTestCase < Homebrew::TestCase end def cmd_output(*args) - # 1.8-compatible way of writing def cmd_output(*args, **env) env = args.last.is_a?(Hash) ? args.pop : {} - cmd_args = %W[ - -W0 - -I#{HOMEBREW_LIBRARY_PATH}/test/support/lib - -I#{HOMEBREW_LIBRARY_PATH} - -rconfig + + env.merge!( + "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", + "HOMEBREW_INTEGRATION_TEST" => cmd_id_from_args(args), + "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, + "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"] + ) + + ruby_args = [ + "-W0", + "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", + "-I", HOMEBREW_LIBRARY_PATH.to_s, + "-rconfig" ] - if ENV["HOMEBREW_TESTS_COVERAGE"] - # This is needed only because we currently use a patched version of - # simplecov, and gems installed through git are not available without - # requiring bundler/setup first. See also the comment in test/Gemfile. - # Remove this line when we'll switch back to a stable simplecov release. - cmd_args << "-rbundler/setup" - cmd_args << "-rsimplecov" - end - cmd_args << "-rtest/support/helper/integration_mocks" - cmd_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - cmd_args += args - developer = ENV["HOMEBREW_DEVELOPER"] - Bundler.with_original_env do - ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew" - ENV["HOMEBREW_INTEGRATION_TEST"] = cmd_id_from_args(args) - ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR - ENV["HOMEBREW_DEVELOPER"] = developer - env.each_pair do |k, v| - ENV[k] = v - end + ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] + ruby_args << "-rtest/support/helper/integration_mocks" + ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - read, write = IO.pipe - begin - pid = fork do - read.close - $stdout.reopen(write) - $stderr.reopen(write) - write.close - exec RUBY_PATH, *cmd_args - end - write.close - read.read.chomp - ensure - Process.wait(pid) - read.close - end + Bundler.with_original_env do + output, status = Open3.capture2e(env, RUBY_PATH, *ruby_args, *args) + [output.chomp, status] end end def cmd(*args) - output = cmd_output(*args) - status = $?.exitstatus - assert_equal 0, status, <<-EOS.undent + output, status = cmd_output(*args) + assert status.success?, <<-EOS.undent `brew #{args.join " "}` exited with non-zero status! #{output} EOS @@ -86,9 +64,8 @@ class IntegrationCommandTestCase < Homebrew::TestCase end def cmd_fail(*args) - output = cmd_output(*args) - status = $?.exitstatus - refute_equal 0, status, <<-EOS.undent + output, status = cmd_output(*args) + refute status.success?, <<-EOS.undent `brew #{args.join " "}` exited with zero status! #{output} EOS -- cgit v1.2.3 From 94dceeab1dac30983057737e1efe0d732c5aa551 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 13:43:00 +0100 Subject: Move `require_relocation?` from `os/mac/keg` to `keg`. --- Library/Homebrew/keg.rb | 5 +++++ Library/Homebrew/os/mac/keg.rb | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 837968615..17ff3bcef 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -188,6 +188,7 @@ class Keg @name = path.parent.basename.to_s @linked_keg_record = HOMEBREW_LINKED_KEGS/name @opt_record = HOMEBREW_PREFIX/"opt/#{name}" + @require_relocation = false end def rack @@ -217,6 +218,10 @@ class Keg true end + def require_relocation? + @require_relocation + end + def linked? linked_keg_record.symlink? && linked_keg_record.directory? && diff --git a/Library/Homebrew/os/mac/keg.rb b/Library/Homebrew/os/mac/keg.rb index b2a769849..674ea3330 100644 --- a/Library/Homebrew/os/mac/keg.rb +++ b/Library/Homebrew/os/mac/keg.rb @@ -24,8 +24,4 @@ class Keg EOS raise end - - def require_relocation? - @require_relocation - end end -- cgit v1.2.3 From ab785ca4146eb027e639a43f4efd8925886dfc85 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 10 Feb 2017 21:21:33 +0100 Subject: Add RSpec to Gemfile. --- Library/Homebrew/test/Gemfile | 3 +++ Library/Homebrew/test/Gemfile.lock | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile index 5641684a7..25c8ce7ec 100644 --- a/Library/Homebrew/test/Gemfile +++ b/Library/Homebrew/test/Gemfile @@ -4,6 +4,9 @@ gem "mocha" gem "minitest" gem "minitest-reporters" gem "parallel_tests" +gem "rspec" +gem "rspec-its", require: false +gem "rspec-wait", require: false group :coverage do gem "simplecov", require: false diff --git a/Library/Homebrew/test/Gemfile.lock b/Library/Homebrew/test/Gemfile.lock index 65ac7ef56..fba45d77b 100644 --- a/Library/Homebrew/test/Gemfile.lock +++ b/Library/Homebrew/test/Gemfile.lock @@ -7,6 +7,7 @@ GEM json simplecov url + diff-lcs (1.3) docile (1.1.5) json (2.0.3) metaclass (0.0.4) @@ -21,6 +22,24 @@ GEM parallel (1.10.0) parallel_tests (2.13.0) parallel + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-its (1.2.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + rspec-wait (0.0.9) + rspec (>= 3, < 4) ruby-progressbar (1.8.1) simplecov (0.13.0) docile (~> 1.1.0) @@ -38,7 +57,10 @@ DEPENDENCIES minitest-reporters mocha parallel_tests + rspec + rspec-its + rspec-wait simplecov BUNDLED WITH - 1.13.7 + 1.14.3 -- cgit v1.2.3 From c4ac30830273c9a638b4a7c32d31b0ab22bb39f8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 10 Feb 2017 21:21:57 +0100 Subject: Allow `brew tests` to run specs. --- Library/Homebrew/dev-cmd/tests.rb | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 9d93fc9e8..244fbe027 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -7,10 +7,21 @@ require "tap" module Homebrew module_function + def run_tests(executable, files, args = []) + opts = [] + opts << "--serialize-stdout" if ENV["CI"] + + system "bundle", "exec", executable, *opts, "--", *args, "--", *files + + return if $?.success? + Homebrew.failed = true + end + def tests HOMEBREW_LIBRARY_PATH.cd do ENV.delete "HOMEBREW_VERBOSE" ENV.delete "VERBOSE" + ENV.delete("HOMEBREW_CASK_OPTS") ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_DEVELOPER"] = "1" ENV["TESTOPTS"] = "-v" if ARGV.verbose? @@ -45,27 +56,35 @@ module Homebrew # Make it easier to reproduce test runs. ENV["SEED"] = ARGV.next if ARGV.include? "--seed" - files = Dir.glob("test/**/*_test.rb") + files = Dir.glob("test/**/*_{spec,test}.rb") .reject { |p| !OS.mac? && p.start_with?("test/os/mac/") } + .reject { |p| !OS.mac? && p.start_with?("test/cask/") } .reject { |p| p.start_with?("test/vendor/bundle/") } - opts = [] - opts << "--serialize-stdout" if ENV["CI"] - - args = [] - args << "--trace" if ARGV.include? "--trace" + test_args = [] + test_args << "--trace" if ARGV.include? "--trace" if ARGV.value("only") test_name, test_method = ARGV.value("only").split(":", 2) - files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_test.rb") - args << "--name=test_#{test_method}" if test_method + files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_{spec,test}.rb") + test_args << "--name=test_#{test_method}" if test_method end - args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] } - - system "bundle", "exec", "parallel_test", *opts, "--", *args, "--", *files - - Homebrew.failed = !$?.success? + test_files = files.select { |p| p.end_with?("_test.rb") } + spec_files = files.select { |p| p.end_with?("_spec.rb") } + + test_args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] } + run_tests "parallel_test", test_files, test_args + + spec_args = [ + "--color", + "-I", HOMEBREW_LIBRARY_PATH/"test", + "--require", "spec_helper", + "--format", "progress", + "--format", "ParallelTests::RSpec::RuntimeLogger", + "--out", "tmp/parallel_runtime_rspec.log" + ] + run_tests "parallel_rspec", spec_files, spec_args if (fs_leak_log = HOMEBREW_LIBRARY_PATH/"tmp/fs_leak.log").file? fs_leak_log_content = fs_leak_log.read -- cgit v1.2.3 From cdcf362fc09ca27444b4cb4b8d27c011e3227e67 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 10 Feb 2017 21:41:15 +0100 Subject: Add `spec_helper`. --- Library/Homebrew/test/spec_helper.rb | 77 +++++++++++++++++++++++ Library/Homebrew/test/support/helper/test_case.rb | 3 - Library/Homebrew/test/support/lib/config.rb | 3 + 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 Library/Homebrew/test/spec_helper.rb (limited to 'Library') diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb new file mode 100644 index 000000000..7762b385c --- /dev/null +++ b/Library/Homebrew/test/spec_helper.rb @@ -0,0 +1,77 @@ +require "find" +require "pathname" +require "rspec/its" +require "rspec/wait" +require "set" + +if ENV["HOMEBREW_TESTS_COVERAGE"] + require "simplecov" +end + +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib")) + +require "global" +require "tap" + +require "test/support/helper/shutup" + +TEST_DIRECTORIES = [ + CoreTap.instance.path/"Formula", + HOMEBREW_CACHE, + HOMEBREW_CACHE_FORMULA, + HOMEBREW_CELLAR, + HOMEBREW_LOCK_DIR, + HOMEBREW_LOGS, + HOMEBREW_TEMP, +].freeze + +RSpec.configure do |config| + config.order = :random + config.include(Test::Helper::Shutup) + config.around(:each) do |example| + begin + TEST_DIRECTORIES.each(&:mkpath) + + @__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") } + + @__argv = ARGV.dup + @__env = ENV.to_hash # dup doesn't work on ENV + + example.run + ensure + ARGV.replace(@__argv) + ENV.replace(@__env) + + Tab.clear_cache + + FileUtils.rm_rf [ + TEST_DIRECTORIES.map(&:children), + HOMEBREW_LINKED_KEGS, + HOMEBREW_PINNED_KEGS, + HOMEBREW_PREFIX/".git", + HOMEBREW_PREFIX/"bin", + HOMEBREW_PREFIX/"share", + HOMEBREW_PREFIX/"opt", + HOMEBREW_PREFIX/"Caskroom", + HOMEBREW_LIBRARY/"Taps/caskroom", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", + HOMEBREW_REPOSITORY/".git", + CoreTap.instance.path/".git", + CoreTap.instance.alias_dir, + CoreTap.instance.path/"formula_renames.json", + ] + + files_after_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") } + + diff = Set.new(@__files_before_test).difference(Set.new(files_after_test)) + expect(diff).to be_empty, <<-EOS.undent + file leak detected: + #{diff.map { |f| " #{f}" }.join("\n")} + EOS + end + end +end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index daa663494..568beb947 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -12,9 +12,6 @@ module Homebrew include Test::Helper::Shutup include Test::Helper::VersionAssertions - TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze - TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze - TEST_DIRECTORIES = [ CoreTap.instance.path/"Formula", HOMEBREW_CACHE, diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb index f6fdb4ecb..fb5c210fe 100644 --- a/Library/Homebrew/test/support/lib/config.rb +++ b/Library/Homebrew/test/support/lib/config.rb @@ -38,3 +38,6 @@ TESTBALL_SHA256 = "91e3f7930c98d7ccfb288e115ed52d06b0e5bc16fec7dce8bdda865300270 TESTBALL_PATCHES_SHA256 = "799c2d551ac5c3a5759bea7796631a7906a6a24435b52261a317133a0bfb34d9".freeze PATCH_A_SHA256 = "83404f4936d3257e65f176c4ffb5a5b8d6edd644a21c8d8dcc73e22a6d28fcfa".freeze PATCH_B_SHA256 = "57958271bb802a59452d0816e0670d16c8b70bdf6530bcf6f78726489ad89b90".freeze + +TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze +TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze -- cgit v1.2.3 From 46a1e2f22d866275da68d11b871883f34669705f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 03:07:23 +0100 Subject: Convert `ARGV` test to spec. --- Library/Homebrew/test/ARGV_spec.rb | 149 +++++++++++++++++++++++++++++++++++++ Library/Homebrew/test/ARGV_test.rb | 79 -------------------- 2 files changed, 149 insertions(+), 79 deletions(-) create mode 100644 Library/Homebrew/test/ARGV_spec.rb delete mode 100644 Library/Homebrew/test/ARGV_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/ARGV_spec.rb b/Library/Homebrew/test/ARGV_spec.rb new file mode 100644 index 000000000..bcb7c3f70 --- /dev/null +++ b/Library/Homebrew/test/ARGV_spec.rb @@ -0,0 +1,149 @@ +require "extend/ARGV" + +describe HomebrewArgvExtension do + subject { argv.extend(HomebrewArgvExtension) } + let(:argv) { ["mxcl"] } + + describe "#formulae" do + it "raises an error when a Formula is unavailable" do + expect { subject.formulae }.to raise_error FormulaUnavailableError + end + + context "when there are no Formulae" do + let(:argv) { [] } + + it "returns an empty array" do + expect(subject.formulae).to be_empty + end + end + end + + describe "#casks" do + it "returns an empty array if there is no match" do + expect(subject.casks).to eq [] + end + end + + describe "#kegs" do + context "when there are matching Kegs" do + before(:each) do + keg = HOMEBREW_CELLAR + "mxcl/10.0" + keg.mkpath + end + + it "returns an array of Kegs" do + expect(subject.kegs.length).to eq 1 + end + end + + context "when there are no matching Kegs" do + let(:argv) { [] } + + it "returns an empty array" do + expect(subject.kegs).to be_empty + end + end + end + + describe "#named" do + let(:argv) { ["foo", "--debug", "-v"] } + + it "returns an array of non-option arguments" do + expect(subject.named).to eq ["foo"] + end + + context "when there are no named arguments" do + let(:argv) { [] } + + it "returns an empty array" do + expect(subject.named).to be_empty + end + end + end + + describe "#options_only" do + let(:argv) { ["--foo", "-vds", "a", "b", "cdefg"] } + + it "returns an array of option arguments" do + expect(subject.options_only).to eq ["--foo", "-vds"] + end + end + + describe "#flags_only" do + let(:argv) { ["--foo", "-vds", "a", "b", "cdefg"] } + + it "returns an array of flags" do + expect(subject.flags_only).to eq ["--foo"] + end + end + + describe "#empty?" do + let(:argv) { [] } + + it "returns true if it is empty" do + expect(subject).to be_empty + end + end + + describe "#switch?" do + let(:argv) { ["-ns", "-i", "--bar", "-a-bad-arg"] } + + it "returns true if the given string is a switch" do + %w[n s i].each do |s| + expect(subject.switch?(s)).to be true + end + end + + it "returns false if the given string is not a switch" do + %w[b ns bar --bar -n a bad arg].each do |s| + expect(subject.switch?(s)).to be false + end + end + end + + describe "#flag?" do + let(:argv) { ["--foo", "-bq", "--bar"] } + + it "returns true if the given string is a flag" do + expect(subject.flag?("--foo")).to eq true + expect(subject.flag?("--bar")).to eq true + end + + it "returns true if there is a switch with the same initial character" do + expect(subject.flag?("--baz")).to eq true + expect(subject.flag?("--qux")).to eq true + end + + it "returns false if there is no matching flag" do + expect(subject.flag?("--frotz")).to eq false + expect(subject.flag?("--debug")).to eq false + end + end + + describe "#value" do + let(:argv) { ["--foo=", "--bar=ab"] } + + it "returns the value for a given string" do + expect(subject.value("foo")).to eq "" + expect(subject.value("bar")).to eq "ab" + end + + it "returns nil if there is no matching argument" do + expect(subject.value("baz")).to be nil + end + end + + describe "#values" do + let(:argv) { ["--foo=", "--bar=a", "--baz=b,c"] } + + it "returns the value for a given argument" do + expect(subject.values("foo")).to eq [] + expect(subject.values("bar")).to eq ["a"] + expect(subject.values("baz")).to eq ["b", "c"] + end + + it "returns nil if there is no matching argument" do + expect(subject.values("qux")).to be nil + end + end +end diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb deleted file mode 100644 index e93d09c39..000000000 --- a/Library/Homebrew/test/ARGV_test.rb +++ /dev/null @@ -1,79 +0,0 @@ -require "testing_env" -require "extend/ARGV" - -class ArgvExtensionTests < Homebrew::TestCase - def setup - super - @argv = [].extend(HomebrewArgvExtension) - end - - def test_argv_formulae - @argv.unshift "mxcl" - assert_raises(FormulaUnavailableError) { @argv.formulae } - end - - def test_argv_casks - @argv.unshift "mxcl" - assert_equal [], @argv.casks - end - - def test_argv_kegs - keg = HOMEBREW_CELLAR + "mxcl/10.0" - keg.mkpath - @argv << "mxcl" - assert_equal 1, @argv.kegs.length - end - - def test_argv_named - @argv << "foo" << "--debug" << "-v" - assert_equal %w[foo], @argv.named - end - - def test_options_only - @argv << "--foo" << "-vds" << "a" << "b" << "cdefg" - assert_equal %w[--foo -vds], @argv.options_only - end - - def test_flags_only - @argv << "--foo" << "-vds" << "a" << "b" << "cdefg" - assert_equal %w[--foo], @argv.flags_only - end - - def test_empty_argv - assert_empty @argv.named - assert_empty @argv.kegs - assert_empty @argv.formulae - assert_empty @argv - end - - def test_switch? - @argv << "-ns" << "-i" << "--bar" << "-a-bad-arg" - %w[n s i].each { |s| assert @argv.switch?(s) } - %w[b ns bar --bar -n a bad arg].each { |s| assert !@argv.switch?(s) } - end - - def test_flag? - @argv << "--foo" << "-bq" << "--bar" - assert @argv.flag?("--foo") - assert @argv.flag?("--bar") - assert @argv.flag?("--baz") - assert @argv.flag?("--qux") - assert !@argv.flag?("--frotz") - assert !@argv.flag?("--debug") - end - - def test_value - @argv << "--foo=" << "--bar=ab" - assert_equal "", @argv.value("foo") - assert_equal "ab", @argv.value("bar") - assert_nil @argv.value("baz") - end - - def test_values - @argv << "--foo=" << "--bar=a" << "--baz=b,c" - assert_equal [], @argv.values("foo") - assert_equal ["a"], @argv.values("bar") - assert_equal ["b", "c"], @argv.values("baz") - assert_nil @argv.values("qux") - end -end -- cgit v1.2.3 From f531e63949683a7bf33ec96014901e3c6d5eaf61 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 16:53:11 +0100 Subject: Convert Bash test to spec. --- Library/Homebrew/test/bash_spec.rb | 52 ++++++++++++++++++++++++++++++++++++++ Library/Homebrew/test/bash_test.rb | 35 ------------------------- 2 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 Library/Homebrew/test/bash_spec.rb delete mode 100644 Library/Homebrew/test/bash_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/bash_spec.rb b/Library/Homebrew/test/bash_spec.rb new file mode 100644 index 000000000..1b0f15066 --- /dev/null +++ b/Library/Homebrew/test/bash_spec.rb @@ -0,0 +1,52 @@ +require "open3" + +RSpec::Matchers.define :have_valid_bash_syntax do + match do |file| + stdout, stderr, status = Open3.capture3("/bin/bash", "-n", file) + + @actual = [file, stderr] + + stdout.empty? && status.success? + end + + failure_message do |(file, stderr)| + "expected that #{file} is a valid Bash file:\n#{stderr}" + end +end + +describe "Bash" do + context "brew" do + subject { HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" } + it { is_expected.to have_valid_bash_syntax } + end + + context "every `.sh` file" do + it "has valid bash syntax" do + Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |path| + relative_path = path.relative_path_from(HOMEBREW_LIBRARY_PATH) + next if relative_path.to_s.start_with?("shims/", "test/", "vendor/") + + expect(path).to have_valid_bash_syntax + end + end + end + + context "Bash completion" do + subject { HOMEBREW_LIBRARY_PATH.parent.parent/"completions/bash/brew" } + it { is_expected.to have_valid_bash_syntax } + end + + context "every shim script" do + it "has valid bash syntax" do + # These have no file extension, but can be identified by their shebang. + (HOMEBREW_LIBRARY_PATH/"shims").find do |path| + next if path.directory? + next if path.symlink? + next unless path.executable? + next unless path.read(12) == "#!/bin/bash\n" + + expect(path).to have_valid_bash_syntax + end + end + end +end diff --git a/Library/Homebrew/test/bash_test.rb b/Library/Homebrew/test/bash_test.rb deleted file mode 100644 index 671ab5ec8..000000000 --- a/Library/Homebrew/test/bash_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "testing_env" - -class BashTests < Homebrew::TestCase - def assert_valid_bash_syntax(file) - return unless file.exist? - output = Utils.popen_read("/bin/bash -n #{file} 2>&1") - assert $?.success?, output - end - - def test_bin_brew - assert_valid_bash_syntax HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" - end - - def test_bash_code - Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |pn| - pn_relative = pn.relative_path_from(HOMEBREW_LIBRARY_PATH) - next if pn_relative.to_s.start_with?("shims/", "test/", "vendor/") - assert_valid_bash_syntax pn - end - end - - def test_bash_completion - script = HOMEBREW_LIBRARY_PATH.parent.parent/"completions/bash/brew" - assert_valid_bash_syntax script - end - - def test_bash_shims - # These have no file extension, but can be identified by their shebang. - (HOMEBREW_LIBRARY_PATH/"shims").find do |pn| - next if pn.directory? || pn.symlink? - next unless pn.executable? && pn.read(12) == "#!/bin/bash\n" - assert_valid_bash_syntax pn - end - end -end -- cgit v1.2.3 From 7be5a6a3d2cdb68870a37bdaa2d0c5cdec20c70b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 17:33:27 +0100 Subject: Convert Blacklist test to spec. --- Library/Homebrew/test/blacklist_spec.rb | 111 ++++++++++++++++++++++++++++++++ Library/Homebrew/test/blacklist_test.rb | 68 ------------------- 2 files changed, 111 insertions(+), 68 deletions(-) create mode 100644 Library/Homebrew/test/blacklist_spec.rb delete mode 100644 Library/Homebrew/test/blacklist_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/blacklist_spec.rb b/Library/Homebrew/test/blacklist_spec.rb new file mode 100644 index 000000000..89d254893 --- /dev/null +++ b/Library/Homebrew/test/blacklist_spec.rb @@ -0,0 +1,111 @@ +require "blacklist" + +RSpec::Matchers.define :be_blacklisted do + match do |actual| + blacklisted?(actual) + end +end + +describe "Blacklist" do + context "rubygems" do + %w[gem rubygem rubygems].each do |s| + subject { s } + + it { is_expected.to be_blacklisted } + end + end + + context "latex" do + %w[latex tex tex-live texlive TexLive].each do |s| + subject { s } + + it { is_expected.to be_blacklisted } + end + end + + context "pip" do + subject { "pip" } + + it { is_expected.to be_blacklisted } + end + + context "pil" do + subject { "pil" } + + it { is_expected.to be_blacklisted } + end + + context "macruby" do + subject { "MacRuby" } + + it { is_expected.to be_blacklisted } + end + + context "lzma" do + %w[lzma liblzma].each do |s| + subject { s } + + it { is_expected.to be_blacklisted } + end + end + + context "gtest" do + %w[gtest googletest google-test].each do |s| + subject { s } + + it { is_expected.to be_blacklisted } + end + end + + context "gmock" do + %w[gmock googlemock google-mock].each do |s| + subject { s } + + it { is_expected.to be_blacklisted } + end + end + + context "sshpass" do + subject { "sshpass" } + + it { is_expected.to be_blacklisted } + end + + context "gsutil" do + subject { "gsutil" } + + it { is_expected.to be_blacklisted } + end + + context "clojure" do + subject { "clojure" } + + it { is_expected.to be_blacklisted } + end + + context "osmium" do + %w[osmium Osmium].each do |s| + subject { s } + + it { is_expected.to be_blacklisted } + end + end + + context "gfortran" do + subject { "gfortran" } + + it { is_expected.to be_blacklisted } + end + + context "play" do + subject { "play" } + + it { is_expected.to be_blacklisted } + end + + context "haskell_platform" do + subject { "haskell-platform" } + + it { is_expected.to be_blacklisted } + end +end diff --git a/Library/Homebrew/test/blacklist_test.rb b/Library/Homebrew/test/blacklist_test.rb deleted file mode 100644 index 585a35484..000000000 --- a/Library/Homebrew/test/blacklist_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -require "testing_env" -require "blacklist" - -class BlacklistTests < Homebrew::TestCase - def assert_blacklisted(s) - assert blacklisted?(s), "'#{s}' should be blacklisted" - end - - def test_rubygems - %w[gem rubygem rubygems].each { |s| assert_blacklisted s } - end - - def test_latex - %w[latex tex tex-live texlive TexLive].each { |s| assert_blacklisted s } - end - - def test_pip - assert_blacklisted "pip" - end - - def test_pil - assert_blacklisted "pil" - end - - def test_macruby - assert_blacklisted "MacRuby" - end - - def test_lzma - %w[lzma liblzma].each { |s| assert_blacklisted s } - end - - def test_gtest - %w[gtest googletest google-test].each { |s| assert_blacklisted s } - end - - def test_gmock - %w[gmock googlemock google-mock].each { |s| assert_blacklisted s } - end - - def test_sshpass - assert_blacklisted "sshpass" - end - - def test_gsutil - assert_blacklisted "gsutil" - end - - def test_clojure - assert_blacklisted "clojure" - end - - def test_osmium - %w[osmium Osmium].each { |s| assert_blacklisted s } - end - - def test_gfortran - assert_blacklisted "gfortran" - end - - def test_play - assert_blacklisted "play" - end - - def test_haskell_platform - assert_blacklisted "haskell-platform" - end -end -- cgit v1.2.3 From ae829ed229395159adf6f1f17fb26518ec27fca6 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 7 Feb 2017 23:25:02 -0800 Subject: add brew where command --- Library/Homebrew/cmd/help.rb | 2 +- Library/Homebrew/dev-cmd/where.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Library/Homebrew/dev-cmd/where.rb (limited to 'Library') diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index 1378e7b1f..70379314e 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -15,7 +15,7 @@ Troubleshooting: Developers: brew create [URL [--no-fetch]] - brew edit [FORMULA...] + brew (where|edit) [FORMULA...] http://docs.brew.sh/Formula-Cookbook.html Further help: diff --git a/Library/Homebrew/dev-cmd/where.rb b/Library/Homebrew/dev-cmd/where.rb new file mode 100644 index 000000000..63237301b --- /dev/null +++ b/Library/Homebrew/dev-cmd/where.rb @@ -0,0 +1,15 @@ +#: * `where` : +#: echo location of the specified to stdout + +require "formula" + +module Homebrew + module_function + + def where + raise FormulaUnspecifiedError if ARGV.named.empty? + ARGV.resolved_formulae.each do |f| + puts "#{f.path}\n" + end + end +end -- cgit v1.2.3 From ac091437e5b2ae8ca21058cf47184f1788c8d697 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 8 Feb 2017 00:12:50 -0800 Subject: renamed where to formula --- Library/Homebrew/cmd/help.rb | 2 +- Library/Homebrew/dev-cmd/formula.rb | 15 +++++++++++++++ Library/Homebrew/dev-cmd/where.rb | 15 --------------- 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 Library/Homebrew/dev-cmd/formula.rb delete mode 100644 Library/Homebrew/dev-cmd/where.rb (limited to 'Library') diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index 70379314e..669f92ddd 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -15,7 +15,7 @@ Troubleshooting: Developers: brew create [URL [--no-fetch]] - brew (where|edit) [FORMULA...] + brew (formula|edit) [FORMULA...] http://docs.brew.sh/Formula-Cookbook.html Further help: diff --git a/Library/Homebrew/dev-cmd/formula.rb b/Library/Homebrew/dev-cmd/formula.rb new file mode 100644 index 000000000..80008a354 --- /dev/null +++ b/Library/Homebrew/dev-cmd/formula.rb @@ -0,0 +1,15 @@ +#: * `formula` : +#: echo location of the specified to stdout + +require "formula" + +module Homebrew + module_function + + def formula + raise FormulaUnspecifiedError if ARGV.named.empty? + ARGV.resolved_formulae.each do |f| + puts "#{f.path}\n" + end + end +end diff --git a/Library/Homebrew/dev-cmd/where.rb b/Library/Homebrew/dev-cmd/where.rb deleted file mode 100644 index 63237301b..000000000 --- a/Library/Homebrew/dev-cmd/where.rb +++ /dev/null @@ -1,15 +0,0 @@ -#: * `where` : -#: echo location of the specified to stdout - -require "formula" - -module Homebrew - module_function - - def where - raise FormulaUnspecifiedError if ARGV.named.empty? - ARGV.resolved_formulae.each do |f| - puts "#{f.path}\n" - end - end -end -- cgit v1.2.3 From de16dcc1ade56878cae04cf26bdaa465730c28d8 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 8 Feb 2017 00:27:50 -0800 Subject: brew formula not shown in --help to avoid increasing vertical space --- Library/Homebrew/cmd/help.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index 669f92ddd..1378e7b1f 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -15,7 +15,7 @@ Troubleshooting: Developers: brew create [URL [--no-fetch]] - brew (formula|edit) [FORMULA...] + brew edit [FORMULA...] http://docs.brew.sh/Formula-Cookbook.html Further help: -- cgit v1.2.3 From 0d715f90ea0e9b84231ce2221709f2134ee0ae31 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sat, 11 Feb 2017 16:37:41 -0800 Subject: applied changes suggested in PR --- Library/Homebrew/dev-cmd/formula.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/formula.rb b/Library/Homebrew/dev-cmd/formula.rb index 80008a354..71687dfa7 100644 --- a/Library/Homebrew/dev-cmd/formula.rb +++ b/Library/Homebrew/dev-cmd/formula.rb @@ -1,5 +1,5 @@ -#: * `formula` : -#: echo location of the specified to stdout +#: * `formula` : +#: Display the path where is require "formula" @@ -8,8 +8,6 @@ module Homebrew def formula raise FormulaUnspecifiedError if ARGV.named.empty? - ARGV.resolved_formulae.each do |f| - puts "#{f.path}\n" - end + ARGV.resolved_formulae.each { |f| puts f.path } end end -- cgit v1.2.3 From fd343a11fbde41420fe13b4acab7bce8eea34d13 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Fri, 3 Feb 2017 10:47:44 -0800 Subject: gcc_version_formula: Use gcc@4.x rather than gcc4x --- Library/Homebrew/extend/ENV/shared.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 7b468574a..3b07e0a71 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -269,7 +269,7 @@ module SharedEnvExtension # @private def gcc_version_formula(name) version = name[GNU_GCC_REGEXP, 1] - gcc_version_name = "gcc#{version.delete(".")}" + gcc_version_name = "gcc@#{version}" gcc = Formulary.factory("gcc") if gcc.version_suffix == version @@ -286,7 +286,6 @@ module SharedEnvExtension rescue FormulaUnavailableError => e raise <<-EOS.undent Homebrew GCC requested, but formula #{e.name} not found! - You may need to: brew tap homebrew/versions EOS end -- cgit v1.2.3 From 5dc358c1b7254aa622504cd98528779caf6dee00 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sun, 12 Feb 2017 11:07:03 +0530 Subject: Update rubocop config --- Library/.rubocop.yml | 9 ++++----- Library/Homebrew/rubocops.rb | 1 + Library/Homebrew/rubocops/bottle_block_cop.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 Library/Homebrew/rubocops.rb (limited to 'Library') diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 012fcd609..30b9ec81e 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -6,10 +6,9 @@ AllCops: - '**/Casks/**/*' - '**/vendor/**/*' -require: - - ./Homebrew/rubocops/bottle_block_cop.rb +require: ./Homebrew/rubocops.rb -CustomCops/CorrectBottleBlock: +Homebrew/CorrectBottleBlock: Enabled: true Metrics/AbcSize: @@ -47,7 +46,7 @@ Lint/AssignmentInCondition: Enabled: false Lint/EndAlignment: - AlignWith: variable + EnforcedStyleAlignWith: variable Lint/ParenthesesAsGroupedExpression: Enabled: false @@ -69,7 +68,7 @@ Style/BlockDelimiters: EnforcedStyle: line_count_based Style/CaseIndentation: - IndentWhenRelativeTo: end + EnforcedStyle: end Style/ClassAndModuleChildren: EnforcedStyle: nested diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb new file mode 100644 index 000000000..1a28dd213 --- /dev/null +++ b/Library/Homebrew/rubocops.rb @@ -0,0 +1 @@ +require_relative "./rubocops/bottle_block_cop" diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb index e16672683..55eb55152 100644 --- a/Library/Homebrew/rubocops/bottle_block_cop.rb +++ b/Library/Homebrew/rubocops/bottle_block_cop.rb @@ -1,6 +1,6 @@ module RuboCop module Cop - module CustomCops + module Homebrew class CorrectBottleBlock < Cop MSG = "Use rebuild instead of revision in bottle block".freeze -- cgit v1.2.3 From 93441743794a3d44f90bc53438ca31add960f757 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 12 Feb 2017 13:57:52 +0000 Subject: Use HTTPS for the homepage. --- Library/Homebrew/global.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 5fd356909..5e88947c9 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -15,7 +15,7 @@ ARGV.extend(HomebrewArgvExtension) HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"] HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"] -HOMEBREW_WWW = "http://brew.sh".freeze +HOMEBREW_WWW = "https://brew.sh".freeze require "config" -- cgit v1.2.3 From efc1f1c7da50e77e96a4324c9380e19848dcf03d Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 12 Feb 2017 14:45:34 +0000 Subject: formula_installer: add env to allow unlinked deps. We can enable this locally and/or in `brew test-bot` to see if this code is needed any more. If we can remove it we can start doing much more interesting things with linking keg-only, versioned formulae and system dupe formulae. --- Library/Homebrew/formula_installer.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index e8f0e4bf8..4db599079 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -171,12 +171,14 @@ class FormulaInstaller end end - unlinked_deps = recursive_formulae.select do |dep| - dep.installed? && !dep.keg_only? && !dep.linked_keg.directory? - end + unless ENV["HOMEBREW_NO_CHECK_UNLINKED_DEPENDENCIES"] + unlinked_deps = recursive_formulae.select do |dep| + dep.installed? && !dep.keg_only? && !dep.linked_keg.directory? + end - unless unlinked_deps.empty? - raise CannotInstallFormulaError, "You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed" + unless unlinked_deps.empty? + raise CannotInstallFormulaError, "You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed" + end end pinned_unsatisfied_deps = recursive_deps.select do |dep| -- cgit v1.2.3 From 9e97eadccbd99df1c6ffe489ab316d7ebde7fe86 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 12 Feb 2017 15:06:54 +0000 Subject: rubocop: trailing comma in multiline method calls Discussed in https://github.com/Homebrew/brew/pull/1987/files#r100693581. This was originally ommitted because it wasn't compatible with Ruby 1.8. (See https://github.com/Homebrew/legacy-homebrew/pull/48144#r49928971). --- Library/.rubocop.yml | 2 ++ .../Homebrew/cask/spec/cask/accessibility_spec.rb | 6 ++-- .../Homebrew/cask/spec/cask/artifact/pkg_spec.rb | 4 +-- .../cask/spec/cask/artifact/uninstall_spec.rb | 40 +++++++++++----------- .../Homebrew/cask/spec/cask/artifact/zap_spec.rb | 40 +++++++++++----------- .../Homebrew/cask/spec/cask/container/dmg_spec.rb | 2 +- .../cask/spec/cask/download_strategy_spec.rb | 10 +++--- Library/Homebrew/cask/spec/cask/macos_spec.rb | 32 ++++++++--------- Library/Homebrew/cask/spec/cask/pkg_spec.rb | 8 ++--- Library/Homebrew/cask/spec/cask/scopes_spec.rb | 2 +- .../Homebrew/cask/spec/cask/url_checker_spec.rb | 2 +- Library/Homebrew/cask/spec/formatter_spec.rb | 6 ++-- Library/Homebrew/cask/spec/plist/parser_spec.rb | 2 +- .../cask/spec/support/shared_examples/staged.rb | 16 ++++----- Library/Homebrew/cmd/deps.rb | 2 +- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/extend/ENV/super.rb | 2 +- Library/Homebrew/extend/os/mac/hardware/cpu.rb | 2 +- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/keg_relocate.rb | 6 ++-- Library/Homebrew/test/dependency_expansion_test.rb | 2 +- Library/Homebrew/test/formula_test.rb | 4 +-- Library/Homebrew/test/language_python_test.rb | 4 +-- Library/Homebrew/test/patch_test.rb | 10 +++--- Library/Homebrew/test/shell_test.rb | 2 +- .../helper/integration_command_test_case.rb | 2 +- Library/Homebrew/test/tab_test.rb | 2 +- Library/Homebrew/version.rb | 2 +- 28 files changed, 109 insertions(+), 107 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 30b9ec81e..314467ef0 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -168,6 +168,8 @@ Style/TernaryParentheses: # makes diffs nicer Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma Style/VariableNumber: Enabled: false diff --git a/Library/Homebrew/cask/spec/cask/accessibility_spec.rb b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb index 8787a2c6d..71bebfa4b 100644 --- a/Library/Homebrew/cask/spec/cask/accessibility_spec.rb +++ b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb @@ -19,7 +19,7 @@ describe "Accessibility Access" do expect(fake_system_command).to receive(:run!).with( "/usr/bin/touch", args: [Hbc.pre_mavericks_accessibility_dotfile], - sudo: true + sudo: true, ) shutup do @@ -41,7 +41,7 @@ describe "Accessibility Access" do expect(fake_system_command).to receive(:run!).with( "/usr/bin/sqlite3", args: [Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"], - sudo: true + sudo: true, ) shutup do @@ -53,7 +53,7 @@ describe "Accessibility Access" do expect(fake_system_command).to receive(:run!).with( "/usr/bin/sqlite3", args: [Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"], - sudo: true + sudo: true, ) shutup do diff --git a/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb index d4d69ea66..93ef2ecdf 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb @@ -18,7 +18,7 @@ describe Hbc::Artifact::Pkg do "/usr/sbin/installer", args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"], sudo: true, - print_stdout: true + print_stdout: true, ) shutup do @@ -60,7 +60,7 @@ describe Hbc::Artifact::Pkg do "/usr/sbin/installer", args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", cask.staged_path.join("/tmp/choices.xml")], sudo: true, - print_stdout: true + print_stdout: true, ) shutup do diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb index 008e2ad2a..a38ed903e 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb @@ -44,12 +44,12 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.stubs_command( launchctl_list_cmd, - service_info + service_info, ) Hbc::FakeSystemCommand.stubs_command( sudo(launchctl_list_cmd), - unknown_response + unknown_response, ) Hbc::FakeSystemCommand.expects_command(launchctl_remove_cmd) @@ -62,12 +62,12 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.stubs_command( launchctl_list_cmd, - unknown_response + unknown_response, ) Hbc::FakeSystemCommand.stubs_command( sudo(launchctl_list_cmd), - service_info + service_info, ) Hbc::FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) @@ -125,7 +125,7 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.stubs_command( %w[/usr/sbin/pkgutil --pkgs=my.fancy.package.*], - "#{main_pkg_id}\n#{agent_pkg_id}" + "#{main_pkg_id}\n#{agent_pkg_id}", ) [ @@ -134,28 +134,28 @@ describe Hbc::Artifact::Uninstall do ].each do |pkg_id, pkg_files, pkg_dirs| Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --only-files --files #{pkg_id}], - pkg_files.join("\n") + pkg_files.join("\n"), ) Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --only-dirs --files #{pkg_id}], - pkg_dirs.join("\n") + pkg_dirs.join("\n"), ) Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --files #{pkg_id}], - (pkg_files + pkg_dirs).join("\n") + (pkg_files + pkg_dirs).join("\n"), ) Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --pkg-info-plist #{pkg_id}], - pkg_info_plist + pkg_info_plist, ) Hbc::FakeSystemCommand.expects_command(sudo(%W[/usr/sbin/pkgutil --forget #{pkg_id}])) Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }) + sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }), ) end @@ -173,7 +173,7 @@ describe Hbc::Artifact::Uninstall do ) Hbc::FakeSystemCommand.expects_command( - sudo(%W[/sbin/kextunload -b #{kext_id}]) + sudo(%W[/sbin/kextunload -b #{kext_id}]), ) Hbc::FakeSystemCommand.expects_command( @@ -181,7 +181,7 @@ describe Hbc::Artifact::Uninstall do ) Hbc::FakeSystemCommand.expects_command( - sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]) + sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]), ) subject @@ -201,7 +201,7 @@ describe Hbc::Artifact::Uninstall do ) Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list] + %w[/bin/launchctl list], ) subject @@ -234,7 +234,7 @@ describe Hbc::Artifact::Uninstall do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) + Pathname.new("~/permissible/path/with/tilde").expand_path), ) subject @@ -248,7 +248,7 @@ describe Hbc::Artifact::Uninstall do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) + Pathname.new("~/permissible/path/with/tilde").expand_path), ) subject @@ -261,11 +261,11 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")) + sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")), ) Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rmdir --], dir_pathname) + sudo(%w[/bin/rmdir --], dir_pathname), ) subject @@ -280,7 +280,7 @@ describe Hbc::Artifact::Uninstall do Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"), ) subject @@ -295,7 +295,7 @@ describe Hbc::Artifact::Uninstall do Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"), ) subject @@ -308,7 +308,7 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.expects_command( ["/usr/bin/osascript", "-e", 'tell application "System Events" to delete every login ' \ - 'item whose name is "Fancy"'] + 'item whose name is "Fancy"'], ) subject diff --git a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb index bd14cd6de..50e132bfa 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb @@ -45,12 +45,12 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.stubs_command( launchctl_list_cmd, - service_info + service_info, ) Hbc::FakeSystemCommand.stubs_command( sudo(launchctl_list_cmd), - unknown_response + unknown_response, ) Hbc::FakeSystemCommand.expects_command(launchctl_remove_cmd) @@ -63,12 +63,12 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.stubs_command( launchctl_list_cmd, - unknown_response + unknown_response, ) Hbc::FakeSystemCommand.stubs_command( sudo(launchctl_list_cmd), - service_info + service_info, ) Hbc::FakeSystemCommand.expects_command(sudo(launchctl_remove_cmd)) @@ -126,7 +126,7 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.stubs_command( %w[/usr/sbin/pkgutil --pkgs=my.fancy.package.*], - "#{main_pkg_id}\n#{agent_pkg_id}" + "#{main_pkg_id}\n#{agent_pkg_id}", ) [ @@ -135,28 +135,28 @@ describe Hbc::Artifact::Zap do ].each do |pkg_id, pkg_files, pkg_dirs| Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --only-files --files #{pkg_id}], - pkg_files.join("\n") + pkg_files.join("\n"), ) Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --only-dirs --files #{pkg_id}], - pkg_dirs.join("\n") + pkg_dirs.join("\n"), ) Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --files #{pkg_id}], - (pkg_files + pkg_dirs).join("\n") + (pkg_files + pkg_dirs).join("\n"), ) Hbc::FakeSystemCommand.stubs_command( %W[/usr/sbin/pkgutil --pkg-info-plist #{pkg_id}], - pkg_info_plist + pkg_info_plist, ) Hbc::FakeSystemCommand.expects_command(sudo(%W[/usr/sbin/pkgutil --forget #{pkg_id}])) Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }) + sudo(%w[/bin/rm -f --] + pkg_files.map { |path| Pathname("/tmp/#{path}") }), ) end @@ -174,7 +174,7 @@ describe Hbc::Artifact::Zap do ) Hbc::FakeSystemCommand.expects_command( - sudo(%W[/sbin/kextunload -b #{kext_id}]) + sudo(%W[/sbin/kextunload -b #{kext_id}]), ) Hbc::FakeSystemCommand.expects_command( @@ -182,7 +182,7 @@ describe Hbc::Artifact::Zap do ) Hbc::FakeSystemCommand.expects_command( - sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]) + sudo(["/bin/rm", "-rf", "/Library/Extensions/FancyPackage.kext"]), ) subject @@ -202,7 +202,7 @@ describe Hbc::Artifact::Zap do ) Hbc::FakeSystemCommand.stubs_command( - %w[/bin/launchctl list] + %w[/bin/launchctl list], ) subject @@ -235,7 +235,7 @@ describe Hbc::Artifact::Zap do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) + Pathname.new("~/permissible/path/with/tilde").expand_path), ) subject @@ -249,7 +249,7 @@ describe Hbc::Artifact::Zap do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path) + Pathname.new("~/permissible/path/with/tilde").expand_path), ) subject @@ -262,11 +262,11 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")) + sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")), ) Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rmdir --], dir_pathname) + sudo(%w[/bin/rmdir --], dir_pathname), ) subject @@ -281,7 +281,7 @@ describe Hbc::Artifact::Zap do Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"), ) subject @@ -296,7 +296,7 @@ describe Hbc::Artifact::Zap do Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please") + sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"), ) subject @@ -309,7 +309,7 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.expects_command( ["/usr/bin/osascript", "-e", 'tell application "System Events" to delete every login ' \ - 'item whose name is "Fancy"'] + 'item whose name is "Fancy"'], ) subject diff --git a/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb index af42d89b1..cf35b7545 100644 --- a/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb +++ b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb @@ -8,7 +8,7 @@ describe Hbc::Container::Dmg do dmg = Hbc::Container::Dmg.new( transmission, Pathname(transmission.url.path), - Hbc::SystemCommand + Hbc::SystemCommand, ) begin diff --git a/Library/Homebrew/cask/spec/cask/download_strategy_spec.rb b/Library/Homebrew/cask/spec/cask/download_strategy_spec.rb index d6c28bbd1..900ceb3e2 100644 --- a/Library/Homebrew/cask/spec/cask/download_strategy_spec.rb +++ b/Library/Homebrew/cask/spec/cask/download_strategy_spec.rb @@ -176,7 +176,7 @@ describe "download strategies" do expect(downloader).to have_received(:fetch_repo).with( downloader.cached_location, - cask.url.to_s + cask.url.to_s, ) end @@ -196,7 +196,7 @@ describe "download strategies" do "config:miscellany:use-commit-times=yes", cask.url.to_s, downloader.cached_location, - ]) + ]), ) end @@ -226,7 +226,7 @@ describe "download strategies" do "--non-interactive", cask.url.to_s, downloader.cached_location, - ]) + ]), ) end end @@ -257,7 +257,7 @@ describe "download strategies" do downloader.cached_location, "-r", "10", - ]) + ]), ) end end @@ -283,7 +283,7 @@ describe "download strategies" do downloader.tarball_path, "--", ".", - ]) + ]), ) end end diff --git a/Library/Homebrew/cask/spec/cask/macos_spec.rb b/Library/Homebrew/cask/spec/cask/macos_spec.rb index a1ebb0a9e..f931e1104 100644 --- a/Library/Homebrew/cask/spec/cask/macos_spec.rb +++ b/Library/Homebrew/cask/spec/cask/macos_spec.rb @@ -1,67 +1,67 @@ describe MacOS do it "says '/' is undeletable" do expect(MacOS).to be_undeletable( - "/" + "/", ) expect(MacOS).to be_undeletable( - "/." + "/.", ) expect(MacOS).to be_undeletable( - "/usr/local/Library/Taps/../../../.." + "/usr/local/Library/Taps/../../../..", ) end it "says '/Applications' is undeletable" do expect(MacOS).to be_undeletable( - "/Applications" + "/Applications", ) expect(MacOS).to be_undeletable( - "/Applications/" + "/Applications/", ) expect(MacOS).to be_undeletable( - "/Applications/." + "/Applications/.", ) expect(MacOS).to be_undeletable( - "/Applications/Mail.app/.." + "/Applications/Mail.app/..", ) end it "says the home directory is undeletable" do expect(MacOS).to be_undeletable( - Dir.home + Dir.home, ) expect(MacOS).to be_undeletable( - "#{Dir.home}/" + "#{Dir.home}/", ) expect(MacOS).to be_undeletable( - "#{Dir.home}/Documents/.." + "#{Dir.home}/Documents/..", ) end it "says the user library directory is undeletable" do expect(MacOS).to be_undeletable( - "#{Dir.home}/Library" + "#{Dir.home}/Library", ) expect(MacOS).to be_undeletable( - "#{Dir.home}/Library/" + "#{Dir.home}/Library/", ) expect(MacOS).to be_undeletable( - "#{Dir.home}/Library/." + "#{Dir.home}/Library/.", ) expect(MacOS).to be_undeletable( - "#{Dir.home}/Library/Preferences/.." + "#{Dir.home}/Library/Preferences/..", ) end it "says '/Applications/.app' is deletable" do expect(MacOS).not_to be_undeletable( - "/Applications/.app" + "/Applications/.app", ) end it "says '/Applications/SnakeOil Professional.app' is deletable" do expect(MacOS).not_to be_undeletable( - "/Applications/SnakeOil Professional.app" + "/Applications/SnakeOil Professional.app", ) end end diff --git a/Library/Homebrew/cask/spec/cask/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/pkg_spec.rb index 2f0ba0839..6610b0e48 100644 --- a/Library/Homebrew/cask/spec/cask/pkg_spec.rb +++ b/Library/Homebrew/cask/spec/cask/pkg_spec.rb @@ -35,23 +35,23 @@ describe Hbc::Pkg do it "forgets the pkg" do allow(fake_system_command).to receive(:run!).with( "/usr/sbin/pkgutil", - args: ["--only-files", "--files", "my.fake.pkg"] + args: ["--only-files", "--files", "my.fake.pkg"], ).and_return(empty_response) allow(fake_system_command).to receive(:run!).with( "/usr/sbin/pkgutil", - args: ["--only-dirs", "--files", "my.fake.pkg"] + args: ["--only-dirs", "--files", "my.fake.pkg"], ).and_return(empty_response) allow(fake_system_command).to receive(:run!).with( "/usr/sbin/pkgutil", - args: ["--files", "my.fake.pkg"] + args: ["--files", "my.fake.pkg"], ).and_return(empty_response) expect(fake_system_command).to receive(:run!).with( "/usr/sbin/pkgutil", args: ["--forget", "my.fake.pkg"], - sudo: true + sudo: true, ) pkg.uninstall diff --git a/Library/Homebrew/cask/spec/cask/scopes_spec.rb b/Library/Homebrew/cask/spec/cask/scopes_spec.rb index abf4b6401..e6e507da8 100644 --- a/Library/Homebrew/cask/spec/cask/scopes_spec.rb +++ b/Library/Homebrew/cask/spec/cask/scopes_spec.rb @@ -14,7 +14,7 @@ describe Hbc::Scopes do %w[ loaded-cask-bar loaded-cask-foo - ] + ], ) end diff --git a/Library/Homebrew/cask/spec/cask/url_checker_spec.rb b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb index 3b46bc587..8d2161586 100644 --- a/Library/Homebrew/cask/spec/cask/url_checker_spec.rb +++ b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb @@ -36,7 +36,7 @@ describe Hbc::UrlChecker do "Content-Type" => "application/x-apple-diskimage", "ETag" => '"b4208f3e84967be4b078ecaa03fba941"', "Content-Length" => "23726161", - "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT" + "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT", ) end end diff --git a/Library/Homebrew/cask/spec/formatter_spec.rb b/Library/Homebrew/cask/spec/formatter_spec.rb index ad4c441cb..e8bd34416 100644 --- a/Library/Homebrew/cask/spec/formatter_spec.rb +++ b/Library/Homebrew/cask/spec/formatter_spec.rb @@ -21,7 +21,7 @@ describe Formatter do "aa\n" \ "bbb\n" \ "ccc\n" \ - "dd\n" + "dd\n", ) end @@ -32,7 +32,7 @@ describe Formatter do expect(subject).to eq( "aa ccc\n" \ - "bbb dd\n" + "bbb dd\n", ) end @@ -41,7 +41,7 @@ describe Formatter do allow(Tty).to receive(:width).and_return(20) expect(subject).to eq( - "aa bbb ccc dd\n" + "aa bbb ccc dd\n", ) end end diff --git a/Library/Homebrew/cask/spec/plist/parser_spec.rb b/Library/Homebrew/cask/spec/plist/parser_spec.rb index 9d4a59fdc..a71b7ea2e 100644 --- a/Library/Homebrew/cask/spec/plist/parser_spec.rb +++ b/Library/Homebrew/cask/spec/plist/parser_spec.rb @@ -61,7 +61,7 @@ describe Plist do /dev/disk3s1 /dev/disk3 /dev/disk3s2 - ] + ], ) end end diff --git a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb index f791696ac..d815ef7a0 100644 --- a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb +++ b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb @@ -19,7 +19,7 @@ shared_examples Hbc::Staged do it "can run system commands with list-form arguments" do Hbc::FakeSystemCommand.expects_command( - ["echo", "homebrew-cask", "rocks!"] + ["echo", "homebrew-cask", "rocks!"], ) shutup do @@ -35,7 +35,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask") Hbc::FakeSystemCommand.expects_command( - ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file] + ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file], ) shutup do @@ -47,7 +47,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask") Hbc::FakeSystemCommand.expects_command( - ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file] + ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file], ) shutup do @@ -60,7 +60,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/bin/chmod", "-R", "--", "777", fake_pathname] + ["/bin/chmod", "-R", "--", "777", fake_pathname], ) shutup do @@ -73,7 +73,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname] + ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname], ) shutup do @@ -94,7 +94,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname] + ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname], ) shutup do @@ -109,7 +109,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname] + ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname], ) shutup do @@ -123,7 +123,7 @@ shared_examples Hbc::Staged do allow(staged).to receive(:Pathname).and_return(fake_pathname) Hbc::FakeSystemCommand.expects_command( - ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname] + ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname], ) shutup do diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 205cbe172..f80bdfb0d 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -50,7 +50,7 @@ module Homebrew tree?: ARGV.include?("--tree"), all?: ARGV.include?("--all"), topo_order?: ARGV.include?("-n"), - union?: ARGV.include?("--union") + union?: ARGV.include?("--union"), ) if mode.installed? && mode.tree? diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 0e7c11005..0522c7878 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -191,7 +191,7 @@ class FormulaAuditor args = curl_args( extra_args: extra_args, show_output: true, - user_agent: user_agent + user_agent: user_agent, ) status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } break if status_code.start_with? "20" diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 39ddb6681..1a5f420f6 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -277,7 +277,7 @@ module Superenv return unless Hardware::CPU.is_32_bit? self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub( /-march=\S*/, - "-Xarch_#{Hardware::CPU.arch_32_bit} \\0" + "-Xarch_#{Hardware::CPU.arch_32_bit} \\0", ) end diff --git a/Library/Homebrew/extend/os/mac/hardware/cpu.rb b/Library/Homebrew/extend/os/mac/hardware/cpu.rb index 0695d4a5b..f759895c7 100644 --- a/Library/Homebrew/extend/os/mac/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/mac/hardware/cpu.rb @@ -111,7 +111,7 @@ module Hardware @features ||= sysctl_n( "machdep.cpu.features", "machdep.cpu.extfeatures", - "machdep.cpu.leaf7_features" + "machdep.cpu.leaf7_features", ).split(" ").map { |s| s.downcase.to_sym } end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index e8f0e4bf8..023548000 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -431,7 +431,7 @@ class FormulaInstaller inherited_options[dep.name] |= inherited_options_for(dep) build = effective_build_options_for( dependent, - inherited_options.fetch(dependent.name, []) + inherited_options.fetch(dependent.name, []), ) if (dep.optional? || dep.recommended?) && build.without?(dep) diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 0ab4b9731..d17e7f75a 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -34,7 +34,7 @@ class Keg old_repository: HOMEBREW_REPOSITORY.to_s, new_prefix: PREFIX_PLACEHOLDER, new_cellar: CELLAR_PLACEHOLDER, - new_repository: REPOSITORY_PLACEHOLDER + new_repository: REPOSITORY_PLACEHOLDER, ) relocate_dynamic_linkage(relocation) replace_text_in_files(relocation) @@ -47,7 +47,7 @@ class Keg old_repository: REPOSITORY_PLACEHOLDER, new_prefix: HOMEBREW_PREFIX.to_s, new_cellar: HOMEBREW_CELLAR.to_s, - new_repository: HOMEBREW_REPOSITORY.to_s + new_repository: HOMEBREW_REPOSITORY.to_s, ) relocate_dynamic_linkage(relocation) unless skip_linkage replace_text_in_files(relocation, files: files) @@ -71,7 +71,7 @@ class Keg regexp = Regexp.union( relocation.old_cellar, relocation.old_repository, - relocation.old_prefix + relocation.old_prefix, ) changed = s.gsub!(regexp, replacements) diff --git a/Library/Homebrew/test/dependency_expansion_test.rb b/Library/Homebrew/test/dependency_expansion_test.rb index de743ce03..58a731121 100644 --- a/Library/Homebrew/test/dependency_expansion_test.rb +++ b/Library/Homebrew/test/dependency_expansion_test.rb @@ -93,7 +93,7 @@ class DependencyExpansionTests < Homebrew::TestCase deps: [ build_dep(:foo, [], [@bar, @baz]), build_dep(:foo, [], [@baz]), - ] + ], ) deps = Dependency.expand(f) do |_dependent, dep| diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index f7b06b079..318175d49 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -209,12 +209,12 @@ class FormulaTests < Homebrew::TestCase refute_predicate f, :installed? f.stubs(:installed_prefix).returns( - stub(directory?: true, children: []) + stub(directory?: true, children: []), ) refute_predicate f, :installed? f.stubs(:installed_prefix).returns( - stub(directory?: true, children: [stub]) + stub(directory?: true, children: [stub]), ) assert_predicate f, :installed? end diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb index aa0a7d51d..cc21cbfbd 100644 --- a/Library/Homebrew/test/language_python_test.rb +++ b/Library/Homebrew/test/language_python_test.rb @@ -17,7 +17,7 @@ class LanguagePythonTests < Homebrew::TestCase def test_virtualenv_creation @formula.expects(:resource).with("homebrew-virtualenv").returns( - mock("resource", stage: true) + mock("resource", stage: true), ) @venv.create end @@ -25,7 +25,7 @@ class LanguagePythonTests < Homebrew::TestCase # or at least doesn't crash the second time def test_virtualenv_creation_is_idempotent @formula.expects(:resource).with("homebrew-virtualenv").returns( - mock("resource", stage: true) + mock("resource", stage: true), ) @venv.create FileUtils.mkdir_p @dir/"bin" diff --git a/Library/Homebrew/test/patch_test.rb b/Library/Homebrew/test/patch_test.rb index f5a61398a..3055eaf48 100644 --- a/Library/Homebrew/test/patch_test.rb +++ b/Library/Homebrew/test/patch_test.rb @@ -48,7 +48,7 @@ class LegacyPatchTests < Homebrew::TestCase def test_patch_array patches = Patch.normalize_legacy_patches( - %w[http://example.com/patch1.diff http://example.com/patch2.diff] + %w[http://example.com/patch1.diff http://example.com/patch2.diff], ) assert_equal 2, patches.length @@ -58,7 +58,7 @@ class LegacyPatchTests < Homebrew::TestCase def test_p0_hash_to_string patches = Patch.normalize_legacy_patches( - p0: "http://example.com/patch.diff" + p0: "http://example.com/patch.diff", ) assert_equal 1, patches.length @@ -67,7 +67,7 @@ class LegacyPatchTests < Homebrew::TestCase def test_p1_hash_to_string patches = Patch.normalize_legacy_patches( - p1: "http://example.com/patch.diff" + p1: "http://example.com/patch.diff", ) assert_equal 1, patches.length @@ -77,7 +77,7 @@ class LegacyPatchTests < Homebrew::TestCase def test_mixed_hash_to_strings patches = Patch.normalize_legacy_patches( p1: "http://example.com/patch1.diff", - p0: "http://example.com/patch0.diff" + p0: "http://example.com/patch0.diff", ) assert_equal 2, patches.length assert_equal 1, patches.count { |p| p.strip == :p0 } @@ -89,7 +89,7 @@ class LegacyPatchTests < Homebrew::TestCase p1: ["http://example.com/patch10.diff", "http://example.com/patch11.diff"], p0: ["http://example.com/patch00.diff", - "http://example.com/patch01.diff"] + "http://example.com/patch01.diff"], ) assert_equal 4, patches.length diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb index a04ab8331..970489702 100644 --- a/Library/Homebrew/test/shell_test.rb +++ b/Library/Homebrew/test/shell_test.rb @@ -42,7 +42,7 @@ class ShellSmokeTest < Homebrew::TestCase prepend_message = Utils::Shell.prepend_path_in_shell_profile(path) assert( prepend_message.start_with?(fragment), - "#{shell}: expected #{prepend_message} to match #{fragment}" + "#{shell}: expected #{prepend_message} to match #{fragment}", ) end diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index 45e73757a..7ba094645 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -35,7 +35,7 @@ class IntegrationCommandTestCase < Homebrew::TestCase "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", "HOMEBREW_INTEGRATION_TEST" => cmd_id_from_args(args), "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, - "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"] + "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"], ) ruby_args = [ diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index 99c95a3f0..08d45ee90 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -32,7 +32,7 @@ class TabTests < Homebrew::TestCase "devel" => "0.14", "head" => "HEAD-1111111", }, - } + }, ) end diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 0f3cbb773..77f270dd9 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -164,7 +164,7 @@ class Version RCToken::PATTERN, PatchToken::PATTERN, NumericToken::PATTERN, - StringToken::PATTERN + StringToken::PATTERN, ) class FromURL < Version -- cgit v1.2.3 From fdea0b2f3aac60e14ffa42c6a070c4edca8ca056 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 12 Feb 2017 15:55:03 +0000 Subject: official_taps: remove emacs. --- Library/Homebrew/official_taps.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index 35295c1e8..c7b96ae64 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -1,7 +1,6 @@ OFFICIAL_TAPS = %w[ apache dupes - emacs fuse nginx php -- cgit v1.2.3 From e07a587f42abcf107866f0937643b1a261adf185 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 12 Feb 2017 16:17:56 +0000 Subject: --prefix: use opt_prefix when available. Fixes #1952. --- Library/Homebrew/cmd/--prefix.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/--prefix.rb b/Library/Homebrew/cmd/--prefix.rb index f6e7d2ee2..956ab0403 100644 --- a/Library/Homebrew/cmd/--prefix.rb +++ b/Library/Homebrew/cmd/--prefix.rb @@ -11,7 +11,9 @@ module Homebrew if ARGV.named.empty? puts HOMEBREW_PREFIX else - puts ARGV.resolved_formulae.map(&:installed_prefix) + puts ARGV.resolved_formulae.map { |f| + f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix + } end end end -- cgit v1.2.3 From 23767a378bf4c10d2e78e49050ab566d9f8cdaed Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 11:58:34 +0100 Subject: Convert X11Requirement test to spec. --- Library/Homebrew/test/x11_requirement_spec.rb | 36 +++++++++++++++++++++++++++ Library/Homebrew/test/x11_requirement_test.rb | 31 ----------------------- 2 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 Library/Homebrew/test/x11_requirement_spec.rb delete mode 100644 Library/Homebrew/test/x11_requirement_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/x11_requirement_spec.rb b/Library/Homebrew/test/x11_requirement_spec.rb new file mode 100644 index 000000000..f60c8bffe --- /dev/null +++ b/Library/Homebrew/test/x11_requirement_spec.rb @@ -0,0 +1,36 @@ +require "requirements/x11_requirement" + +describe X11Requirement do + let(:default_name) { "x11" } + + describe "#name" do + it "defaults to x11" do + expect(subject.name).to eq(default_name) + end + end + + describe "#eql?" do + it "returns true if the names are equal" do + other = described_class.new(default_name) + expect(subject).to eql(other) + end + + it "and returns false if the names differ" do + other = described_class.new("foo") + expect(subject).not_to eql(other) + end + + it "returns false if the minimum version differs" do + other = described_class.new(default_name, ["2.5"]) + expect(subject).not_to eql(other) + end + end + + describe "#modify_build_environment" do + it "calls ENV#x11" do + allow(subject).to receive(:satisfied?).and_return(true) + expect(ENV).to receive(:x11) + subject.modify_build_environment + end + end +end diff --git a/Library/Homebrew/test/x11_requirement_test.rb b/Library/Homebrew/test/x11_requirement_test.rb deleted file mode 100644 index b82a59e53..000000000 --- a/Library/Homebrew/test/x11_requirement_test.rb +++ /dev/null @@ -1,31 +0,0 @@ -require "testing_env" -require "requirements/x11_requirement" - -class X11RequirementTests < Homebrew::TestCase - def test_eql_instances_are_eql - x = X11Requirement.new - y = X11Requirement.new - assert_eql x, y - assert_equal x.hash, y.hash - end - - def test_not_eql_when_hashes_differ - x = X11Requirement.new("foo") - y = X11Requirement.new - refute_eql x, y - refute_equal x.hash, y.hash - end - - def test_different_min_version - x = X11Requirement.new - y = X11Requirement.new("x11", %w[2.5]) - refute_eql x, y - end - - def test_x_env - x = X11Requirement.new - x.stubs(:satisfied?).returns(true) - ENV.expects(:x11) - x.modify_build_environment - end -end -- cgit v1.2.3 From 735532840d4b4c26972480a9b9282da3e0b130f5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 12 Feb 2017 16:53:22 +0000 Subject: log: follow renames. Now that we can rename formulae this makes this command more useful for viewing longer histories. --- Library/Homebrew/cmd/log.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/log.rb b/Library/Homebrew/cmd/log.rb index 81f972b02..22a3ee11d 100644 --- a/Library/Homebrew/cmd/log.rb +++ b/Library/Homebrew/cmd/log.rb @@ -26,7 +26,7 @@ module Homebrew EOS end args = ARGV.options_only - args += ["--", path] unless path.nil? + args += ["--follow", "--", path] unless path.nil? exec "git", "log", *args end end -- cgit v1.2.3 From 539120143bad6ffb9a8a7c3e2ab76c6bc951036e Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sun, 12 Feb 2017 09:22:26 -0800 Subject: bump-formula-pr: block duplicate pull-requests --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 68bf32d0b..ea2daf1c4 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -78,8 +78,43 @@ module Homebrew end end + def fetch_pull_requests(formula) + GitHub.issues_for_formula(formula.name, tap: formula.tap).select do |pr| + pr["html_url"].include?("/pull/") + end + rescue GitHub::RateLimitExceededError => e + opoo e.message + [] + end + + def check_for_duplicate_pull_requests(formula) + pull_requests = fetch_pull_requests(formula) + return unless pull_requests && !pull_requests.empty? + duplicates_message = <<-EOS.undent + These open pull requests may be duplicates: + #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")} + EOS + error_message = "Duplicate PRs should not be opened. Use --force to override this error." + if ARGV.force? && !ARGV.flag?("--quiet") + opoo duplicates_message + elsif !ARGV.force? && ARGV.flag?("--quiet") + odie error_message + elsif !ARGV.force? + odie <<-EOS.undent + #{duplicates_message.chomp} + #{error_message} + EOS + end + end + def bump_formula_pr formula = ARGV.formulae.first + + if formula + check_for_duplicate_pull_requests(formula) + checked_for_duplicates = true + end + new_url = ARGV.value("url") if new_url && !formula is_devel = ARGV.include?("--devel") @@ -101,6 +136,8 @@ module Homebrew end odie "No formula found!" unless formula + check_for_duplicate_pull_requests(formula) unless checked_for_duplicates + requested_spec, formula_spec = if ARGV.include?("--devel") devel_message = " (devel)" [:devel, formula.devel] -- cgit v1.2.3 From 1cbec60829b76cab10067ae0ee535a2eb94838c1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 21:37:46 +0100 Subject: Convert Utils::Bottles::Collector test to spec. --- Library/Homebrew/test/bottle_collector_test.rb | 39 ---------------------- .../Homebrew/test/utils/bottles/collector_spec.rb | 31 +++++++++++++++++ 2 files changed, 31 insertions(+), 39 deletions(-) delete mode 100644 Library/Homebrew/test/bottle_collector_test.rb create mode 100644 Library/Homebrew/test/utils/bottles/collector_spec.rb (limited to 'Library') diff --git a/Library/Homebrew/test/bottle_collector_test.rb b/Library/Homebrew/test/bottle_collector_test.rb deleted file mode 100644 index 5879da92c..000000000 --- a/Library/Homebrew/test/bottle_collector_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -require "testing_env" -require "utils/bottles" - -class BottleCollectorTests < Homebrew::TestCase - def setup - super - @collector = Utils::Bottles::Collector.new - end - - def checksum_for(tag) - @collector.fetch_checksum_for(tag) - end - - def test_collector_returns_passed_tags - @collector[:lion] = "foo" - @collector[:mountain_lion] = "bar" - assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion) - end - - def test_collector_returns_when_empty - assert_nil checksum_for(:foo) - end - - def test_collector_returns_nil_for_no_match - @collector[:lion] = "foo" - assert_nil checksum_for(:foo) - end - - def test_collector_returns_nil_for_no_match_when_later_tag_present - @collector[:lion_or_later] = "foo" - assert_nil checksum_for(:foo) - end - - def test_collector_prefers_exact_matches - @collector[:lion_or_later] = "foo" - @collector[:mountain_lion] = "bar" - assert_equal ["bar", :mountain_lion], checksum_for(:mountain_lion) - end -end diff --git a/Library/Homebrew/test/utils/bottles/collector_spec.rb b/Library/Homebrew/test/utils/bottles/collector_spec.rb new file mode 100644 index 000000000..73757234e --- /dev/null +++ b/Library/Homebrew/test/utils/bottles/collector_spec.rb @@ -0,0 +1,31 @@ +require "utils/bottles" + +describe Utils::Bottles::Collector do + describe "#fetch_checksum_for" do + it "returns passed tags" do + subject[:lion] = "foo" + subject[:mountain_lion] = "bar" + expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion]) + end + + it "returns nil if empty" do + expect(subject.fetch_checksum_for(:foo)).to be nil + end + + it "returns nil when there is no match" do + subject[:lion] = "foo" + expect(subject.fetch_checksum_for(:foo)).to be nil + end + + it "returns nil when there is no match and later tag is present" do + subject[:lion_or_later] = "foo" + expect(subject.fetch_checksum_for(:foo)).to be nil + end + + it "prefers exact matches" do + subject[:lion_or_later] = "foo" + subject[:mountain_lion] = "bar" + expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion]) + end + end +end -- cgit v1.2.3 From 6799081f8a156fbb07246cab936717fc00826857 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 21:46:15 +0100 Subject: Convert Emoji test to spec. --- Library/Homebrew/test/emoji_spec.rb | 16 ++++++++++++++++ Library/Homebrew/test/emoji_test.rb | 11 ----------- 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 Library/Homebrew/test/emoji_spec.rb delete mode 100644 Library/Homebrew/test/emoji_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/emoji_spec.rb b/Library/Homebrew/test/emoji_spec.rb new file mode 100644 index 000000000..35d077ebe --- /dev/null +++ b/Library/Homebrew/test/emoji_spec.rb @@ -0,0 +1,16 @@ +require "emoji" + +describe Emoji do + describe "#install_badge" do + subject { described_class.install_badge } + + it "returns 🍺 by default" do + expect(subject).to eq "🍺" + end + + it "returns the contents of HOMEBREW_INSTALL_BADGE if set" do + ENV["HOMEBREW_INSTALL_BADGE"] = "foo" + expect(subject).to eq "foo" + end + end +end diff --git a/Library/Homebrew/test/emoji_test.rb b/Library/Homebrew/test/emoji_test.rb deleted file mode 100644 index ea68db8f6..000000000 --- a/Library/Homebrew/test/emoji_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "testing_env" -require "emoji" - -class EmojiTest < Homebrew::TestCase - def test_install_badge - assert_equal "🍺", Emoji.install_badge - - ENV["HOMEBREW_INSTALL_BADGE"] = "foo" - assert_equal "foo", Emoji.install_badge - end -end -- cgit v1.2.3 From f85d3d1f7ff891552c3bd54f8010cd9c401e8cd4 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 17:26:34 +0100 Subject: Convert Requirement test to spec. --- Library/Homebrew/.rubocop.yml | 2 +- Library/Homebrew/test/requirement_spec.rb | 288 ++++++++++++++++++++++++++++++ Library/Homebrew/test/requirement_test.rb | 152 ---------------- 3 files changed, 289 insertions(+), 153 deletions(-) create mode 100644 Library/Homebrew/test/requirement_spec.rb delete mode 100644 Library/Homebrew/test/requirement_test.rb (limited to 'Library') diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index a85f0dcab..938bf21b7 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: Style/BlockDelimiters: Exclude: - '**/cask/spec/**/*' - - '**/cask/test/**/*' + - '**/*_spec.rb' # so many of these in formulae but none in here Lint/AmbiguousRegexpLiteral: diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb new file mode 100644 index 000000000..110a7ac4f --- /dev/null +++ b/Library/Homebrew/test/requirement_spec.rb @@ -0,0 +1,288 @@ +require "extend/ENV" +require "requirement" + +RSpec::Matchers.alias_matcher :have_a_default_formula, :be_a_default_formula +RSpec::Matchers.alias_matcher :be_a_build_requirement, :be_a_build + +describe Requirement do + subject { klass.new } + + let(:klass) { Class.new(described_class) } + + describe "#tags" do + subject { described_class.new(tags) } + + context "single tag" do + let(:tags) { ["bar"] } + + its(:tags) { are_expected.to eq(tags) } + end + + context "multiple tags" do + let(:tags) { ["bar", "baz"] } + + its(:tags) { are_expected.to eq(tags) } + end + + context "symbol tags" do + let(:tags) { [:build] } + + its(:tags) { are_expected.to eq(tags) } + end + + context "symbol and string tags" do + let(:tags) { [:build, "bar"] } + + its(:tags) { are_expected.to eq(tags) } + end + end + + describe "#fatal?" do + context "#fatal true is specified" do + let(:klass) do + Class.new(described_class) do + fatal true + end + end + + it { is_expected.to be_fatal } + end + + context "#fatal is ommitted" do + it { is_expected.not_to be_fatal } + end + end + + describe "#satisfied?" do + context "#satisfy with block and build_env returns true" do + let(:klass) do + Class.new(described_class) do + satisfy(build_env: false) do + true + end + end + end + + it { is_expected.to be_satisfied } + end + + context "#satisfy with block and build_env returns false" do + let(:klass) do + Class.new(described_class) do + satisfy(build_env: false) do + false + end + end + end + + it { is_expected.not_to be_satisfied } + end + + context "#satisfy returns true" do + let(:klass) do + Class.new(described_class) do + satisfy true + end + end + + it { is_expected.to be_satisfied } + end + + context "#satisfy returns false" do + let(:klass) do + Class.new(described_class) do + satisfy false + end + end + + it { is_expected.not_to be_satisfied } + end + + context "#satisfy with block returning true and without :build_env" do + let(:klass) do + Class.new(described_class) do + satisfy do + true + end + end + end + + it "sets up build environment" do + expect(ENV).to receive(:with_build_environment).and_call_original + subject.satisfied? + end + end + + context "#satisfy with block returning true and :build_env set to false" do + let(:klass) do + Class.new(described_class) do + satisfy(build_env: false) do + true + end + end + end + + it "skips setting up build environment" do + expect(ENV).not_to receive(:with_build_environment) + subject.satisfied? + end + end + + context "#satisfy with block returning path and without :build_env" do + let(:klass) do + Class.new(described_class) do + satisfy do + Pathname.new("/foo/bar/baz") + end + end + end + + it "infers path from #satisfy result" do + expect(ENV).to receive(:append_path).with("PATH", Pathname.new("/foo/bar")) + subject.satisfied? + subject.modify_build_environment + end + end + end + + describe "#build?" do + context "#build true is specified" do + let(:klass) do + Class.new(described_class) do + build true + end + end + + it { is_expected.to be_a_build_requirement } + end + + context "#build ommitted" do + it { is_expected.not_to be_a_build_requirement } + end + end + + describe "#name and #option_names" do + let(:const) { :FooRequirement } + let(:klass) { self.class.const_get(const) } + + before(:each) do + self.class.const_set(const, Class.new(described_class)) + end + + after(:each) do + self.class.send(:remove_const, const) + end + + its(:name) { is_expected.to eq("foo") } + its(:option_names) { are_expected.to eq(["foo"]) } + end + + describe "#default_formula?" do + context "#default_formula specified" do + let(:klass) do + Class.new(described_class) do + default_formula "foo" + end + end + + it { is_expected.to have_a_default_formula } + end + + context "#default_formula ommitted" do + it { is_expected.not_to have_a_default_formula } + end + end + + describe "#to_dependency" do + let(:klass) do + Class.new(described_class) do + default_formula "foo" + end + end + + it "returns a Dependency for its default Formula" do + expect(subject.to_dependency).to eq(Dependency.new("foo")) + end + + context "#modify_build_environment" do + context "with error" do + let(:klass) do + Class.new(described_class) do + class ModifyBuildEnvironmentError < StandardError; end + + default_formula "foo" + + satisfy do + true + end + + env do + raise ModifyBuildEnvironmentError + end + end + end + + it "raises an error" do + expect { + subject.to_dependency.modify_build_environment + }.to raise_error(klass.const_get(:ModifyBuildEnvironmentError)) + end + end + end + end + + describe "#modify_build_environment" do + context "without env proc" do + let(:klass) { Class.new(described_class) } + + it "returns nil" do + expect(subject.modify_build_environment).to be nil + end + end + end + + describe "#eql? and #==" do + subject { described_class.new } + + it "returns true if the names and tags are equal" do + other = described_class.new + + expect(subject).to eql(other) + expect(subject).to eq(other) + end + + it "returns false if names differ" do + other = described_class.new + allow(other).to receive(:name).and_return("foo") + expect(subject).not_to eql(other) + expect(subject).not_to eq(other) + end + + it "returns false if tags differ" do + other = described_class.new([:optional]) + + expect(subject).not_to eql(other) + expect(subject).not_to eq(other) + end + end + + describe "#hash" do + subject { described_class.new } + + it "is equal if names and tags are equal" do + other = described_class.new + expect(subject.hash).to eq(other.hash) + end + + it "differs if names differ" do + other = described_class.new + allow(other).to receive(:name).and_return("foo") + expect(subject.hash).not_to eq(other.hash) + end + + it "differs if tags differ" do + other = described_class.new([:optional]) + expect(subject.hash).not_to eq(other.hash) + end + end +end diff --git a/Library/Homebrew/test/requirement_test.rb b/Library/Homebrew/test/requirement_test.rb deleted file mode 100644 index 580d42bfa..000000000 --- a/Library/Homebrew/test/requirement_test.rb +++ /dev/null @@ -1,152 +0,0 @@ -require "testing_env" -require "requirement" - -class RequirementTests < Homebrew::TestCase - class TestRequirement < Requirement; end - - def test_accepts_single_tag - dep = Requirement.new(%w[bar]) - assert_equal %w[bar], dep.tags - end - - def test_accepts_multiple_tags - dep = Requirement.new(%w[bar baz]) - assert_equal %w[bar baz].sort, dep.tags.sort - end - - def test_option_names - dep = TestRequirement.new - assert_equal %w[test], dep.option_names - end - - def test_preserves_symbol_tags - dep = Requirement.new([:build]) - assert_equal [:build], dep.tags - end - - def test_accepts_symbol_and_string_tags - dep = Requirement.new([:build, "bar"]) - assert_equal [:build, "bar"], dep.tags - end - - def test_dsl_fatal - req = Class.new(Requirement) { fatal true }.new - assert_predicate req, :fatal? - end - - def test_satisfy_true - req = Class.new(Requirement) do - satisfy(build_env: false) { true } - end.new - assert_predicate req, :satisfied? - end - - def test_satisfy_false - req = Class.new(Requirement) do - satisfy(build_env: false) { false } - end.new - refute_predicate req, :satisfied? - end - - def test_satisfy_with_boolean - req = Class.new(Requirement) do - satisfy true - end.new - assert_predicate req, :satisfied? - end - - def test_satisfy_sets_up_build_env_by_default - req = Class.new(Requirement) do - satisfy { true } - end.new - - ENV.expects(:with_build_environment).yields.returns(true) - - assert_predicate req, :satisfied? - end - - def test_satisfy_build_env_can_be_disabled - req = Class.new(Requirement) do - satisfy(build_env: false) { true } - end.new - - ENV.expects(:with_build_environment).never - - assert_predicate req, :satisfied? - end - - def test_infers_path_from_satisfy_result - which_path = Pathname.new("/foo/bar/baz") - req = Class.new(Requirement) do - satisfy { which_path } - end.new - - ENV.expects(:with_build_environment).yields.returns(which_path) - ENV.expects(:append_path).with("PATH", which_path.parent) - - req.satisfied? - req.modify_build_environment - end - - def test_dsl_build - req = Class.new(Requirement) { build true }.new - assert_predicate req, :build? - end - - def test_infer_name_from_class - const = :FooRequirement - klass = self.class - - klass.const_set(const, Class.new(Requirement)) - - begin - assert_equal "foo", klass.const_get(const).new.name - ensure - klass.send(:remove_const, const) - end - end - - def test_dsl_default_formula - req = Class.new(Requirement) { default_formula "foo" }.new - assert_predicate req, :default_formula? - end - - def test_to_dependency - req = Class.new(Requirement) { default_formula "foo" }.new - assert_equal Dependency.new("foo"), req.to_dependency - end - - def test_to_dependency_calls_requirement_modify_build_environment - error = Class.new(StandardError) - - req = Class.new(Requirement) do - default_formula "foo" - satisfy { true } - env { raise error } - end.new - - assert_raises(error) do - req.to_dependency.modify_build_environment - end - end - - def test_modify_build_environment_without_env_proc - assert_nil Class.new(Requirement).new.modify_build_environment - end - - def test_eql - a = Requirement.new - b = Requirement.new - assert_equal a, b - assert_eql a, b - assert_equal a.hash, b.hash - end - - def test_not_eql - a = Requirement.new([:optional]) - b = Requirement.new - refute_equal a, b - refute_eql a, b - refute_equal a.hash, b.hash - end -end -- cgit v1.2.3 From f48857d24657c2cf9c8d01c781ba270cff52c8a0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 3 Feb 2017 11:54:38 +0100 Subject: Use constants for RuboCop version. --- Library/Homebrew/cask/lib/hbc/cli/style.rb | 4 +--- Library/Homebrew/cmd/style.rb | 2 +- Library/Homebrew/config.rb | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb index cdcc135b8..d3e44382d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/style.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb @@ -23,12 +23,10 @@ module Hbc $CHILD_STATUS.success? end - RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze - def install_rubocop Utils.capture_stderr do begin - Homebrew.install_gem_setup_path! "rubocop-cask", RUBOCOP_CASK_VERSION, "rubocop" + Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop" rescue SystemExit raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "") end diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 586c6da6b..3d12561c1 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -47,7 +47,7 @@ module Homebrew def check_style_impl(files, output_type, options = {}) fix = options[:fix] - Homebrew.install_gem_setup_path! "rubocop", "0.47.1" + Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION args = %w[ --force-exclusion diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 38d7c8043..9831b0af8 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -48,3 +48,7 @@ end # Load path used by standalone scripts to access the Homebrew code base HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH + +# RuboCop version used for `brew style` and `brew cask style` +HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes -- cgit v1.2.3 From e70d28cba1b42c555f025b7beb13f67d2df5a067 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 3 Feb 2017 14:05:07 +0100 Subject: Add test to check if `rubocop-cask` version is is outdated. --- Library/Homebrew/cask/spec/cask/cli/style_spec.rb | 16 ++++++++++++++++ Library/Homebrew/config.rb | 6 ++---- Library/Homebrew/constants.rb | 3 +++ Library/Homebrew/test/support/lib/config.rb | 2 ++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Library/Homebrew/constants.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/style_spec.rb b/Library/Homebrew/cask/spec/cask/cli/style_spec.rb index b0d34576a..106bfbb44 100644 --- a/Library/Homebrew/cask/spec/cask/cli/style_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/style_spec.rb @@ -1,4 +1,6 @@ require "English" +require "open3" +require "rubygems" describe Hbc::CLI::Style do let(:args) { [] } @@ -77,6 +79,20 @@ describe Hbc::CLI::Style do expect { subject }.to raise_error(Hbc::CaskError) end end + + context "version" do + it "matches `HOMEBREW_RUBOCOP_VERSION`" do + stdout, status = Open3.capture2("gem", "dependency", "rubocop-cask", "--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote") + + expect(status).to be_a_success + + requirement = Gem::Requirement.new(stdout.scan(/rubocop --version '(.*)'/).flatten.first) + version = Gem::Version.new(HOMEBREW_RUBOCOP_VERSION) + + expect(requirement).not_to be_none + expect(requirement).to be_satisfied_by(version) + end + end end describe "#cask_paths" do diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 9831b0af8..30b7bc6c9 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end +require "constants" + # Path to `bin/brew` main executable in HOMEBREW_PREFIX HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) @@ -48,7 +50,3 @@ end # Load path used by standalone scripts to access the Homebrew code base HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH - -# RuboCop version used for `brew style` and `brew cask style` -HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze -HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes diff --git a/Library/Homebrew/constants.rb b/Library/Homebrew/constants.rb new file mode 100644 index 000000000..033a24dd0 --- /dev/null +++ b/Library/Homebrew/constants.rb @@ -0,0 +1,3 @@ +# RuboCop version used for `brew style` and `brew cask style` +HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb index fb5c210fe..3a0a76722 100644 --- a/Library/Homebrew/test/support/lib/config.rb +++ b/Library/Homebrew/test/support/lib/config.rb @@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end +require "constants" + require "tmpdir" require "pathname" -- cgit v1.2.3 From fd7616b8939e87423ab1785a0c0f17a44c92e571 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 23:07:06 +0100 Subject: Update `rubocop-cask` to 0.11.0. --- Library/Homebrew/constants.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/constants.rb b/Library/Homebrew/constants.rb index 033a24dd0..660cad7a3 100644 --- a/Library/Homebrew/constants.rb +++ b/Library/Homebrew/constants.rb @@ -1,3 +1,3 @@ # RuboCop version used for `brew style` and `brew cask style` HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze -HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze # has to be updated when RuboCop version changes +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.11.0".freeze # has to be updated when RuboCop version changes -- cgit v1.2.3 From 588f98cf825be855782ec00272f8d7e691d37c69 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 12 Feb 2017 14:47:05 -0800 Subject: formula:formula_cmd_test --- Library/Homebrew/test/formula_cmd_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Library/Homebrew/test/formula_cmd_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/formula_cmd_test.rb b/Library/Homebrew/test/formula_cmd_test.rb new file mode 100644 index 000000000..abbe42d98 --- /dev/null +++ b/Library/Homebrew/test/formula_cmd_test.rb @@ -0,0 +1,8 @@ +require "testing_env" + +class IntegrationCommandTestFormula < IntegrationCommandTestCase + def test_formula + formula_file = setup_test_formula "testball" + assert_equal formula_file.to_s, cmd("formula", "testball") + end +end -- cgit v1.2.3 From a09169f248de707bf8121acfb6c5d5c2b92c58de Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 13 Feb 2017 15:49:33 +0100 Subject: audit: enforce https for *.sourceforge.io urls --- Library/Homebrew/dev-cmd/audit.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 0522c7878..3447633eb 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -584,7 +584,9 @@ class FormulaAuditor # People will run into mixed content sometimes, but we should enforce and then add # exemptions as they are discovered. Treat mixed content on homepages as a bug. # Justify each exemptions with a code comment so we can keep track here. - if homepage =~ %r{^http://[^/]*github\.io/} + case homepage + when %r{^http://[^/]*github\.io/}, + %r{^http://[^/]*\.sourceforge\.io/} problem "Please use https:// for #{homepage}" end -- cgit v1.2.3 From 64448834a68ee1e183e5c2bf9504dadfa9431dc1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 13 Feb 2017 16:20:34 +0000 Subject: fix existing rule for github.io homepages --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 3447633eb..6aeb18749 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -585,7 +585,7 @@ class FormulaAuditor # exemptions as they are discovered. Treat mixed content on homepages as a bug. # Justify each exemptions with a code comment so we can keep track here. case homepage - when %r{^http://[^/]*github\.io/}, + when %r{^http://[^/]*\.github\.io/}, %r{^http://[^/]*\.sourceforge\.io/} problem "Please use https:// for #{homepage}" end -- cgit v1.2.3 From 2f919089ef381758f4db236dff4c4e6410259a7e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 14 Feb 2017 16:52:21 +0100 Subject: Remove JSON test. --- Library/Homebrew/test/json_test.rb | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 Library/Homebrew/test/json_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/json_test.rb b/Library/Homebrew/test/json_test.rb deleted file mode 100644 index 7c4c3671d..000000000 --- a/Library/Homebrew/test/json_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "testing_env" -require "json" - -class JsonSmokeTest < Homebrew::TestCase - def test_encode - hash = { "foo" => ["bar", "baz"] } - json = '{"foo":["bar","baz"]}' - assert_equal json, JSON.generate(hash) - end - - def test_decode - hash = { "foo" => ["bar", "baz"], "qux" => 1 } - json = '{"foo":["bar","baz"],"qux":1}' - assert_equal hash, JSON.parse(json) - end - - def test_decode_failure - assert_raises(JSON::ParserError) { JSON.parse("nope") } - end -end -- cgit v1.2.3 From bf314fb08250cffa9bacb164b59b463f598da571 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 14 Feb 2017 18:46:48 +0000 Subject: add test --- Library/Homebrew/test/audit_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library') diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index b1ccb1e10..9165edef1 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -434,6 +434,7 @@ class FormulaAuditorTests < Homebrew::TestCase "sf1" => "http://foo.sourceforge.net/", "sf2" => "http://foo.sourceforge.net", "sf3" => "http://foo.sf.net/", + "sf4" => "http://foo.sourceforge.io/", "waldo" => "http://www.gnu.org/waldo", } -- cgit v1.2.3 From 3bc0c6bd1a74fb5a77fdaca45543eca752eee64f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 14 Feb 2017 20:01:45 +0100 Subject: Convert Checksum test to spec. --- Library/Homebrew/test/checksum_spec.rb | 19 +++++++++++++++++++ Library/Homebrew/test/checksum_test.rb | 22 ---------------------- 2 files changed, 19 insertions(+), 22 deletions(-) create mode 100644 Library/Homebrew/test/checksum_spec.rb delete mode 100644 Library/Homebrew/test/checksum_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/checksum_spec.rb b/Library/Homebrew/test/checksum_spec.rb new file mode 100644 index 000000000..acab348b7 --- /dev/null +++ b/Library/Homebrew/test/checksum_spec.rb @@ -0,0 +1,19 @@ +require "checksum" + +describe Checksum do + describe "#empty?" do + subject { described_class.new(:sha256, "") } + it { is_expected.to be_empty } + end + + describe "#==" do + subject { described_class.new(:sha256, TEST_SHA256) } + let(:other) { described_class.new(:sha256, TEST_SHA256) } + let(:other_reversed) { described_class.new(:sha256, TEST_SHA256.reverse) } + let(:other_sha1) { described_class.new(:sha1, TEST_SHA1) } + + it { is_expected.to eq(other) } + it { is_expected.not_to eq(other_reversed) } + it { is_expected.not_to eq(other_sha1) } + end +end diff --git a/Library/Homebrew/test/checksum_test.rb b/Library/Homebrew/test/checksum_test.rb deleted file mode 100644 index 5505f6824..000000000 --- a/Library/Homebrew/test/checksum_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require "testing_env" -require "checksum" - -class ChecksumTests < Homebrew::TestCase - def test_empty? - assert_empty Checksum.new(:sha256, "") - end - - def test_equality - a = Checksum.new(:sha256, TEST_SHA256) - b = Checksum.new(:sha256, TEST_SHA256) - assert_equal a, b - - a = Checksum.new(:sha256, TEST_SHA256) - b = Checksum.new(:sha256, TEST_SHA256.reverse) - refute_equal a, b - - a = Checksum.new(:sha1, TEST_SHA1) - b = Checksum.new(:sha256, TEST_SHA256) - refute_equal a, b - end -end -- cgit v1.2.3 From 8d7d41dc852e9a6bd51aa36b4142a372681bae39 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 14 Feb 2017 19:26:29 +0100 Subject: Convert Hardware test to spec. --- Library/Homebrew/test/hardware_spec.rb | 40 ++++++++++++++++++++++++++++++++++ Library/Homebrew/test/hardware_test.rb | 15 ------------- 2 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 Library/Homebrew/test/hardware_spec.rb delete mode 100644 Library/Homebrew/test/hardware_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/hardware_spec.rb b/Library/Homebrew/test/hardware_spec.rb new file mode 100644 index 000000000..c5f8daf4e --- /dev/null +++ b/Library/Homebrew/test/hardware_spec.rb @@ -0,0 +1,40 @@ +require "hardware" + +module Hardware + describe CPU do + describe "::type" do + it "returns the current CPU's type as a symbol, or :dunno if it cannot be detected" do + expect( + [ + :intel, + :ppc, + :dunno, + ], + ).to include(described_class.type) + end + end + + describe "::family" do + it "returns the current CPU's family name as a symbol, or :dunno if it cannot be detected" do + skip "Needs an Intel CPU." unless described_class.intel? + + expect( + [ + :core, + :core2, + :penryn, + :nehalem, + :arrandale, + :sandybridge, + :ivybridge, + :haswell, + :broadwell, + :skylake, + :kabylake, + :dunno, + ], + ).to include(described_class.family) + end + end + end +end diff --git a/Library/Homebrew/test/hardware_test.rb b/Library/Homebrew/test/hardware_test.rb deleted file mode 100644 index 69f881a60..000000000 --- a/Library/Homebrew/test/hardware_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "testing_env" -require "hardware" - -class HardwareTests < Homebrew::TestCase - def test_hardware_cpu_type - assert_includes [:intel, :ppc, :dunno], Hardware::CPU.type - end - - if Hardware::CPU.intel? - def test_hardware_intel_family - families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :kabylake, :dunno] - assert_includes families, Hardware::CPU.family - end - end -end -- cgit v1.2.3 From a3e0b188cf3bacdecff4bae188ea123af0848cef Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 15 Feb 2017 15:19:06 +0100 Subject: Convert Patch test to spec. --- Library/Homebrew/test/patch_spec.rb | 165 ++++++++++++++++++++++++++++++++++++ Library/Homebrew/test/patch_test.rb | 155 --------------------------------- 2 files changed, 165 insertions(+), 155 deletions(-) create mode 100644 Library/Homebrew/test/patch_spec.rb delete mode 100644 Library/Homebrew/test/patch_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/patch_spec.rb b/Library/Homebrew/test/patch_spec.rb new file mode 100644 index 000000000..22c103662 --- /dev/null +++ b/Library/Homebrew/test/patch_spec.rb @@ -0,0 +1,165 @@ +require "patch" + +describe Patch do + describe "#create" do + context "simple patch" do + subject { described_class.create(:p2, nil) } + it { is_expected.to be_kind_of ExternalPatch } + it { is_expected.to be_external } + its(:strip) { is_expected.to eq(:p2) } + end + + context "string patch" do + subject { described_class.create(:p0, "foo") } + it { is_expected.to be_kind_of StringPatch } + its(:strip) { is_expected.to eq(:p0) } + end + + context "string patch without strip" do + subject { described_class.create("foo", nil) } + it { is_expected.to be_kind_of StringPatch } + its(:strip) { is_expected.to eq(:p1) } + end + + context "data patch" do + subject { described_class.create(:p0, :DATA) } + it { is_expected.to be_kind_of DATAPatch } + its(:strip) { is_expected.to eq(:p0) } + end + + context "data patch without strip" do + subject { described_class.create(:DATA, nil) } + it { is_expected.to be_kind_of DATAPatch } + its(:strip) { is_expected.to eq(:p1) } + end + + it "raises an error for unknown values" do + expect { + described_class.create(Object.new) + }.to raise_error(ArgumentError) + + expect { + described_class.create(Object.new, Object.new) + }.to raise_error(ArgumentError) + end + end + + describe "#patch_files" do + subject { described_class.create(:p2, nil) } + + context "empty patch" do + its(:resource) { is_expected.to be_kind_of Resource::Patch } + its(:patch_files) { is_expected.to eq(subject.resource.patch_files) } + its(:patch_files) { is_expected.to eq([]) } + end + + it "returns applied patch files" do + subject.resource.apply("patch1.diff") + expect(subject.patch_files).to eq(["patch1.diff"]) + + subject.resource.apply("patch2.diff", "patch3.diff") + expect(subject.patch_files).to eq(["patch1.diff", "patch2.diff", "patch3.diff"]) + + subject.resource.apply(["patch4.diff", "patch5.diff"]) + expect(subject.patch_files.count).to eq(5) + + subject.resource.apply("patch4.diff", ["patch5.diff", "patch6.diff"], "patch7.diff") + expect(subject.patch_files.count).to eq(7) + end + end + + describe "#normalize_legacy_patches" do + it "can create a patch from a single string" do + patches = described_class.normalize_legacy_patches("http://example.com/patch.diff") + expect(patches.length).to eq(1) + expect(patches.first.strip).to eq(:p1) + end + + it "can create patches from an array" do + patches = described_class.normalize_legacy_patches( + %w[http://example.com/patch1.diff http://example.com/patch2.diff], + ) + + expect(patches.length).to eq(2) + expect(patches[0].strip).to eq(:p1) + expect(patches[1].strip).to eq(:p1) + end + + it "can create patches from a :p0 hash" do + patches = Patch.normalize_legacy_patches( + p0: "http://example.com/patch.diff", + ) + + expect(patches.length).to eq(1) + expect(patches.first.strip).to eq(:p0) + end + + it "can create patches from a :p1 hash" do + patches = Patch.normalize_legacy_patches( + p1: "http://example.com/patch.diff", + ) + + expect(patches.length).to eq(1) + expect(patches.first.strip).to eq(:p1) + end + + it "can create patches from a mixed hash" do + patches = Patch.normalize_legacy_patches( + p1: "http://example.com/patch1.diff", + p0: "http://example.com/patch0.diff", + ) + + expect(patches.length).to eq(2) + expect(patches.count { |p| p.strip == :p0 }).to eq(1) + expect(patches.count { |p| p.strip == :p1 }).to eq(1) + end + + it "can create patches from a mixed hash with array" do + patches = Patch.normalize_legacy_patches( + p1: [ + "http://example.com/patch10.diff", + "http://example.com/patch11.diff", + ], + p0: [ + "http://example.com/patch00.diff", + "http://example.com/patch01.diff", + ], + ) + + expect(patches.length).to eq(4) + expect(patches.count { |p| p.strip == :p0 }).to eq(2) + expect(patches.count { |p| p.strip == :p1 }).to eq(2) + end + + it "returns an empty array if given nil" do + expect(Patch.normalize_legacy_patches(nil)).to be_empty + end + end +end + +describe EmbeddedPatch do + describe "#new" do + subject { described_class.new(:p1) } + its(:inspect) { is_expected.to eq("#") } + end +end + +describe ExternalPatch do + subject { described_class.new(:p1) { url "file:///my.patch" } } + + describe "#url" do + its(:url) { is_expected.to eq("file:///my.patch") } + end + + describe "#inspect" do + its(:inspect) { is_expected.to eq('#') } + end + + describe "#cached_download" do + before(:each) do + allow(subject.resource).to receive(:cached_download).and_return("/tmp/foo.tar.gz") + end + + its(:cached_download) { is_expected.to eq("/tmp/foo.tar.gz") } + end +end diff --git a/Library/Homebrew/test/patch_test.rb b/Library/Homebrew/test/patch_test.rb deleted file mode 100644 index 3055eaf48..000000000 --- a/Library/Homebrew/test/patch_test.rb +++ /dev/null @@ -1,155 +0,0 @@ -require "testing_env" -require "patch" - -class PatchTests < Homebrew::TestCase - def test_create_simple - patch = Patch.create(:p2, nil) - assert_kind_of ExternalPatch, patch - assert_predicate patch, :external? - assert_equal :p2, patch.strip - end - - def test_create_string - patch = Patch.create(:p0, "foo") - assert_kind_of StringPatch, patch - assert_equal :p0, patch.strip - end - - def test_create_string_without_strip - patch = Patch.create("foo", nil) - assert_kind_of StringPatch, patch - assert_equal :p1, patch.strip - end - - def test_create_data - patch = Patch.create(:p0, :DATA) - assert_kind_of DATAPatch, patch - assert_equal :p0, patch.strip - end - - def test_create_data_without_strip - patch = Patch.create(:DATA, nil) - assert_kind_of DATAPatch, patch - assert_equal :p1, patch.strip - end - - def test_raises_for_unknown_values - assert_raises(ArgumentError) { Patch.create(Object.new) } - assert_raises(ArgumentError) { Patch.create(Object.new, Object.new) } - end -end - -class LegacyPatchTests < Homebrew::TestCase - def test_patch_single_string - patches = Patch.normalize_legacy_patches("http://example.com/patch.diff") - assert_equal 1, patches.length - assert_equal :p1, patches.first.strip - end - - def test_patch_array - patches = Patch.normalize_legacy_patches( - %w[http://example.com/patch1.diff http://example.com/patch2.diff], - ) - - assert_equal 2, patches.length - assert_equal :p1, patches[0].strip - assert_equal :p1, patches[1].strip - end - - def test_p0_hash_to_string - patches = Patch.normalize_legacy_patches( - p0: "http://example.com/patch.diff", - ) - - assert_equal 1, patches.length - assert_equal :p0, patches.first.strip - end - - def test_p1_hash_to_string - patches = Patch.normalize_legacy_patches( - p1: "http://example.com/patch.diff", - ) - - assert_equal 1, patches.length - assert_equal :p1, patches.first.strip - end - - def test_mixed_hash_to_strings - patches = Patch.normalize_legacy_patches( - p1: "http://example.com/patch1.diff", - p0: "http://example.com/patch0.diff", - ) - assert_equal 2, patches.length - assert_equal 1, patches.count { |p| p.strip == :p0 } - assert_equal 1, patches.count { |p| p.strip == :p1 } - end - - def test_mixed_hash_to_arrays - patches = Patch.normalize_legacy_patches( - p1: ["http://example.com/patch10.diff", - "http://example.com/patch11.diff"], - p0: ["http://example.com/patch00.diff", - "http://example.com/patch01.diff"], - ) - - assert_equal 4, patches.length - assert_equal 2, patches.count { |p| p.strip == :p0 } - assert_equal 2, patches.count { |p| p.strip == :p1 } - end - - def test_nil - assert_empty Patch.normalize_legacy_patches(nil) - end -end - -class EmbeddedPatchTests < Homebrew::TestCase - def test_inspect - p = EmbeddedPatch.new :p1 - assert_equal "#", p.inspect - end -end - -class ExternalPatchTests < Homebrew::TestCase - def setup - super - @p = ExternalPatch.new(:p1) { url "file:///my.patch" } - end - - def test_url - assert_equal "file:///my.patch", @p.url - end - - def test_inspect - assert_equal '#', @p.inspect - end - - def test_cached_download - @p.resource.stubs(:cached_download).returns "/tmp/foo.tar.gz" - assert_equal "/tmp/foo.tar.gz", @p.cached_download - end -end - -class ApplyPatchTests < Homebrew::TestCase - def test_empty_patch_files - patch = Patch.create(:p2, nil) - resource = patch.resource - patch_files = patch.patch_files - assert_kind_of Resource::Patch, resource - assert_equal patch_files, resource.patch_files - assert_equal patch_files, [] - end - - def test_resource_patch_apply_method - patch = Patch.create(:p2, nil) - resource = patch.resource - patch_files = patch.patch_files - resource.apply("patch1.diff") - assert_equal patch_files, ["patch1.diff"] - resource.apply("patch2.diff", "patch3.diff") - assert_equal patch_files, ["patch1.diff", "patch2.diff", "patch3.diff"] - resource.apply(["patch4.diff", "patch5.diff"]) - assert_equal patch_files.count, 5 - resource.apply("patch4.diff", ["patch5.diff", "patch6.diff"], "patch7.diff") - assert_equal patch_files.count, 7 - end -end -- cgit v1.2.3 From b2dd6bc9b0c765104898d128c455b2f107498399 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 15 Feb 2017 14:41:06 +0000 Subject: audit: fix brew style warning. --- Library/Homebrew/dev-cmd/audit.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index b4906cb80..5e674cf12 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1495,9 +1495,8 @@ class ResourceAuditor content_length_match = details[:content_length] && details[:content_length] == secure_details[:content_length] file_match = details[:file_hash] == secure_details[:file_hash] - if etag_match || content_length_match || file_match - problem "The URL #{url} could use HTTPS rather than HTTP" - end + return if !etag_match && !content_length_match && !file_match + problem "The URL #{url} could use HTTPS rather than HTTP" end def problem(text) -- cgit v1.2.3 From 279831fc0e3241eda17b6007aef02299b3c82c9e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 14 Feb 2017 17:45:20 +0100 Subject: Convert Exceptions test to spec. --- Library/Homebrew/test/exceptions_spec.rb | 188 +++++++++++++++++++++++++++++++ Library/Homebrew/test/exceptions_test.rb | 147 ------------------------ 2 files changed, 188 insertions(+), 147 deletions(-) create mode 100644 Library/Homebrew/test/exceptions_spec.rb delete mode 100644 Library/Homebrew/test/exceptions_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/exceptions_spec.rb b/Library/Homebrew/test/exceptions_spec.rb new file mode 100644 index 000000000..33547ea32 --- /dev/null +++ b/Library/Homebrew/test/exceptions_spec.rb @@ -0,0 +1,188 @@ +require "exceptions" + +describe MultipleVersionsInstalledError do + subject { described_class.new("foo") } + its(:to_s) { is_expected.to eq("foo has multiple installed versions") } +end + +describe NoSuchKegError do + subject { described_class.new("foo") } + its(:to_s) { is_expected.to eq("No such keg: #{HOMEBREW_CELLAR}/foo") } +end + +describe FormulaValidationError do + subject { described_class.new("foo", "sha257", "magic") } + its(:to_s) { + is_expected.to eq(%q(invalid attribute for formula 'foo': sha257 ("magic"))) + } +end + +describe FormulaUnavailableError do + subject { described_class.new("foo") } + + describe "#dependent_s" do + it "returns nil if there is no dependent" do + expect(subject.dependent_s).to be nil + end + + it "returns nil if it depended on by itself" do + subject.dependent = "foo" + expect(subject.dependent_s).to be nil + end + + it "returns a string if there is a dependent" do + subject.dependent = "foobar" + expect(subject.dependent_s).to eq("(dependency of foobar)") + end + end + + context "without a dependent" do + its(:to_s) { is_expected.to eq('No available formula with the name "foo" ') } + end + + context "with a dependent" do + before(:each) do + subject.dependent = "foobar" + end + + its(:to_s) { + is_expected.to eq('No available formula with the name "foo" (dependency of foobar)') + } + end +end + +describe TapFormulaUnavailableError do + subject { described_class.new(tap, "foo") } + let(:tap) { double(Tap, user: "u", repo: "r", to_s: "u/r", installed?: false) } + its(:to_s) { is_expected.to match(%r{Please tap it and then try again: brew tap u/r}) } +end + +describe FormulaClassUnavailableError do + subject { described_class.new("foo", "foo.rb", "Foo", list) } + let(:mod) do + Module.new do + class Bar < Requirement; end + class Baz < Formula; end + end + end + + context "no classes" do + let(:list) { [] } + its(:to_s) { + is_expected.to match(/Expected to find class Foo, but found no classes\./) + } + end + + context "class not derived from Formula" do + let(:list) { [mod.const_get(:Bar)] } + its(:to_s) { + is_expected.to match(/Expected to find class Foo, but only found: Bar \(not derived from Formula!\)\./) + } + end + + context "class derived from Formula" do + let(:list) { [mod.const_get(:Baz)] } + its(:to_s) { is_expected.to match(/Expected to find class Foo, but only found: Baz\./) } + end +end + +describe FormulaUnreadableError do + subject { described_class.new("foo", formula_error) } + let(:formula_error) { LoadError.new("bar") } + its(:to_s) { is_expected.to eq("foo: bar") } +end + +describe TapUnavailableError do + subject { described_class.new("foo") } + its(:to_s) { is_expected.to eq("No available tap foo.\n") } +end + +describe TapAlreadyTappedError do + subject { described_class.new("foo") } + its(:to_s) { is_expected.to eq("Tap foo already tapped.\n") } +end + +describe TapPinStatusError do + context "pinned" do + subject { described_class.new("foo", true) } + its(:to_s) { is_expected.to eq("foo is already pinned.") } + end + + context "unpinned" do + subject { described_class.new("foo", false) } + its(:to_s) { is_expected.to eq("foo is already unpinned.") } + end +end + +describe BuildError do + subject { described_class.new(formula, "badprg", %w[arg1 arg2], {}) } + let(:formula) { double(Formula, name: "foo") } + its(:to_s) { is_expected.to eq("Failed executing: badprg arg1 arg2") } +end + +describe OperationInProgressError do + subject { described_class.new("foo") } + its(:to_s) { is_expected.to match(/Operation already in progress for foo/) } +end + +describe FormulaInstallationAlreadyAttemptedError do + subject { described_class.new(formula) } + let(:formula) { double(Formula, full_name: "foo/bar") } + its(:to_s) { is_expected.to eq("Formula installation already attempted: foo/bar") } +end + +describe FormulaConflictError do + subject { described_class.new(formula, [conflict]) } + let(:formula) { double(Formula, full_name: "foo/qux") } + let(:conflict) { double(name: "bar", reason: "I decided to") } + its(:to_s) { is_expected.to match(/Please `brew unlink bar` before continuing\./) } +end + +describe CompilerSelectionError do + subject { described_class.new(formula) } + let(:formula) { double(Formula, full_name: "foo") } + its(:to_s) { is_expected.to match(/foo cannot be built with any available compilers\./) } +end + +describe CurlDownloadStrategyError do + context "file does not exist" do + subject { described_class.new("file:///tmp/foo") } + its(:to_s) { is_expected.to eq("File does not exist: /tmp/foo") } + end + + context "download failed" do + subject { described_class.new("http://brew.sh") } + its(:to_s) { is_expected.to eq("Download failed: http://brew.sh") } + end +end + +describe ErrorDuringExecution do + subject { described_class.new("badprg", %w[arg1 arg2]) } + its(:to_s) { is_expected.to eq("Failure while executing: badprg arg1 arg2") } +end + +describe ChecksumMismatchError do + subject { described_class.new("/file.tar.gz", hash1, hash2) } + let(:hash1) { double(hash_type: "sha256", to_s: "deadbeef") } + let(:hash2) { double(hash_type: "sha256", to_s: "deadcafe") } + its(:to_s) { is_expected.to match(/SHA256 mismatch/) } +end + +describe ResourceMissingError do + subject { described_class.new(formula, resource) } + let(:formula) { double(Formula, full_name: "bar") } + let(:resource) { double(inspect: "") } + its(:to_s) { is_expected.to eq("bar does not define resource ") } +end + +describe DuplicateResourceError do + subject { described_class.new(resource) } + let(:resource) { double(inspect: "") } + its(:to_s) { is_expected.to eq("Resource is defined more than once") } +end + +describe BottleVersionMismatchError do + subject { described_class.new("/foo.bottle.tar.gz", "1.0", formula, "1.1") } + let(:formula) { double(Formula, full_name: "foo") } + its(:to_s) { is_expected.to match(/Bottle version mismatch/) } +end diff --git a/Library/Homebrew/test/exceptions_test.rb b/Library/Homebrew/test/exceptions_test.rb deleted file mode 100644 index e9fedef04..000000000 --- a/Library/Homebrew/test/exceptions_test.rb +++ /dev/null @@ -1,147 +0,0 @@ -require "testing_env" -require "exceptions" - -class ExceptionsTest < Homebrew::TestCase - def test_multiple_versions_installed_error - assert_equal "foo has multiple installed versions", - MultipleVersionsInstalledError.new("foo").to_s - end - - def test_no_such_keg_error - assert_equal "No such keg: #{HOMEBREW_CELLAR}/foo", - NoSuchKegError.new("foo").to_s - end - - def test_formula_validation_error - assert_equal %q(invalid attribute for formula 'foo': sha257 ("magic")), - FormulaValidationError.new("foo", "sha257", "magic").to_s - end - - def test_formula_unavailable_error - e = FormulaUnavailableError.new "foo" - assert_nil e.dependent_s - - e.dependent = "foo" - assert_nil e.dependent_s - - e.dependent = "foobar" - assert_equal "(dependency of foobar)", e.dependent_s - - assert_equal "No available formula with the name \"foo\" (dependency of foobar)", - e.to_s - end - - def test_tap_formula_unavailable_error - t = stub(user: "u", repo: "r", to_s: "u/r", installed?: false) - assert_match "Please tap it and then try again: brew tap u/r", - TapFormulaUnavailableError.new(t, "foo").to_s - end - - def test_formula_class_unavailable_error - mod = Module.new - mod.module_eval <<-EOS.undent - class Bar < Requirement; end - class Baz < Formula; end - EOS - - assert_match "Expected to find class Foo, but found no classes.", - FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", []).to_s - - list = [mod.const_get(:Bar)] - assert_match "Expected to find class Foo, but only found: Bar (not derived from Formula!).", - FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", list).to_s - - list = [mod.const_get(:Baz)] - assert_match "Expected to find class Foo, but only found: Baz.", - FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", list).to_s - end - - def test_formula_unreadable_error - formula_error = LoadError.new("bar") - assert_equal "foo: bar", FormulaUnreadableError.new("foo", formula_error).to_s - end - - def test_tap_unavailable_error - assert_equal "No available tap foo.\n", TapUnavailableError.new("foo").to_s - end - - def test_tap_already_tapped_error - assert_equal "Tap foo already tapped.\n", - TapAlreadyTappedError.new("foo").to_s - end - - def test_pin_status_error - assert_equal "foo is already pinned.", - TapPinStatusError.new("foo", true).to_s - assert_equal "foo is already unpinned.", - TapPinStatusError.new("foo", false).to_s - end - - def test_build_error - f = stub(name: "foo") - assert_equal "Failed executing: badprg arg1 arg2", - BuildError.new(f, "badprg", %w[arg1 arg2], {}).to_s - end - - def test_operation_in_progress_error - assert_match "Operation already in progress for bar", - OperationInProgressError.new("bar").to_s - end - - def test_formula_installation_already_attempted_error - f = stub(full_name: "foo/bar") - assert_equal "Formula installation already attempted: foo/bar", - FormulaInstallationAlreadyAttemptedError.new(f).to_s - end - - def test_formula_conflict_error - f = stub(full_name: "foo/qux") - c = stub(name: "bar", reason: "I decided to") - assert_match "Please `brew unlink bar` before continuing.", - FormulaConflictError.new(f, [c]).to_s - end - - def test_compiler_selection_error - f = stub(full_name: "foo") - assert_match "foo cannot be built with any available compilers.", - CompilerSelectionError.new(f).to_s - end - - def test_curl_download_strategy_error - assert_equal "File does not exist: /tmp/foo", - CurlDownloadStrategyError.new("file:///tmp/foo").to_s - assert_equal "Download failed: http://brew.sh", - CurlDownloadStrategyError.new("http://brew.sh").to_s - end - - def test_error_during_execution - assert_equal "Failure while executing: badprg arg1 arg2", - ErrorDuringExecution.new("badprg", %w[arg1 arg2]).to_s - end - - def test_checksum_mismatch_error - h1 = stub(hash_type: "sha256", to_s: "deadbeef") - h2 = stub(hash_type: "sha256", to_s: "deadcafe") - assert_match "SHA256 mismatch", - ChecksumMismatchError.new("/file.tar.gz", h1, h2).to_s - end - - def test_resource_missing_error - f = stub(full_name: "bar") - r = stub(inspect: "") - assert_match "bar does not define resource ", - ResourceMissingError.new(f, r).to_s - end - - def test_duplicate_resource_error - r = stub(inspect: "") - assert_equal "Resource is defined more than once", - DuplicateResourceError.new(r).to_s - end - - def test_bottle_version_mismatch_error - f = stub(full_name: "foo") - assert_match "Bottle version mismatch", - BottleVersionMismatchError.new("/foo.bottle.tar.gz", "1.0", f, "1.1").to_s - end -end -- cgit v1.2.3 From b89c0f16dd5e5d75e6e72187bf2956ce456c8090 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 15 Feb 2017 15:38:43 +0100 Subject: Convert CxxStdlib test to spec. --- Library/Homebrew/test/cxxstdlib_spec.rb | 68 +++++++++++++++++++++++++++++++++ Library/Homebrew/test/stdlib_test.rb | 63 ------------------------------ 2 files changed, 68 insertions(+), 63 deletions(-) create mode 100644 Library/Homebrew/test/cxxstdlib_spec.rb delete mode 100644 Library/Homebrew/test/stdlib_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/cxxstdlib_spec.rb b/Library/Homebrew/test/cxxstdlib_spec.rb new file mode 100644 index 000000000..dd2e4e1c6 --- /dev/null +++ b/Library/Homebrew/test/cxxstdlib_spec.rb @@ -0,0 +1,68 @@ +require "formula" +require "cxxstdlib" + +describe CxxStdlib do + let(:clang) { CxxStdlib.create(:libstdcxx, :clang) } + let(:gcc) { CxxStdlib.create(:libstdcxx, :gcc) } + let(:gcc40) { CxxStdlib.create(:libstdcxx, :gcc_4_0) } + let(:gcc42) { CxxStdlib.create(:libstdcxx, :gcc_4_2) } + let(:gcc48) { CxxStdlib.create(:libstdcxx, "gcc-4.8") } + let(:gcc49) { CxxStdlib.create(:libstdcxx, "gcc-4.9") } + let(:lcxx) { CxxStdlib.create(:libcxx, :clang) } + let(:purec) { CxxStdlib.create(nil, :clang) } + + describe "#compatible_with?" do + specify "Apple libstdcxx intercompatibility" do + expect(clang).to be_compatible_with(gcc) + expect(clang).to be_compatible_with(gcc42) + end + + specify "compatibility with itself" do + expect(gcc).to be_compatible_with(gcc) + expect(gcc48).to be_compatible_with(gcc48) + expect(clang).to be_compatible_with(clang) + end + + specify "Apple/GNU libstdcxx incompatibility" do + expect(clang).not_to be_compatible_with(gcc48) + expect(gcc48).not_to be_compatible_with(clang) + end + + specify "GNU cross-version incompatibility" do + expect(gcc48).not_to be_compatible_with(gcc49) + expect(gcc49).not_to be_compatible_with(gcc48) + end + + specify "libstdcxx and libcxx incompatibility" do + expect(clang).not_to be_compatible_with(lcxx) + expect(lcxx).not_to be_compatible_with(clang) + end + + specify "compatibility for non-cxx software" do + expect(purec).to be_compatible_with(clang) + expect(clang).to be_compatible_with(purec) + expect(purec).to be_compatible_with(purec) + expect(purec).to be_compatible_with(gcc48) + expect(gcc48).to be_compatible_with(purec) + end + end + + describe "#apple_compiler?" do + it "returns true for Apple compilers" do + expect(clang).to be_an_apple_compiler + expect(gcc).to be_an_apple_compiler + expect(gcc42).to be_an_apple_compiler + end + + it "returns false for non-Apple compilers" do + expect(gcc48).not_to be_an_apple_compiler + end + end + + describe "#type_string" do + specify "formatting" do + expect(clang.type_string).to eq("libstdc++") + expect(lcxx.type_string).to eq("libc++") + end + end +end diff --git a/Library/Homebrew/test/stdlib_test.rb b/Library/Homebrew/test/stdlib_test.rb deleted file mode 100644 index f193ae71e..000000000 --- a/Library/Homebrew/test/stdlib_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -require "testing_env" -require "formula" -require "cxxstdlib" - -class CxxStdlibTests < Homebrew::TestCase - def setup - super - @clang = CxxStdlib.create(:libstdcxx, :clang) - @gcc = CxxStdlib.create(:libstdcxx, :gcc) - @gcc40 = CxxStdlib.create(:libstdcxx, :gcc_4_0) - @gcc42 = CxxStdlib.create(:libstdcxx, :gcc_4_2) - @gcc48 = CxxStdlib.create(:libstdcxx, "gcc-4.8") - @gcc49 = CxxStdlib.create(:libstdcxx, "gcc-4.9") - @lcxx = CxxStdlib.create(:libcxx, :clang) - @purec = CxxStdlib.create(nil, :clang) - end - - def test_apple_libstdcxx_intercompatibility - assert @clang.compatible_with?(@gcc) - assert @clang.compatible_with?(@gcc42) - end - - def test_compatibility_same_compilers_and_type - assert @gcc.compatible_with?(@gcc) - assert @gcc48.compatible_with?(@gcc48) - assert @clang.compatible_with?(@clang) - end - - def test_apple_gnu_libstdcxx_incompatibility - assert !@clang.compatible_with?(@gcc48) - assert !@gcc48.compatible_with?(@clang) - end - - def test_gnu_cross_version_incompatibility - assert !@gcc48.compatible_with?(@gcc49) - assert !@gcc49.compatible_with?(@gcc48) - end - - def test_libstdcxx_libcxx_incompatibility - assert !@clang.compatible_with?(@lcxx) - assert !@lcxx.compatible_with?(@clang) - end - - def test_apple_compiler_reporting - assert_predicate @clang, :apple_compiler? - assert_predicate @gcc, :apple_compiler? - assert_predicate @gcc42, :apple_compiler? - refute_predicate @gcc48, :apple_compiler? - end - - def test_type_string_formatting - assert_equal "libstdc++", @clang.type_string - assert_equal "libc++", @lcxx.type_string - end - - def test_compatibility_for_non_cxx_software - assert @purec.compatible_with?(@clang) - assert @clang.compatible_with?(@purec) - assert @purec.compatible_with?(@purec) - assert @purec.compatible_with?(@gcc48) - assert @gcc48.compatible_with?(@purec) - end -end -- cgit v1.2.3 From f581ad7f0b73e0a8d38868d2d4fa85bb7fb0c486 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 18:21:30 +0100 Subject: Convert BuildEnvironment test to spec. --- Library/Homebrew/test/build_environment_spec.rb | 66 +++++++++++++++++++++++++ Library/Homebrew/test/build_environment_test.rb | 46 ----------------- 2 files changed, 66 insertions(+), 46 deletions(-) create mode 100644 Library/Homebrew/test/build_environment_spec.rb delete mode 100644 Library/Homebrew/test/build_environment_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/build_environment_spec.rb b/Library/Homebrew/test/build_environment_spec.rb new file mode 100644 index 000000000..5a3cec452 --- /dev/null +++ b/Library/Homebrew/test/build_environment_spec.rb @@ -0,0 +1,66 @@ +require "build_environment" + +RSpec::Matchers.alias_matcher :use_userpaths, :be_userpaths + +describe BuildEnvironment do + let(:env) { described_class.new } + + describe "#<<" do + it "returns itself" do + expect(env << :foo).to be env + end + end + + describe "#merge" do + it "returns itself" do + expect(env.merge([])).to be env + end + end + + describe "#std?" do + it "returns true if the environment contains :std" do + env << :std + expect(env).to be_std + end + + it "returns false if the environment does not contain :std" do + expect(env).not_to be_std + end + end + + describe "#userpaths?" do + it "returns true if the environment contains :userpaths" do + env << :userpaths + expect(env).to use_userpaths + end + + it "returns false if the environment does not contain :userpaths" do + expect(env).not_to use_userpaths + end + end +end + +describe BuildEnvironmentDSL do + subject { double.extend(described_class) } + + context "single argument" do + before(:each) do + subject.instance_eval do + env :userpaths + end + end + + its(:env) { is_expected.to use_userpaths } + end + + context "multiple arguments" do + before(:each) do + subject.instance_eval do + env :userpaths, :std + end + end + + its(:env) { is_expected.to be_std } + its(:env) { is_expected.to use_userpaths } + end +end diff --git a/Library/Homebrew/test/build_environment_test.rb b/Library/Homebrew/test/build_environment_test.rb deleted file mode 100644 index 54b9cb2b1..000000000 --- a/Library/Homebrew/test/build_environment_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require "testing_env" -require "build_environment" - -class BuildEnvironmentTests < Homebrew::TestCase - def setup - super - @env = BuildEnvironment.new - end - - def test_shovel_returns_self - assert_same @env, @env << :foo - end - - def test_merge_returns_self - assert_same @env, @env.merge([]) - end - - def test_std? - @env << :std - assert_predicate @env, :std? - end - - def test_userpaths? - @env << :userpaths - assert_predicate @env, :userpaths? - end -end - -class BuildEnvironmentDSLTests < Homebrew::TestCase - def make_instance(&block) - obj = Object.new.extend(BuildEnvironmentDSL) - obj.instance_eval(&block) - obj - end - - def test_env_single_argument - obj = make_instance { env :userpaths } - assert_predicate obj.env, :userpaths? - end - - def test_env_multiple_arguments - obj = make_instance { env :userpaths, :std } - assert_predicate obj.env, :userpaths? - assert_predicate obj.env, :std? - end -end -- cgit v1.2.3 From cfed07734c3eae46afc69d572fe2cc8bc68f0945 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 11 Feb 2017 18:46:56 +0100 Subject: Convert Homebrew::Hooks::Bottles test to spec. --- Library/Homebrew/test/bottle_hooks_spec.rb | 50 ++++++++++++++++++++++++++++++ Library/Homebrew/test/bottle_hooks_test.rb | 49 ----------------------------- 2 files changed, 50 insertions(+), 49 deletions(-) create mode 100644 Library/Homebrew/test/bottle_hooks_spec.rb delete mode 100644 Library/Homebrew/test/bottle_hooks_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/bottle_hooks_spec.rb b/Library/Homebrew/test/bottle_hooks_spec.rb new file mode 100644 index 000000000..05c6ea7f0 --- /dev/null +++ b/Library/Homebrew/test/bottle_hooks_spec.rb @@ -0,0 +1,50 @@ +require "formula_installer" +require "hooks/bottles" + +RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle + +describe Homebrew::Hooks::Bottles do + subject { FormulaInstaller.new formula } + + let(:formula) do + double( + bottle: nil, + local_bottle_path: nil, + bottle_disabled?: false, + some_random_method: true, + ) + end + + after(:each) do + described_class.reset_hooks + end + + describe "#setup_formula_has_bottle" do + context "given a block which evaluates to true" do + before(:each) do + described_class.setup_formula_has_bottle(&:some_random_method) + end + + it { is_expected.to pour_bottle } + end + + context "given a block which evaluates to false" do + before(:each) do + described_class.setup_formula_has_bottle { |f| !f.some_random_method } + end + + it { is_expected.not_to pour_bottle } + end + end + + describe "#setup_pour_formula_bottle" do + before(:each) do + described_class.setup_formula_has_bottle { true } + described_class.setup_pour_formula_bottle(&:some_random_method) + end + + it "does not raise an error" do + expect { subject.pour }.not_to raise_error + end + end +end diff --git a/Library/Homebrew/test/bottle_hooks_test.rb b/Library/Homebrew/test/bottle_hooks_test.rb deleted file mode 100644 index fd890192f..000000000 --- a/Library/Homebrew/test/bottle_hooks_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require "testing_env" -require "formula_installer" -require "hooks/bottles" - -class BottleHookTests < Homebrew::TestCase - class FormulaDouble - def bottle; end - def local_bottle_path; end - - def bottle_disabled? - false - end - - def some_random_method - true - end - end - - def setup - super - @fi = FormulaInstaller.new FormulaDouble.new - end - - def test_has_bottle - Homebrew::Hooks::Bottles.setup_formula_has_bottle(&:some_random_method) - assert_predicate @fi, :pour_bottle? - end - - def test_has_no_bottle - Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f| - !f.some_random_method - end - refute_predicate @fi, :pour_bottle? - end - - def test_pour_formula_bottle - Homebrew::Hooks::Bottles.setup_formula_has_bottle do |_f| - true - end - - Homebrew::Hooks::Bottles.setup_pour_formula_bottle(&:some_random_method) - @fi.pour - end - - def teardown - Homebrew::Hooks::Bottles.reset_hooks - super - end -end -- cgit v1.2.3 From 66735b91a316e2d56ad484699178496da5c83656 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 15 Feb 2017 03:33:21 +0100 Subject: Convert Descriptions test to spec. --- Library/Homebrew/test/descriptions_spec.rb | 42 ++++++++++++++++++++++++++ Library/Homebrew/test/descriptions_test.rb | 48 ------------------------------ 2 files changed, 42 insertions(+), 48 deletions(-) create mode 100644 Library/Homebrew/test/descriptions_spec.rb delete mode 100644 Library/Homebrew/test/descriptions_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/descriptions_spec.rb b/Library/Homebrew/test/descriptions_spec.rb new file mode 100644 index 000000000..e873c73b4 --- /dev/null +++ b/Library/Homebrew/test/descriptions_spec.rb @@ -0,0 +1,42 @@ +require "descriptions" + +describe Descriptions do + subject { described_class.new(descriptions_hash) } + let(:descriptions_hash) { {} } + + it "can print description for a core Formula" do + descriptions_hash["homebrew/core/foo"] = "Core foo" + expect { subject.print }.to output("foo: Core foo\n").to_stdout + end + + it "can print description for an external Formula" do + descriptions_hash["somedev/external/foo"] = "External foo" + expect { subject.print }.to output("foo: External foo\n").to_stdout + end + + it "can print descriptions for duplicate Formulae" do + descriptions_hash["homebrew/core/foo"] = "Core foo" + descriptions_hash["somedev/external/foo"] = "External foo" + + expect { subject.print }.to output( + <<-EOS.undent + homebrew/core/foo: Core foo + somedev/external/foo: External foo + EOS + ).to_stdout + end + + it "can print descriptions for duplicate core and external Formulae" do + descriptions_hash["homebrew/core/foo"] = "Core foo" + descriptions_hash["somedev/external/foo"] = "External foo" + descriptions_hash["otherdev/external/foo"] = "Other external foo" + + expect { subject.print }.to output( + <<-EOS.undent + homebrew/core/foo: Core foo + otherdev/external/foo: Other external foo + somedev/external/foo: External foo + EOS + ).to_stdout + end +end diff --git a/Library/Homebrew/test/descriptions_test.rb b/Library/Homebrew/test/descriptions_test.rb deleted file mode 100644 index baeeb7b19..000000000 --- a/Library/Homebrew/test/descriptions_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require "testing_env" -require "descriptions" - -class DescriptionsTest < Homebrew::TestCase - def setup - super - - @descriptions_hash = {} - @descriptions = Descriptions.new(@descriptions_hash) - - @old_stdout = $stdout - $stdout = StringIO.new - end - - def teardown - $stdout = @old_stdout - super - end - - def test_single_core_formula - @descriptions_hash["homebrew/core/foo"] = "Core foo" - @descriptions.print - assert_equal "foo: Core foo", $stdout.string.chomp - end - - def test_single_external_formula - @descriptions_hash["somedev/external/foo"] = "External foo" - @descriptions.print - assert_equal "foo: External foo", $stdout.string.chomp - end - - def test_even_dupes - @descriptions_hash["homebrew/core/foo"] = "Core foo" - @descriptions_hash["somedev/external/foo"] = "External foo" - @descriptions.print - assert_equal "homebrew/core/foo: Core foo\nsomedev/external/foo: External foo", - $stdout.string.chomp - end - - def test_odd_dupes - @descriptions_hash["homebrew/core/foo"] = "Core foo" - @descriptions_hash["somedev/external/foo"] = "External foo" - @descriptions_hash["otherdev/external/foo"] = "Other external foo" - @descriptions.print - assert_equal "homebrew/core/foo: Core foo\notherdev/external/foo: Other external foo\nsomedev/external/foo: External foo", - $stdout.string.chomp - end -end -- cgit v1.2.3 From 5a214de68d52eef0bbf99f740dc22c721dd02233 Mon Sep 17 00:00:00 2001 From: Bob W. Hogg Date: Sun, 4 Dec 2016 18:43:46 -0800 Subject: java_requirement: port to Linux and refactor Split the core requirement class into generic, Linux-specific, and macOS-specific parts. Additionally, the Linux version is now able to detect Java versions (the previous Linuxbrew implementation was only able to detect if Java was present at all.) --- .../os/linux/requirements/java_requirement.rb | 19 ++++ .../extend/os/mac/requirements/java_requirement.rb | 40 ++++++++ .../extend/os/requirements/java_requirement.rb | 7 ++ Library/Homebrew/requirements/java_requirement.rb | 104 ++++++++++++++++----- Library/Homebrew/test/java_requirement_test.rb | 50 ++++++++++ .../Homebrew/test/os/mac/java_requirement_test.rb | 31 ++++++ 6 files changed, 226 insertions(+), 25 deletions(-) create mode 100644 Library/Homebrew/extend/os/linux/requirements/java_requirement.rb create mode 100644 Library/Homebrew/extend/os/mac/requirements/java_requirement.rb create mode 100644 Library/Homebrew/extend/os/requirements/java_requirement.rb create mode 100644 Library/Homebrew/test/java_requirement_test.rb create mode 100644 Library/Homebrew/test/os/mac/java_requirement_test.rb (limited to 'Library') diff --git a/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb b/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb new file mode 100644 index 000000000..c8cbabb0d --- /dev/null +++ b/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb @@ -0,0 +1,19 @@ +require "language/java" + +class JavaRequirement < Requirement + default_formula "jdk" + + env do + next unless @java_home + env_java_common + if (Pathname.new(@java_home)/"include").exist? # Oracle JVM + env_oracle_jdk + end + end + + private + + def oracle_java_os + :linux + end +end diff --git a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb new file mode 100644 index 000000000..9c60aff95 --- /dev/null +++ b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb @@ -0,0 +1,40 @@ +class JavaRequirement + cask "java" + + env do + env_java_common + java_home = Pathname.new(@java_home) + if (java_home/"include").exist? # Oracle JVM + env_oracle_jdk + else # Apple JVM + env_apple + end + end + + private + + def possible_javas + javas = [] + javas << Pathname.new(ENV["JAVA_HOME"])/"bin/java" if ENV["JAVA_HOME"] + javas << java_home_cmd + javas << which("java") + javas + end + + def java_home_cmd + return nil unless File.executable?("/usr/libexec/java_home") + args = %w[--failfast] + args << "--version" << @version.to_s if @version + java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp + return nil unless $?.success? + Pathname.new(java_home)/"bin/java" + end + + def env_apple + ENV.append_to_cflags "-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/" + end + + def oracle_java_os + :darwin + end +end diff --git a/Library/Homebrew/extend/os/requirements/java_requirement.rb b/Library/Homebrew/extend/os/requirements/java_requirement.rb new file mode 100644 index 000000000..b512ada47 --- /dev/null +++ b/Library/Homebrew/extend/os/requirements/java_requirement.rb @@ -0,0 +1,7 @@ +require "requirements/java_requirement" + +if OS.mac? + require "extend/os/mac/requirements/java_requirement" +elsif OS.linux? + require "extend/os/linux/requirements/java_requirement" +end diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index 33fc01229..fa9b6439e 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -2,28 +2,12 @@ require "language/java" class JavaRequirement < Requirement fatal true - cask "java" download "http://www.oracle.com/technetwork/java/javase/downloads/index.html" satisfy build_env: false do - next false unless File.executable? "/usr/libexec/java_home" - - args = %w[--failfast] - args << "--version" << @version.to_s if @version - @java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp - $?.success? - end - - env do - java_home = Pathname.new(@java_home) - ENV["JAVA_HOME"] = java_home - ENV.prepend_path "PATH", java_home/"bin" - if (java_home/"include").exist? # Oracle JVM - ENV.append_to_cflags "-I#{java_home}/include" - ENV.append_to_cflags "-I#{java_home}/include/darwin" - else # Apple JVM - ENV.append_to_cflags "-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/" - end + setup_java + next false unless @java + next true end def initialize(tags) @@ -45,16 +29,86 @@ class JavaRequirement < Requirement def display_s if @version - if @version[-1] == "+" - op = ">=" - version = @version[0, @version.length-1] - else + if exact_version? op = "=" - version = @version + else + op = ">=" end - "#{name} #{op} #{version}" + "#{name} #{op} #{version_without_plus}" else name end end + + private + + def version_without_plus + if exact_version? + @version + else + @version[0, @version.length-1] + end + end + + def exact_version? + @version && @version.to_s.chars.last != "+" + end + + def setup_java + java = preferred_java + return unless java + @java = java + @java_home = java.parent.parent + end + + def possible_javas + javas = [] + javas << Pathname.new(ENV["JAVA_HOME"])/"bin/java" if ENV["JAVA_HOME"] + jdk = begin + Formula["jdk"] + rescue FormulaUnavailableError + nil + end + javas << jdk.bin/"java" if jdk && jdk.installed? + javas << which("java") + javas + end + + def preferred_java + possible_javas.detect do |java| + next false unless java && java.executable? + next true unless @version + next true if satisfies_version(java) + end + end + + def env_java_common + java_home = Pathname.new(@java_home) + ENV["JAVA_HOME"] = java_home + ENV.prepend_path "PATH", java_home/"bin" + end + + def env_oracle_jdk + java_home = Pathname.new(@java_home) + ENV.append_to_cflags "-I#{java_home}/include" + ENV.append_to_cflags "-I#{java_home}/include/#{oracle_java_os}" + end + + def oracle_java_os + nil + end + + def satisfies_version(java) + java_version_s = Utils.popen_read("#{java} -version 2>&1")[/1.\d/] + return false unless java_version_s + java_version = Version.create(java_version_s) + needed_version = Version.create(version_without_plus) + if exact_version? + java_version == needed_version + else + java_version >= needed_version + end + end end + +require "extend/os/requirements/java_requirement" diff --git a/Library/Homebrew/test/java_requirement_test.rb b/Library/Homebrew/test/java_requirement_test.rb new file mode 100644 index 000000000..d0b51f92c --- /dev/null +++ b/Library/Homebrew/test/java_requirement_test.rb @@ -0,0 +1,50 @@ +require "testing_env" +require "requirements/java_requirement" + +class JavaRequirementTests < Homebrew::TestCase + def setup + super + ENV["JAVA_HOME"] = nil + end + + def test_message + a = JavaRequirement.new([]) + assert_match(/Java is required to install this formula./, a.message) + end + + def test_inspect + a = JavaRequirement.new(%w[1.7+]) + assert_equal a.inspect, '#' + end + + def test_display_s + x = JavaRequirement.new([]) + assert_equal x.display_s, "java" + y = JavaRequirement.new(%w[1.8]) + assert_equal y.display_s, "java = 1.8" + z = JavaRequirement.new(%w[1.8+]) + assert_equal z.display_s, "java >= 1.8" + end + + def test_satisfied? + a = JavaRequirement.new(%w[1.8]) + File.stubs(:executable?).returns(false) + refute_predicate a, :satisfied? + + b = JavaRequirement.new([]) + b.stubs(:preferred_java).returns(Pathname.new("/usr/bin/java")) + assert_predicate b, :satisfied? + + c = JavaRequirement.new(%w[1.7+]) + c.stubs(:possible_javas).returns([Pathname.new("/usr/bin/java")]) + Utils.stubs(:popen_read).returns('java version "1.6.0_5"') + refute_predicate c, :satisfied? + Utils.stubs(:popen_read).returns('java version "1.8.0_5"') + assert_predicate c, :satisfied? + + d = JavaRequirement.new(%w[1.7]) + d.stubs(:possible_javas).returns([Pathname.new("/usr/bin/java")]) + Utils.stubs(:popen_read).returns('java version "1.8.0_5"') + refute_predicate d, :satisfied? + end +end diff --git a/Library/Homebrew/test/os/mac/java_requirement_test.rb b/Library/Homebrew/test/os/mac/java_requirement_test.rb new file mode 100644 index 000000000..83c1af95c --- /dev/null +++ b/Library/Homebrew/test/os/mac/java_requirement_test.rb @@ -0,0 +1,31 @@ +require "testing_env" +require "requirements/java_requirement" +require "fileutils" + +class OSMacJavaRequirementTests < Homebrew::TestCase + def setup + super + @java_req = JavaRequirement.new(%w[1.8]) + @tmp_java_home = mktmpdir + @tmp_pathname = Pathname.new(@tmp_java_home) + FileUtils.mkdir @tmp_pathname/"bin" + FileUtils.touch @tmp_pathname/"bin/java" + @java_req.stubs(:preferred_java).returns(@tmp_pathname/"bin/java") + @java_req.satisfied? + end + + def test_java_env_apple + ENV.expects(:prepend_path) + ENV.expects(:append_to_cflags) + @java_req.modify_build_environment + assert_equal ENV["JAVA_HOME"], @tmp_java_home + end + + def test_java_env_oracle + FileUtils.mkdir @tmp_pathname/"include" + ENV.expects(:prepend_path) + ENV.expects(:append_to_cflags).twice + @java_req.modify_build_environment + assert_equal ENV["JAVA_HOME"], @tmp_java_home + end +end -- cgit v1.2.3 From c49b97dd9c4d65a68494a467d542a42528ea9b38 Mon Sep 17 00:00:00 2001 From: Bob W. Hogg Date: Wed, 15 Feb 2017 21:47:08 -0800 Subject: Code review cleanups --- Library/Homebrew/extend/os/linux/requirements/java_requirement.rb | 5 +---- Library/Homebrew/extend/os/mac/requirements/java_requirement.rb | 7 +------ Library/Homebrew/requirements/java_requirement.rb | 4 ++++ 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb b/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb index c8cbabb0d..7816f6b6f 100644 --- a/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb +++ b/Library/Homebrew/extend/os/linux/requirements/java_requirement.rb @@ -4,11 +4,8 @@ class JavaRequirement < Requirement default_formula "jdk" env do - next unless @java_home env_java_common - if (Pathname.new(@java_home)/"include").exist? # Oracle JVM - env_oracle_jdk - end + env_oracle_jdk end private diff --git a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb index 9c60aff95..451e0001b 100644 --- a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb +++ b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb @@ -3,12 +3,7 @@ class JavaRequirement env do env_java_common - java_home = Pathname.new(@java_home) - if (java_home/"include").exist? # Oracle JVM - env_oracle_jdk - else # Apple JVM - env_apple - end + env_oracle_jdk || env_apple end private diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index fa9b6439e..010b7dbc9 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -83,15 +83,19 @@ class JavaRequirement < Requirement end def env_java_common + return unless @java_home java_home = Pathname.new(@java_home) ENV["JAVA_HOME"] = java_home ENV.prepend_path "PATH", java_home/"bin" end def env_oracle_jdk + return unless @java_home java_home = Pathname.new(@java_home) + return unless (java_home/"include").exist? ENV.append_to_cflags "-I#{java_home}/include" ENV.append_to_cflags "-I#{java_home}/include/#{oracle_java_os}" + true end def oracle_java_os -- cgit v1.2.3 From 2a21991b1fc8039bfa0c950e439db5a725b62b42 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 17:10:40 +0100 Subject: Make sure `uninstall` is called before artifacts are removed. --- Library/Homebrew/cask/lib/hbc/installer.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index cafc9d8b9..b86f3264d 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -318,7 +318,13 @@ module Hbc def uninstall_artifacts odebug "Un-installing artifacts" artifacts = Artifact.for_cask(@cask, command: @command, force: force) + + # Make sure the `uninstall` stanza is run first, as it + # may depend on other artifacts still being installed. + artifacts = artifacts.sort_by { |a| a.is_a?(Artifact::Uninstall) ? -1 : 1 } + odebug "#{artifacts.length} artifact/s defined", artifacts + artifacts.each do |artifact| next unless artifact.respond_to?(:uninstall_phase) odebug "Un-installing artifact of class #{artifact.class}" -- cgit v1.2.3 From ecb17f4f1d265e1625828565ecbbdac6d5f989c6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 17:46:23 +0100 Subject: Add test for `uninstall` before removing artifacts. --- .../Homebrew/cask/spec/cask/cli/uninstall_spec.rb | 19 +++++++++++++++++++ .../cask/Casks/with-uninstall-script-app.rb | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb index be0aa31b6..243be49d9 100644 --- a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb @@ -41,6 +41,25 @@ describe Hbc::CLI::Uninstall do expect(Hbc.appdir.join("Caffeine.app")).not_to exist end + it "calls `uninstall` before removing artifacts" do + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb") + + shutup do + Hbc::Installer.new(cask).install + end + + expect(cask).to be_installed + + expect { + shutup do + Hbc::CLI::Uninstall.run("with-uninstall-script-app") + end + }.not_to raise_error + + expect(cask).not_to be_installed + expect(Hbc.appdir.join("MyFancyApp.app")).not_to exist + end + describe "when multiple versions of a cask are installed" do let(:token) { "versioned-cask" } let(:first_installed_version) { "1.2.3" } diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb new file mode 100644 index 000000000..f5f3ae5dd --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb @@ -0,0 +1,21 @@ +cask 'with-uninstall-script-app' do + version '1.2.3' + sha256 '5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip" + homepage 'http://example.com/MyFancyApp' + + app 'MyFancyApp/MyFancyApp.app' + + postflight do + IO.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<-EOS.undent + #!/bin/sh + /bin/rm -r "#{appdir}/MyFancyApp.app" + EOS + end + + uninstall script: { + executable: "#{appdir}/MyFancyApp.app/uninstall.sh", + sudo: false + } +end -- cgit v1.2.3 From fcd88b71f5eb0d9915264473dd0c155003563f89 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 21:53:22 +0100 Subject: Allow skipping `uninstall script:` when `--force` is passed. --- Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index ce2b1f51a..cc47e05ad 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -201,7 +201,15 @@ module Hbc ohai "Running uninstall script #{executable}" raise CaskInvalidError.new(@cask, "#{stanza} :#{directive_name} without :executable.") if executable.nil? executable_path = @cask.staged_path.join(executable) - @command.run("/bin/chmod", args: ["--", "+x", executable_path]) if File.exist?(executable_path) + + unless executable_path.exist? + message = "uninstall script #{executable} does not exist" + raise CaskError, "#{message}." unless force + opoo "#{message}, skipping." + return + end + + @command.run("/bin/chmod", args: ["--", "+x", executable_path]) @command.run(executable_path, script_arguments) sleep 1 end -- cgit v1.2.3 From b51161b08b3e3b26d279952a34e9e54da4a059f0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 22:00:29 +0100 Subject: Add test for non-existant `uninstall script:`. --- .../Homebrew/cask/spec/cask/cli/uninstall_spec.rb | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb index 243be49d9..a1b47e823 100644 --- a/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb @@ -60,6 +60,34 @@ describe Hbc::CLI::Uninstall do expect(Hbc.appdir.join("MyFancyApp.app")).not_to exist end + it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do + cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb") + + shutup do + Hbc::Installer.new(cask).install + end + + expect(cask).to be_installed + + Hbc.appdir.join("MyFancyApp.app").rmtree + + expect { + shutup do + Hbc::CLI::Uninstall.run("with-uninstall-script-app") + end + }.to raise_error(Hbc::CaskError, /does not exist/) + + expect(cask).to be_installed + + expect { + shutup do + Hbc::CLI::Uninstall.run("with-uninstall-script-app", "--force") + end + }.not_to raise_error + + expect(cask).not_to be_installed + end + describe "when multiple versions of a cask are installed" do let(:token) { "versioned-cask" } let(:first_installed_version) { "1.2.3" } -- cgit v1.2.3 From 89f4d153a22cde0fe7903713bcfe42426977274b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 17 Feb 2017 04:01:50 +0100 Subject: Only show “sudo” message when it is actually needed. --- Library/Homebrew/cask/lib/hbc/caskroom.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb index 644728129..255e23888 100644 --- a/Library/Homebrew/cask/lib/hbc/caskroom.rb +++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb @@ -21,9 +21,10 @@ module Hbc return if Hbc.caskroom.exist? ohai "Creating Caskroom at #{Hbc.caskroom}" - ohai "We'll set permissions properly so we won't need sudo in the future" sudo = !Hbc.caskroom.parent.writable? + ohai "We'll set permissions properly so we won't need sudo in the future" if sudo + SystemCommand.run("/bin/mkdir", args: ["-p", Hbc.caskroom], sudo: sudo) SystemCommand.run("/bin/chmod", args: ["g+rwx", Hbc.caskroom], sudo: sudo) SystemCommand.run("/usr/sbin/chown", args: [Utils.current_user, Hbc.caskroom], sudo: sudo) -- cgit v1.2.3 From a0597a3f15b8044a4bf2c4b58fdc4df54026a347 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 17 Feb 2017 04:02:17 +0100 Subject: `fetch` needs cache to be created. --- Library/Homebrew/cask/lib/hbc/cli/fetch.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/fetch.rb b/Library/Homebrew/cask/lib/hbc/cli/fetch.rb index 9b3d5099c..fc928586f 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/fetch.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/fetch.rb @@ -15,6 +15,10 @@ module Hbc end end + def self.needs_init? + true + end + def self.help "downloads remote application files to local cache" end -- cgit v1.2.3 From f8ea9266410c0c2733b6de3c5a3e690842e7b9a8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 17 Feb 2017 19:17:08 +0100 Subject: Convert Language::Go test to spec. --- Library/Homebrew/test/language/go_spec.rb | 15 +++++++++++++++ Library/Homebrew/test/language_go_test.rb | 17 ----------------- 2 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 Library/Homebrew/test/language/go_spec.rb delete mode 100644 Library/Homebrew/test/language_go_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/language/go_spec.rb b/Library/Homebrew/test/language/go_spec.rb new file mode 100644 index 000000000..24db78594 --- /dev/null +++ b/Library/Homebrew/test/language/go_spec.rb @@ -0,0 +1,15 @@ +require "language/go" + +describe Language::Go do + specify "#stage_deps" do + ENV.delete("HOMEBREW_DEVELOPER") + + expect(described_class).to receive(:opoo).once + + Dir.mktmpdir do |path| + shutup do + described_class.stage_deps [], path + end + end + end +end diff --git a/Library/Homebrew/test/language_go_test.rb b/Library/Homebrew/test/language_go_test.rb deleted file mode 100644 index 692a5d2cc..000000000 --- a/Library/Homebrew/test/language_go_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: UTF-8 -*- - -require "testing_env" -require "language/go" - -class LanguageGoTests < Homebrew::TestCase - def test_stage_deps_empty - if ARGV.homebrew_developer? - Language::Go.expects(:odie).once - else - Language::Go.expects(:opoo).once - end - mktmpdir do |path| - shutup { Language::Go.stage_deps [], path } - end - end -end -- cgit v1.2.3 From 6ac0de1b40699042ea124813f2e953285efbd05f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 17 Feb 2017 21:27:40 +0000 Subject: Revert "Skip Xcode outdated check on CircleCI" --- Library/Homebrew/extend/os/mac/diagnostic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 3e0c1d04d..6d30cd294 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -53,8 +53,8 @@ module Homebrew return unless MacOS::Xcode.installed? return unless MacOS::Xcode.outdated? - # CI images are going to end up outdated so don't complain. - return if ENV["TRAVIS"] || ENV["CIRCLECI"] + # Travis CI images are going to end up outdated so don't complain. + return if ENV["TRAVIS"] message = <<-EOS.undent Your Xcode (#{MacOS::Xcode.version}) is outdated. -- cgit v1.2.3 From 3678d60a284cb2ebf1026cf0bb1a9b613f71a734 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 17 Feb 2017 21:53:30 +0000 Subject: diagnostic: detail TRAVIS opt-out reasoning. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 6d30cd294..229c10e9f 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -53,7 +53,10 @@ module Homebrew return unless MacOS::Xcode.installed? return unless MacOS::Xcode.outdated? - # Travis CI images are going to end up outdated so don't complain. + # Travis CI images are going to end up outdated so don't complain when + # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew + # repository. This only needs to support whatever CI provided + # Homebrew/brew is currently using. return if ENV["TRAVIS"] message = <<-EOS.undent -- cgit v1.2.3 From 398289c72cf9268866b8bb0b706dfeedd7dfee24 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 17 Feb 2017 22:03:04 +0000 Subject: diagnostic: fix typo. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 229c10e9f..4da59bc2f 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -55,7 +55,7 @@ module Homebrew # Travis CI images are going to end up outdated so don't complain when # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew - # repository. This only needs to support whatever CI provided + # repository. This only needs to support whatever CI provider # Homebrew/brew is currently using. return if ENV["TRAVIS"] -- cgit v1.2.3 From 779d9ce60fd931b5ac1819209bf00470703f6a55 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 19:53:32 +0100 Subject: Convert PkgVersion test to spec. --- Library/Homebrew/test/pkg_version_spec.rb | 81 +++++++++++++++++++++++++++++++ Library/Homebrew/test/pkg_version_test.rb | 51 ------------------- 2 files changed, 81 insertions(+), 51 deletions(-) create mode 100644 Library/Homebrew/test/pkg_version_spec.rb delete mode 100644 Library/Homebrew/test/pkg_version_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/pkg_version_spec.rb b/Library/Homebrew/test/pkg_version_spec.rb new file mode 100644 index 000000000..b1cceb32c --- /dev/null +++ b/Library/Homebrew/test/pkg_version_spec.rb @@ -0,0 +1,81 @@ +require "pkg_version" + +describe PkgVersion do + describe "::parse" do + it "parses versions from a string" do + expect(described_class.parse("1.0_1")).to eq(described_class.new(Version.create("1.0"), 1)) + expect(described_class.parse("1.0_1")).to eq(described_class.new(Version.create("1.0"), 1)) + expect(described_class.parse("1.0")).to eq(described_class.new(Version.create("1.0"), 0)) + expect(described_class.parse("1.0_0")).to eq(described_class.new(Version.create("1.0"), 0)) + expect(described_class.parse("2.1.4_0")).to eq(described_class.new(Version.create("2.1.4"), 0)) + expect(described_class.parse("1.0.1e_1")).to eq(described_class.new(Version.create("1.0.1e"), 1)) + end + end + + specify "#==" do + expect(described_class.parse("1.0_0")).to be == described_class.parse("1.0") + expect(described_class.parse("1.0_1")).to be == described_class.parse("1.0_1") + end + + describe "#>" do + it "returns true if the left version is bigger than the right" do + expect(described_class.parse("1.1")).to be > described_class.parse("1.0_1") + end + + it "returns true if the left version is HEAD" do + expect(described_class.parse("HEAD")).to be > described_class.parse("1.0") + end + + it "raises an error if the other side isn't of the same class" do + expect { + described_class.new(Version.create("1.0"), 0) > Object.new + }.to raise_error(ArgumentError) + end + + it "is not compatible with Version" do + expect { + described_class.new(Version.create("1.0"), 0) > Version.create("1.0") + }.to raise_error(ArgumentError) + end + end + + describe "#<" do + it "returns true if the left version is smaller than the right" do + expect(described_class.parse("1.0_1")).to be < described_class.parse("2.0_1") + end + + it "returns true if the right version is HEAD" do + expect(described_class.parse("1.0")).to be < described_class.parse("HEAD") + end + end + + describe "#<=>" do + it "returns nil if the comparison fails" do + expect(described_class.new(Version.create("1.0"), 0) <=> Object.new).to be nil + end + end + + describe "#to_s" do + it "returns a string of the form 'version_revision'" do + expect(described_class.new(Version.create("1.0"), 0).to_s).to eq("1.0") + expect(described_class.new(Version.create("1.0"), 1).to_s).to eq("1.0_1") + expect(described_class.new(Version.create("1.0"), 0).to_s).to eq("1.0") + expect(described_class.new(Version.create("1.0"), 0).to_s).to eq("1.0") + expect(described_class.new(Version.create("HEAD"), 1).to_s).to eq("HEAD_1") + expect(described_class.new(Version.create("HEAD-ffffff"), 1).to_s).to eq("HEAD-ffffff_1") + end + end + + describe "#hash" do + let(:p1) { described_class.new(Version.create("1.0"), 1) } + let(:p2) { described_class.new(Version.create("1.0"), 1) } + let(:p3) { described_class.new(Version.create("1.1"), 1) } + let(:p4) { described_class.new(Version.create("1.0"), 0) } + + it "returns a hash based on the version and revision" do + expect(p1.hash).to eq(p2.hash) + expect(p1.hash).not_to eq(p3.hash) + expect(p1.hash).not_to eq(p4.hash) + end + end +end diff --git a/Library/Homebrew/test/pkg_version_test.rb b/Library/Homebrew/test/pkg_version_test.rb deleted file mode 100644 index ff7896f8b..000000000 --- a/Library/Homebrew/test/pkg_version_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require "testing_env" -require "pkg_version" - -class PkgVersionTests < Homebrew::TestCase - def v(version) - PkgVersion.parse(version) - end - - def test_parse - assert_equal PkgVersion.new(Version.create("1.0"), 1), PkgVersion.parse("1.0_1") - assert_equal PkgVersion.new(Version.create("1.0"), 1), PkgVersion.parse("1.0_1") - assert_equal PkgVersion.new(Version.create("1.0"), 0), PkgVersion.parse("1.0") - assert_equal PkgVersion.new(Version.create("1.0"), 0), PkgVersion.parse("1.0_0") - assert_equal PkgVersion.new(Version.create("2.1.4"), 0), PkgVersion.parse("2.1.4_0") - assert_equal PkgVersion.new(Version.create("1.0.1e"), 1), PkgVersion.parse("1.0.1e_1") - end - - def test_comparison - assert_operator v("1.0_0"), :==, v("1.0") - assert_operator v("1.0_1"), :==, v("1.0_1") - assert_operator v("1.1"), :>, v("1.0_1") - assert_operator v("1.0_0"), :==, v("1.0") - assert_operator v("1.0_1"), :<, v("2.0_1") - assert_operator v("HEAD"), :>, v("1.0") - assert_operator v("1.0"), :<, v("HEAD") - - v = PkgVersion.new(Version.create("1.0"), 0) - assert_nil v <=> Object.new - assert_raises(ArgumentError) { v > Object.new } - assert_raises(ArgumentError) { v > Version.create("1.0") } - end - - def test_to_s - assert_equal "1.0", PkgVersion.new(Version.create("1.0"), 0).to_s - assert_equal "1.0_1", PkgVersion.new(Version.create("1.0"), 1).to_s - assert_equal "1.0", PkgVersion.new(Version.create("1.0"), 0).to_s - assert_equal "1.0", PkgVersion.new(Version.create("1.0"), 0).to_s - assert_equal "HEAD_1", PkgVersion.new(Version.create("HEAD"), 1).to_s - assert_equal "HEAD-ffffff_1", PkgVersion.new(Version.create("HEAD-ffffff"), 1).to_s - end - - def test_hash - p1 = PkgVersion.new(Version.create("1.0"), 1) - p2 = PkgVersion.new(Version.create("1.0"), 1) - p3 = PkgVersion.new(Version.create("1.1"), 1) - p4 = PkgVersion.new(Version.create("1.0"), 0) - assert_equal p1.hash, p2.hash - refute_equal p1.hash, p3.hash - refute_equal p1.hash, p4.hash - end -end -- cgit v1.2.3 From 99da779434bda113f50f4a17880d1dfcacd93d24 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 18:14:05 +0100 Subject: Convert Gpg test to spec. --- Library/Homebrew/test/gpg_spec.rb | 21 +++++++++++++++++++++ Library/Homebrew/test/gpg_test.rb | 18 ------------------ 2 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 Library/Homebrew/test/gpg_spec.rb delete mode 100644 Library/Homebrew/test/gpg_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/gpg_spec.rb b/Library/Homebrew/test/gpg_spec.rb new file mode 100644 index 000000000..9809dccb5 --- /dev/null +++ b/Library/Homebrew/test/gpg_spec.rb @@ -0,0 +1,21 @@ +require "gpg" + +describe Gpg do + subject { described_class } + + describe "::create_test_key" do + it "creates a test key in the home directory" do + skip "GPG Unavailable" unless subject.available? + + Dir.mktmpdir do |dir| + ENV["HOME"] = dir + dir = Pathname.new(dir) + + shutup do + subject.create_test_key(dir) + end + expect(dir/".gnupg/secring.gpg").to exist + end + end + end +end diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb deleted file mode 100644 index ea4372549..000000000 --- a/Library/Homebrew/test/gpg_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "testing_env" -require "gpg" - -class GpgTest < Homebrew::TestCase - def setup - super - skip "GPG Unavailable" unless Gpg.available? - @dir = Pathname.new(mktmpdir) - end - - def test_create_test_key - Dir.chdir(@dir) do - ENV["HOME"] = @dir - shutup { Gpg.create_test_key(@dir) } - assert_predicate @dir/".gnupg/secring.gpg", :exist? - end - end -end -- cgit v1.2.3 From 8fee9bf44dad59b422293b6eb37ac83435475b01 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 22:31:43 +0100 Subject: Convert MPIRequirement test to spec. --- Library/Homebrew/test/mpi_requirement_spec.rb | 14 ++++++++++++++ Library/Homebrew/test/mpi_requirement_test.rb | 12 ------------ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 Library/Homebrew/test/mpi_requirement_spec.rb delete mode 100644 Library/Homebrew/test/mpi_requirement_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/mpi_requirement_spec.rb b/Library/Homebrew/test/mpi_requirement_spec.rb new file mode 100644 index 000000000..f32b27993 --- /dev/null +++ b/Library/Homebrew/test/mpi_requirement_spec.rb @@ -0,0 +1,14 @@ +require "requirements/mpi_requirement" + +describe MPIRequirement do + describe "::new" do + subject { described_class.new(*(wrappers + tags)) } + let(:wrappers) { [:cc, :cxx, :f77] } + let(:tags) { [:optional, "some-other-tag"] } + + it "untangles wrappers and tags" do + expect(subject.lang_list).to eq(wrappers) + expect(subject.tags).to eq(tags) + end + end +end diff --git a/Library/Homebrew/test/mpi_requirement_test.rb b/Library/Homebrew/test/mpi_requirement_test.rb deleted file mode 100644 index e0f97e8ee..000000000 --- a/Library/Homebrew/test/mpi_requirement_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "testing_env" -require "requirements/mpi_requirement" - -class MPIRequirementTests < Homebrew::TestCase - def test_initialize_untangles_tags_and_wrapper_symbols - wrappers = [:cc, :cxx, :f77] - tags = [:optional, "some-other-tag"] - dep = MPIRequirement.new(*wrappers + tags) - assert_equal wrappers, dep.lang_list - assert_equal tags, dep.tags - end -end -- cgit v1.2.3 From 8736b6cee0d94c1927b7abaa3dbde0d3a0239b85 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 22:42:52 +0100 Subject: Convert Tty test to spec. --- Library/Homebrew/test/utils/tty_spec.rb | 67 +++++++++++++++++++++++++++++++++ Library/Homebrew/test/utils/tty_test.rb | 46 ---------------------- 2 files changed, 67 insertions(+), 46 deletions(-) create mode 100644 Library/Homebrew/test/utils/tty_spec.rb delete mode 100644 Library/Homebrew/test/utils/tty_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/utils/tty_spec.rb b/Library/Homebrew/test/utils/tty_spec.rb new file mode 100644 index 000000000..3ba89b6fd --- /dev/null +++ b/Library/Homebrew/test/utils/tty_spec.rb @@ -0,0 +1,67 @@ +require "utils" + +describe Tty do + describe "::strip_ansi" do + it "removes ANSI escape codes from a string" do + expect(subject.strip_ansi("\033\[36;7mhello\033\[0m")).to eq("hello") + end + end + + describe "::width" do + it "returns an Integer" do + expect(subject.width).to be_kind_of(Integer) + end + + it "cannot be negative" do + expect(subject.width).to be >= 0 + end + end + + describe "::truncate" do + it "truncates the text to the terminal width, minus 4, to account for '==> '" do + allow(subject).to receive(:width).and_return(15) + + expect(subject.truncate("foobar something very long")).to eq("foobar some") + expect(subject.truncate("truncate")).to eq("truncate") + end + + it "doesn't truncate the text if the terminal is unsupported, i.e. the width is 0" do + allow(subject).to receive(:width).and_return(0) + expect(subject.truncate("foobar something very long")).to eq("foobar something very long") + end + end + + context "when $stdout is not a TTY" do + before(:each) do + allow($stdout).to receive(:tty?).and_return(false) + end + + it "returns an empty string for all colors" do + expect(subject.to_s).to eq("") + expect(subject.red.to_s).to eq("") + expect(subject.green.to_s).to eq("") + expect(subject.yellow.to_s).to eq("") + expect(subject.blue.to_s).to eq("") + expect(subject.magenta.to_s).to eq("") + expect(subject.cyan.to_s).to eq("") + expect(subject.default.to_s).to eq("") + end + end + + context "when $stdout is a TTY" do + before(:each) do + allow($stdout).to receive(:tty?).and_return(true) + end + + it "returns an empty string for all colors" do + expect(subject.to_s).to eq("") + expect(subject.red.to_s).to eq("\033[31m") + expect(subject.green.to_s).to eq("\033[32m") + expect(subject.yellow.to_s).to eq("\033[33m") + expect(subject.blue.to_s).to eq("\033[34m") + expect(subject.magenta.to_s).to eq("\033[35m") + expect(subject.cyan.to_s).to eq("\033[36m") + expect(subject.default.to_s).to eq("\033[39m") + end + end +end diff --git a/Library/Homebrew/test/utils/tty_test.rb b/Library/Homebrew/test/utils/tty_test.rb deleted file mode 100644 index 09f092cbd..000000000 --- a/Library/Homebrew/test/utils/tty_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require "testing_env" -require "utils" - -class TtyTests < Homebrew::TestCase - def test_strip_ansi - assert_equal "hello", Tty.strip_ansi("\033\[36;7mhello\033\[0m") - end - - def test_width - assert_kind_of Integer, Tty.width - end - - def test_truncate - Tty.stubs(:width).returns 15 - assert_equal "foobar some", Tty.truncate("foobar something very long") - assert_equal "truncate", Tty.truncate("truncate") - - # When the terminal is unsupported, we report 0 width - Tty.stubs(:width).returns 0 - assert_equal "foobar something very long", Tty.truncate("foobar something very long") - end - - def test_no_tty_formatting - $stdout.stubs(:tty?).returns false - assert_equal "", Tty.to_s - assert_equal "", Tty.red.to_s - assert_equal "", Tty.green.to_s - assert_equal "", Tty.yellow.to_s - assert_equal "", Tty.blue.to_s - assert_equal "", Tty.magenta.to_s - assert_equal "", Tty.cyan.to_s - assert_equal "", Tty.default.to_s - end - - def test_formatting - $stdout.stubs(:tty?).returns(true) - assert_equal "", Tty.to_s - assert_equal "\033[31m", Tty.red.to_s - assert_equal "\033[32m", Tty.green.to_s - assert_equal "\033[33m", Tty.yellow.to_s - assert_equal "\033[34m", Tty.blue.to_s - assert_equal "\033[35m", Tty.magenta.to_s - assert_equal "\033[36m", Tty.cyan.to_s - assert_equal "\033[39m", Tty.default.to_s - end -end -- cgit v1.2.3 From 95f9af24d360afad7c4c81131b91c886031ff0dc Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Fri, 17 Feb 2017 12:34:24 -0500 Subject: update-report: unlink rather than uninstall --force formula when ... migrating a formula to a cask. --- Library/Homebrew/cmd/update-report.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index dcf2891d9..7cc1ce264 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -475,12 +475,18 @@ class Reporter if new_tap_name == "caskroom/cask" if new_tap.installed? && (HOMEBREW_PREFIX/"Caskroom").directory? ohai "#{name} has been moved to Homebrew-Cask." - ohai "brew uninstall --force #{name}" - system HOMEBREW_BREW_FILE, "uninstall", "--force", name + ohai "brew unlink #{name}" + system HOMEBREW_BREW_FILE, "unlink", name ohai "brew prune" system HOMEBREW_BREW_FILE, "prune" ohai "brew cask install #{new_name}" system HOMEBREW_BREW_FILE, "cask", "install", new_name + ohai <<-EOS.undent + #{name} has been moved to Homebrew-Cask. + The existing keg has been unlinked. + Please uninstall the formula when convenient by running: + brew uninstall --force #{name} + EOS else ohai "#{name} has been moved to Homebrew-Cask.", <<-EOS.undent To uninstall the formula and install the cask run: -- cgit v1.2.3 From e1fef54b7624eed1ee04379f215a63d13e7700ca Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 18 Feb 2017 02:30:47 +0100 Subject: Replace `Set::difference` with `Set::^`. --- Library/Homebrew/test/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 7762b385c..292c5786a 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -67,7 +67,7 @@ RSpec.configure do |config| files_after_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") } - diff = Set.new(@__files_before_test).difference(Set.new(files_after_test)) + diff = Set.new(@__files_before_test) ^ Set.new(files_after_test) expect(diff).to be_empty, <<-EOS.undent file leak detected: #{diff.map { |f| " #{f}" }.join("\n")} -- cgit v1.2.3 From 9e0c0a8b3aff2b273f0e9fc94ac72f0309fc5834 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 18 Feb 2017 05:30:13 +0100 Subject: Convert Language::Python test to spec. --- Library/Homebrew/test/language/python_spec.rb | 106 ++++++++++++++++++++++++++ Library/Homebrew/test/language_python_test.rb | 96 ----------------------- 2 files changed, 106 insertions(+), 96 deletions(-) create mode 100644 Library/Homebrew/test/language/python_spec.rb delete mode 100644 Library/Homebrew/test/language_python_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/language/python_spec.rb b/Library/Homebrew/test/language/python_spec.rb new file mode 100644 index 000000000..c78520897 --- /dev/null +++ b/Library/Homebrew/test/language/python_spec.rb @@ -0,0 +1,106 @@ +require "language/python" +require "resource" + +describe Language::Python::Virtualenv::Virtualenv do + subject { described_class.new(formula, dir, "python") } + + let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + + let(:resource) { double("resource", stage: true) } + let(:formula_bin) { dir/"formula_bin" } + let(:formula) { double("formula", resource: resource, bin: formula_bin) } + + after(:each) { dir.rmtree unless @dir.nil? } + + describe "#create" do + it "creates a virtual environment" do + expect(formula).to receive(:resource).with("homebrew-virtualenv").and_return(resource) + subject.create + end + + specify "virtual environment creation is idempotent" do + expect(formula).to receive(:resource).with("homebrew-virtualenv").and_return(resource) + subject.create + FileUtils.mkdir_p dir/"bin" + FileUtils.touch dir/"bin/python" + subject.create + FileUtils.rm dir/"bin/python" + end + end + + describe "#pip_install" do + it "accepts a string" do + expect(formula).to receive(:system) + .with(dir/"bin/pip", "install", "-v", "--no-deps", + "--no-binary", ":all:", "--ignore-installed", "foo") + .and_return(true) + subject.pip_install "foo" + end + + it "accepts a multi-line strings" do + expect(formula).to receive(:system) + .with(dir/"bin/pip", "install", "-v", "--no-deps", + "--no-binary", ":all:", "--ignore-installed", "foo", "bar") + .and_return(true) + + subject.pip_install <<-EOS.undent + foo + bar + EOS + end + + it "accepts an array" do + expect(formula).to receive(:system) + .with(dir/"bin/pip", "install", "-v", "--no-deps", + "--no-binary", ":all:", "--ignore-installed", "foo") + .and_return(true) + + expect(formula).to receive(:system) + .with(dir/"bin/pip", "install", "-v", "--no-deps", + "--no-binary", ":all:", "--ignore-installed", "bar") + .and_return(true) + + subject.pip_install ["foo", "bar"] + end + + it "accepts a Resource" do + res = Resource.new("test") + + expect(res).to receive(:stage).and_yield + expect(formula).to receive(:system) + .with(dir/"bin/pip", "install", "-v", "--no-deps", + "--no-binary", ":all:", "--ignore-installed", Pathname.pwd) + .and_return(true) + + subject.pip_install res + end + end + + describe "#pip_install_and_link" do + let(:src_bin) { dir/"bin" } + let(:dest_bin) { formula.bin } + + it "can link scripts" do + src_bin.mkpath + + expect(src_bin/"kilroy").not_to exist + expect(dest_bin/"kilroy").not_to exist + + FileUtils.touch src_bin/"irrelevant" + bin_before = Dir.glob(src_bin/"*") + FileUtils.touch src_bin/"kilroy" + bin_after = Dir.glob(src_bin/"*") + + expect(subject).to receive(:pip_install).with("foo") + expect(Dir).to receive(:[]).with(src_bin/"*").twice.and_return(bin_before, bin_after) + + subject.pip_install_and_link "foo" + + expect(src_bin/"kilroy").to exist + expect(dest_bin/"kilroy").to exist + expect(dest_bin/"kilroy").to be_a_symlink + expect((src_bin/"kilroy").realpath).to eq((dest_bin/"kilroy").realpath) + expect(dest_bin/"irrelevant").not_to exist + end + end +end diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb deleted file mode 100644 index cc21cbfbd..000000000 --- a/Library/Homebrew/test/language_python_test.rb +++ /dev/null @@ -1,96 +0,0 @@ -require "testing_env" -require "language/python" -require "resource" - -class LanguagePythonTests < Homebrew::TestCase - def setup - super - @dir = Pathname.new(mktmpdir) - resource = stub("resource", stage: true) - formula_bin = @dir/"formula_bin" - @formula = mock("formula") do - stubs(:resource).returns(resource) - stubs(:bin).returns(formula_bin) - end - @venv = Language::Python::Virtualenv::Virtualenv.new(@formula, @dir, "python") - end - - def test_virtualenv_creation - @formula.expects(:resource).with("homebrew-virtualenv").returns( - mock("resource", stage: true), - ) - @venv.create - end - - # or at least doesn't crash the second time - def test_virtualenv_creation_is_idempotent - @formula.expects(:resource).with("homebrew-virtualenv").returns( - mock("resource", stage: true), - ) - @venv.create - FileUtils.mkdir_p @dir/"bin" - FileUtils.touch @dir/"bin/python" - @venv.create - FileUtils.rm @dir/"bin/python" - end - - def test_pip_install_accepts_string - @formula.expects(:system).returns(true).with do |*params| - params.first == @dir/"bin/pip" && params.last == "foo" - end - @venv.pip_install "foo" - end - - def test_pip_install_accepts_multiline_string - @formula.expects(:system).returns(true).with do |*params| - params.first == @dir/"bin/pip" && params[-2..-1] == ["foo", "bar"] - end - @venv.pip_install <<-EOS.undent - foo - bar - EOS - end - - def test_pip_install_accepts_array - @formula.expects(:system).returns(true).with do |*params| - params.first == @dir/"bin/pip" && params.last == "foo" - end - @formula.expects(:system).returns(true).with do |*params| - params.first == @dir/"bin/pip" && params.last == "bar" - end - @venv.pip_install ["foo", "bar"] - end - - def test_pip_install_accepts_resource - res = Resource.new "test" - res.expects(:stage).yields(nil) - @formula.expects(:system).returns(true).with do |*params| - params.first == @dir/"bin/pip" && params.last == Pathname.pwd - end - @venv.pip_install res - end - - def test_pip_install_and_link_links_scripts - bin = @dir/"bin" - bin.mkpath - dest = @formula.bin - - refute_predicate bin/"kilroy", :exist? - refute_predicate dest/"kilroy", :exist? - - FileUtils.touch bin/"irrelevant" - bin_before = Dir[bin/"*"] - FileUtils.touch bin/"kilroy" - bin_after = Dir[bin/"*"] - @venv.expects(:pip_install).with("foo") - Dir.expects(:[]).twice.returns(bin_before, bin_after) - - @venv.pip_install_and_link "foo" - - assert_predicate bin/"kilroy", :exist? - assert_predicate dest/"kilroy", :exist? - assert_predicate dest/"kilroy", :symlink? - assert_equal((bin/"kilroy").realpath, (dest/"kilroy").realpath) - refute_predicate dest/"irrelevant", :exist? - end -end -- cgit v1.2.3 From aeaf3d594c5ba417bfad582f48c79a2883f8475c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 17 Feb 2017 18:35:26 +0100 Subject: Convert Utils::Shell test to spec. --- Library/Homebrew/test/shell_test.rb | 56 ------------------- Library/Homebrew/test/utils/shell_spec.rb | 93 +++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 56 deletions(-) delete mode 100644 Library/Homebrew/test/shell_test.rb create mode 100644 Library/Homebrew/test/utils/shell_spec.rb (limited to 'Library') diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb deleted file mode 100644 index 970489702..000000000 --- a/Library/Homebrew/test/shell_test.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "testing_env" -require "utils/shell" - -class ShellSmokeTest < Homebrew::TestCase - def test_path_to_shell - # raw command name - assert_equal :bash, Utils::Shell.path_to_shell("bash") - # full path - assert_equal :bash, Utils::Shell.path_to_shell("/bin/bash") - # versions - assert_equal :zsh, Utils::Shell.path_to_shell("zsh-5.2") - # strip newline too - assert_equal :zsh, Utils::Shell.path_to_shell("zsh-5.2\n") - end - - def test_path_to_shell_failure - assert_nil Utils::Shell.path_to_shell("") - assert_nil Utils::Shell.path_to_shell("@@@@@@") - assert_nil Utils::Shell.path_to_shell("invalid_shell-4.2") - end - - def test_sh_quote - assert_equal "''", Utils::Shell.sh_quote("") - assert_equal "\\\\", Utils::Shell.sh_quote("\\") - assert_equal "'\n'", Utils::Shell.sh_quote("\n") - assert_equal "\\$", Utils::Shell.sh_quote("$") - assert_equal "word", Utils::Shell.sh_quote("word") - end - - def test_csh_quote - assert_equal "''", Utils::Shell.csh_quote("") - assert_equal "\\\\", Utils::Shell.csh_quote("\\") - # note this test is different than for sh - assert_equal "'\\\n'", Utils::Shell.csh_quote("\n") - assert_equal "\\$", Utils::Shell.csh_quote("$") - assert_equal "word", Utils::Shell.csh_quote("word") - end - - def prepend_path_shell(shell, path, fragment) - ENV["SHELL"] = shell - - prepend_message = Utils::Shell.prepend_path_in_shell_profile(path) - assert( - prepend_message.start_with?(fragment), - "#{shell}: expected #{prepend_message} to match #{fragment}", - ) - end - - def test_prepend_path_in_shell_profile - prepend_path_shell "/bin/tcsh", "/path", "echo 'setenv PATH /path" - - prepend_path_shell "/bin/bash", "/path", "echo 'export PATH=\"/path" - - prepend_path_shell "/usr/local/bin/fish", "/path", "echo 'set -g fish_user_paths \"/path\" $fish_user_paths' >>" - end -end diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb new file mode 100644 index 000000000..c44bd8253 --- /dev/null +++ b/Library/Homebrew/test/utils/shell_spec.rb @@ -0,0 +1,93 @@ +require "utils/shell" + +describe Utils::Shell do + describe "::shell_profile" do + it "returns ~/.bash_profile by default" do + ENV["SHELL"] = "/bin/another_shell" + expect(subject.shell_profile).to eq("~/.bash_profile") + end + + it "returns ~/.bash_profile for Sh" do + ENV["SHELL"] = "/bin/another_shell" + expect(subject.shell_profile).to eq("~/.bash_profile") + end + + it "returns ~/.bash_profile for Bash" do + ENV["SHELL"] = "/bin/bash" + expect(subject.shell_profile).to eq("~/.bash_profile") + end + + it "returns ~/.zshrc for Zsh" do + ENV["SHELL"] = "/bin/zsh" + expect(subject.shell_profile).to eq("~/.zshrc") + end + + it "returns ~/.kshrc for Ksh" do + ENV["SHELL"] = "/bin/ksh" + expect(subject.shell_profile).to eq("~/.kshrc") + end + end + + describe "::path_to_shell" do + it "supports a raw command name" do + expect(subject.path_to_shell("bash")).to eq(:bash) + end + + it "supports full paths" do + expect(subject.path_to_shell("/bin/bash")).to eq(:bash) + end + + it "supports versions" do + expect(subject.path_to_shell("zsh-5.2")).to eq(:zsh) + end + + it "strips newlines" do + expect(subject.path_to_shell("zsh-5.2\n")).to eq(:zsh) + end + + it "returns nil when input is invalid" do + expect(subject.path_to_shell("")).to be nil + expect(subject.path_to_shell("@@@@@@")).to be nil + expect(subject.path_to_shell("invalid_shell-4.2")).to be nil + end + end + + specify "::sh_quote" do + expect(subject.sh_quote("")).to eq("''") + expect(subject.sh_quote("\\")).to eq("\\\\") + expect(subject.sh_quote("\n")).to eq("'\n'") + expect(subject.sh_quote("$")).to eq("\\$") + expect(subject.sh_quote("word")).to eq("word") + end + + specify "::csh_quote" do + expect(subject.csh_quote("")).to eq("''") + expect(subject.csh_quote("\\")).to eq("\\\\") + # note this test is different than for sh + expect(subject.csh_quote("\n")).to eq("'\\\n'") + expect(subject.csh_quote("$")).to eq("\\$") + expect(subject.csh_quote("word")).to eq("word") + end + + describe "::prepend_path_in_shell_profile" do + let(:path) { "/my/path" } + + it "supports Tcsh" do + ENV["SHELL"] = "/bin/tcsh" + expect(subject.prepend_path_in_shell_profile(path)) + .to start_with("echo 'setenv PATH #{path}:$") + end + + it "supports Bash" do + ENV["SHELL"] = "/bin/bash" + expect(subject.prepend_path_in_shell_profile(path)) + .to start_with("echo 'export PATH=\"#{path}:$") + end + + it "supports Fish" do + ENV["SHELL"] = "/usr/local/bin/fish" + expect(subject.prepend_path_in_shell_profile(path)) + .to start_with("echo 'set -g fish_user_paths \"#{path}\" $fish_user_paths' >>") + end + end +end -- cgit v1.2.3 From 262f357d86f145fad3c78b3d843b32ac4e384f5e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 18 Feb 2017 22:17:32 +0100 Subject: Convert CompilerFailure test to spec. --- Library/Homebrew/test/compiler_failure_spec.rb | 41 ++++++++++++++++++++ Library/Homebrew/test/compiler_failure_test.rb | 52 -------------------------- 2 files changed, 41 insertions(+), 52 deletions(-) create mode 100644 Library/Homebrew/test/compiler_failure_spec.rb delete mode 100644 Library/Homebrew/test/compiler_failure_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/compiler_failure_spec.rb b/Library/Homebrew/test/compiler_failure_spec.rb new file mode 100644 index 000000000..81e464a87 --- /dev/null +++ b/Library/Homebrew/test/compiler_failure_spec.rb @@ -0,0 +1,41 @@ +require "compilers" + +describe CompilerFailure do + matcher :fail_with do |expected| + match do |actual| + actual.fails_with?(expected) + end + end + + describe "::create" do + it "creates a failure when given a symbol" do + failure = described_class.create(:clang) + expect(failure).to fail_with(double("Compiler", name: :clang, version: 425)) + end + + it "can be given a build number in a block" do + failure = described_class.create(:clang) { build 211 } + expect(failure).to fail_with(double("Compiler", name: :clang, version: 210)) + expect(failure).not_to fail_with(double("Compiler", name: :clang, version: 318)) + end + + it "can be given an empty block" do + failure = described_class.create(:clang) {} + expect(failure).to fail_with(double("Compiler", name: :clang, version: 425)) + end + + it "creates a failure when given a hash" do + failure = described_class.create(gcc: "4.8") + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8")) + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8.1")) + expect(failure).not_to fail_with(double("Compiler", name: "gcc-4.7", version: "4.7")) + end + + it "creates a failure when given a hash and a block with aversion" do + failure = described_class.create(gcc: "4.8") { version "4.8.1" } + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8")) + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8.1")) + expect(failure).not_to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8.2")) + end + end +end diff --git a/Library/Homebrew/test/compiler_failure_test.rb b/Library/Homebrew/test/compiler_failure_test.rb deleted file mode 100644 index c0b74d128..000000000 --- a/Library/Homebrew/test/compiler_failure_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require "testing_env" -require "compilers" - -class CompilerFailureTests < Homebrew::TestCase - Compiler = Struct.new(:name, :version) - - def assert_fails_with(compiler, failure) - assert_operator failure, :fails_with?, compiler - end - - def refute_fails_with(compiler, failure) - refute_operator failure, :fails_with?, compiler - end - - def compiler(name, version) - Compiler.new(name, version) - end - - def create(spec, &block) - CompilerFailure.create(spec, &block) - end - - def test_create_with_symbol - failure = create(:clang) - assert_fails_with compiler(:clang, 425), failure - end - - def test_create_with_block - failure = create(:clang) { build 211 } - assert_fails_with compiler(:clang, 210), failure - refute_fails_with compiler(:clang, 318), failure - end - - def test_create_with_block_without_build - failure = create(:clang) {} - assert_fails_with compiler(:clang, 425), failure - end - - def test_create_with_hash - failure = create(gcc: "4.8") - assert_fails_with compiler("gcc-4.8", "4.8"), failure - assert_fails_with compiler("gcc-4.8", "4.8.1"), failure - refute_fails_with compiler("gcc-4.7", "4.7"), failure - end - - def test_create_with_hash_and_version - failure = create(gcc: "4.8") { version "4.8.1" } - assert_fails_with compiler("gcc-4.8", "4.8"), failure - assert_fails_with compiler("gcc-4.8", "4.8.1"), failure - refute_fails_with compiler("gcc-4.8", "4.8.2"), failure - end -end -- cgit v1.2.3 From e622116f277b49eec59f663417210c1770dd8c5a Mon Sep 17 00:00:00 2001 From: Bob W. Hogg Date: Sat, 18 Feb 2017 14:35:02 -0800 Subject: .simplecov: require English with capital E On case-sensitive filesystems, require "english" will fail with "cannot load such file -- english"--- Library/Homebrew/.simplecov | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/.simplecov b/Library/Homebrew/.simplecov index 952bb466b..f74aec72e 100755 --- a/Library/Homebrew/.simplecov +++ b/Library/Homebrew/.simplecov @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require "english" +require "English" SimpleCov.start do coverage_dir File.expand_path("../test/coverage", File.realpath(__FILE__)) -- cgit v1.2.3 From e84b3eaf485153158eaf7c3624eb72126ceb27b3 Mon Sep 17 00:00:00 2001 From: JCount Date: Sat, 18 Feb 2017 23:37:37 -0500 Subject: ARGV: add missing "--force" arg to formula_install_option_names --- Library/Homebrew/extend/ARGV.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 767ddc6e3..0825b13a7 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -16,11 +16,13 @@ module HomebrewArgvExtension --build-bottle --force-bottle --verbose + --force -i -v -d -g -s + -f ].freeze end -- cgit v1.2.3 From 5c185eaa4355810ccc6617cb078ee67d4fa0777c Mon Sep 17 00:00:00 2001 From: Michael Ledin Date: Sun, 19 Feb 2017 07:57:41 +0300 Subject: Expand glob patterns. --- .../cask/lib/hbc/artifact/uninstall_base.rb | 23 ++++++++++++++-------- .../cask/spec/cask/artifact/uninstall_spec.rb | 22 +++++++++++++++++---- .../Homebrew/cask/spec/cask/artifact/zap_spec.rb | 22 +++++++++++++++++---- .../fixtures/cask/Casks/with-installable.rb | 5 +++-- .../fixtures/cask/Casks/with-uninstall-delete.rb | 5 +++-- .../fixtures/cask/Casks/with-uninstall-trash.rb | 5 +++-- .../support/fixtures/cask/Casks/with-zap-delete.rb | 5 +++-- .../support/fixtures/cask/Casks/with-zap-trash.rb | 5 +++-- 8 files changed, 66 insertions(+), 26 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index cc47e05ad..75d210931 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -34,6 +34,10 @@ module Hbc end end + def self.expand_glob(path_strings) + path_strings.flat_map(&Pathname.method(:glob)) + end + def self.remove_relative_path_strings(action, path_strings) relative = path_strings.map do |path_string| path_string if %r{/\.\.(?:/|\Z)}.match(path_string) || !%r{\A/}.match(path_string) @@ -54,6 +58,13 @@ module Hbc path_strings - undeletable end + def self.prepare_path_strings(action, path_strings, expand_tilde) + path_strings = expand_path_strings(path_strings) if expand_tilde + path_strings = remove_relative_path_strings(action, path_strings) + path_strings = expand_glob(path_strings) + remove_undeletable_path_strings(action, path_strings) + end + def dispatch_uninstall_directives(expand_tilde: true) directives_set = @cask.artifacts[stanza] ohai "Running #{stanza} process for #{@cask}; your password may be necessary" @@ -225,9 +236,7 @@ module Hbc def uninstall_delete(directives, expand_tilde = true) Array(directives[:delete]).concat(Array(directives[:trash])).flatten.each_slice(PATH_ARG_SLICE_SIZE) do |path_slice| ohai "Removing files: #{path_slice.utf8_inspect}" - path_slice = self.class.expand_path_strings(path_slice) if expand_tilde - path_slice = self.class.remove_relative_path_strings(:delete, path_slice) - path_slice = self.class.remove_undeletable_path_strings(:delete, path_slice) + path_slice = self.class.prepare_path_strings(:delete, path_slice, expand_tilde) @command.run!("/bin/rm", args: path_slice.unshift("-rf", "--"), sudo: true) end end @@ -238,11 +247,9 @@ module Hbc uninstall_delete(directives, expand_tilde) end - def uninstall_rmdir(directives, expand_tilde = true) - Array(directives[:rmdir]).flatten.each do |directory| - directory = self.class.expand_path_strings([directory]).first if expand_tilde - directory = self.class.remove_relative_path_strings(:rmdir, [directory]).first - directory = self.class.remove_undeletable_path_strings(:rmdir, [directory]).first + def uninstall_rmdir(directories, expand_tilde = true) + action = :rmdir + self.class.prepare_path_strings(action, Array(directories[action]).flatten, expand_tilde).each do |directory| next if directory.to_s.empty? ohai "Removing directory if empty: #{directory.to_s.utf8_inspect}" directory = Pathname.new(directory) diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb index a38ed903e..05af462dc 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb @@ -7,7 +7,17 @@ describe Hbc::Artifact::Uninstall do Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand) } + let(:absolute_path) { Pathname.new("#{TEST_TMPDIR}/absolute_path") } + let(:path_with_tilde) { Pathname.new("#{TEST_TMPDIR}/path_with_tilde") } + let(:glob_path1) { Pathname.new("#{TEST_TMPDIR}/glob_path1") } + let(:glob_path2) { Pathname.new("#{TEST_TMPDIR}/glob_path2") } + before(:each) do + FileUtils.touch(absolute_path) + FileUtils.touch(path_with_tilde) + FileUtils.touch(glob_path1) + FileUtils.touch(glob_path2) + ENV["HOME"] = TEST_TMPDIR shutup do InstallHelper.install_without_artifacts(cask) end @@ -233,8 +243,10 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path), + absolute_path, + path_with_tilde, + glob_path1, + glob_path2), ) subject @@ -247,8 +259,10 @@ describe Hbc::Artifact::Uninstall do it "can uninstall" do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path), + absolute_path, + path_with_tilde, + glob_path1, + glob_path2), ) subject diff --git a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb index 50e132bfa..b87b6ce1c 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb @@ -8,7 +8,17 @@ describe Hbc::Artifact::Zap do Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand) } + let(:absolute_path) { Pathname.new("#{TEST_TMPDIR}/absolute_path") } + let(:path_with_tilde) { Pathname.new("#{TEST_TMPDIR}/path_with_tilde") } + let(:glob_path1) { Pathname.new("#{TEST_TMPDIR}/glob_path1") } + let(:glob_path2) { Pathname.new("#{TEST_TMPDIR}/glob_path2") } + before(:each) do + FileUtils.touch(absolute_path) + FileUtils.touch(path_with_tilde) + FileUtils.touch(glob_path1) + FileUtils.touch(glob_path2) + ENV["HOME"] = TEST_TMPDIR shutup do InstallHelper.install_without_artifacts(cask) end @@ -234,8 +244,10 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path), + absolute_path, + path_with_tilde, + glob_path1, + glob_path2), ) subject @@ -248,8 +260,10 @@ describe Hbc::Artifact::Zap do it "can zap" do Hbc::FakeSystemCommand.expects_command( sudo(%w[/bin/rm -rf --], - Pathname.new("/permissible/absolute/path"), - Pathname.new("~/permissible/path/with/tilde").expand_path), + absolute_path, + path_with_tilde, + glob_path1, + glob_path2), ) subject diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb index b0ad0c626..706b85f6b 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb @@ -11,8 +11,9 @@ cask 'with-installable' do quit: 'my.fancy.package.app', login_item: 'Fancy', delete: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', + "#{TEST_TMPDIR}/absolute_path", + '~/path_with_tilde', + "#{TEST_TMPDIR}/glob_path*", 'impermissible/relative/path', '/another/impermissible/../relative/path', ], diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb index cba51f18f..c7d2e4767 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb @@ -8,8 +8,9 @@ cask 'with-uninstall-delete' do pkg 'Fancy.pkg' uninstall delete: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', + "#{TEST_TMPDIR}/absolute_path", + '~/path_with_tilde', + "#{TEST_TMPDIR}/glob_path*", 'impermissible/relative/path', '/another/impermissible/../relative/path', ] diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb index 171780bb7..b085b3e32 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb @@ -8,8 +8,9 @@ cask 'with-uninstall-trash' do pkg 'Fancy.pkg' uninstall trash: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', + "#{TEST_TMPDIR}/absolute_path", + '~/path_with_tilde', + "#{TEST_TMPDIR}/glob_path*", 'impermissible/relative/path', '/another/impermissible/../relative/path', ] diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb index a0ab83fc2..d81a387f9 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb @@ -8,8 +8,9 @@ cask 'with-zap-delete' do pkg 'Fancy.pkg' zap delete: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', + "#{TEST_TMPDIR}/absolute_path", + '~/path_with_tilde', + "#{TEST_TMPDIR}/glob_path*", 'impermissible/relative/path', '/another/impermissible/../relative/path', ] diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb index 8f4e91d67..ea2bc2a01 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb @@ -8,8 +8,9 @@ cask 'with-zap-trash' do pkg 'Fancy.pkg' zap trash: [ - '/permissible/absolute/path', - '~/permissible/path/with/tilde', + "#{TEST_TMPDIR}/absolute_path", + '~/path_with_tilde', + "#{TEST_TMPDIR}/glob_path*", 'impermissible/relative/path', '/another/impermissible/../relative/path', ] -- cgit v1.2.3 From 92fe130cbb1faef375c6cb86bae02551882fd72d Mon Sep 17 00:00:00 2001 From: Michael Ledin Date: Sun, 19 Feb 2017 07:59:57 +0300 Subject: Use TEST_TMPDIR in rmdir tests. --- Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb | 14 +++++++++++--- Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb | 14 +++++++++++--- .../test/support/fixtures/cask/Casks/with-installable.rb | 2 +- .../support/fixtures/cask/Casks/with-uninstall-rmdir.rb | 2 +- .../test/support/fixtures/cask/Casks/with-zap-rmdir.rb | 2 +- .../test/support/fixtures/cask/empty_directory/.gitignore | 0 6 files changed, 25 insertions(+), 9 deletions(-) delete mode 100644 Library/Homebrew/test/support/fixtures/cask/empty_directory/.gitignore (limited to 'Library') diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb index 05af462dc..e3595621d 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb @@ -271,15 +271,23 @@ describe Hbc::Artifact::Uninstall do context "when using rmdir" do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") } - let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } + let(:empty_directory_path) { Pathname.new("#{TEST_TMPDIR}/empty_directory_path") } + + before(:each) do + empty_directory_path.mkdir + end + + after(:each) do + empty_directory_path.rmdir + end it "can uninstall" do Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")), + sudo(%w[/bin/rm -f --], empty_directory_path/".DS_Store"), ) Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rmdir --], dir_pathname), + sudo(%w[/bin/rmdir --], empty_directory_path), ) subject diff --git a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb index b87b6ce1c..c49cebbb8 100644 --- a/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb +++ b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb @@ -272,15 +272,23 @@ describe Hbc::Artifact::Zap do context "when using rmdir" do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") } - let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") } + let(:empty_directory_path) { Pathname.new("#{TEST_TMPDIR}/empty_directory_path") } + + before(:each) do + empty_directory_path.mkdir + end + + after(:each) do + empty_directory_path.rmdir + end it "can zap" do Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rm -f --], dir_pathname.join(".DS_Store")), + sudo(%w[/bin/rm -f --], empty_directory_path/".DS_Store"), ) Hbc::FakeSystemCommand.expects_command( - sudo(%w[/bin/rmdir --], dir_pathname), + sudo(%w[/bin/rmdir --], empty_directory_path), ) subject diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb index 706b85f6b..8416f3f88 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb @@ -17,5 +17,5 @@ cask 'with-installable' do 'impermissible/relative/path', '/another/impermissible/../relative/path', ], - rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" + rmdir: "#{TEST_TMPDIR}/empty_directory_path" end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb index 252d81994..8ded5b835 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb @@ -7,5 +7,5 @@ cask 'with-uninstall-rmdir' do pkg 'MyFancyPkg/Fancy.pkg' - uninstall rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" + uninstall rmdir: "#{TEST_TMPDIR}/empty_directory_path" end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb index 02139b3b0..a67c4ca9a 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb @@ -7,5 +7,5 @@ cask 'with-zap-rmdir' do pkg 'MyFancyPkg/Fancy.pkg' - zap rmdir: "#{TEST_FIXTURE_DIR}/cask/empty_directory" + zap rmdir: "#{TEST_TMPDIR}/empty_directory_path" end diff --git a/Library/Homebrew/test/support/fixtures/cask/empty_directory/.gitignore b/Library/Homebrew/test/support/fixtures/cask/empty_directory/.gitignore deleted file mode 100644 index e69de29bb..000000000 -- cgit v1.2.3 From df50a7e56e5947dce3bbbec671dfb9312dd2bbd1 Mon Sep 17 00:00:00 2001 From: Sergey Parhomenko Date: Sun, 19 Feb 2017 14:06:51 +0100 Subject: Add /usr/libexec/cups to the list of system dirs --- Library/Homebrew/cask/lib/hbc/macos.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/macos.rb b/Library/Homebrew/cask/lib/hbc/macos.rb index 5c1515d0c..d47e04fb2 100644 --- a/Library/Homebrew/cask/lib/hbc/macos.rb +++ b/Library/Homebrew/cask/lib/hbc/macos.rb @@ -181,6 +181,7 @@ module OS "/usr/include", "/usr/lib", "/usr/libexec", + "/usr/libexec/cups", "/usr/local", "/usr/local/Cellar", "/usr/local/Frameworks", -- cgit v1.2.3 From 0c4eb95b9f42b6bf7057254cddd7d7fddde8cd97 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 19 Feb 2017 15:39:52 +0000 Subject: diagnostic: strip trailing whitespace. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 4da59bc2f..c7dabde2b 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -54,7 +54,7 @@ module Homebrew return unless MacOS::Xcode.outdated? # Travis CI images are going to end up outdated so don't complain when - # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew + # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew # repository. This only needs to support whatever CI provider # Homebrew/brew is currently using. return if ENV["TRAVIS"] -- cgit v1.2.3 From 92710c50c65beccfc2fca744cc8ee1be19a87aad Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 23:53:06 +0100 Subject: Convert Download Strategies test to spec. --- Library/Homebrew/test/download_strategies_spec.rb | 232 ++++++++++++++++++++ Library/Homebrew/test/download_strategies_test.rb | 245 ---------------------- 2 files changed, 232 insertions(+), 245 deletions(-) create mode 100644 Library/Homebrew/test/download_strategies_spec.rb delete mode 100644 Library/Homebrew/test/download_strategies_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/download_strategies_spec.rb b/Library/Homebrew/test/download_strategies_spec.rb new file mode 100644 index 000000000..f466b97f4 --- /dev/null +++ b/Library/Homebrew/test/download_strategies_spec.rb @@ -0,0 +1,232 @@ +require "download_strategy" + +describe AbstractDownloadStrategy do + subject { described_class.new(name, resource) } + let(:name) { "foo" } + let(:url) { "http://example.com/foo.tar.gz" } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: nil) } + let(:args) { %w[foo bar baz] } + + describe "#expand_safe_system_args" do + it "works with an explicit quiet flag" do + args << { quiet_flag: "--flag" } + expanded_args = subject.expand_safe_system_args(args) + expect(expanded_args).to eq(%w[foo bar baz --flag]) + end + + it "adds an implicit quiet flag" do + expanded_args = subject.expand_safe_system_args(args) + expect(expanded_args).to eq(%w[foo bar -q baz]) + end + + it "does not mutate the arguments" do + result = subject.expand_safe_system_args(args) + expect(args).to eq(%w[foo bar baz]) + expect(result).not_to be args + end + end + + specify "#source_modified_time" do + FileUtils.mktemp "mtime" do + FileUtils.touch "foo", mtime: Time.now - 10 + FileUtils.touch "bar", mtime: Time.now - 100 + FileUtils.ln_s "not-exist", "baz" + expect(subject.source_modified_time).to eq(File.mtime("foo")) + end + end +end + +describe VCSDownloadStrategy do + let(:url) { "http://example.com/bar" } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: nil) } + + describe "#cached_location" do + it "returns the path of the cached resource" do + allow_any_instance_of(described_class).to receive(:cache_tag).and_return("foo") + downloader = described_class.new("baz", resource) + expect(downloader.cached_location).to eq(HOMEBREW_CACHE/"baz--foo") + end + end +end + +describe GitHubPrivateRepositoryDownloadStrategy do + subject { described_class.new("foo", resource) } + let(:url) { "https://github.com/owner/repo/archive/1.1.5.tar.gz" } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: nil) } + + before(:each) do + ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" + allow(GitHub).to receive(:repository).and_return({}) + end + + it "sets the @github_token instance variable" do + expect(subject.instance_variable_get(:@github_token)).to eq("token") + end + + it "parses the URL and sets the corresponding instance variables" do + expect(subject.instance_variable_get(:@owner)).to eq("owner") + expect(subject.instance_variable_get(:@repo)).to eq("repo") + expect(subject.instance_variable_get(:@filepath)).to eq("archive/1.1.5.tar.gz") + end + + its(:download_url) { is_expected.to eq("https://token@github.com/owner/repo/archive/1.1.5.tar.gz") } +end + +describe GitHubPrivateRepositoryReleaseDownloadStrategy do + subject { described_class.new("foo", resource) } + let(:url) { "https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz" } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: nil) } + + before(:each) do + ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" + allow(GitHub).to receive(:repository).and_return({}) + end + + it "parses the URL and sets the corresponding instance variables" do + expect(subject.instance_variable_get(:@owner)).to eq("owner") + expect(subject.instance_variable_get(:@repo)).to eq("repo") + expect(subject.instance_variable_get(:@tag)).to eq("tag") + expect(subject.instance_variable_get(:@filename)).to eq("foo_v0.1.0_darwin_amd64.tar.gz") + end + + describe "#download_url" do + it "returns the download URL for a given resource" do + allow(subject).to receive(:resolve_asset_id).and_return(456) + expect(subject.download_url).to eq("https://token@api.github.com/repos/owner/repo/releases/assets/456") + end + end + + specify "#resolve_asset_id" do + release_metadata = { + "assets" => [ + { + "id" => 123, + "name" => "foo_v0.1.0_linux_amd64.tar.gz", + }, + { + "id" => 456, + "name" => "foo_v0.1.0_darwin_amd64.tar.gz", + }, + ], + } + allow(subject).to receive(:fetch_release_metadata).and_return(release_metadata) + expect(subject.send(:resolve_asset_id)).to eq(456) + end + + describe "#fetch_release_metadata" do + it "fetches release metadata from GitHub" do + expected_release_url = "https://api.github.com/repos/owner/repo/releases/tags/tag" + expect(GitHub).to receive(:open).with(expected_release_url).and_return({}) + subject.send(:fetch_release_metadata) + end + end +end + +describe GitHubGitDownloadStrategy do + subject { described_class.new(name, resource) } + let(:name) { "brew" } + let(:url) { "https://github.com/homebrew/brew.git" } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: nil) } + + it "parses the URL and sets the corresponding instance variables" do + expect(subject.instance_variable_get(:@user)).to eq("homebrew") + expect(subject.instance_variable_get(:@repo)).to eq("brew") + end +end + +describe GitDownloadStrategy do + subject { described_class.new(name, resource) } + let(:name) { "baz" } + let(:url) { "https://github.com/homebrew/foo" } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: nil) } + let(:cached_location) { subject.cached_location } + + before(:each) do + @commit_id = 1 + FileUtils.mkpath cached_location + end + + def git_commit_all + shutup do + system "git", "add", "--all" + system "git", "commit", "-m", "commit number #{@commit_id}" + @commit_id += 1 + end + end + + def setup_git_repo + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + end + FileUtils.touch "README" + git_commit_all + end + + describe "#source_modified_time" do + it "returns the right modification time" do + cached_location.cd do + setup_git_repo + end + expect(subject.source_modified_time.to_i).to eq(1_485_115_153) + end + end + + specify "#last_commit" do + cached_location.cd do + setup_git_repo + FileUtils.touch "LICENSE" + git_commit_all + end + expect(subject.last_commit).to eq("f68266e") + end + + describe "#fetch_last_commit" do + let(:url) { "file://#{remote_repo}" } + let(:version) { Version.create("HEAD") } + let(:resource) { double(Resource, url: url, mirrors: [], specs: {}, version: version) } + let(:remote_repo) { HOMEBREW_PREFIX/"remote_repo" } + + before(:each) { remote_repo.mkpath } + + after(:each) { FileUtils.rm_rf remote_repo } + + it "fetches the hash of the last commit" do + remote_repo.cd do + setup_git_repo + FileUtils.touch "LICENSE" + git_commit_all + end + + subject.shutup! + expect(subject.fetch_last_commit).to eq("f68266e") + end + end +end + +describe DownloadStrategyDetector do + describe "::detect" do + subject { described_class.detect(url) } + let(:url) { Object.new } + + context "when given Git URL" do + let(:url) { "git://example.com/foo.git" } + it { is_expected.to eq(GitDownloadStrategy) } + end + + context "when given a GitHub Git URL" do + let(:url) { "https://github.com/homebrew/brew.git" } + it { is_expected.to eq(GitHubGitDownloadStrategy) } + end + + it "defaults to cURL" do + expect(subject).to eq(CurlDownloadStrategy) + end + + it "raises an error when passed an unrecognized strategy" do + expect { + described_class.detect("foo", Class.new) + }.to raise_error(TypeError) + end + end +end diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb deleted file mode 100644 index 40236b420..000000000 --- a/Library/Homebrew/test/download_strategies_test.rb +++ /dev/null @@ -1,245 +0,0 @@ -require "testing_env" -require "download_strategy" - -class ResourceDouble - attr_reader :url, :specs, :version, :mirrors - - def initialize(url = "http://example.com/foo.tar.gz", specs = {}) - @url = url - @specs = specs - @mirrors = [] - end -end - -class AbstractDownloadStrategyTests < Homebrew::TestCase - include FileUtils - - def setup - super - @name = "foo" - @resource = ResourceDouble.new - @strategy = AbstractDownloadStrategy.new(@name, @resource) - @args = %w[foo bar baz] - end - - def test_expand_safe_system_args_with_explicit_quiet_flag - @args << { quiet_flag: "--flag" } - expanded_args = @strategy.expand_safe_system_args(@args) - assert_equal %w[foo bar baz --flag], expanded_args - end - - def test_expand_safe_system_args_with_implicit_quiet_flag - expanded_args = @strategy.expand_safe_system_args(@args) - assert_equal %w[foo bar -q baz], expanded_args - end - - def test_expand_safe_system_args_does_not_mutate_argument - result = @strategy.expand_safe_system_args(@args) - assert_equal %w[foo bar baz], @args - refute_same @args, result - end - - def test_source_modified_time - mktemp "mtime" do - touch "foo", mtime: Time.now - 10 - touch "bar", mtime: Time.now - 100 - ln_s "not-exist", "baz" - assert_equal File.mtime("foo"), @strategy.source_modified_time - end - end -end - -class VCSDownloadStrategyTests < Homebrew::TestCase - def test_cache_filename - resource = ResourceDouble.new("http://example.com/bar") - strategy = Class.new(VCSDownloadStrategy) do - def cache_tag - "foo" - end - end - downloader = strategy.new("baz", resource) - assert_equal HOMEBREW_CACHE.join("baz--foo"), downloader.cached_location - end -end - -class GitHubPrivateRepositoryDownloadStrategyTests < Homebrew::TestCase - def setup - super - resource = ResourceDouble.new("https://github.com/owner/repo/archive/1.1.5.tar.gz") - ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" - GitHub.stubs(:repository).returns {} - @strategy = GitHubPrivateRepositoryDownloadStrategy.new("foo", resource) - end - - def test_set_github_token - assert_equal "token", @strategy.instance_variable_get(:@github_token) - end - - def test_parse_url_pattern - assert_equal "owner", @strategy.instance_variable_get(:@owner) - assert_equal "repo", @strategy.instance_variable_get(:@repo) - assert_equal "archive/1.1.5.tar.gz", @strategy.instance_variable_get(:@filepath) - end - - def test_download_url - expected = "https://token@github.com/owner/repo/archive/1.1.5.tar.gz" - assert_equal expected, @strategy.download_url - end -end - -class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase - def setup - super - resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") - ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" - GitHub.stubs(:repository).returns {} - @strategy = GitHubPrivateRepositoryReleaseDownloadStrategy.new("foo", resource) - end - - def test_parse_url_pattern - assert_equal "owner", @strategy.instance_variable_get(:@owner) - assert_equal "repo", @strategy.instance_variable_get(:@repo) - assert_equal "tag", @strategy.instance_variable_get(:@tag) - assert_equal "foo_v0.1.0_darwin_amd64.tar.gz", @strategy.instance_variable_get(:@filename) - end - - def test_download_url - @strategy.stubs(:resolve_asset_id).returns(456) - expected = "https://token@api.github.com/repos/owner/repo/releases/assets/456" - assert_equal expected, @strategy.download_url - end - - def test_resolve_asset_id - release_metadata = { - "assets" => [ - { - "id" => 123, - "name" => "foo_v0.1.0_linux_amd64.tar.gz", - }, - { - "id" => 456, - "name" => "foo_v0.1.0_darwin_amd64.tar.gz", - }, - ], - } - @strategy.stubs(:fetch_release_metadata).returns(release_metadata) - assert_equal 456, @strategy.send(:resolve_asset_id) - end - - def test_fetch_release_metadata - expected_release_url = "https://api.github.com/repos/owner/repo/releases/tags/tag" - github_mock = MiniTest::Mock.new - github_mock.expect :call, {}, [expected_release_url] - GitHub.stub :open, github_mock do - @strategy.send(:fetch_release_metadata) - end - github_mock.verify - end -end - -class GitDownloadStrategyTests < Homebrew::TestCase - include FileUtils - - def setup - super - resource = ResourceDouble.new("https://github.com/homebrew/foo") - @commit_id = 1 - @strategy = GitDownloadStrategy.new("baz", resource) - @cached_location = @strategy.cached_location - mkpath @cached_location - end - - def git_commit_all - shutup do - system "git", "add", "--all" - system "git", "commit", "-m", "commit number #{@commit_id}" - @commit_id += 1 - end - end - - def setup_git_repo - @cached_location.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - end - touch "README" - git_commit_all - end - end - - def test_github_git_download_strategy_user_repo - resource = ResourceDouble.new("https://github.com/homebrew/brew.git") - strategy = GitHubGitDownloadStrategy.new("brew", resource) - - assert_equal strategy.instance_variable_get(:@user), "homebrew" - assert_equal strategy.instance_variable_get(:@repo), "brew" - end - - def test_source_modified_time - setup_git_repo - assert_equal 1_485_115_153, @strategy.source_modified_time.to_i - end - - def test_last_commit - setup_git_repo - @cached_location.cd do - touch "LICENSE" - git_commit_all - end - assert_equal "f68266e", @strategy.last_commit - end - - def test_fetch_last_commit - remote_repo = HOMEBREW_PREFIX.join("remote_repo") - remote_repo.mkdir - - resource = ResourceDouble.new("file://#{remote_repo}") - resource.instance_variable_set(:@version, Version.create("HEAD")) - @strategy = GitDownloadStrategy.new("baz", resource) - - remote_repo.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - end - touch "README" - git_commit_all - touch "LICENSE" - git_commit_all - end - - @strategy.shutup! - assert_equal "f68266e", @strategy.fetch_last_commit - ensure - remote_repo.rmtree if remote_repo.directory? - end -end - -class DownloadStrategyDetectorTests < Homebrew::TestCase - def setup - super - @d = DownloadStrategyDetector.new - end - - def test_detect_git_download_startegy - @d = DownloadStrategyDetector.detect("git://example.com/foo.git") - assert_equal GitDownloadStrategy, @d - end - - def test_detect_github_git_download_strategy - @d = DownloadStrategyDetector.detect("https://github.com/homebrew/brew.git") - assert_equal GitHubGitDownloadStrategy, @d - end - - def test_default_to_curl_strategy - @d = DownloadStrategyDetector.detect(Object.new) - assert_equal CurlDownloadStrategy, @d - end - - def test_raises_when_passed_unrecognized_strategy - assert_raises(TypeError) do - DownloadStrategyDetector.detect("foo", Class.new) - end - end -end -- cgit v1.2.3 From 05a98f24c4d21b3a3c7fcb4045e74619a4628f4c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 16 Feb 2017 21:17:46 +0100 Subject: Convert Utils test to spec. --- .../Homebrew/test/utils/bottles/bintray_spec.rb | 18 ++ Library/Homebrew/test/utils/popen_spec.rb | 28 ++ Library/Homebrew/test/utils_spec.rb | 283 +++++++++++++++++++++ Library/Homebrew/test/utils_test.rb | 252 ------------------ 4 files changed, 329 insertions(+), 252 deletions(-) create mode 100644 Library/Homebrew/test/utils/bottles/bintray_spec.rb create mode 100644 Library/Homebrew/test/utils/popen_spec.rb create mode 100644 Library/Homebrew/test/utils_spec.rb delete mode 100644 Library/Homebrew/test/utils_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/utils/bottles/bintray_spec.rb b/Library/Homebrew/test/utils/bottles/bintray_spec.rb new file mode 100644 index 000000000..a7dfc00ea --- /dev/null +++ b/Library/Homebrew/test/utils/bottles/bintray_spec.rb @@ -0,0 +1,18 @@ +require "utils/bottles" + +describe Utils::Bottles::Bintray do + describe "::package" do + it "converts a Formula name to a package name" do + expect(described_class.package("openssl@1.1")).to eq("openssl:1.1") + expect(described_class.package("gtk+")).to eq("gtkx") + expect(described_class.package("llvm")).to eq("llvm") + end + end + + describe "::repository" do + it "returns the repository for a given Tap" do + expect(described_class.repository(Tap.new("homebrew", "bintray-test"))) + .to eq("bottles-bintray-test") + end + end +end diff --git a/Library/Homebrew/test/utils/popen_spec.rb b/Library/Homebrew/test/utils/popen_spec.rb new file mode 100644 index 000000000..e3704a876 --- /dev/null +++ b/Library/Homebrew/test/utils/popen_spec.rb @@ -0,0 +1,28 @@ +require "utils/popen" + +describe Utils do + describe "::popen_read" do + it "reads the standard output of a given command" do + expect(subject.popen_read("sh", "-c", "echo success").chomp).to eq("success") + expect($?).to be_a_success + end + + it "can be given a block to manually read from the pipe" do + expect( + subject.popen_read("sh", "-c", "echo success") do |pipe| + pipe.read.chomp + end, + ).to eq("success") + expect($?).to be_a_success + end + end + + describe "::popen_write" do + it "with supports writing to a command's standard input" do + subject.popen_write("grep", "-q", "success") do |pipe| + pipe.write("success\n") + end + expect($?).to be_a_success + end + end +end diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb new file mode 100644 index 000000000..de6b287d2 --- /dev/null +++ b/Library/Homebrew/test/utils_spec.rb @@ -0,0 +1,283 @@ +require "utils" + +RSpec::Matchers.alias_matcher :have_failed, :be_failed + +describe "globally-scoped helper methods" do + let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + + after(:each) { dir.rmtree unless @dir.nil? } + + def esc(code) + /(\e\[\d+m)*\e\[#{code}m/ + end + + describe "#ofail" do + it "sets Homebrew.failed to true" do + begin + shutup do + ofail "foo" + end + + expect(Homebrew).to have_failed + ensure + Homebrew.failed = false + end + end + end + + describe "#odie" do + it "exits with 1" do + expect(self).to receive(:exit).and_return(1) + expect { + odie "foo" + }.to output("Error: foo\n").to_stderr + end + end + + describe "#pretty_installed" do + subject { pretty_installed("foo") } + + context "when $stdout is a TTY" do + before(:each) { allow($stdout).to receive(:tty?).and_return(true) } + + context "with HOMEBREW_NO_EMOJI unset" do + before(:each) { ENV.delete("HOMEBREW_NO_EMOJI") } + + it "returns a string with a colored checkmark" do + expect(subject) + .to match(/#{esc 1}foo #{esc 32}✔#{esc 0}/) + end + end + + context "with HOMEBREW_NO_EMOJI set" do + before(:each) { ENV["HOMEBREW_NO_EMOJI"] = "1" } + + it "returns a string with colored info" do + expect(subject) + .to match(/#{esc 1}foo \(installed\)#{esc 0}/) + end + end + end + + context "when $stdout is not a TTY" do + before(:each) { allow($stdout).to receive(:tty?).and_return(false) } + + it "returns plain text" do + expect(subject).to eq("foo") + end + end + end + + describe "#pretty_uninstalled" do + subject { pretty_uninstalled("foo") } + + context "when $stdout is a TTY" do + before(:each) { allow($stdout).to receive(:tty?).and_return(true) } + + context "with HOMEBREW_NO_EMOJI unset" do + before(:each) { ENV.delete("HOMEBREW_NO_EMOJI") } + + it "returns a string with a colored checkmark" do + expect(subject) + .to match(/#{esc 1}foo #{esc 31}✘#{esc 0}/) + end + end + + context "with HOMEBREW_NO_EMOJI set" do + before(:each) { ENV["HOMEBREW_NO_EMOJI"] = "1" } + + it "returns a string with colored info" do + expect(subject) + .to match(/#{esc 1}foo \(uninstalled\)#{esc 0}/) + end + end + end + + context "when $stdout is not a TTY" do + before(:each) { allow($stdout).to receive(:tty?).and_return(false) } + + it "returns plain text" do + expect(subject).to eq("foo") + end + end + end + + describe "#interactive_shell" do + let(:shell) { dir/"myshell" } + + it "starts an interactive shell session" do + IO.write shell, <<-EOS.undent + #!/bin/sh + echo called > "#{dir}/called" + EOS + + FileUtils.chmod 0755, shell + + ENV["SHELL"] = shell + + expect { interactive_shell }.not_to raise_error + expect(dir/"called").to exist + end + end + + describe "#with_custom_locale" do + it "temporarily overrides the system locale" do + ENV["LC_ALL"] = "en_US.UTF-8" + + with_custom_locale("C") do + expect(ENV["LC_ALL"]).to eq("C") + end + + expect(ENV["LC_ALL"]).to eq("en_US.UTF-8") + end + end + + describe "#run_as_not_developer" do + it "temporarily unsets HOMEBREW_DEVELOPER" do + ENV["HOMEBREW_DEVELOPER"] = "foo" + + run_as_not_developer do + expect(ENV["HOMEBREW_DEVELOPER"]).to be nil + end + + expect(ENV["HOMEBREW_DEVELOPER"]).to eq("foo") + end + end + + describe "#which" do + let(:cmd) { dir/"foo" } + + before(:each) { FileUtils.touch cmd } + + it "returns the first executable that is found" do + cmd.chmod 0744 + expect(which(File.basename(cmd), File.dirname(cmd))).to eq(cmd) + end + + it "skips non-executables" do + expect(which(File.basename(cmd), File.dirname(cmd))).to be nil + end + + it "skips malformed path and doesn't fail" do + # 'which' should not fail if a path is malformed + # see https://github.com/Homebrew/legacy-homebrew/issues/32789 for an example + cmd.chmod 0744 + + # ~~ will fail because ~foo resolves to foo's home and there is no '~' user + path = ["~~", File.dirname(cmd)].join(File::PATH_SEPARATOR) + expect(which(File.basename(cmd), path)).to eq(cmd) + end + end + + describe "#which_all" do + let(:cmd1) { dir/"foo" } + let(:cmd2) { dir/"bar/foo" } + let(:cmd3) { dir/"bar/baz/foo" } + + before(:each) do + (dir/"bar/baz").mkpath + + FileUtils.touch cmd2 + + [cmd1, cmd3].each do |cmd| + FileUtils.touch cmd + cmd.chmod 0744 + end + end + + it "returns an array of all executables that are found" do + path = [ + "#{dir}/bar/baz", + "#{dir}/baz:#{dir}", + "~baduserpath", + ].join(File::PATH_SEPARATOR) + expect(which_all("foo", path)).to eq([cmd3, cmd1]) + end + end + + specify "#which_editor" do + ENV["HOMEBREW_EDITOR"] = "vemate" + expect(which_editor).to eq("vemate") + end + + specify "#gzip" do + Dir.mktmpdir do |path| + path = Pathname.new(path) + somefile = path/"somefile" + FileUtils.touch somefile + expect(gzip(somefile)[0].to_s).to eq("#{somefile}.gz") + expect(Pathname.new("#{somefile}.gz")).to exist + end + end + + specify "#capture_stderr" do + err = capture_stderr do + $stderr.print "test" + end + + expect(err).to eq("test") + end + + describe "#pretty_duration" do + it "converts seconds to a human-readable string" do + expect(pretty_duration(1)).to eq("1 second") + expect(pretty_duration(2.5)).to eq("2 seconds") + expect(pretty_duration(42)).to eq("42 seconds") + expect(pretty_duration(240)).to eq("4 minutes") + expect(pretty_duration(252.45)).to eq("4 minutes 12 seconds") + end + end + + specify "#plural" do + expect(plural(1)).to eq("") + expect(plural(0)).to eq("s") + expect(plural(42)).to eq("s") + expect(plural(42, "")).to eq("") + end + + specify "#disk_usage_readable" do + expect(disk_usage_readable(1)).to eq("1B") + expect(disk_usage_readable(1000)).to eq("1000B") + expect(disk_usage_readable(1024)).to eq("1K") + expect(disk_usage_readable(1025)).to eq("1K") + expect(disk_usage_readable(4_404_020)).to eq("4.2M") + expect(disk_usage_readable(4_509_715_660)).to eq("4.2G") + end + + describe "#number_readable" do + it "returns a string with thousands separators" do + expect(number_readable(1)).to eq("1") + expect(number_readable(1_000)).to eq("1,000") + expect(number_readable(1_000_000)).to eq("1,000,000") + end + end + + specify "#truncate_text_to_approximate_size" do + glue = "\n[...snip...]\n" # hard-coded copy from truncate_text_to_approximate_size + n = 20 + long_s = "x" * 40 + + s = truncate_text_to_approximate_size(long_s, n) + expect(s.length).to eq(n) + expect(s).to match(/^x+#{Regexp.escape(glue)}x+$/) + + s = truncate_text_to_approximate_size(long_s, n, front_weight: 0.0) + expect(s).to eq(glue + ("x" * (n - glue.length))) + + s = truncate_text_to_approximate_size(long_s, n, front_weight: 1.0) + expect(s).to eq(("x" * (n - glue.length)) + glue) + end + + describe "#odeprecated" do + it "raises a MethodDeprecatedError" do + ENV.delete("HOMEBREW_DEVELOPER") + expect { + odeprecated( + "method", "replacement", + caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], + disable: true + ) + }.to raise_error(MethodDeprecatedError, %r{method.*replacement.*homebrew/homebrew-core.*homebrew/core}m) + end + end +end diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb deleted file mode 100644 index 1f2fb7b55..000000000 --- a/Library/Homebrew/test/utils_test.rb +++ /dev/null @@ -1,252 +0,0 @@ -require "testing_env" -require "utils" -require "tempfile" -require "utils/shell" - -class UtilTests < Homebrew::TestCase - def setup - super - @dir = Pathname.new(mktmpdir) - end - - def esc(code) - /(\e\[\d+m)*\e\[#{code}m/ - end - - def test_ofail - shutup { ofail "foo" } - assert Homebrew.failed? - ensure - Homebrew.failed = false - end - - def test_odie - expects(:exit).returns 1 - shutup { odie "foo" } - end - - def test_pretty_installed - $stdout.stubs(:tty?).returns true - ENV.delete("HOMEBREW_NO_EMOJI") - tty_with_emoji_output = /\A#{esc 1}foo #{esc 32}✔#{esc 0}\Z/ - assert_match tty_with_emoji_output, pretty_installed("foo") - - ENV["HOMEBREW_NO_EMOJI"] = "1" - tty_no_emoji_output = /\A#{esc 1}foo \(installed\)#{esc 0}\Z/ - assert_match tty_no_emoji_output, pretty_installed("foo") - - $stdout.stubs(:tty?).returns false - assert_equal "foo", pretty_installed("foo") - end - - def test_pretty_uninstalled - $stdout.stubs(:tty?).returns true - ENV.delete("HOMEBREW_NO_EMOJI") - tty_with_emoji_output = /\A#{esc 1}foo #{esc 31}✘#{esc 0}\Z/ - assert_match tty_with_emoji_output, pretty_uninstalled("foo") - - ENV["HOMEBREW_NO_EMOJI"] = "1" - tty_no_emoji_output = /\A#{esc 1}foo \(uninstalled\)#{esc 0}\Z/ - assert_match tty_no_emoji_output, pretty_uninstalled("foo") - - $stdout.stubs(:tty?).returns false - assert_equal "foo", pretty_uninstalled("foo") - end - - def test_interactive_shell - mktmpdir do |path| - shell = "#{path}/myshell" - File.open(shell, "w") do |file| - file.write "#!/bin/sh\necho called > #{path}/called\n" - end - FileUtils.chmod 0755, shell - ENV["SHELL"] = shell - assert_nothing_raised { interactive_shell } - assert File.exist? "#{path}/called" - end - end - - def test_with_custom_locale - ENV["LC_ALL"] = "en_US.UTF-8" - with_custom_locale("C") do - assert_equal "C", ENV["LC_ALL"] - end - assert_equal "en_US.UTF-8", ENV["LC_ALL"] - end - - def test_run_as_not_developer - ENV["HOMEBREW_DEVELOPER"] = "foo" - run_as_not_developer do - assert_nil ENV["HOMEBREW_DEVELOPER"] - end - assert_equal "foo", ENV["HOMEBREW_DEVELOPER"] - end - - def test_put_columns_empty - out, err = capture_io do - puts Formatter.columns([]) - end - - assert_equal out, "\n" - assert_equal err, "" - end - - def test_which - cmd = @dir/"foo" - FileUtils.touch cmd - cmd.chmod 0744 - assert_equal Pathname.new(cmd), - which(File.basename(cmd), File.dirname(cmd)) - end - - def test_which_skip_non_executables - cmd = @dir/"foo" - FileUtils.touch cmd - assert_nil which(File.basename(cmd), File.dirname(cmd)) - end - - def test_which_skip_malformed_path - # 'which' should not fail if a path is malformed - # see https://github.com/Homebrew/legacy-homebrew/issues/32789 for an example - cmd = @dir/"foo" - FileUtils.touch cmd - cmd.chmod 0744 - - # ~~ will fail because ~foo resolves to foo's home and there is no '~' user - # here - assert_equal Pathname.new(cmd), - which(File.basename(cmd), "~~#{File::PATH_SEPARATOR}#{File.dirname(cmd)}") - end - - def test_which_all - (@dir/"bar/baz").mkpath - cmd1 = @dir/"foo" - cmd2 = @dir/"bar/foo" - cmd3 = @dir/"bar/baz/foo" - FileUtils.touch cmd2 - [cmd1, cmd3].each do |cmd| - FileUtils.touch cmd - cmd.chmod 0744 - end - assert_equal [cmd3, cmd1], - which_all("foo", "#{@dir}/bar/baz:#{@dir}/baz:#{@dir}:~baduserpath") - end - - def test_which_editor - ENV["HOMEBREW_EDITOR"] = "vemate" - assert_equal "vemate", which_editor - end - - def test_gzip - mktmpdir do |path| - somefile = "#{path}/somefile" - FileUtils.touch somefile - assert_equal "#{somefile}.gz", - gzip(somefile)[0].to_s - assert File.exist?("#{somefile}.gz") - end - end - - def test_capture_stderr - assert_equal "test\n", capture_stderr { $stderr.puts "test" } - end - - def test_shell_profile - ENV["SHELL"] = "/bin/sh" - assert_equal "~/.bash_profile", Utils::Shell.shell_profile - ENV["SHELL"] = "/bin/bash" - assert_equal "~/.bash_profile", Utils::Shell.shell_profile - ENV["SHELL"] = "/bin/another_shell" - assert_equal "~/.bash_profile", Utils::Shell.shell_profile - ENV["SHELL"] = "/bin/zsh" - assert_equal "~/.zshrc", Utils::Shell.shell_profile - ENV["SHELL"] = "/bin/ksh" - assert_equal "~/.kshrc", Utils::Shell.shell_profile - end - - def test_popen_read - out = Utils.popen_read("sh", "-c", "echo success").chomp - assert_equal "success", out - assert_predicate $?, :success? - end - - def test_popen_read_with_block - out = Utils.popen_read("sh", "-c", "echo success") do |pipe| - pipe.read.chomp - end - assert_equal "success", out - assert_predicate $?, :success? - end - - def test_popen_write_with_block - Utils.popen_write("grep", "-q", "success") do |pipe| - pipe.write("success\n") - end - assert_predicate $?, :success? - end - - def test_pretty_duration - assert_equal "1 second", pretty_duration(1) - assert_equal "2 seconds", pretty_duration(2.5) - assert_equal "42 seconds", pretty_duration(42) - assert_equal "4 minutes", pretty_duration(240) - assert_equal "4 minutes 12 seconds", pretty_duration(252.45) - end - - def test_plural - assert_equal "", plural(1) - assert_equal "s", plural(0) - assert_equal "s", plural(42) - assert_equal "", plural(42, "") - end - - def test_disk_usage_readable - assert_equal "1B", disk_usage_readable(1) - assert_equal "1000B", disk_usage_readable(1000) - assert_equal "1K", disk_usage_readable(1024) - assert_equal "1K", disk_usage_readable(1025) - assert_equal "4.2M", disk_usage_readable(4_404_020) - assert_equal "4.2G", disk_usage_readable(4_509_715_660) - end - - def test_number_readable - assert_equal "1", number_readable(1) - assert_equal "1,000", number_readable(1_000) - assert_equal "1,000,000", number_readable(1_000_000) - end - - def test_truncate_text_to_approximate_size - glue = "\n[...snip...]\n" # hard-coded copy from truncate_text_to_approximate_size - n = 20 - long_s = "x" * 40 - s = truncate_text_to_approximate_size(long_s, n) - assert_equal n, s.length - assert_match(/^x+#{Regexp.escape(glue)}x+$/, s) - s = truncate_text_to_approximate_size(long_s, n, front_weight: 0.0) - assert_equal glue + ("x" * (n - glue.length)), s - s = truncate_text_to_approximate_size(long_s, n, front_weight: 1.0) - assert_equal(("x" * (n - glue.length)) + glue, s) - end - - def test_odeprecated - ENV.delete("HOMEBREW_DEVELOPER") - e = assert_raises(MethodDeprecatedError) do - odeprecated("method", "replacement", - caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], - disable: true) - end - assert_match "method", e.message - assert_match "replacement", e.message - assert_match "homebrew/homebrew-core", e.message - assert_match "homebrew/core", e.message - end - - def test_bottles_bintray - assert_equal "openssl:1.1", Utils::Bottles::Bintray.package("openssl@1.1") - assert_equal "gtkx", Utils::Bottles::Bintray.package("gtk+") - assert_equal "llvm", Utils::Bottles::Bintray.package("llvm") - - tap = Tap.new("homebrew", "bintray-test") - assert_equal "bottles-bintray-test", Utils::Bottles::Bintray.repository(tap) - end -end -- cgit v1.2.3 From 44d2617030f8407e74036decd93d94b33db881e7 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 18 Feb 2017 16:52:36 +0100 Subject: Handle `Homebrew.failed` in `spec_helper`. --- Library/Homebrew/test/spec_helper.rb | 6 ++++++ Library/Homebrew/test/utils_spec.rb | 14 ++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 292c5786a..63ffe63fe 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -33,6 +33,8 @@ RSpec.configure do |config| begin TEST_DIRECTORIES.each(&:mkpath) + @__homebrew_failed = Homebrew.failed? + @__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") } @__argv = ARGV.dup @@ -72,6 +74,10 @@ RSpec.configure do |config| file leak detected: #{diff.map { |f| " #{f}" }.join("\n")} EOS + + Homebrew.failed = @__homebrew_failed end end end + +RSpec::Matchers.alias_matcher :have_failed, :be_failed diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb index de6b287d2..040ad630b 100644 --- a/Library/Homebrew/test/utils_spec.rb +++ b/Library/Homebrew/test/utils_spec.rb @@ -1,7 +1,5 @@ require "utils" -RSpec::Matchers.alias_matcher :have_failed, :be_failed - describe "globally-scoped helper methods" do let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } @@ -13,15 +11,11 @@ describe "globally-scoped helper methods" do describe "#ofail" do it "sets Homebrew.failed to true" do - begin - shutup do - ofail "foo" - end + expect { + ofail "foo" + }.to output("Error: foo\n").to_stderr - expect(Homebrew).to have_failed - ensure - Homebrew.failed = false - end + expect(Homebrew).to have_failed end end -- cgit v1.2.3 From 15ae8870a39930ccb87f6492aef085f66efa0d7a Mon Sep 17 00:00:00 2001 From: Chris Long Date: Sun, 19 Feb 2017 13:21:55 -0800 Subject: Docs for tag-based urls use preferred formatting --- Library/Homebrew/formula.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a4ef11276..35bf52584 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2033,7 +2033,7 @@ class Formula # @!attribute [w] url # The URL used to download the source for the {#stable} version of the formula. # We prefer `https` for security and proxy reasons. - # Optionally specify the download strategy with `:using => ...` + # If not inferrable, specify the download strategy with `:using => ...` # `:git`, `:hg`, `:svn`, `:bzr`, `:cvs`, # `:curl` (normal file download. Will also extract.) # `:nounzip` (without extracting) @@ -2041,7 +2041,10 @@ class Formula # `S3DownloadStrategy` (download from S3 using signed request) # #
url "https://packed.sources.and.we.prefer.https.example.com/archive-1.2.3.tar.bz2"
- #
url "https://some.dont.provide.archives.example.com", :using => :git, :tag => "1.2.3", :revision => "db8e4de5b2d6653f66aea53094624468caad15d2"
+ #
url "https://some.dont.provide.archives.example.com",
+    #     :using => :git,
+    #     :tag => "1.2.3",
+    #     :revision => "db8e4de5b2d6653f66aea53094624468caad15d2"
def url(val, specs = {}) stable.url(val, specs) end -- cgit v1.2.3 From 6dfbf7066b59ada428a3b5d06acee1f02bb4f166 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 12 Feb 2017 21:37:46 +0100 Subject: Convert Utils::Bottles::Collector test to spec. --- .../Homebrew/test/os/mac/bottle_collector_test.rb | 27 ---------------------- Library/Homebrew/test/spec_helper.rb | 5 ++++ .../Homebrew/test/utils/bottles/collector_spec.rb | 14 +++++++++++ 3 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 Library/Homebrew/test/os/mac/bottle_collector_test.rb (limited to 'Library') diff --git a/Library/Homebrew/test/os/mac/bottle_collector_test.rb b/Library/Homebrew/test/os/mac/bottle_collector_test.rb deleted file mode 100644 index e9ae9b753..000000000 --- a/Library/Homebrew/test/os/mac/bottle_collector_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require "testing_env" -require "utils/bottles" - -class OSMacBottleCollectorTests < Homebrew::TestCase - def setup - super - @collector = Utils::Bottles::Collector.new - end - - def checksum_for(tag) - @collector.fetch_checksum_for(tag) - end - - def test_collector_finds_or_later_tags - @collector[:lion_or_later] = "foo" - assert_equal ["foo", :lion_or_later], checksum_for(:mountain_lion) - assert_nil checksum_for(:snow_leopard) - end - - def test_collector_finds_altivec_tags - @collector[:tiger_altivec] = "foo" - assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4) - assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g4e) - assert_equal ["foo", :tiger_altivec], checksum_for(:tiger_g5) - assert_nil checksum_for(:tiger_g3) - end -end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 292c5786a..6ffbf5c8e 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -29,6 +29,11 @@ TEST_DIRECTORIES = [ RSpec.configure do |config| config.order = :random config.include(Test::Helper::Shutup) + config.before(:each) do |example| + if example.metadata[:needs_macos] + skip "not on macOS" unless OS.mac? + end + end config.around(:each) do |example| begin TEST_DIRECTORIES.each(&:mkpath) diff --git a/Library/Homebrew/test/utils/bottles/collector_spec.rb b/Library/Homebrew/test/utils/bottles/collector_spec.rb index 73757234e..08484e545 100644 --- a/Library/Homebrew/test/utils/bottles/collector_spec.rb +++ b/Library/Homebrew/test/utils/bottles/collector_spec.rb @@ -27,5 +27,19 @@ describe Utils::Bottles::Collector do subject[:mountain_lion] = "bar" expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["bar", :mountain_lion]) end + + it "finds '_or_later' tags", :needs_macos do + subject[:lion_or_later] = "foo" + expect(subject.fetch_checksum_for(:mountain_lion)).to eq(["foo", :lion_or_later]) + expect(subject.fetch_checksum_for(:snow_leopard)).to be nil + end + + it "finds '_altivec' tags", :needs_macos do + subject[:tiger_altivec] = "foo" + expect(subject.fetch_checksum_for(:tiger_g4)).to eq(["foo", :tiger_altivec]) + expect(subject.fetch_checksum_for(:tiger_g4e)).to eq(["foo", :tiger_altivec]) + expect(subject.fetch_checksum_for(:tiger_g5)).to eq(["foo", :tiger_altivec]) + expect(subject.fetch_checksum_for(:tiger_g3)).to be nil + end end end -- cgit v1.2.3 From 0f89f6520ee9054d3e1ba09a3f6e14455375d2ed Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Thu, 16 Feb 2017 01:33:24 -0500 Subject: keg_relocate: Don't relocate dylib IDs containing metavariables. --- Library/Homebrew/extend/os/mac/keg_relocate.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index f44a97b31..476e5da4a 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -78,13 +78,19 @@ class Keg end end + def filename_contains_metavariable?(fn) + fn =~ /^@(loader_|executable_|r)path/ + end + def each_install_name_for(file, &block) dylibs = file.dynamically_linked_libraries - dylibs.reject! { |fn| fn =~ /^@(loader_|executable_|r)path/ } + dylibs.reject! { |fn| filename_contains_metavariable?(fn) } dylibs.each(&block) end def dylib_id_for(file) + return file.dylib_id if filename_contains_metavariable?(file.dylib_id) + # The new dylib ID should have the same basename as the old dylib ID, not # the basename of the file itself. basename = File.basename(file.dylib_id) -- cgit v1.2.3 From 10970a5c54c0723126bef3582f9e9a63d25e1b54 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 20 Feb 2017 11:18:44 +0000 Subject: formula: clarify caveats usage. --- Library/Homebrew/formula.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a4ef11276..7b3d1c326 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1026,7 +1026,9 @@ class Formula @prefix_returns_versioned_prefix = false end - # Tell the user about any caveats regarding this package. + # Tell the user about any Homebrew-specific caveats or locations regarding + # this package. These should not contain setup instructions that would apply + # to installation through a different package manager on a different OS. # @return [String] #
def caveats
   #   <<-EOS.undent
-- 
cgit v1.2.3


From 86bec56bf87dcbd923ebd74409685f6fe4a9f38e Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Mon, 20 Feb 2017 13:06:23 +0100
Subject: Make `Formulary` a `module`.

---
 Library/Homebrew/formulary.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index cf85ba03f..4a65f8704 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -4,7 +4,7 @@ require "tap"
 # The Formulary is responsible for creating instances of Formula.
 # It is not meant to be used directly from formulae.
 
-class Formulary
+module Formulary
   FORMULAE = {}
 
   def self.formula_class_defined?(path)
-- 
cgit v1.2.3


From 81d105d9a4cbdba1072c3828d173dcaac4bcc2a6 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 16 Feb 2017 03:15:46 +0100
Subject: Convert String test to spec.

---
 Library/Homebrew/test/string_spec.rb | 49 ++++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/string_test.rb | 40 -----------------------------
 2 files changed, 49 insertions(+), 40 deletions(-)
 create mode 100644 Library/Homebrew/test/string_spec.rb
 delete mode 100644 Library/Homebrew/test/string_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/string_spec.rb b/Library/Homebrew/test/string_spec.rb
new file mode 100644
index 000000000..d1b820b66
--- /dev/null
+++ b/Library/Homebrew/test/string_spec.rb
@@ -0,0 +1,49 @@
+require "extend/string"
+
+describe String do
+  describe "#undent" do
+    it "removes leading whitespace, taking the first line as reference" do
+      string = <<-EOS.undent
+        hi
+........my friend over
+          there
+      EOS
+
+      expect(string).to eq("hi\n........my friend over\n  there\n")
+    end
+
+    it "removes nothing if the text is not indented" do
+      string = <<-EOS.undent
+hi
+I'm not indented
+      EOS
+
+      expect(string).to eq("hi\nI'm not indented\n")
+    end
+
+    it "can be nested" do
+      nested_string = <<-EOS.undent
+        goodbye
+      EOS
+
+      string = <<-EOS.undent
+        hello
+        #{nested_string}
+      EOS
+
+      expect(string).to eq("hello\ngoodbye\n\n")
+    end
+  end
+end
+
+describe StringInreplaceExtension do
+  subject { string.extend(described_class) }
+  let(:string) { "foobar" }
+
+  describe "#sub!" do
+    it "adds an error to #errors when no replacement was made" do
+      subject.sub! "not here", "test"
+      expect(subject.errors).to eq(['expected replacement of "not here" with "test"'])
+    end
+  end
+end
diff --git a/Library/Homebrew/test/string_test.rb b/Library/Homebrew/test/string_test.rb
deleted file mode 100644
index 497c4badb..000000000
--- a/Library/Homebrew/test/string_test.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require "testing_env"
-require "extend/string"
-
-class StringTest < Homebrew::TestCase
-  def test_undent
-    undented = <<-EOS.undent
-    hi
-....my friend over
-    there
-    EOS
-    assert_equal "hi\n....my friend over\nthere\n", undented
-  end
-
-  def test_undent_not_indented
-    undented = <<-EOS.undent
-hi
-I'm not indented
-    EOS
-    assert_equal "hi\nI'm not indented\n", undented
-  end
-
-  def test_undent_nested
-    nest = <<-EOS.undent
-      goodbye
-    EOS
-
-    undented = <<-EOS.undent
-      hello
-      #{nest}
-    EOS
-
-    assert_equal "hello\ngoodbye\n\n", undented
-  end
-
-  def test_inreplace_sub_failure
-    s = "foobar".extend StringInreplaceExtension
-    s.sub! "not here", "test"
-    assert_equal ['expected replacement of "not here" with "test"'], s.errors
-  end
-end
-- 
cgit v1.2.3


From f33efbe7c46d4a148af00c83dff73c14717ed0d1 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Mon, 20 Feb 2017 13:02:54 +0100
Subject: Convert LanguageModuleRequirement test to spec.

---
 .../test/language_module_requirement_spec.rb       | 49 +++++++++++++++++++
 .../test/language_module_requirement_test.rb       | 55 ----------------------
 Library/Homebrew/test/spec_helper.rb               |  4 ++
 3 files changed, 53 insertions(+), 55 deletions(-)
 create mode 100644 Library/Homebrew/test/language_module_requirement_spec.rb
 delete mode 100644 Library/Homebrew/test/language_module_requirement_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/language_module_requirement_spec.rb b/Library/Homebrew/test/language_module_requirement_spec.rb
new file mode 100644
index 000000000..7f2666855
--- /dev/null
+++ b/Library/Homebrew/test/language_module_requirement_spec.rb
@@ -0,0 +1,49 @@
+require "requirements/language_module_requirement"
+
+describe LanguageModuleRequirement do
+  specify "unique dependencies are not equal" do
+    x = described_class.new(:node, "less")
+    y = described_class.new(:node, "coffee-script")
+    expect(x).not_to eq(y)
+    expect(x.hash).not_to eq(y.hash)
+  end
+
+  context "when module and import name differ" do
+    subject { described_class.new(:python, mod_name, import_name) }
+    let(:mod_name) { "foo" }
+    let(:import_name) { "bar" }
+
+    its(:message) { is_expected.to include(mod_name) }
+    its(:the_test) { is_expected.to include("import #{import_name}") }
+  end
+
+  context "when the language is Perl" do
+    it "does not satisfy invalid dependencies" do
+      expect(described_class.new(:perl, "notapackage")).not_to be_satisfied
+    end
+
+    it "satisfies valid dependencies" do
+      expect(described_class.new(:perl, "Env")).to be_satisfied
+    end
+  end
+
+  context "when the language is Python", :needs_python do
+    it "does not satisfy invalid dependencies" do
+      expect(described_class.new(:python, "notapackage")).not_to be_satisfied
+    end
+
+    it "satisfies valid dependencies" do
+      expect(described_class.new(:python, "datetime")).to be_satisfied
+    end
+  end
+
+  context "when the language is Ruby" do
+    it "does not satisfy invalid dependencies" do
+      expect(described_class.new(:ruby, "notapackage")).not_to be_satisfied
+    end
+
+    it "satisfies valid dependencies" do
+      expect(described_class.new(:ruby, "date")).to be_satisfied
+    end
+  end
+end
diff --git a/Library/Homebrew/test/language_module_requirement_test.rb b/Library/Homebrew/test/language_module_requirement_test.rb
deleted file mode 100644
index dfa992287..000000000
--- a/Library/Homebrew/test/language_module_requirement_test.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require "testing_env"
-require "requirements/language_module_requirement"
-
-class LanguageModuleRequirementTests < Homebrew::TestCase
-  parallelize_me!
-
-  def assert_deps_fail(spec)
-    refute_predicate LanguageModuleRequirement.new(*spec.shift.reverse), :satisfied?
-  end
-
-  def assert_deps_pass(spec)
-    assert_predicate LanguageModuleRequirement.new(*spec.shift.reverse), :satisfied?
-  end
-
-  def test_unique_deps_are_not_eql
-    x = LanguageModuleRequirement.new(:node, "less")
-    y = LanguageModuleRequirement.new(:node, "coffee-script")
-    refute_eql x, y
-    refute_equal x.hash, y.hash
-  end
-
-  def test_differing_module_and_import_name
-    mod_name = "foo"
-    import_name = "bar"
-    l = LanguageModuleRequirement.new(:python, mod_name, import_name)
-    assert_includes l.message, mod_name
-    assert_includes l.the_test, "import #{import_name}"
-  end
-
-  def test_bad_perl_deps
-    assert_deps_fail "notapackage" => :perl
-  end
-
-  def test_good_perl_deps
-    assert_deps_pass "Env" => :perl
-  end
-
-  def test_bad_python_deps
-    needs_python
-    assert_deps_fail "notapackage" => :python
-  end
-
-  def test_good_python_deps
-    needs_python
-    assert_deps_pass "datetime" => :python
-  end
-
-  def test_bad_ruby_deps
-    assert_deps_fail "notapackage" => :ruby
-  end
-
-  def test_good_ruby_deps
-    assert_deps_pass "date" => :ruby
-  end
-end
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 6ffbf5c8e..67e5f555a 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -33,6 +33,10 @@ RSpec.configure do |config|
     if example.metadata[:needs_macos]
       skip "not on macOS" unless OS.mac?
     end
+
+    if example.metadata[:needs_python]
+      skip "Python not installed." unless which("python")
+    end
   end
   config.around(:each) do |example|
     begin
-- 
cgit v1.2.3


From 14ef15f591795c517b7771c5eb01863b2b577a46 Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Fri, 30 Sep 2016 03:22:09 -0700
Subject: keg: create symlinks in opt for formula aliases

---
 Library/Homebrew/keg.rb | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 17ff3bcef..bebc3c887 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -239,6 +239,11 @@ class Keg
 
   def remove_opt_record
     opt_record.unlink
+    unless aliases.empty?
+      aliases.each do |a|
+        (opt_record.parent/a).unlink
+      end
+    end
     opt_record.parent.rmdir_if_possible
   end
 
@@ -461,9 +466,25 @@ class Keg
     @oldname_opt_record = nil
   end
 
+  def aliases
+    formula_name = rack.basename.to_s
+    aliases_path = Formula[formula_name].tap.path/"Aliases"
+    result = aliases_path.children.select do |c|
+      c.symlink? && c.readlink.basename(".rb").to_s == formula_name
+    end
+    result.map(&:basename).map(&:to_s)
+  end
+
   def optlink(mode = OpenStruct.new)
     opt_record.delete if opt_record.symlink? || opt_record.exist?
     make_relative_symlink(opt_record, path, mode)
+    unless aliases.empty?
+      aliases.each do |a|
+        alias_opt_record = opt_record.parent/a
+        alias_opt_record.delete if alias_opt_record.symlink? || alias_opt_record.exist?
+        make_relative_symlink(alias_opt_record, opt_record, mode)
+      end
+    end
 
     return unless oldname_opt_record
     oldname_opt_record.delete
-- 
cgit v1.2.3


From 4c922a089bf2bb8ff379291c90d46b91978dbbb4 Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Mon, 3 Oct 2016 02:41:17 -0700
Subject: remove unless empty since each is no-op for empty

---
 Library/Homebrew/keg.rb | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index bebc3c887..06ac68310 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -239,10 +239,8 @@ class Keg
 
   def remove_opt_record
     opt_record.unlink
-    unless aliases.empty?
-      aliases.each do |a|
-        (opt_record.parent/a).unlink
-      end
+    aliases.each do |a|
+      (opt_record.parent/a).unlink
     end
     opt_record.parent.rmdir_if_possible
   end
@@ -478,12 +476,10 @@ class Keg
   def optlink(mode = OpenStruct.new)
     opt_record.delete if opt_record.symlink? || opt_record.exist?
     make_relative_symlink(opt_record, path, mode)
-    unless aliases.empty?
-      aliases.each do |a|
-        alias_opt_record = opt_record.parent/a
-        alias_opt_record.delete if alias_opt_record.symlink? || alias_opt_record.exist?
-        make_relative_symlink(alias_opt_record, opt_record, mode)
-      end
+    aliases.each do |a|
+      alias_opt_record = opt_record.parent/a
+      alias_opt_record.delete if alias_opt_record.symlink? || alias_opt_record.exist?
+      make_relative_symlink(alias_opt_record, opt_record, mode)
     end
 
     return unless oldname_opt_record
-- 
cgit v1.2.3


From 63295fd81af2b3fa5dc8e933f904b6959727f62e Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Mon, 3 Oct 2016 02:42:33 -0700
Subject: have opt alias symlink point into the Cellar

in case people expect to be able to find the prefix by only resolving
the symlink once (e.g., if they're using readlink not realpath)
---
 Library/Homebrew/keg.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 06ac68310..dfbf0ad98 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -479,7 +479,7 @@ class Keg
     aliases.each do |a|
       alias_opt_record = opt_record.parent/a
       alias_opt_record.delete if alias_opt_record.symlink? || alias_opt_record.exist?
-      make_relative_symlink(alias_opt_record, opt_record, mode)
+      make_relative_symlink(alias_opt_record, path, mode)
     end
 
     return unless oldname_opt_record
-- 
cgit v1.2.3


From dfa2c247e0dbdbf506f5175a1c839bfd09caecd9 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Mon, 20 Feb 2017 14:23:01 +0000
Subject: keg: simplify code, handle exceptions.

---
 Library/Homebrew/keg.rb | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index dfbf0ad98..b31997d5a 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -239,9 +239,7 @@ class Keg
 
   def remove_opt_record
     opt_record.unlink
-    aliases.each do |a|
-      (opt_record.parent/a).unlink
-    end
+    aliases.each { |a| (opt_record.parent/a).unlink }
     opt_record.parent.rmdir_if_possible
   end
 
@@ -465,12 +463,9 @@ class Keg
   end
 
   def aliases
-    formula_name = rack.basename.to_s
-    aliases_path = Formula[formula_name].tap.path/"Aliases"
-    result = aliases_path.children.select do |c|
-      c.symlink? && c.readlink.basename(".rb").to_s == formula_name
-    end
-    result.map(&:basename).map(&:to_s)
+    Formula[rack.basename.to_s].aliases
+  rescue FormulaUnavailableError
+    []
   end
 
   def optlink(mode = OpenStruct.new)
-- 
cgit v1.2.3


From 81a760921320b6508458d6cdbe4c73b3e01b14b3 Mon Sep 17 00:00:00 2001
From: Zhiming Wang
Date: Sat, 18 Feb 2017 10:16:59 -0500
Subject: bump-formula-pr: improve duplicate detection

Reduce the chance of false flagging by making sure that the existing pr
surfaced by GitHub.issues_for_formula actually contains the exact formula name
in its title.
---
 Library/Homebrew/dev-cmd/bump-formula-pr.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
index ea2daf1c4..bfe9c7776 100644
--- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -80,7 +80,8 @@ module Homebrew
 
   def fetch_pull_requests(formula)
     GitHub.issues_for_formula(formula.name, tap: formula.tap).select do |pr|
-      pr["html_url"].include?("/pull/")
+      pr["html_url"].include?("/pull/") &&
+        /(^|\s)#{Regexp.quote(formula.name)}(:|\s|$)/i =~ pr["title"]
     end
   rescue GitHub::RateLimitExceededError => e
     opoo e.message
-- 
cgit v1.2.3


From c667a43b9790be9887bf3f175d9e6ab3dad80e1a Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Mon, 20 Feb 2017 07:51:04 -0800
Subject: audit: fix insecure mirror check when stdout is empty

---
 Library/Homebrew/dev-cmd/audit.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 5ed363f7c..9ffef0f99 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1499,7 +1499,7 @@ class ResourceAuditor
     secure_url = url.sub "http", "https"
     secure_details = get_content_details(secure_url)
 
-    return if !details[:status].start_with?("2") || !secure_details[:status].start_with?("2")
+    return if details[:status].nil? || secure_details[:status].nil? || !details[:status].start_with?("2") || !secure_details[:status].start_with?("2")
 
     etag_match = details[:etag] && details[:etag] == secure_details[:etag]
     content_length_match = details[:content_length] && details[:content_length] == secure_details[:content_length]
-- 
cgit v1.2.3


From 8e0940cc2f79def7f19c01dc2a9429cf624f0c6e Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 16 Feb 2017 02:47:44 +0100
Subject: Convert Formulary test to spec.

---
 Library/Homebrew/test/formulary_spec.rb | 219 ++++++++++++++++++++++++++++++++
 Library/Homebrew/test/formulary_test.rb | 189 ---------------------------
 2 files changed, 219 insertions(+), 189 deletions(-)
 create mode 100644 Library/Homebrew/test/formulary_spec.rb
 delete mode 100644 Library/Homebrew/test/formulary_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb
new file mode 100644
index 000000000..8e9d23589
--- /dev/null
+++ b/Library/Homebrew/test/formulary_spec.rb
@@ -0,0 +1,219 @@
+require "formula"
+require "formula_installer"
+require "utils/bottles"
+
+describe Formulary do
+  let(:formula_name) { "testball_bottle" }
+  let(:formula_path) { CoreTap.new.formula_dir/"#{formula_name}.rb" }
+  let(:formula_content) do
+    <<-EOS.undent
+      class #{subject.class_s(formula_name)} < Formula
+        url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
+        sha256 TESTBALL_SHA256
+
+        bottle do
+          cellar :any_skip_relocation
+          root_url "file://#{bottle_dir}"
+          sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => :#{Utils::Bottles.tag}
+        end
+
+        def install
+          prefix.install "bin"
+          prefix.install "libexec"
+        end
+      end
+    EOS
+  end
+  let(:bottle_dir) { Pathname.new("#{TEST_FIXTURE_DIR}/bottles") }
+  let(:bottle) { bottle_dir/"testball_bottle-0.1.#{Utils::Bottles.tag}.bottle.tar.gz" }
+
+  describe "::class_s" do
+    it "replaces '+' with 'x'" do
+      expect(subject.class_s("foo++")).to eq("Fooxx")
+    end
+
+    it "converts a string to PascalCase" do
+      expect(subject.class_s("shell.fm")).to eq("ShellFm")
+      expect(subject.class_s("s-lang")).to eq("SLang")
+      expect(subject.class_s("pkg-config")).to eq("PkgConfig")
+      expect(subject.class_s("foo_bar")).to eq("FooBar")
+    end
+
+    it "replaces '@' with 'AT'" do
+      expect(subject.class_s("openssl@1.1")).to eq("OpensslAT11")
+    end
+  end
+
+  describe "::factory" do
+    before(:each) do
+      formula_path.write formula_content
+    end
+
+    it "returns a Formula" do
+      expect(subject.factory(formula_name)).to be_kind_of(Formula)
+    end
+
+    it "returns a Formula when given a fully qualified name" do
+      expect(subject.factory("homebrew/core/#{formula_name}")).to be_kind_of(Formula)
+    end
+
+    it "raises an error if the Formula cannot be found" do
+      expect {
+        subject.factory("not_existed_formula")
+      }.to raise_error(FormulaUnavailableError)
+    end
+
+    context "if the Formula has the wrong class" do
+      let(:formula_name) { "giraffe" }
+      let(:formula_content) do
+        <<-EOS.undent
+          class Wrong#{subject.class_s(formula_name)} < Formula
+          end
+        EOS
+      end
+
+      it "raises an error" do
+        expect {
+          subject.factory(formula_name)
+        }.to raise_error(FormulaClassUnavailableError)
+      end
+    end
+
+    it "returns a Formula when given a path" do
+      expect(subject.factory(formula_path)).to be_kind_of(Formula)
+    end
+
+    it "returns a Formula when given a URL" do
+      formula = shutup do
+        subject.factory("file://#{formula_path}")
+      end
+
+      expect(formula).to be_kind_of(Formula)
+    end
+
+    it "returns a Formula when given a bottle" do
+      formula = subject.factory(bottle)
+      expect(formula).to be_kind_of(Formula)
+      expect(formula.local_bottle_path).to eq(bottle.realpath)
+    end
+
+    it "returns a Formula when given an alias" do
+      alias_dir = CoreTap.instance.alias_dir
+      alias_dir.mkpath
+      alias_path = alias_dir/"foo"
+      FileUtils.ln_s formula_path, alias_path
+      result = subject.factory("foo")
+      expect(result).to be_kind_of(Formula)
+      expect(result.alias_path).to eq(alias_path.to_s)
+    end
+
+    context "with installed Formula" do
+      let(:formula) { subject.factory(formula_path) }
+      let(:installer) { FormulaInstaller.new(formula) }
+
+      it "returns a Formula when given a rack" do
+        shutup do
+          installer.install
+        end
+
+        f = subject.from_rack(formula.rack)
+        expect(f).to be_kind_of(Formula)
+        expect(f.build).to be_kind_of(Tab)
+      end
+
+      it "returns a Formula when given a Keg" do
+        shutup do
+          installer.install
+        end
+
+        keg = Keg.new(formula.prefix)
+        f = subject.from_keg(keg)
+        expect(f).to be_kind_of(Formula)
+        expect(f.build).to be_kind_of(Tab)
+      end
+    end
+
+    context "from Tap" do
+      let(:tap) { Tap.new("homebrew", "foo") }
+      let(:formula_path) { tap.path/"#{formula_name}.rb" }
+
+      it "returns a Formula when given a name" do
+        expect(subject.factory(formula_name)).to be_kind_of(Formula)
+      end
+
+      it "returns a Formula from an Alias path" do
+        alias_dir = tap.path/"Aliases"
+        alias_dir.mkpath
+        FileUtils.ln_s formula_path, alias_dir/"bar"
+        expect(subject.factory("bar")).to be_kind_of(Formula)
+      end
+
+      it "raises an error when the Formula cannot be found" do
+        expect {
+          subject.factory("#{tap}/not_existed_formula")
+        }.to raise_error(TapFormulaUnavailableError)
+      end
+
+      it "returns a Formula when given a fully qualified name" do
+        expect(subject.factory("#{tap}/#{formula_name}")).to be_kind_of(Formula)
+      end
+
+      it "raises an error if a Formula is in multiple Taps" do
+        begin
+          another_tap = Tap.new("homebrew", "bar")
+          (another_tap.path/"#{formula_name}.rb").write formula_content
+          expect {
+            subject.factory(formula_name)
+          }.to raise_error(TapFormulaAmbiguityError)
+        ensure
+          another_tap.path.rmtree
+        end
+      end
+    end
+  end
+
+  specify "::from_contents" do
+    expect(subject.from_contents(formula_name, formula_path, formula_content)).to be_kind_of(Formula)
+  end
+
+  specify "::to_rack" do
+    expect(subject.to_rack(formula_name)).to eq(HOMEBREW_CELLAR/formula_name)
+
+    (HOMEBREW_CELLAR/formula_name).mkpath
+    expect(subject.to_rack(formula_name)).to eq(HOMEBREW_CELLAR/formula_name)
+
+    expect {
+      subject.to_rack("a/b/#{formula_name}")
+    }.to raise_error(TapFormulaUnavailableError)
+  end
+
+  describe "::find_with_priority" do
+    let(:core_path) { CoreTap.new.formula_dir/"#{formula_name}.rb" }
+    let(:tap) { Tap.new("homebrew", "foo") }
+    let(:tap_path) { tap.path/"#{formula_name}.rb" }
+
+    before(:each) do
+      core_path.write formula_content
+      tap_path.write formula_content
+    end
+
+    it "prioritizes core Formulae" do
+      formula = subject.find_with_priority(formula_name)
+      expect(formula).to be_kind_of(Formula)
+      expect(formula.path).to eq(core_path)
+    end
+
+    it "prioritizes Formulae from pinned Taps" do
+      begin
+        tap.pin
+        formula = shutup do
+          subject.find_with_priority(formula_name)
+        end
+        expect(formula).to be_kind_of(Formula)
+        expect(formula.path).to eq(tap_path.realpath)
+      ensure
+        tap.pinned_symlink_path.parent.parent.rmtree
+      end
+    end
+  end
+end
diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb
deleted file mode 100644
index ea7ecf8d0..000000000
--- a/Library/Homebrew/test/formulary_test.rb
+++ /dev/null
@@ -1,189 +0,0 @@
-require "testing_env"
-require "formula"
-require "formula_installer"
-require "utils/bottles"
-
-class FormularyTest < Homebrew::TestCase
-  def test_class_naming
-    assert_equal "ShellFm", Formulary.class_s("shell.fm")
-    assert_equal "Fooxx", Formulary.class_s("foo++")
-    assert_equal "SLang", Formulary.class_s("s-lang")
-    assert_equal "PkgConfig", Formulary.class_s("pkg-config")
-    assert_equal "FooBar", Formulary.class_s("foo_bar")
-    assert_equal "OpensslAT11", Formulary.class_s("openssl@1.1")
-  end
-end
-
-class FormularyFactoryTest < Homebrew::TestCase
-  def setup
-    super
-    @name = "testball_bottle"
-    @path = CoreTap.new.formula_dir/"#{@name}.rb"
-    @bottle_dir = Pathname.new("#{TEST_FIXTURE_DIR}/bottles")
-    @bottle = @bottle_dir/"testball_bottle-0.1.#{Utils::Bottles.tag}.bottle.tar.gz"
-    @path.write <<-EOS.undent
-      class #{Formulary.class_s(@name)} < Formula
-        url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
-        sha256 TESTBALL_SHA256
-
-        bottle do
-          cellar :any_skip_relocation
-          root_url "file://#{@bottle_dir}"
-          sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => :#{Utils::Bottles.tag}
-        end
-
-        def install
-          prefix.install "bin"
-          prefix.install "libexec"
-        end
-      end
-    EOS
-  end
-
-  def test_factory
-    assert_kind_of Formula, Formulary.factory(@name)
-  end
-
-  def test_factory_with_fully_qualified_name
-    assert_kind_of Formula, Formulary.factory("homebrew/core/#{@name}")
-  end
-
-  def test_formula_unavailable_error
-    assert_raises(FormulaUnavailableError) { Formulary.factory("not_existed_formula") }
-  end
-
-  def test_formula_class_unavailable_error
-    name = "giraffe"
-    path = CoreTap.new.formula_dir/"#{name}.rb"
-    path.write "class Wrong#{Formulary.class_s(name)} < Formula\nend\n"
-
-    assert_raises(FormulaClassUnavailableError) { Formulary.factory(name) }
-  end
-
-  def test_factory_from_path
-    assert_kind_of Formula, Formulary.factory(@path)
-  end
-
-  def test_factory_from_url
-    formula = shutup { Formulary.factory("file://#{@path}") }
-    assert_kind_of Formula, formula
-  ensure
-    formula.path.unlink
-  end
-
-  def test_factory_from_bottle
-    formula = Formulary.factory(@bottle)
-    assert_kind_of Formula, formula
-    assert_equal @bottle.realpath, formula.local_bottle_path
-  end
-
-  def test_factory_from_alias
-    alias_dir = CoreTap.instance.alias_dir
-    alias_dir.mkpath
-    alias_path = alias_dir/"foo"
-    FileUtils.ln_s @path, alias_path
-    result = Formulary.factory("foo")
-    assert_kind_of Formula, result
-    assert_equal alias_path.to_s, result.alias_path
-  end
-
-  def test_factory_from_rack_and_from_keg
-    formula = Formulary.factory(@path)
-    installer = FormulaInstaller.new(formula)
-    shutup { installer.install }
-    keg = Keg.new(formula.prefix)
-    f = Formulary.from_rack(formula.rack)
-    assert_kind_of Formula, f
-    assert_kind_of Tab, f.build
-    f = Formulary.from_keg(keg)
-    assert_kind_of Formula, f
-    assert_kind_of Tab, f.build
-  ensure
-    keg.unlink
-  end
-
-  def test_load_from_contents
-    assert_kind_of Formula, Formulary.from_contents(@name, @path, @path.read)
-  end
-
-  def test_to_rack
-    assert_equal HOMEBREW_CELLAR/@name, Formulary.to_rack(@name)
-    (HOMEBREW_CELLAR/@name).mkpath
-    assert_equal HOMEBREW_CELLAR/@name, Formulary.to_rack(@name)
-    assert_raises(TapFormulaUnavailableError) { Formulary.to_rack("a/b/#{@name}") }
-  end
-end
-
-class FormularyTapFactoryTest < Homebrew::TestCase
-  def setup
-    super
-    @name = "foo"
-    @tap = Tap.new "homebrew", "foo"
-    @path = @tap.path/"#{@name}.rb"
-    @code = <<-EOS.undent
-      class #{Formulary.class_s(@name)} < Formula
-        url "foo-1.0"
-      end
-    EOS
-    @path.write @code
-  end
-
-  def test_factory_tap_formula
-    assert_kind_of Formula, Formulary.factory(@name)
-  end
-
-  def test_factory_tap_alias
-    alias_dir = @tap.path/"Aliases"
-    alias_dir.mkpath
-    FileUtils.ln_s @path, alias_dir/"bar"
-    assert_kind_of Formula, Formulary.factory("bar")
-  end
-
-  def test_tap_formula_unavailable_error
-    assert_raises(TapFormulaUnavailableError) { Formulary.factory("#{@tap}/not_existed_formula") }
-  end
-
-  def test_factory_tap_formula_with_fully_qualified_name
-    assert_kind_of Formula, Formulary.factory("#{@tap}/#{@name}")
-  end
-
-  def test_factory_ambiguity_tap_formulae
-    another_tap = Tap.new "homebrew", "bar"
-    (another_tap.path/"#{@name}.rb").write @code
-    assert_raises(TapFormulaAmbiguityError) { Formulary.factory(@name) }
-  ensure
-    another_tap.path.rmtree
-  end
-end
-
-class FormularyTapPriorityTest < Homebrew::TestCase
-  def setup
-    super
-    @name = "foo"
-    @core_path = CoreTap.new.formula_dir/"#{@name}.rb"
-    @tap = Tap.new "homebrew", "foo"
-    @tap_path = @tap.path/"#{@name}.rb"
-    code = <<-EOS.undent
-      class #{Formulary.class_s(@name)} < Formula
-        url "foo-1.0"
-      end
-    EOS
-    @core_path.write code
-    @tap_path.write code
-  end
-
-  def test_find_with_priority_core_formula
-    formula = Formulary.find_with_priority(@name)
-    assert_kind_of Formula, formula
-    assert_equal @core_path, formula.path
-  end
-
-  def test_find_with_priority_tap_formula
-    @tap.pin
-    formula = shutup { Formulary.find_with_priority(@name) }
-    assert_kind_of Formula, formula
-    assert_equal @tap_path.realpath, formula.path
-  ensure
-    @tap.pinned_symlink_path.parent.parent.rmtree
-  end
-end
-- 
cgit v1.2.3


From 7eec6a3a255d7d7ca0c29814345ee9358f6fd300 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Thu, 8 Dec 2016 21:41:24 +0000
Subject: Updated resource auditing to detect invalid mirrors when using
 --online

---
 Library/Homebrew/dev-cmd/audit.rb | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 5ed363f7c..3a4429c86 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1490,6 +1490,11 @@ class ResourceAuditor
 
     return unless @online
     urls.each do |url|
+      begin
+        nostdout { curl "--connect-timeout", "15", "-o", "/dev/null", "-r", "0-0", url }
+      rescue ErrorDuringExecution
+        problem "The mirror #{u} is not reachable (curl exit code #{$?.exitstatus})"
+      end
       check_insecure_mirror(url) if url.start_with? "http:"
     end
   end
-- 
cgit v1.2.3


From ea440ca3284138ebe3be26d5763f8c6af93749b1 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Sat, 10 Dec 2016 11:10:29 +0000
Subject: Markups to online mirror auditing

---
 Library/Homebrew/dev-cmd/audit.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 3a4429c86..db7973eb3 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1491,9 +1491,9 @@ class ResourceAuditor
     return unless @online
     urls.each do |url|
       begin
-        nostdout { curl "--connect-timeout", "15", "-o", "/dev/null", "-r", "0-0", url }
+        nostdout { curl "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", url }
       rescue ErrorDuringExecution
-        problem "The mirror #{u} is not reachable (curl exit code #{$?.exitstatus})"
+        problem "The mirror #{url} is not reachable (curl exit code #{$?.exitstatus})"
       end
       check_insecure_mirror(url) if url.start_with? "http:"
     end
-- 
cgit v1.2.3


From ed9f775b778bad961a9e2fb178fce3a7af201e75 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Sat, 10 Dec 2016 14:20:47 +0000
Subject: Added support for returning HTTP status codes and for git and svn
 URLs

---
 Library/Homebrew/dev-cmd/audit.rb | 18 ++++++++++++++----
 Library/Homebrew/utils.rb         |  1 +
 Library/Homebrew/utils/git.rb     |  5 +++++
 Library/Homebrew/utils/svn.rb     | 11 +++++++++++
 4 files changed, 31 insertions(+), 4 deletions(-)
 create mode 100644 Library/Homebrew/utils/svn.rb

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index db7973eb3..839d1c429 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1490,10 +1490,20 @@ class ResourceAuditor
 
     return unless @online
     urls.each do |url|
-      begin
-        nostdout { curl "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", url }
-      rescue ErrorDuringExecution
-        problem "The mirror #{url} is not reachable (curl exit code #{$?.exitstatus})"
+      if url.start_with? "http", "ftp"
+        status_code, _, _ = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \
+                                        "--write-out", "%{http_code}", url
+        unless status_code.start_with? "20"
+          problem "The mirror #{url} is not reachable (HTTP status code #{status_code})"
+        end
+      elsif url.start_with? "git"
+        unless Utils.git_remote_exists url
+          problem "The mirror #{url} is not a valid git URL"
+        end
+      elsif url.start_with? "svn"
+        unless Utils.svn_remote_exists url
+          problem "The mirror #{url} is not a valid svn URL"
+        end
       end
       check_insecure_mirror(url) if url.start_with? "http:"
     end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 70d2787d9..b129c7328 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -10,6 +10,7 @@ require "utils/github"
 require "utils/hash"
 require "utils/inreplace"
 require "utils/popen"
+require "utils/svn"
 require "utils/tty"
 require "time"
 
diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb
index dfe47f890..1b4d24894 100644
--- a/Library/Homebrew/utils/git.rb
+++ b/Library/Homebrew/utils/git.rb
@@ -40,4 +40,9 @@ module Utils
     @git_path = nil
     @git_version = nil
   end
+
+  def self.git_remote_exists(url)
+    return true unless git_available?
+    quiet_system "git", "ls-remote", url
+  end
 end
diff --git a/Library/Homebrew/utils/svn.rb b/Library/Homebrew/utils/svn.rb
new file mode 100644
index 000000000..fb49ac2e9
--- /dev/null
+++ b/Library/Homebrew/utils/svn.rb
@@ -0,0 +1,11 @@
+module Utils
+  def self.svn_available?
+    return @svn if instance_variable_defined?(:@svn)
+    @svn = quiet_system HOMEBREW_SHIMS_PATH/"scm/svn", "--version"
+  end
+
+  def self.svn_remote_exists(url)
+    return true unless svn_available?
+    quiet_system "svn", "ls", url, "--depth", "empty"
+  end
+end
-- 
cgit v1.2.3


From 3e7dfe4aaba2aa41d01f6fd06a9dd40298d118d3 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Sun, 11 Dec 2016 21:36:58 +0000
Subject: Updated mirror audit problem message

---
 Library/Homebrew/dev-cmd/audit.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 839d1c429..460302fb7 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1494,15 +1494,15 @@ class ResourceAuditor
         status_code, _, _ = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \
                                         "--write-out", "%{http_code}", url
         unless status_code.start_with? "20"
-          problem "The mirror #{url} is not reachable (HTTP status code #{status_code})"
+          problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
         end
       elsif url.start_with? "git"
         unless Utils.git_remote_exists url
-          problem "The mirror #{url} is not a valid git URL"
+          problem "The URL #{url} is not a valid git URL"
         end
       elsif url.start_with? "svn"
         unless Utils.svn_remote_exists url
-          problem "The mirror #{url} is not a valid svn URL"
+          problem "The URL #{url} is not a valid svn URL"
         end
       end
       check_insecure_mirror(url) if url.start_with? "http:"
-- 
cgit v1.2.3


From d3ac333197de4d2fcb560bf95e5cd4df81871bbd Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Mon, 12 Dec 2016 21:18:22 +0000
Subject: Rubocop styling fixes

---
 Library/Homebrew/dev-cmd/audit.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 460302fb7..b323297e4 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1491,8 +1491,8 @@ class ResourceAuditor
     return unless @online
     urls.each do |url|
       if url.start_with? "http", "ftp"
-        status_code, _, _ = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \
-                                        "--write-out", "%{http_code}", url
+        status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \
+                                   "--write-out", "%{http_code}", url
         unless status_code.start_with? "20"
           problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
         end
-- 
cgit v1.2.3


From a731f4e17cc45bed5ed0f1121326551c558ce583 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Tue, 10 Jan 2017 20:13:14 +0000
Subject: Updated HTTP mirror check to use new url_status_code method

---
 Library/Homebrew/dev-cmd/audit.rb | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index b323297e4..f187f17f5 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -174,7 +174,7 @@ class FormulaAuditor
     @specs = %w[stable devel head].map { |s| formula.send(s) }.compact
   end
 
-  def url_status_code(url, range: false)
+  def self.url_status_code(url, range: false)
     # The system Curl is too old and unreliable with HTTPS homepages on
     # Yosemite and below.
     return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
@@ -195,7 +195,7 @@ class FormulaAuditor
         user_agent: user_agent,
       )
       status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
-      break if status_code.start_with? "20"
+      break if status_code.start_with? "2"
     end
     status_code
   end
@@ -619,7 +619,7 @@ class FormulaAuditor
 
     return unless @online
 
-    status_code = url_status_code(homepage)
+    status_code = FormulaAuditor.url_status_code(homepage, user_agent: :browser)
     return if status_code.start_with? "20"
     problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
   end
@@ -1491,9 +1491,8 @@ class ResourceAuditor
     return unless @online
     urls.each do |url|
       if url.start_with? "http", "ftp"
-        status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \
-                                   "--write-out", "%{http_code}", url
-        unless status_code.start_with? "20"
+        status_code = FormulaAuditor.url_status_code url
+        unless status_code.start_with? "2"
           problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
         end
       elsif url.start_with? "git"
-- 
cgit v1.2.3


From 81b3368c9cba0f9db93af5732d8f10e75d00cdf9 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Tue, 24 Jan 2017 20:35:07 +0000
Subject: Added better check for HTTP git URLs

---
 Library/Homebrew/dev-cmd/audit.rb | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index f187f17f5..c685dacae 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1490,15 +1490,15 @@ class ResourceAuditor
 
     return unless @online
     urls.each do |url|
-      if url.start_with? "http", "ftp"
+      if url.start_with?("git") || url.end_with?(".git")
+        unless Utils.git_remote_exists url
+          problem "The URL #{url} is not a valid git URL"
+        end
+      elsif url.start_with? "http", "ftp"
         status_code = FormulaAuditor.url_status_code url
         unless status_code.start_with? "2"
           problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
         end
-      elsif url.start_with? "git"
-        unless Utils.git_remote_exists url
-          problem "The URL #{url} is not a valid git URL"
-        end
       elsif url.start_with? "svn"
         unless Utils.svn_remote_exists url
           problem "The URL #{url} is not a valid svn URL"
-- 
cgit v1.2.3


From a699d284d038907f884bb48f928f2e75ebadfc11 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Tue, 24 Jan 2017 23:11:50 +0000
Subject: Use DownloadStrategyDetector to classify mirror URLs

---
 Library/Homebrew/dev-cmd/audit.rb | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index c685dacae..a7c9de576 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1490,16 +1490,18 @@ class ResourceAuditor
 
     return unless @online
     urls.each do |url|
-      if url.start_with?("git") || url.end_with?(".git")
-        unless Utils.git_remote_exists url
-          problem "The URL #{url} is not a valid git URL"
-        end
-      elsif url.start_with? "http", "ftp"
+      strategy = DownloadStrategyDetector.detect(url)
+      if strategy <= CurlDownloadStrategy
+        problem url
         status_code = FormulaAuditor.url_status_code url
         unless status_code.start_with? "2"
           problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
         end
-      elsif url.start_with? "svn"
+      elsif strategy <= GitDownloadStrategy
+        unless Utils.git_remote_exists url
+          problem "The URL #{url} is not a valid git URL"
+        end
+      elsif strategy <= SubversionDownloadStrategy
         unless Utils.svn_remote_exists url
           problem "The URL #{url} is not a valid svn URL"
         end
-- 
cgit v1.2.3


From 12501b4046339b6becd42e37730873babeaa9dc2 Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Mon, 30 Jan 2017 18:30:57 +0000
Subject: Prevent mirror curl for file:/// URL

---
 Library/Homebrew/dev-cmd/audit.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index a7c9de576..180783f79 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1491,7 +1491,7 @@ class ResourceAuditor
     return unless @online
     urls.each do |url|
       strategy = DownloadStrategyDetector.detect(url)
-      if strategy <= CurlDownloadStrategy
+      if strategy <= CurlDownloadStrategy && !url.start_with?("file")
         problem url
         status_code = FormulaAuditor.url_status_code url
         unless status_code.start_with? "2"
-- 
cgit v1.2.3


From 55bc2a30195db915a60c862bf1c3d4ba6cd3cd4a Mon Sep 17 00:00:00 2001
From: David Broder-Rodgers
Date: Mon, 20 Feb 2017 19:00:27 +0000
Subject: Merged 404 and security mirror auditing logic

---
 Library/Homebrew/dev-cmd/audit.rb | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 180783f79..6e454f4d2 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -174,7 +174,7 @@ class FormulaAuditor
     @specs = %w[stable devel head].map { |s| formula.send(s) }.compact
   end
 
-  def self.url_status_code(url, range: false)
+  def url_status_code(url, range: false)
     # The system Curl is too old and unreliable with HTTPS homepages on
     # Yosemite and below.
     return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
@@ -619,8 +619,8 @@ class FormulaAuditor
 
     return unless @online
 
-    status_code = FormulaAuditor.url_status_code(homepage, user_agent: :browser)
-    return if status_code.start_with? "20"
+    status_code = url_status_code(homepage)
+    return if status_code.start_with? "2"
     problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
   end
 
@@ -1492,11 +1492,7 @@ class ResourceAuditor
     urls.each do |url|
       strategy = DownloadStrategyDetector.detect(url)
       if strategy <= CurlDownloadStrategy && !url.start_with?("file")
-        problem url
-        status_code = FormulaAuditor.url_status_code url
-        unless status_code.start_with? "2"
-          problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
-        end
+        check_http_mirror url
       elsif strategy <= GitDownloadStrategy
         unless Utils.git_remote_exists url
           problem "The URL #{url} is not a valid git URL"
@@ -1506,12 +1502,20 @@ class ResourceAuditor
           problem "The URL #{url} is not a valid svn URL"
         end
       end
-      check_insecure_mirror(url) if url.start_with? "http:"
     end
   end
 
-  def check_insecure_mirror(url)
+  def check_http_mirror(url)
     details =  get_content_details(url)
+
+    if details[:status].nil?
+      problem "The URL #{url} is not reachable"
+    elsif !details[:status].start_with? "2"
+      problem "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
+    end
+
+    return unless url.start_with? "http:"
+
     secure_url = url.sub "http", "https"
     secure_details = get_content_details(secure_url)
 
-- 
cgit v1.2.3


From 68a2471916bfbe1a4491e92c097f93c38cdaeecc Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Mon, 20 Feb 2017 22:24:44 +0100
Subject: Use `alias_matcher` for `fail_with`.

---
 Library/Homebrew/test/compiler_failure_spec.rb | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/compiler_failure_spec.rb b/Library/Homebrew/test/compiler_failure_spec.rb
index 81e464a87..b4fab0b27 100644
--- a/Library/Homebrew/test/compiler_failure_spec.rb
+++ b/Library/Homebrew/test/compiler_failure_spec.rb
@@ -1,12 +1,8 @@
 require "compilers"
 
-describe CompilerFailure do
-  matcher :fail_with do |expected|
-    match do |actual|
-      actual.fails_with?(expected)
-    end
-  end
+RSpec::Matchers.alias_matcher :fail_with, :be_fails_with
 
+describe CompilerFailure do
   describe "::create" do
     it "creates a failure when given a symbol" do
       failure = described_class.create(:clang)
-- 
cgit v1.2.3


From 9904eae48a5e4129905b48e5fe61afbb82726a39 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Fri, 17 Feb 2017 19:05:17 +0100
Subject: Convert FormulaPin test to spec.

---
 Library/Homebrew/test/formula_pin_spec.rb | 41 +++++++++++++++++++++++++
 Library/Homebrew/test/formula_pin_test.rb | 51 -------------------------------
 2 files changed, 41 insertions(+), 51 deletions(-)
 create mode 100644 Library/Homebrew/test/formula_pin_spec.rb
 delete mode 100644 Library/Homebrew/test/formula_pin_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/formula_pin_spec.rb b/Library/Homebrew/test/formula_pin_spec.rb
new file mode 100644
index 000000000..909bfbc2b
--- /dev/null
+++ b/Library/Homebrew/test/formula_pin_spec.rb
@@ -0,0 +1,41 @@
+require "formula_pin"
+
+describe FormulaPin do
+  subject { described_class.new(formula) }
+  let(:name) { "double" }
+  let(:formula) { double(Formula, name: name, rack: HOMEBREW_CELLAR/name) }
+
+  before(:each) do
+    formula.rack.mkpath
+
+    allow(formula).to receive(:installed_prefixes) do
+      formula.rack.directory? ? formula.rack.subdirs : []
+    end
+
+    allow(formula).to receive(:installed_kegs) do
+      formula.installed_prefixes.map { |prefix| Keg.new(prefix) }
+    end
+  end
+
+  it "is not pinnable by default" do
+    expect(subject).not_to be_pinnable
+  end
+
+  it "is pinnable if the Keg exists" do
+    (formula.rack/"0.1").mkpath
+    expect(subject).to be_pinnable
+  end
+
+  specify "#pin and #unpin" do
+    (formula.rack/"0.1").mkpath
+
+    subject.pin
+    expect(subject).to be_pinned
+    expect(HOMEBREW_PINNED_KEGS/name).to be_a_directory
+    expect(HOMEBREW_PINNED_KEGS.children.count).to eq(1)
+
+    subject.unpin
+    expect(subject).not_to be_pinned
+    expect(HOMEBREW_PINNED_KEGS).not_to be_a_directory
+  end
+end
diff --git a/Library/Homebrew/test/formula_pin_test.rb b/Library/Homebrew/test/formula_pin_test.rb
deleted file mode 100644
index 7e3c7efa0..000000000
--- a/Library/Homebrew/test/formula_pin_test.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require "testing_env"
-require "formula_pin"
-
-class FormulaPinTests < Homebrew::TestCase
-  class FormulaDouble
-    def name
-      "double"
-    end
-
-    def rack
-      HOMEBREW_CELLAR/name
-    end
-
-    def installed_prefixes
-      rack.directory? ? rack.subdirs : []
-    end
-
-    def installed_kegs
-      installed_prefixes.map { |d| Keg.new d }
-    end
-  end
-
-  def setup
-    super
-    @f   = FormulaDouble.new
-    @pin = FormulaPin.new(@f)
-    @f.rack.mkpath
-  end
-
-  def test_not_pinnable
-    refute_predicate @pin, :pinnable?
-  end
-
-  def test_pinnable_if_kegs_exist
-    (@f.rack/"0.1").mkpath
-    assert_predicate @pin, :pinnable?
-  end
-
-  def test_unpin
-    (@f.rack/"0.1").mkpath
-    @pin.pin
-
-    assert_predicate @pin, :pinned?
-    assert_equal 1, HOMEBREW_PINNED_KEGS.children.length
-
-    @pin.unpin
-
-    refute_predicate @pin, :pinned?
-    refute_predicate HOMEBREW_PINNED_KEGS, :directory?
-  end
-end
-- 
cgit v1.2.3


From 1ff6846218367fc73736039d668b319acebd8cae Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sun, 12 Feb 2017 23:03:46 +0100
Subject: Convert StringInreplaceExtension test to spec.

---
 Library/Homebrew/test/inreplace_spec.rb | 251 ++++++++++++++++++++++++++++++++
 Library/Homebrew/test/inreplace_test.rb | 119 ---------------
 2 files changed, 251 insertions(+), 119 deletions(-)
 create mode 100644 Library/Homebrew/test/inreplace_spec.rb
 delete mode 100644 Library/Homebrew/test/inreplace_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/inreplace_spec.rb b/Library/Homebrew/test/inreplace_spec.rb
new file mode 100644
index 000000000..5be44f50d
--- /dev/null
+++ b/Library/Homebrew/test/inreplace_spec.rb
@@ -0,0 +1,251 @@
+require "extend/string"
+require "tempfile"
+require "utils/inreplace"
+
+describe StringInreplaceExtension do
+  subject { string.extend(described_class) }
+
+  describe "#change_make_var!" do
+    context "flag" do
+      context "with spaces" do
+        let(:string) do
+          <<-EOS.undent
+            OTHER=def
+            FLAG = abc
+            FLAG2=abc
+          EOS
+        end
+
+        it "is successfully replaced" do
+          subject.change_make_var! "FLAG", "def"
+          expect(subject).to eq <<-EOS.undent
+            OTHER=def
+            FLAG=def
+            FLAG2=abc
+          EOS
+        end
+
+        it "is successfully appended" do
+          subject.change_make_var! "FLAG", "\\1 def"
+          expect(subject).to eq <<-EOS.undent
+            OTHER=def
+            FLAG=abc def
+            FLAG2=abc
+          EOS
+        end
+      end
+
+      context "with tabs" do
+        let(:string) do
+          <<-EOS.undent
+            CFLAGS\t=\t-Wall -O2
+            LDFLAGS\t=\t-lcrypto -lssl
+          EOS
+        end
+
+        it "is successfully replaced" do
+          subject.change_make_var! "CFLAGS", "-O3"
+          expect(subject).to eq <<-EOS.undent
+            CFLAGS=-O3
+            LDFLAGS\t=\t-lcrypto -lssl
+          EOS
+        end
+      end
+    end
+
+    context "empty flag between other flags" do
+      let(:string) do
+        <<-EOS.undent
+          OTHER=def
+          FLAG =
+          FLAG2=abc
+        EOS
+      end
+
+      it "is successfully replaced" do
+        subject.change_make_var! "FLAG", "def"
+        expect(subject).to eq <<-EOS.undent
+          OTHER=def
+          FLAG=def
+          FLAG2=abc
+        EOS
+      end
+    end
+
+    context "empty flag" do
+      let(:string) do
+        <<-EOS.undent
+          FLAG =
+          mv file_a file_b
+        EOS
+      end
+
+      it "is successfully replaced" do
+        subject.change_make_var! "FLAG", "def"
+        expect(subject).to eq <<-EOS.undent
+          FLAG=def
+          mv file_a file_b
+        EOS
+      end
+    end
+
+    context "shell-style variable" do
+      let(:string) do
+        <<-EOS.undent
+          OTHER=def
+          FLAG=abc
+          FLAG2=abc
+        EOS
+      end
+
+      it "is successfully replaced" do
+        subject.change_make_var! "FLAG", "def"
+        expect(subject).to eq <<-EOS.undent
+          OTHER=def
+          FLAG=def
+          FLAG2=abc
+        EOS
+      end
+    end
+  end
+
+  describe "#remove_make_var!" do
+    context "flag" do
+      context "with spaces" do
+        let(:string) do
+          <<-EOS.undent
+            OTHER=def
+            FLAG = abc
+            FLAG2 = def
+          EOS
+        end
+
+        it "is successfully removed" do
+          subject.remove_make_var! "FLAG"
+          expect(subject).to eq <<-EOS.undent
+            OTHER=def
+            FLAG2 = def
+          EOS
+        end
+      end
+
+      context "with tabs" do
+        let(:string) do
+          <<-EOS.undent
+            CFLAGS\t=\t-Wall -O2
+            LDFLAGS\t=\t-lcrypto -lssl
+          EOS
+        end
+
+        it "is successfully removed" do
+          subject.remove_make_var! "LDFLAGS"
+          expect(subject).to eq <<-EOS.undent
+            CFLAGS\t=\t-Wall -O2
+          EOS
+        end
+      end
+    end
+
+    context "multiple flags" do
+      let(:string) do
+        <<-EOS.undent
+          OTHER=def
+          FLAG = abc
+          FLAG2 = def
+          OTHER2=def
+        EOS
+      end
+
+      specify "are be successfully removed" do
+        subject.remove_make_var! ["FLAG", "FLAG2"]
+        expect(subject).to eq <<-EOS.undent
+          OTHER=def
+          OTHER2=def
+        EOS
+      end
+    end
+  end
+
+  describe "#get_make_var" do
+    context "with spaces" do
+      let(:string) do
+        <<-EOS.undent
+          CFLAGS = -Wall -O2
+          LDFLAGS = -lcrypto -lssl
+        EOS
+      end
+
+      it "extracts the value for a given variable" do
+        expect(subject.get_make_var("CFLAGS")).to eq("-Wall -O2")
+      end
+    end
+
+    context "with tabs" do
+      let(:string) do
+        <<-EOS.undent
+          CFLAGS\t=\t-Wall -O2
+          LDFLAGS\t=\t-lcrypto -lssl
+        EOS
+      end
+
+      it "extracts the value for a given variable" do
+        expect(subject.get_make_var("CFLAGS")).to eq("-Wall -O2")
+      end
+    end
+  end
+
+  describe "#sub!" do
+    let(:string) { "foo" }
+
+    it "replaces the first occurence" do
+      subject.sub!("o", "e")
+      expect(subject).to eq("feo")
+    end
+  end
+
+  describe "#gsub!" do
+    let(:string) { "foo" }
+
+    it "replaces the all occurences" do
+      subject.gsub!("o", "e") # rubocop:disable Performance/StringReplacement
+      expect(subject).to eq("fee")
+    end
+  end
+end
+
+describe Utils::Inreplace do
+  let(:file) { Tempfile.new("test") }
+
+  before(:each) do
+    file.write <<-EOS.undent
+      a
+      b
+      c
+    EOS
+  end
+
+  after(:each) { file.unlink }
+
+  it "raises error if there is nothing to replace" do
+    expect {
+      described_class.inreplace file.path, "d", "f"
+    }.to raise_error(Utils::InreplaceError)
+  end
+
+  it "raises error if there is nothing to replace" do
+    expect {
+      described_class.inreplace(file.path) do |s|
+        s.gsub!("d", "f") # rubocop:disable Performance/StringReplacement
+      end
+    }.to raise_error(Utils::InreplaceError)
+  end
+
+  it "raises error if there is nothing to replace" do
+    expect {
+      described_class.inreplace(file.path) do |s|
+        s.change_make_var! "VAR", "value"
+        s.remove_make_var! "VAR2"
+      end
+    }.to raise_error(Utils::InreplaceError)
+  end
+end
diff --git a/Library/Homebrew/test/inreplace_test.rb b/Library/Homebrew/test/inreplace_test.rb
deleted file mode 100644
index 0e62f9d3f..000000000
--- a/Library/Homebrew/test/inreplace_test.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-require "testing_env"
-require "extend/string"
-require "utils/inreplace"
-
-class InreplaceTest < Homebrew::TestCase
-  def test_change_make_var
-    # Replace flag
-    s1 = "OTHER=def\nFLAG = abc\nFLAG2=abc"
-    s1.extend(StringInreplaceExtension)
-    s1.change_make_var! "FLAG", "def"
-    assert_equal "OTHER=def\nFLAG=def\nFLAG2=abc", s1
-  end
-
-  def test_change_make_var_empty
-    # Replace empty flag
-    s1 = "OTHER=def\nFLAG = \nFLAG2=abc"
-    s1.extend(StringInreplaceExtension)
-    s1.change_make_var! "FLAG", "def"
-    assert_equal "OTHER=def\nFLAG=def\nFLAG2=abc", s1
-  end
-
-  def test_change_make_var_empty_2
-    # Replace empty flag
-    s1 = "FLAG = \nmv file_a file_b"
-    s1.extend(StringInreplaceExtension)
-    s1.change_make_var! "FLAG", "def"
-    assert_equal "FLAG=def\nmv file_a file_b", s1
-  end
-
-  def test_change_make_var_append
-    # Append to flag
-    s1 = "OTHER=def\nFLAG = abc\nFLAG2=abc"
-    s1.extend(StringInreplaceExtension)
-    s1.change_make_var! "FLAG", "\\1 def"
-    assert_equal "OTHER=def\nFLAG=abc def\nFLAG2=abc", s1
-  end
-
-  def test_change_make_var_shell_style
-    # Shell variables have no spaces around =
-    s1 = "OTHER=def\nFLAG=abc\nFLAG2=abc"
-    s1.extend(StringInreplaceExtension)
-    s1.change_make_var! "FLAG", "def"
-    assert_equal "OTHER=def\nFLAG=def\nFLAG2=abc", s1
-  end
-
-  def test_remove_make_var
-    # Replace flag
-    s1 = "OTHER=def\nFLAG = abc\nFLAG2 = def"
-    s1.extend(StringInreplaceExtension)
-    s1.remove_make_var! "FLAG"
-    assert_equal "OTHER=def\nFLAG2 = def", s1
-  end
-
-  def test_remove_make_vars
-    # Replace flag
-    s1 = "OTHER=def\nFLAG = abc\nFLAG2 = def\nOTHER2=def"
-    s1.extend(StringInreplaceExtension)
-    s1.remove_make_var! ["FLAG", "FLAG2"]
-    assert_equal "OTHER=def\nOTHER2=def", s1
-  end
-
-  def test_get_make_var
-    s = "CFLAGS = -Wall -O2\nLDFLAGS = -lcrypto -lssl"
-    s.extend(StringInreplaceExtension)
-    assert_equal "-Wall -O2", s.get_make_var("CFLAGS")
-  end
-
-  def test_change_make_var_with_tabs
-    s = "CFLAGS\t=\t-Wall -O2\nLDFLAGS\t=\t-lcrypto -lssl"
-    s.extend(StringInreplaceExtension)
-
-    assert_equal "-Wall -O2", s.get_make_var("CFLAGS")
-
-    s.change_make_var! "CFLAGS", "-O3"
-    assert_equal "CFLAGS=-O3\nLDFLAGS\t=\t-lcrypto -lssl", s
-
-    s.remove_make_var! "LDFLAGS"
-    assert_equal "CFLAGS=-O3\n", s
-  end
-
-  def test_sub_gsub
-    s = "foo"
-    s.extend(StringInreplaceExtension)
-
-    s.sub!("f", "b")
-    assert_equal "boo", s
-
-    # Under current context, we are testing `String#gsub!`, so let's disable rubocop temporarily.
-    s.gsub!("o", "e") # rubocop:disable Performance/StringReplacement
-    assert_equal "bee", s
-  end
-
-  def test_inreplace_errors
-    require "tempfile"
-    extend(Utils::Inreplace)
-
-    file = Tempfile.new("test")
-
-    file.write "a\nb\nc\n"
-
-    assert_raises(Utils::InreplaceError) do
-      inreplace file.path, "d", "f"
-    end
-
-    assert_raises(Utils::InreplaceError) do
-      # Under current context, we are testing `String#gsub!`, so let's disable rubocop temporarily.
-      inreplace(file.path) { |s| s.gsub!("d", "f") } # rubocop:disable Performance/StringReplacement
-    end
-
-    assert_raises(Utils::InreplaceError) do
-      inreplace(file.path) do |s|
-        s.change_make_var! "VAR", "value"
-        s.remove_make_var! "VAR2"
-      end
-    end
-  ensure
-    file.unlink
-  end
-end
-- 
cgit v1.2.3


From 125a6eee2165039d3b7329543d2e33e321c267d2 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Mon, 20 Feb 2017 22:48:03 +0000
Subject: audit: fix `brew style`.

---
 Library/Homebrew/dev-cmd/audit.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 6e454f4d2..b63d39905 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1506,7 +1506,7 @@ class ResourceAuditor
   end
 
   def check_http_mirror(url)
-    details =  get_content_details(url)
+    details = get_content_details(url)
 
     if details[:status].nil?
       problem "The URL #{url} is not reachable"
-- 
cgit v1.2.3


From 9c1db3c820f715f62f550ba1e54f16f9b89bc6ed Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 02:50:52 +0100
Subject: Convert JavaRequirement test to spec.

---
 .../Homebrew/test/os/mac/java_requirement_spec.rb  | 34 ++++++++++++++++++++++
 .../Homebrew/test/os/mac/java_requirement_test.rb  | 31 --------------------
 2 files changed, 34 insertions(+), 31 deletions(-)
 create mode 100644 Library/Homebrew/test/os/mac/java_requirement_spec.rb
 delete mode 100644 Library/Homebrew/test/os/mac/java_requirement_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/java_requirement_spec.rb b/Library/Homebrew/test/os/mac/java_requirement_spec.rb
new file mode 100644
index 000000000..f6404db92
--- /dev/null
+++ b/Library/Homebrew/test/os/mac/java_requirement_spec.rb
@@ -0,0 +1,34 @@
+require "requirements/java_requirement"
+require "fileutils"
+
+describe JavaRequirement do
+  subject { described_class.new(%w[1.8]) }
+  let(:java_home) { Dir.mktmpdir }
+  let(:java_home_path) { Pathname.new(java_home) }
+
+  before(:each) do
+    FileUtils.mkdir java_home_path/"bin"
+    FileUtils.touch java_home_path/"bin/java"
+    allow(subject).to receive(:preferred_java).and_return(java_home_path/"bin/java")
+    expect(subject).to be_satisfied
+  end
+
+  after(:each) { java_home_path.rmtree }
+
+  specify "Apple Java environment" do
+    expect(ENV).to receive(:prepend_path)
+    expect(ENV).to receive(:append_to_cflags)
+
+    subject.modify_build_environment
+    expect(ENV["JAVA_HOME"]).to eq(java_home)
+  end
+
+  specify "Oracle Java environment" do
+    FileUtils.mkdir java_home_path/"include"
+    expect(ENV).to receive(:prepend_path)
+    expect(ENV).to receive(:append_to_cflags).twice
+
+    subject.modify_build_environment
+    expect(ENV["JAVA_HOME"]).to eq(java_home)
+  end
+end
diff --git a/Library/Homebrew/test/os/mac/java_requirement_test.rb b/Library/Homebrew/test/os/mac/java_requirement_test.rb
deleted file mode 100644
index 83c1af95c..000000000
--- a/Library/Homebrew/test/os/mac/java_requirement_test.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require "testing_env"
-require "requirements/java_requirement"
-require "fileutils"
-
-class OSMacJavaRequirementTests < Homebrew::TestCase
-  def setup
-    super
-    @java_req = JavaRequirement.new(%w[1.8])
-    @tmp_java_home = mktmpdir
-    @tmp_pathname = Pathname.new(@tmp_java_home)
-    FileUtils.mkdir @tmp_pathname/"bin"
-    FileUtils.touch @tmp_pathname/"bin/java"
-    @java_req.stubs(:preferred_java).returns(@tmp_pathname/"bin/java")
-    @java_req.satisfied?
-  end
-
-  def test_java_env_apple
-    ENV.expects(:prepend_path)
-    ENV.expects(:append_to_cflags)
-    @java_req.modify_build_environment
-    assert_equal ENV["JAVA_HOME"], @tmp_java_home
-  end
-
-  def test_java_env_oracle
-    FileUtils.mkdir @tmp_pathname/"include"
-    ENV.expects(:prepend_path)
-    ENV.expects(:append_to_cflags).twice
-    @java_req.modify_build_environment
-    assert_equal ENV["JAVA_HOME"], @tmp_java_home
-  end
-end
-- 
cgit v1.2.3


From 1be7852493cee7f7af9b31cef4547aca23bebb0b Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Mon, 20 Feb 2017 23:28:13 +0100
Subject: Convert SoftwareSpec test to spec.

---
 Library/Homebrew/test/software_spec_spec.rb | 184 ++++++++++++++++++++++++++++
 Library/Homebrew/test/software_spec_test.rb | 184 ----------------------------
 2 files changed, 184 insertions(+), 184 deletions(-)
 create mode 100644 Library/Homebrew/test/software_spec_spec.rb
 delete mode 100644 Library/Homebrew/test/software_spec_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/software_spec_spec.rb b/Library/Homebrew/test/software_spec_spec.rb
new file mode 100644
index 000000000..5fd4f598a
--- /dev/null
+++ b/Library/Homebrew/test/software_spec_spec.rb
@@ -0,0 +1,184 @@
+require "software_spec"
+
+RSpec::Matchers.alias_matcher :have_defined_resource, :be_resource_defined
+RSpec::Matchers.alias_matcher :have_defined_option, :be_option_defined
+
+describe SoftwareSpec do
+  let(:owner) { double(name: "some_name", full_name: "some_name", tap: "homebrew/core") }
+
+  describe "#resource" do
+    it "defines a resource" do
+      subject.resource("foo") { url "foo-1.0" }
+      expect(subject).to have_defined_resource("foo")
+    end
+
+    it "sets itself to be the resource's owner" do
+      subject.resource("foo") { url "foo-1.0" }
+      subject.owner = owner
+      subject.resources.each_value do |r|
+        expect(r.owner).to eq(subject)
+      end
+    end
+
+    it "receives the owner's version if it has no own version" do
+      subject.url("foo-42")
+      subject.resource("bar") { url "bar" }
+      subject.owner = owner
+
+      expect(subject.resource("bar").version).to eq("42")
+    end
+
+    it "raises an error when duplicate resources are defined" do
+      subject.resource("foo") { url "foo-1.0" }
+      expect {
+        subject.resource("foo") { url "foo-1.0" }
+      }.to raise_error(DuplicateResourceError)
+    end
+
+    it "raises an error when accessing missing resources" do
+      subject.owner = owner
+      expect {
+        subject.resource("foo")
+      }.to raise_error(ResourceMissingError)
+    end
+  end
+
+  describe "#owner" do
+    it "sets the owner" do
+      subject.owner = owner
+      expect(subject.owner).to eq(owner)
+    end
+
+    it "sets the name" do
+      subject.owner = owner
+      expect(subject.name).to eq(owner.name)
+    end
+  end
+
+  describe "#option" do
+    it "defines an option" do
+      subject.option("foo")
+      expect(subject).to have_defined_option("foo")
+    end
+
+    it "raises an error when it begins with dashes" do
+      expect {
+        subject.option("--foo")
+      }.to raise_error(ArgumentError)
+    end
+
+    it "raises an error when name is empty" do
+      expect {
+        subject.option("")
+      }.to raise_error(ArgumentError)
+    end
+
+    it "special cases the cxx11 option" do
+      subject.option(:cxx11)
+      expect(subject).to have_defined_option("c++11")
+      expect(subject).not_to have_defined_option("cxx11")
+    end
+
+    it "supports options with descriptions" do
+      subject.option("bar", "description")
+      expect(subject.options.first.description).to eq("description")
+    end
+
+    it "defaults to an empty string when no description is given" do
+      subject.option("foo")
+      expect(subject.options.first.description).to eq("")
+    end
+  end
+
+  describe "#deprecated_option" do
+    it "allows specifying deprecated options" do
+      subject.deprecated_option("foo" => "bar")
+      expect(subject.deprecated_options).not_to be_empty
+      expect(subject.deprecated_options.first.old).to eq("foo")
+      expect(subject.deprecated_options.first.current).to eq("bar")
+    end
+
+    it "allows specifying deprecated options as a Hash from an Array/String to an Array/String" do
+      subject.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"])
+      expect(subject.deprecated_options).to include(DeprecatedOption.new("foo1", "bar1"))
+      expect(subject.deprecated_options).to include(DeprecatedOption.new("foo2", "bar1"))
+      expect(subject.deprecated_options).to include(DeprecatedOption.new("foo3", "bar2"))
+      expect(subject.deprecated_options).to include(DeprecatedOption.new("foo3", "bar3"))
+    end
+
+    it "raises an error when empty" do
+      expect {
+        subject.deprecated_option({})
+      }.to raise_error(ArgumentError)
+    end
+  end
+
+  describe "#depends_on" do
+    it "allows specifying dependencies" do
+      subject.depends_on("foo")
+      expect(subject.deps.first.name).to eq("foo")
+    end
+
+    it "allows specifying optional dependencies" do
+      subject.depends_on "foo" => :optional
+      expect(subject).to have_defined_option("with-foo")
+    end
+
+    it "allows specifying recommended dependencies" do
+      subject.depends_on "bar" => :recommended
+      expect(subject).to have_defined_option("without-bar")
+    end
+  end
+
+  specify "explicit options override defaupt depends_on option description" do
+    subject.option("with-foo", "blah")
+    subject.depends_on("foo" => :optional)
+    expect(subject.options.first.description).to eq("blah")
+  end
+
+  describe "#patch" do
+    it "adds a patch" do
+      subject.patch(:p1, :DATA)
+      expect(subject.patches.count).to eq(1)
+      expect(subject.patches.first.strip).to eq(:p1)
+    end
+  end
+end
+
+describe HeadSoftwareSpec do
+  specify "#version" do
+    expect(subject.version).to eq(Version.create("HEAD"))
+  end
+
+  specify "#verify_download_integrity" do
+    expect(subject.verify_download_integrity(Object.new)).to be nil
+  end
+end
+
+describe BottleSpecification do
+  specify "#sha256" do
+    checksums = {
+      snow_leopard_32: "deadbeef" * 8,
+      snow_leopard: "faceb00c" * 8,
+      lion: "baadf00d" * 8,
+      mountain_lion: "8badf00d" * 8,
+    }
+
+    checksums.each_pair do |cat, digest|
+      subject.sha256(digest => cat)
+    end
+
+    checksums.each_pair do |cat, digest|
+      checksum, = subject.checksum_for(cat)
+      expect(Checksum.new(:sha256, digest)).to eq(checksum)
+    end
+  end
+
+  %w[root_url prefix cellar rebuild].each do |method|
+    specify "##{method}" do
+      object = Object.new
+      subject.public_send(method, object)
+      expect(subject.public_send(method)).to eq(object)
+    end
+  end
+end
diff --git a/Library/Homebrew/test/software_spec_test.rb b/Library/Homebrew/test/software_spec_test.rb
deleted file mode 100644
index 026265a4a..000000000
--- a/Library/Homebrew/test/software_spec_test.rb
+++ /dev/null
@@ -1,184 +0,0 @@
-require "testing_env"
-require "software_spec"
-
-class SoftwareSpecTests < Homebrew::TestCase
-  def setup
-    super
-    @spec = SoftwareSpec.new
-  end
-
-  def test_resource
-    @spec.resource("foo") { url "foo-1.0" }
-    assert @spec.resource_defined?("foo")
-  end
-
-  def test_raises_when_duplicate_resources_are_defined
-    @spec.resource("foo") { url "foo-1.0" }
-    assert_raises(DuplicateResourceError) do
-      @spec.resource("foo") { url "foo-1.0" }
-    end
-  end
-
-  def test_raises_when_accessing_missing_resources
-    @spec.owner = Class.new do
-      def name
-        "test"
-      end
-
-      def full_name
-        "test"
-      end
-
-      def tap
-        "homebrew/core"
-      end
-    end.new
-    assert_raises(ResourceMissingError) { @spec.resource("foo") }
-  end
-
-  def test_set_owner
-    owner = stub name: "some_name",
-                 full_name: "some_name",
-                 tap: "homebrew/core"
-    @spec.owner = owner
-    assert_equal owner, @spec.owner
-  end
-
-  def test_resource_owner
-    @spec.resource("foo") { url "foo-1.0" }
-    @spec.owner = stub name: "some_name",
-                       full_name: "some_name",
-                       tap: "homebrew/core"
-    assert_equal "some_name", @spec.name
-    @spec.resources.each_value { |r| assert_equal @spec, r.owner }
-  end
-
-  def test_resource_without_version_receives_owners_version
-    @spec.url("foo-42")
-    @spec.resource("bar") { url "bar" }
-    @spec.owner = stub name: "some_name",
-                       full_name: "some_name",
-                       tap: "homebrew/core"
-    assert_version_equal "42", @spec.resource("bar").version
-  end
-
-  def test_option
-    @spec.option("foo")
-    assert @spec.option_defined?("foo")
-  end
-
-  def test_option_raises_when_begins_with_dashes
-    assert_raises(ArgumentError) { @spec.option("--foo") }
-  end
-
-  def test_option_raises_when_name_empty
-    assert_raises(ArgumentError) { @spec.option("") }
-  end
-
-  def test_cxx11_option_special_case
-    @spec.option(:cxx11)
-    assert @spec.option_defined?("c++11")
-    refute @spec.option_defined?("cxx11")
-  end
-
-  def test_option_description
-    @spec.option("bar", "description")
-    assert_equal "description", @spec.options.first.description
-  end
-
-  def test_option_description_defaults_to_empty_string
-    @spec.option("foo")
-    assert_equal "", @spec.options.first.description
-  end
-
-  def test_deprecated_option
-    @spec.deprecated_option("foo" => "bar")
-    refute_empty @spec.deprecated_options
-    assert_equal "foo", @spec.deprecated_options.first.old
-    assert_equal "bar", @spec.deprecated_options.first.current
-  end
-
-  def test_deprecated_options
-    @spec.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"])
-    assert_includes @spec.deprecated_options, DeprecatedOption.new("foo1", "bar1")
-    assert_includes @spec.deprecated_options, DeprecatedOption.new("foo2", "bar1")
-    assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar2")
-    assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar3")
-  end
-
-  def test_deprecated_option_raises_when_empty
-    assert_raises(ArgumentError) { @spec.deprecated_option({}) }
-  end
-
-  def test_depends_on
-    @spec.depends_on("foo")
-    assert_equal "foo", @spec.deps.first.name
-  end
-
-  def test_dependency_option_integration
-    @spec.depends_on "foo" => :optional
-    @spec.depends_on "bar" => :recommended
-    assert @spec.option_defined?("with-foo")
-    assert @spec.option_defined?("without-bar")
-  end
-
-  def test_explicit_options_override_default_dep_option_description
-    @spec.option("with-foo", "blah")
-    @spec.depends_on("foo" => :optional)
-    assert_equal "blah", @spec.options.first.description
-  end
-
-  def test_patch
-    @spec.patch :p1, :DATA
-    assert_equal 1, @spec.patches.length
-    assert_equal :p1, @spec.patches.first.strip
-  end
-end
-
-class HeadSoftwareSpecTests < Homebrew::TestCase
-  def setup
-    super
-    @spec = HeadSoftwareSpec.new
-  end
-
-  def test_version
-    assert_version_equal "HEAD", @spec.version
-  end
-
-  def test_verify_download_integrity
-    assert_nil @spec.verify_download_integrity(Object.new)
-  end
-end
-
-class BottleSpecificationTests < Homebrew::TestCase
-  def setup
-    super
-    @spec = BottleSpecification.new
-  end
-
-  def test_checksum_setters
-    checksums = {
-      snow_leopard_32: "deadbeef"*8,
-      snow_leopard: "faceb00c"*8,
-      lion: "baadf00d"*8,
-      mountain_lion: "8badf00d"*8,
-    }
-
-    checksums.each_pair do |cat, digest|
-      @spec.sha256(digest => cat)
-    end
-
-    checksums.each_pair do |cat, digest|
-      checksum, = @spec.checksum_for(cat)
-      assert_equal Checksum.new(:sha256, digest), checksum
-    end
-  end
-
-  def test_other_setters
-    double = Object.new
-    %w[root_url prefix cellar rebuild].each do |method|
-      @spec.send(method, double)
-      assert_equal double, @spec.send(method)
-    end
-  end
-end
-- 
cgit v1.2.3


From e0d5afc2375709e217729806016cfd283eb912d5 Mon Sep 17 00:00:00 2001
From: Bob W. Hogg
Date: Mon, 20 Feb 2017 19:19:26 -0800
Subject: java_requirement: Make macOS overrides extend Requirement

This doesn't actually seem to make that much difference,
but it is at least consistent with the main class body and with
the Linux overrides.
---
 Library/Homebrew/extend/os/mac/requirements/java_requirement.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb
index 451e0001b..5f989bb56 100644
--- a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb
+++ b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb
@@ -1,4 +1,4 @@
-class JavaRequirement
+class JavaRequirement < Requirement
   cask "java"
 
   env do
-- 
cgit v1.2.3


From 5ec95978104eab9679340e739c3a5fd5786b4722 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 04:52:53 +0100
Subject: Convert OS::Mac::Keg test to spec.

---
 Library/Homebrew/test/os/mac/keg_spec.rb         | 32 +++++++++++
 Library/Homebrew/test/os/mac/keg_test.rb         | 69 ------------------------
 Library/Homebrew/test/spec_helper.rb             |  2 +
 Library/Homebrew/test/support/helper/fixtures.rb | 13 +++++
 4 files changed, 47 insertions(+), 69 deletions(-)
 create mode 100644 Library/Homebrew/test/os/mac/keg_spec.rb
 delete mode 100644 Library/Homebrew/test/os/mac/keg_test.rb
 create mode 100644 Library/Homebrew/test/support/helper/fixtures.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/keg_spec.rb b/Library/Homebrew/test/os/mac/keg_spec.rb
new file mode 100644
index 000000000..562c2ba6a
--- /dev/null
+++ b/Library/Homebrew/test/os/mac/keg_spec.rb
@@ -0,0 +1,32 @@
+require "keg"
+
+describe Keg do
+  include FileUtils
+
+  subject { described_class.new(keg_path) }
+
+  describe "#mach_o_files" do
+    let(:keg_path) { HOMEBREW_CELLAR/"a/1.0" }
+
+    before(:each) { (keg_path/"lib").mkpath }
+
+    after(:each) { subject.unlink }
+
+    it "skips hardlinks" do
+      cp dylib_path("i386"), keg_path/"lib/i386.dylib"
+      ln keg_path/"lib/i386.dylib", keg_path/"lib/i386_hardlink.dylib"
+
+      subject.link
+      expect(subject.mach_o_files.count).to eq(1)
+    end
+
+    it "isn't confused by symlinks" do
+      cp dylib_path("i386"), keg_path/"lib/i386.dylib"
+      ln keg_path/"lib/i386.dylib", keg_path/"lib/i386_hardlink.dylib"
+      ln_s keg_path/"lib/i386.dylib", keg_path/"lib/i386_symlink.dylib"
+
+      subject.link
+      expect(subject.mach_o_files.count).to eq(1)
+    end
+  end
+end
diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb
deleted file mode 100644
index d1103415d..000000000
--- a/Library/Homebrew/test/os/mac/keg_test.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require "testing_env"
-require "keg"
-require "stringio"
-
-class OSMacLinkTests < Homebrew::TestCase
-  include FileUtils
-
-  def setup
-    super
-
-    keg = HOMEBREW_CELLAR.join("foo", "1.0")
-    keg.join("bin").mkpath
-
-    %w[hiworld helloworld goodbye_cruel_world].each do |file|
-      touch keg.join("bin", file)
-    end
-
-    @keg = Keg.new(keg)
-    @dst = HOMEBREW_PREFIX.join("bin", "helloworld")
-    @nonexistent = Pathname.new("/some/nonexistent/path")
-
-    @mode = OpenStruct.new
-
-    @old_stdout = $stdout
-    $stdout = StringIO.new
-
-    mkpath HOMEBREW_PREFIX/"bin"
-    mkpath HOMEBREW_PREFIX/"lib"
-  end
-
-  def teardown
-    @keg.unlink
-
-    $stdout = @old_stdout
-
-    rmtree HOMEBREW_PREFIX/"lib"
-
-    super
-  end
-
-  def test_mach_o_files_skips_hardlinks
-    a = HOMEBREW_CELLAR/"a/1.0"
-    (a/"lib").mkpath
-    FileUtils.cp dylib_path("i386"), a/"lib/i386.dylib"
-    FileUtils.ln a/"lib/i386.dylib", a/"lib/i386_link.dylib"
-
-    keg = Keg.new(a)
-    keg.link
-
-    assert_equal 1, keg.mach_o_files.size
-  ensure
-    keg.unlink
-  end
-
-  def test_mach_o_files_isnt_confused_by_symlinks
-    a = HOMEBREW_CELLAR/"a/1.0"
-    (a/"lib").mkpath
-    FileUtils.cp dylib_path("i386"), a/"lib/i386.dylib"
-    FileUtils.ln a/"lib/i386.dylib", a/"lib/i386_link.dylib"
-    FileUtils.ln_s a/"lib/i386.dylib", a/"lib/1.dylib"
-
-    keg = Keg.new(a)
-    keg.link
-
-    assert_equal 1, keg.mach_o_files.size
-  ensure
-    keg.unlink
-  end
-end
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index d8694eefc..b58125aec 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -15,6 +15,7 @@ require "global"
 require "tap"
 
 require "test/support/helper/shutup"
+require "test/support/helper/fixtures"
 
 TEST_DIRECTORIES = [
   CoreTap.instance.path/"Formula",
@@ -29,6 +30,7 @@ TEST_DIRECTORIES = [
 RSpec.configure do |config|
   config.order = :random
   config.include(Test::Helper::Shutup)
+  config.include(Test::Helper::Fixtures)
   config.before(:each) do |example|
     if example.metadata[:needs_macos]
       skip "not on macOS" unless OS.mac?
diff --git a/Library/Homebrew/test/support/helper/fixtures.rb b/Library/Homebrew/test/support/helper/fixtures.rb
new file mode 100644
index 000000000..716fe2008
--- /dev/null
+++ b/Library/Homebrew/test/support/helper/fixtures.rb
@@ -0,0 +1,13 @@
+module Test
+  module Helper
+    module Fixtures
+      def dylib_path(name)
+        Pathname.new("#{TEST_FIXTURE_DIR}/mach/#{name}.dylib")
+      end
+
+      def bundle_path(name)
+        Pathname.new("#{TEST_FIXTURE_DIR}/mach/#{name}.bundle")
+      end
+    end
+  end
+end
-- 
cgit v1.2.3


From 9fc14e663bc52b5e32a4c2d07ed6114b99fcbf54 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 05:00:26 +0100
Subject: Convert GPG2Requirement test to spec.

---
 Library/Homebrew/test/gpg2_requirement_spec.rb | 23 +++++++++++++++++++++++
 Library/Homebrew/test/gpg2_requirement_test.rb | 25 -------------------------
 2 files changed, 23 insertions(+), 25 deletions(-)
 create mode 100644 Library/Homebrew/test/gpg2_requirement_spec.rb
 delete mode 100644 Library/Homebrew/test/gpg2_requirement_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/gpg2_requirement_spec.rb b/Library/Homebrew/test/gpg2_requirement_spec.rb
new file mode 100644
index 000000000..f46b31196
--- /dev/null
+++ b/Library/Homebrew/test/gpg2_requirement_spec.rb
@@ -0,0 +1,23 @@
+require "requirements/gpg2_requirement"
+require "fileutils"
+
+describe GPG2Requirement do
+  let(:dir) { @dir = Pathname.new(Dir.mktmpdir) }
+
+  after(:each) do
+    FileUtils.rm_rf dir unless @dir.nil?
+  end
+
+  describe "#satisfied?" do
+    it "returns true if GPG2 is installed" do
+      ENV["PATH"] = dir/"bin"
+      (dir/"bin/gpg").write <<-EOS.undent
+        #!/bin/bash
+        echo 2.0.30
+      EOS
+      FileUtils.chmod 0755, dir/"bin/gpg"
+
+      expect(subject).to be_satisfied
+    end
+  end
+end
diff --git a/Library/Homebrew/test/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb
deleted file mode 100644
index 3297c2851..000000000
--- a/Library/Homebrew/test/gpg2_requirement_test.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require "testing_env"
-require "requirements/gpg2_requirement"
-require "fileutils"
-
-class GPG2RequirementTests < Homebrew::TestCase
-  def setup
-    super
-    @dir = Pathname.new(mktmpdir)
-    (@dir/"bin/gpg").write <<-EOS.undent
-      #!/bin/bash
-      echo 2.0.30
-    EOS
-    FileUtils.chmod 0755, @dir/"bin/gpg"
-  end
-
-  def teardown
-    FileUtils.rm_rf @dir
-    super
-  end
-
-  def test_satisfied
-    ENV["PATH"] = @dir/"bin"
-    assert_predicate GPG2Requirement.new, :satisfied?
-  end
-end
-- 
cgit v1.2.3


From 423f22df0033f83a04a9452d2e755a96e830b039 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 05:13:05 +0100
Subject: Convert `search_remote_tap` test to spec.

---
 Library/Homebrew/test/cmd/search_remote_tap_spec.rb | 19 +++++++++++++++++++
 Library/Homebrew/test/search_remote_tap_test.rb     | 19 -------------------
 2 files changed, 19 insertions(+), 19 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/search_remote_tap_spec.rb
 delete mode 100644 Library/Homebrew/test/search_remote_tap_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/search_remote_tap_spec.rb b/Library/Homebrew/test/cmd/search_remote_tap_spec.rb
new file mode 100644
index 000000000..99c2cc20b
--- /dev/null
+++ b/Library/Homebrew/test/cmd/search_remote_tap_spec.rb
@@ -0,0 +1,19 @@
+require "cmd/search"
+
+describe Homebrew do
+  specify "#search_tap" do
+    json_response = {
+      "tree" => [
+        {
+          "path" => "Formula/not-a-formula.rb",
+          "type" => "blob",
+        },
+      ],
+    }
+
+    allow(GitHub).to receive(:open).and_yield(json_response)
+
+    expect(described_class.search_tap("homebrew", "not-a-tap", "not-a-formula"))
+      .to eq(["homebrew/not-a-tap/not-a-formula"])
+  end
+end
diff --git a/Library/Homebrew/test/search_remote_tap_test.rb b/Library/Homebrew/test/search_remote_tap_test.rb
deleted file mode 100644
index 9dd9ee654..000000000
--- a/Library/Homebrew/test/search_remote_tap_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "testing_env"
-require "cmd/search"
-
-class SearchRemoteTapTests < Homebrew::TestCase
-  def test_search_remote_tap
-    json_response = {
-      "tree" => [
-        {
-          "path" => "Formula/not-a-formula.rb",
-          "type" => "blob",
-        },
-      ],
-    }
-
-    GitHub.stubs(:open).yields(json_response)
-
-    assert_equal ["homebrew/not-a-tap/not-a-formula"], Homebrew.search_tap("homebrew", "not-a-tap", "not-a-formula")
-  end
-end
-- 
cgit v1.2.3


From 66e3541b12eddaa18422a29b0f0ca968f54952f5 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 05:54:16 +0100
Subject: Convert MacOS::Version test to spec.

---
 Library/Homebrew/test/os/mac/version_spec.rb | 51 ++++++++++++++++++++++++++
 Library/Homebrew/test/os/mac/version_test.rb | 54 ----------------------------
 2 files changed, 51 insertions(+), 54 deletions(-)
 create mode 100644 Library/Homebrew/test/os/mac/version_spec.rb
 delete mode 100644 Library/Homebrew/test/os/mac/version_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/version_spec.rb b/Library/Homebrew/test/os/mac/version_spec.rb
new file mode 100644
index 000000000..797207b67
--- /dev/null
+++ b/Library/Homebrew/test/os/mac/version_spec.rb
@@ -0,0 +1,51 @@
+require "version"
+require "os/mac/version"
+
+describe OS::Mac::Version do
+  subject { described_class.new("10.7") }
+
+  specify "comparison with Symbol" do
+    expect(subject).to be > :snow_leopard
+    expect(subject).to be == :lion
+    expect(subject).to be === :lion # rubocop:disable Style/CaseEquality
+    expect(subject).to be < :mountain_lion
+  end
+
+  specify "comparison with Fixnum" do
+    expect(subject).to be > 10
+    expect(subject).to be < 11
+  end
+
+  specify "comparison with Float" do
+    expect(subject).to be > 10.6
+    expect(subject).to be == 10.7
+    expect(subject).to be === 10.7 # rubocop:disable Style/CaseEquality
+    expect(subject).to be < 10.8
+  end
+
+  specify "comparison with String" do
+    expect(subject).to be > "10.6"
+    expect(subject).to be == "10.7"
+    expect(subject).to be === "10.7" # rubocop:disable Style/CaseEquality
+    expect(subject).to be < "10.8"
+  end
+
+  specify "comparison with Version" do
+    expect(subject).to be > Version.create("10.6")
+    expect(subject).to be == Version.create("10.7")
+    expect(subject).to be === Version.create("10.7") # rubocop:disable Style/CaseEquality
+    expect(subject).to be < Version.create("10.8")
+  end
+
+  specify "#from_symbol" do
+    expect(described_class.from_symbol(:lion)).to eq(subject)
+    expect { described_class.from_symbol(:foo) }
+      .to raise_error(ArgumentError)
+  end
+
+  specify "#pretty_name" do
+    expect(described_class.new("10.11").pretty_name).to eq("El Capitan")
+    expect(described_class.new("10.8").pretty_name).to eq("Mountain Lion")
+    expect(described_class.new("10.10").pretty_name).to eq("Yosemite")
+  end
+end
diff --git a/Library/Homebrew/test/os/mac/version_test.rb b/Library/Homebrew/test/os/mac/version_test.rb
deleted file mode 100644
index ba4217691..000000000
--- a/Library/Homebrew/test/os/mac/version_test.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require "testing_env"
-require "version"
-require "os/mac/version"
-
-class OSMacVersionTests < Homebrew::TestCase
-  def setup
-    super
-    @v = MacOS::Version.new("10.7")
-  end
-
-  def test_compare_with_symbol
-    assert_operator @v, :>, :snow_leopard
-    assert_operator @v, :==, :lion
-    assert_operator @v, :===, :lion
-    assert_operator @v, :<, :mountain_lion
-  end
-
-  def test_compare_with_fixnum
-    assert_operator @v, :>, 10
-    assert_operator @v, :<, 11
-  end
-
-  def test_compare_with_float
-    assert_operator @v, :>, 10.6
-    assert_operator @v, :==, 10.7
-    assert_operator @v, :===, 10.7
-    assert_operator @v, :<, 10.8
-  end
-
-  def test_compare_with_string
-    assert_operator @v, :>, "10.6"
-    assert_operator @v, :==, "10.7"
-    assert_operator @v, :===, "10.7"
-    assert_operator @v, :<, "10.8"
-  end
-
-  def test_compare_with_version
-    assert_operator @v, :>, Version.create("10.6")
-    assert_operator @v, :==, Version.create("10.7")
-    assert_operator @v, :===, Version.create("10.7")
-    assert_operator @v, :<, Version.create("10.8")
-  end
-
-  def test_from_symbol
-    assert_equal @v, MacOS::Version.from_symbol(:lion)
-    assert_raises(ArgumentError) { MacOS::Version.from_symbol(:foo) }
-  end
-
-  def test_pretty_name
-    assert_equal "El Capitan", MacOS::Version.new("10.11").pretty_name
-    assert_equal "Mountain Lion", MacOS::Version.new("10.8").pretty_name
-    assert_equal "Yosemite", MacOS::Version.new("10.10").pretty_name
-  end
-end
-- 
cgit v1.2.3


From 15d681064173f06c5ca9de665d90cc9f036c6613 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 06:09:09 +0100
Subject: Convert `os/mac/blacklist` test to spec.

---
 Library/Homebrew/test/blacklist_spec.rb        | 18 +++++++++++-------
 Library/Homebrew/test/os/mac/blacklist_test.rb | 12 ------------
 2 files changed, 11 insertions(+), 19 deletions(-)
 delete mode 100644 Library/Homebrew/test/os/mac/blacklist_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/blacklist_spec.rb b/Library/Homebrew/test/blacklist_spec.rb
index 89d254893..01882167d 100644
--- a/Library/Homebrew/test/blacklist_spec.rb
+++ b/Library/Homebrew/test/blacklist_spec.rb
@@ -1,12 +1,8 @@
 require "blacklist"
 
-RSpec::Matchers.define :be_blacklisted do
-  match do |actual|
-    blacklisted?(actual)
-  end
-end
-
 describe "Blacklist" do
+  matcher(:be_blacklisted) { match(&method(:blacklisted?)) }
+
   context "rubygems" do
     %w[gem rubygem rubygems].each do |s|
       subject { s }
@@ -103,9 +99,17 @@ describe "Blacklist" do
     it { is_expected.to be_blacklisted }
   end
 
-  context "haskell_platform" do
+  context "haskell-platform" do
     subject { "haskell-platform" }
 
     it { is_expected.to be_blacklisted }
   end
+
+  context "xcode", :needs_macos do
+    %w[xcode Xcode].each do |s|
+      subject { s }
+
+      it { is_expected.to be_blacklisted }
+    end
+  end
 end
diff --git a/Library/Homebrew/test/os/mac/blacklist_test.rb b/Library/Homebrew/test/os/mac/blacklist_test.rb
deleted file mode 100644
index 26dd84ed9..000000000
--- a/Library/Homebrew/test/os/mac/blacklist_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require "testing_env"
-require "blacklist"
-
-class OSMacBlacklistTests < Homebrew::TestCase
-  def assert_blacklisted(s)
-    assert blacklisted?(s), "'#{s}' should be blacklisted"
-  end
-
-  def test_xcode
-    %w[xcode Xcode].each { |s| assert_blacklisted s }
-  end
-end
-- 
cgit v1.2.3


From 799da6dbe80b4808e66d81c0004d279abcbf55ea Mon Sep 17 00:00:00 2001
From: Kimmo Lehto
Date: Tue, 21 Feb 2017 11:12:34 +0200
Subject: Prepend selected ruby to PATH in RubyRequirement

---
 Library/Homebrew/requirements/ruby_requirement.rb | 37 +++++++++++++++++++----
 1 file changed, 31 insertions(+), 6 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/requirements/ruby_requirement.rb
index a890435a5..e432edddb 100644
--- a/Library/Homebrew/requirements/ruby_requirement.rb
+++ b/Library/Homebrew/requirements/ruby_requirement.rb
@@ -9,15 +9,14 @@ class RubyRequirement < Requirement
   end
 
   satisfy build_env: false do
-    which_all("ruby").detect do |ruby|
-      version = /\d\.\d/.match Utils.popen_read(ruby, "--version")
-      next unless version
-      Version.create(version.to_s) >= Version.create(@version)
-    end
+    found_ruby = rubies.detect { |ruby| suitable?(ruby) }
+    return unless found_ruby
+    ENV.prepend_path "PATH", found_ruby.dirname
+    found_ruby
   end
 
   def message
-    s = "Ruby #{@version} is required to install this formula."
+    s = "Ruby >= #{@version} is required to install this formula."
     s += super
     s
   end
@@ -33,4 +32,30 @@ class RubyRequirement < Requirement
       name
     end
   end
+
+  private
+
+  def rubies
+    rubies = which_all("ruby")
+    if ruby_formula.installed?
+      rubies.unshift Pathname.new(ruby_formula.bin/"ruby")
+    end
+    rubies.uniq
+  end
+
+  def suitable?(ruby)
+    version = Utils.popen_read(ruby, "-e", "print RUBY_VERSION").strip
+    version =~ /^\d+\.\d+/ && Version.create(version) >= min_version
+  end
+
+  def min_version
+    @min_version ||= Version.create(@version)
+  end
+
+  def ruby_formula
+    @ruby_formula ||= Formula["ruby"]
+  rescue FormulaUnavailableError
+    nil
+  end
+
 end
-- 
cgit v1.2.3


From df7ae5eb26a9552ff61c66ed5680c701bf0be7df Mon Sep 17 00:00:00 2001
From: Kimmo Lehto
Date: Tue, 21 Feb 2017 11:24:53 +0200
Subject: Use the env block

---
 Library/Homebrew/requirements/ruby_requirement.rb | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/requirements/ruby_requirement.rb
index e432edddb..817cf3e32 100644
--- a/Library/Homebrew/requirements/ruby_requirement.rb
+++ b/Library/Homebrew/requirements/ruby_requirement.rb
@@ -8,11 +8,10 @@ class RubyRequirement < Requirement
     super
   end
 
-  satisfy build_env: false do
-    found_ruby = rubies.detect { |ruby| suitable?(ruby) }
-    return unless found_ruby
-    ENV.prepend_path "PATH", found_ruby.dirname
-    found_ruby
+  satisfy build_env: false { suitable_ruby }
+
+  env do
+    ENV.prepend_path "PATH", suitable_ruby
   end
 
   def message
@@ -35,6 +34,10 @@ class RubyRequirement < Requirement
 
   private
 
+  def suitable_ruby
+    rubies.detect { |ruby| suitable?(ruby) }
+  end
+
   def rubies
     rubies = which_all("ruby")
     if ruby_formula.installed?
-- 
cgit v1.2.3


From 91c1a54b674c0468729de9ba62cccfaef2188af7 Mon Sep 17 00:00:00 2001
From: Kimmo Lehto
Date: Tue, 21 Feb 2017 11:26:40 +0200
Subject: Extra check

---
 Library/Homebrew/requirements/ruby_requirement.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/requirements/ruby_requirement.rb
index 817cf3e32..f03399078 100644
--- a/Library/Homebrew/requirements/ruby_requirement.rb
+++ b/Library/Homebrew/requirements/ruby_requirement.rb
@@ -40,7 +40,7 @@ class RubyRequirement < Requirement
 
   def rubies
     rubies = which_all("ruby")
-    if ruby_formula.installed?
+    if ruby_formula && ruby_formula.installed?
       rubies.unshift Pathname.new(ruby_formula.bin/"ruby")
     end
     rubies.uniq
-- 
cgit v1.2.3


From f5a0ae176a1abed5ecba42a436a8a32595c21a9d Mon Sep 17 00:00:00 2001
From: Kimmo Lehto
Date: Tue, 21 Feb 2017 13:16:04 +0200
Subject: Syntax fail

---
 Library/Homebrew/requirements/ruby_requirement.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/requirements/ruby_requirement.rb
index f03399078..0caedb5ca 100644
--- a/Library/Homebrew/requirements/ruby_requirement.rb
+++ b/Library/Homebrew/requirements/ruby_requirement.rb
@@ -8,7 +8,7 @@ class RubyRequirement < Requirement
     super
   end
 
-  satisfy build_env: false { suitable_ruby }
+  satisfy(build_env: false) { suitable_ruby }
 
   env do
     ENV.prepend_path "PATH", suitable_ruby
-- 
cgit v1.2.3


From a81bd81a14b6f1b85f523dc9cdb925ed7cc62b9a Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Tue, 21 Feb 2017 04:35:52 -0800
Subject: brew uninstal alias for brew uninstall

If `brew instal` is permissible, `brew uninstal` should be, too.
---
 Library/Homebrew/brew.sh             | 1 +
 Library/Homebrew/cask/lib/hbc/cli.rb | 1 +
 Library/Homebrew/global.rb           | 1 +
 3 files changed, 3 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh
index 81a52f474..11c1a6c59 100644
--- a/Library/Homebrew/brew.sh
+++ b/Library/Homebrew/brew.sh
@@ -207,6 +207,7 @@ case "$HOMEBREW_COMMAND" in
   up)          HOMEBREW_COMMAND="update" ;;
   ln)          HOMEBREW_COMMAND="link" ;;
   instal)      HOMEBREW_COMMAND="install" ;; # gem does the same
+  uninstal)    HOMEBREW_COMMAND="uninstall" ;;
   rm)          HOMEBREW_COMMAND="uninstall" ;;
   remove)      HOMEBREW_COMMAND="uninstall" ;;
   configure)   HOMEBREW_COMMAND="diy" ;;
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 73ab121d2..8e178e373 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -37,6 +37,7 @@ module Hbc
       "-S"       => "search",    # verb starting with "-" is questionable
       "up"       => "update",
       "instal"   => "install",   # gem does the same
+      "uninstal" => "uninstall",
       "rm"       => "uninstall",
       "remove"   => "uninstall",
       "abv"      => "info",
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index 5e88947c9..391f5b012 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -69,6 +69,7 @@ HOMEBREW_INTERNAL_COMMAND_ALIASES = {
   "up" => "update",
   "ln" => "link",
   "instal" => "install", # gem does the same
+  "uninstal" => "uninstall",
   "rm" => "uninstall",
   "remove" => "uninstall",
   "configure" => "diy",
-- 
cgit v1.2.3


From 606790d06284df4765128117269c06a4df7e197c Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Tue, 31 Jan 2017 11:42:13 +0000
Subject: audit: check for version aliases.

Current version aliases should be provided for versioned formulae so
people can `brew install foo@1.2` to provide pin-like behaviour.
---
 Library/Homebrew/dev-cmd/audit.rb | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 9ffef0f99..9da5d28b4 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -295,6 +295,27 @@ class FormulaAuditor
 
     problem "File should end with a newline" unless text.trailing_newline?
 
+    versioned_formulae = Dir[formula.path.to_s.gsub(/\.rb$/, "@*.rb")]
+    needs_versioned_alias = !versioned_formulae.empty? &&
+                            formula.tap &&
+                            formula.aliases.grep(/.@\d/).empty?
+    if needs_versioned_alias
+      _, last_alias_version = File.basename(versioned_formulae.sort.reverse.first)
+                                  .gsub(/\.rb$/, "")
+                                  .split("@")
+      major, minor, = formula.version.to_s.split(".")
+      alias_name = if last_alias_version.split(".").length == 1
+        "#{formula.name}@#{major}"
+      else
+        "#{formula.name}@#{major}.#{minor}"
+      end
+      problem <<-EOS.undent
+        Formula has other versions so create an alias:
+          cd #{formula.tap.alias_dir}
+          ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name}
+      EOS
+    end
+
     return unless @strict
 
     present = audit_components
@@ -410,7 +431,8 @@ class FormulaAuditor
           problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'."
         end
 
-        if @@aliases.include?(dep.name)
+        if @@aliases.include?(dep.name) &&
+           (core_formula? || !dep_f.versioned_formula?)
           problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
         end
 
-- 
cgit v1.2.3


From 68bd744d0e44e40a5e3269bb16030134d937a524 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Mon, 20 Feb 2017 14:05:40 +0000
Subject: readall: check for shadowed aliases.

This will become particularly relevant when there’s a new version of a
formula and the existing alias needs to be removed.
---
 Library/Homebrew/readall.rb | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/readall.rb b/Library/Homebrew/readall.rb
index 3dd7075ec..52addfa87 100644
--- a/Library/Homebrew/readall.rb
+++ b/Library/Homebrew/readall.rb
@@ -24,16 +24,15 @@ module Readall
       !failed
     end
 
-    def valid_aliases?(alias_dirs)
+    def valid_aliases?(alias_dir, formula_dir)
+      return false unless alias_dir.directory?
+
       failed = false
-      alias_dirs.each do |alias_dir|
-        next unless alias_dir.directory?
-        alias_dir.children.each do |f|
-          next unless f.symlink?
-          next if f.file?
-          onoe "Broken alias: #{f}"
-          failed = true
-        end
+      alias_dir.each_child do |f|
+        next unless f.symlink?
+        next if f.file? && !(formula_dir/"#{f.basename}.rb").exist?
+        onoe "Broken alias: #{f}"
+        failed = true
       end
       !failed
     end
@@ -57,7 +56,7 @@ module Readall
     def valid_tap?(tap, options = {})
       failed = false
       if options[:aliases]
-        valid_aliases = valid_aliases?([tap.alias_dir])
+        valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir)
         failed = true unless valid_aliases
       end
       valid_formulae = valid_formulae?(tap.formula_files)
-- 
cgit v1.2.3


From 1ea79cd0b33501ce6ed16961d7c82adb8ceb3cd3 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Tue, 21 Feb 2017 18:31:34 +0000
Subject: keg: handle missing alias opt link on uninstall.

Fixes an issue introduced in #1192 where there would be a failure if the
alias link didn't exist on removal (which would be the case for anything
with an alias installed before #1192 was merged).
---
 Library/Homebrew/keg.rb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index b31997d5a..94e3ff55b 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -239,7 +239,10 @@ class Keg
 
   def remove_opt_record
     opt_record.unlink
-    aliases.each { |a| (opt_record.parent/a).unlink }
+    aliases.each do |a|
+      next if !opt_record.symlink? && !opt_record.exist?
+      (opt_record.parent/a).delete
+    end
     opt_record.parent.rmdir_if_possible
   end
 
-- 
cgit v1.2.3


From 2f42dfc68a7c3cfdb2d364fc98dff67fea89e78e Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Tue, 21 Feb 2017 18:50:07 +0000
Subject: audit: fix revision should be removed.

Regression introduced in #1754 which meant that (due to storing the
current formula revision in `attributes_map`) `stable_revisions.empty?`
would never be `true`.
---
 Library/Homebrew/dev-cmd/audit.rb | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 9da5d28b4..d9c4bcddb 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -816,10 +816,12 @@ class FormulaAuditor
 
     return if formula.revision.zero?
     if formula.stable
-      revision_map = attributes_map[:revision][:stable]
-      stable_revisions = revision_map[formula.stable.version] if revision_map
-      if !stable_revisions || stable_revisions.empty?
-        problem "'revision #{formula.revision}' should be removed"
+      if revision_map = attributes_map[:revision][:stable]
+        stable_revisions = revision_map[formula.stable.version]
+        stable_revisions -= [formula.revision]
+        if stable_revisions.empty?
+          problem "'revision #{formula.revision}' should be removed"
+        end
       end
     else # head/devel-only formula
       problem "'revision #{formula.revision}' should be removed"
-- 
cgit v1.2.3


From 400eddcaae9087743ac783d92df23e75808c2006 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 02:02:39 +0100
Subject: Convert Homebrew::Diagnostic::Checks test to spec.

---
 Library/Homebrew/test/diagnostic_spec.rb | 188 ++++++++++++++++++++++++++++++
 Library/Homebrew/test/diagnostic_test.rb | 192 -------------------------------
 2 files changed, 188 insertions(+), 192 deletions(-)
 create mode 100644 Library/Homebrew/test/diagnostic_spec.rb
 delete mode 100644 Library/Homebrew/test/diagnostic_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/diagnostic_spec.rb b/Library/Homebrew/test/diagnostic_spec.rb
new file mode 100644
index 000000000..e749a3b0f
--- /dev/null
+++ b/Library/Homebrew/test/diagnostic_spec.rb
@@ -0,0 +1,188 @@
+require "diagnostic"
+
+describe Homebrew::Diagnostic::Checks do
+  specify "#inject_file_list" do
+    expect(subject.inject_file_list([], "foo:\n")).to eq("foo:\n")
+    expect(subject.inject_file_list(%w[/a /b], "foo:\n")).to eq("foo:\n  /a\n  /b\n")
+  end
+
+  specify "#check_path_for_trailing_slashes" do
+    ENV["PATH"] += File::PATH_SEPARATOR + "/foo/bar/"
+    expect(subject.check_path_for_trailing_slashes)
+      .to match("Some directories in your path end in a slash")
+  end
+
+  specify "#check_for_anaconda" do
+    Dir.mktmpdir do |path|
+      anaconda = "#{path}/anaconda"
+      python = "#{path}/python"
+      FileUtils.touch anaconda
+      File.open(python, "w") do |file|
+        file.write("#! #{`which bash`}\necho -n '#{python}'\n")
+      end
+      FileUtils.chmod 0755, anaconda
+      FileUtils.chmod 0755, python
+
+      ENV["PATH"] = path + File::PATH_SEPARATOR + ENV["PATH"]
+
+      expect(subject.check_for_anaconda).to match("Anaconda")
+    end
+  end
+
+  specify "#check_access_homebrew_repository" do
+    begin
+      mode = HOMEBREW_REPOSITORY.stat.mode & 0777
+      HOMEBREW_REPOSITORY.chmod 0555
+
+      expect(subject.check_access_homebrew_repository)
+        .to match("#{HOMEBREW_REPOSITORY} is not writable.")
+    ensure
+      HOMEBREW_REPOSITORY.chmod mode
+    end
+  end
+
+  specify "#check_access_logs" do
+    begin
+      mode = HOMEBREW_LOGS.stat.mode & 0777
+      HOMEBREW_LOGS.chmod 0555
+
+      expect(subject.check_access_logs)
+        .to match("#{HOMEBREW_LOGS} isn't writable.")
+    ensure
+      HOMEBREW_LOGS.chmod mode
+    end
+  end
+
+  specify "#check_access_cache" do
+    begin
+      mode = HOMEBREW_CACHE.stat.mode & 0777
+      HOMEBREW_CACHE.chmod 0555
+      expect(subject.check_access_cache)
+        .to match("#{HOMEBREW_CACHE} isn't writable.")
+    ensure
+      HOMEBREW_CACHE.chmod mode
+    end
+  end
+
+  specify "#check_access_cellar" do
+    begin
+      mode = HOMEBREW_CELLAR.stat.mode & 0777
+      HOMEBREW_CELLAR.chmod 0555
+
+      expect(subject.check_access_cellar)
+        .to match("#{HOMEBREW_CELLAR} isn't writable.")
+    ensure
+      HOMEBREW_CELLAR.chmod mode
+    end
+  end
+
+  specify "#check_homebrew_prefix" do
+    ENV.delete("JENKINS_HOME")
+    # the integration tests are run in a special prefix
+    expect(subject.check_homebrew_prefix)
+      .to match("Your Homebrew's prefix is not /usr/local.")
+  end
+
+  specify "#check_user_path_1" do
+    bin = HOMEBREW_PREFIX/"bin"
+    sep = File::PATH_SEPARATOR
+    # ensure /usr/bin is before HOMEBREW_PREFIX/bin in the PATH
+    ENV["PATH"] = "/usr/bin#{sep}#{bin}#{sep}" +
+                  ENV["PATH"].gsub(%r{(?:^|#{sep})(?:/usr/bin|#{bin})}, "")
+
+    # ensure there's at least one file with the same name in both /usr/bin/ and
+    # HOMEBREW_PREFIX/bin/
+    (bin/File.basename(Dir["/usr/bin/*"].first)).mkpath
+
+    expect(subject.check_user_path_1)
+      .to match("/usr/bin occurs before #{HOMEBREW_PREFIX}/bin")
+  end
+
+  specify "#check_user_path_2" do
+    ENV["PATH"] = ENV["PATH"].gsub \
+      %r{(?:^|#{File::PATH_SEPARATOR})#{HOMEBREW_PREFIX}/bin}, ""
+
+    expect(subject.check_user_path_1).to be nil
+    expect(subject.check_user_path_2)
+      .to match("Homebrew's bin was not found in your PATH.")
+  end
+
+  specify "#check_user_path_3" do
+    begin
+      sbin = HOMEBREW_PREFIX/"sbin"
+      ENV["PATH"] = "#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
+                    ENV["PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
+      (sbin/"something").mkpath
+
+      expect(subject.check_user_path_1).to be nil
+      expect(subject.check_user_path_2).to be nil
+      expect(subject.check_user_path_3)
+        .to match("Homebrew's sbin was not found in your PATH")
+    ensure
+      sbin.rmtree
+    end
+  end
+
+  specify "#check_user_curlrc" do
+    Dir.mktmpdir do |path|
+      FileUtils.touch "#{path}/.curlrc"
+      ENV["CURL_HOME"] = path
+
+      expect(subject.check_user_curlrc).to match("You have a curlrc file")
+    end
+  end
+
+  specify "#check_for_config_scripts" do
+    Dir.mktmpdir do |path|
+      file = "#{path}/foo-config"
+      FileUtils.touch file
+      FileUtils.chmod 0755, file
+      ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
+
+      expect(subject.check_for_config_scripts)
+        .to match('"config" scripts exist')
+    end
+  end
+
+  specify "#check_dyld_vars" do
+    ENV["DYLD_INSERT_LIBRARIES"] = "foo"
+    expect(subject.check_dyld_vars).to match("Setting DYLD_INSERT_LIBRARIES")
+  end
+
+  specify "#check_for_symlinked_cellar" do
+    begin
+      HOMEBREW_CELLAR.rmtree
+
+      Dir.mktmpdir do |path|
+        FileUtils.ln_s path, HOMEBREW_CELLAR
+
+        expect(subject.check_for_symlinked_cellar).to match(path)
+      end
+    ensure
+      HOMEBREW_CELLAR.unlink
+      HOMEBREW_CELLAR.mkpath
+    end
+  end
+
+  specify "#check_tmpdir" do
+    ENV["TMPDIR"] = "/i/don/t/exis/t"
+    expect(subject.check_tmpdir).to match("doesn't exist")
+  end
+
+  specify "#check_for_external_cmd_name_conflict" do
+    Dir.mktmpdir do |path1|
+      Dir.mktmpdir do |path2|
+        [path1, path2].each do |path|
+          cmd = "#{path}/brew-foo"
+          FileUtils.touch cmd
+          FileUtils.chmod 0755, cmd
+        end
+
+        ENV["PATH"] = [path1, path2, ENV["PATH"]].join File::PATH_SEPARATOR
+
+        expect(subject.check_for_external_cmd_name_conflict)
+          .to match("brew-foo")
+      end
+    end
+  end
+end
diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb
deleted file mode 100644
index 7a1fb25f7..000000000
--- a/Library/Homebrew/test/diagnostic_test.rb
+++ /dev/null
@@ -1,192 +0,0 @@
-require "testing_env"
-require "fileutils"
-require "pathname"
-require "diagnostic"
-
-class DiagnosticChecksTest < Homebrew::TestCase
-  def setup
-    super
-    @checks = Homebrew::Diagnostic::Checks.new
-  end
-
-  def test_inject_file_list
-    assert_equal "foo:\n",
-      @checks.inject_file_list([], "foo:\n")
-    assert_equal "foo:\n  /a\n  /b\n",
-      @checks.inject_file_list(%w[/a /b], "foo:\n")
-  end
-
-  def test_check_path_for_trailing_slashes
-    ENV["PATH"] += File::PATH_SEPARATOR + "/foo/bar/"
-    assert_match "Some directories in your path end in a slash",
-      @checks.check_path_for_trailing_slashes
-  end
-
-  def test_check_for_anaconda
-    mktmpdir do |path|
-      anaconda = "#{path}/anaconda"
-      python = "#{path}/python"
-      FileUtils.touch anaconda
-      File.open(python, "w") do |file|
-        file.write("#! #{`which bash`}\necho -n '#{python}'\n")
-      end
-      FileUtils.chmod 0755, anaconda
-      FileUtils.chmod 0755, python
-
-      ENV["PATH"] = path + File::PATH_SEPARATOR + ENV["PATH"]
-
-      assert_match "Anaconda",
-        @checks.check_for_anaconda
-    end
-  end
-
-  def test_check_access_homebrew_repository
-    mod = HOMEBREW_REPOSITORY.stat.mode & 0777
-    HOMEBREW_REPOSITORY.chmod 0555
-
-    assert_match "#{HOMEBREW_REPOSITORY} is not writable.",
-      @checks.check_access_homebrew_repository
-  ensure
-    HOMEBREW_REPOSITORY.chmod mod
-  end
-
-  def test_check_access_logs
-    mod = HOMEBREW_LOGS.stat.mode & 0777
-    HOMEBREW_LOGS.chmod 0555
-
-    assert_match "#{HOMEBREW_LOGS} isn't writable.",
-      @checks.check_access_logs
-  ensure
-    HOMEBREW_LOGS.chmod mod
-  end
-
-  def test_check_access_cache
-    mod = HOMEBREW_CACHE.stat.mode & 0777
-    HOMEBREW_CACHE.chmod 0555
-    assert_match "#{HOMEBREW_CACHE} isn't writable.",
-      @checks.check_access_cache
-  ensure
-    HOMEBREW_CACHE.chmod mod
-  end
-
-  def test_check_access_cellar
-    mod = HOMEBREW_CELLAR.stat.mode & 0777
-    HOMEBREW_CELLAR.chmod 0555
-
-    assert_match "#{HOMEBREW_CELLAR} isn't writable.",
-      @checks.check_access_cellar
-  ensure
-    HOMEBREW_CELLAR.chmod mod
-  end
-
-  def test_check_homebrew_prefix
-    ENV.delete("JENKINS_HOME")
-    # the integration tests are run in a special prefix
-    assert_match "Your Homebrew's prefix is not /usr/local.",
-      @checks.check_homebrew_prefix
-  end
-
-  def test_check_user_path_usr_bin_before_homebrew
-    bin = HOMEBREW_PREFIX/"bin"
-    sep = File::PATH_SEPARATOR
-    # ensure /usr/bin is before HOMEBREW_PREFIX/bin in the PATH
-    ENV["PATH"] = "/usr/bin#{sep}#{bin}#{sep}" +
-                  ENV["PATH"].gsub(%r{(?:^|#{sep})(?:/usr/bin|#{bin})}, "")
-
-    # ensure there's at least one file with the same name in both /usr/bin/ and
-    # HOMEBREW_PREFIX/bin/
-    (bin/File.basename(Dir["/usr/bin/*"].first)).mkpath
-
-    assert_match "/usr/bin occurs before #{HOMEBREW_PREFIX}/bin",
-      @checks.check_user_path_1
-  end
-
-  def test_check_user_path_bin
-    ENV["PATH"] = ENV["PATH"].gsub \
-      %r{(?:^|#{File::PATH_SEPARATOR})#{HOMEBREW_PREFIX}/bin}, ""
-
-    assert_nil @checks.check_user_path_1
-    assert_match "Homebrew's bin was not found in your PATH.",
-      @checks.check_user_path_2
-  end
-
-  def test_check_user_path_sbin
-    sbin = HOMEBREW_PREFIX/"sbin"
-    ENV["PATH"] = "#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
-                  ENV["PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
-    (sbin/"something").mkpath
-
-    assert_nil @checks.check_user_path_1
-    assert_nil @checks.check_user_path_2
-    assert_match "Homebrew's sbin was not found in your PATH",
-      @checks.check_user_path_3
-  ensure
-    sbin.rmtree
-  end
-
-  def test_check_user_curlrc
-    mktmpdir do |path|
-      FileUtils.touch "#{path}/.curlrc"
-      ENV["CURL_HOME"] = path
-
-      assert_match "You have a curlrc file",
-        @checks.check_user_curlrc
-    end
-  end
-
-  def test_check_for_config_scripts
-    mktmpdir do |path|
-      file = "#{path}/foo-config"
-      FileUtils.touch file
-      FileUtils.chmod 0755, file
-      ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
-
-      assert_match '"config" scripts exist',
-        @checks.check_for_config_scripts
-    end
-  end
-
-  def test_check_dyld_vars
-    ENV["DYLD_INSERT_LIBRARIES"] = "foo"
-    assert_match "Setting DYLD_INSERT_LIBRARIES",
-      @checks.check_dyld_vars
-  end
-
-  def test_check_for_symlinked_cellar
-    HOMEBREW_CELLAR.rmtree
-
-    mktmpdir do |path|
-      FileUtils.ln_s path, HOMEBREW_CELLAR
-
-      assert_match path,
-        @checks.check_for_symlinked_cellar
-    end
-
-  ensure
-    HOMEBREW_CELLAR.unlink
-    HOMEBREW_CELLAR.mkpath
-  end
-
-  def test_check_tmpdir
-    ENV["TMPDIR"] = "/i/don/t/exis/t"
-    assert_match "doesn't exist",
-      @checks.check_tmpdir
-  end
-
-  def test_check_for_external_cmd_name_conflict
-    mktmpdir do |path1|
-      mktmpdir do |path2|
-        [path1, path2].each do |path|
-          cmd = "#{path}/brew-foo"
-          FileUtils.touch cmd
-          FileUtils.chmod 0755, cmd
-        end
-
-        ENV["PATH"] = [path1, path2, ENV["PATH"]].join File::PATH_SEPARATOR
-
-        assert_match "brew-foo",
-          @checks.check_for_external_cmd_name_conflict
-      end
-    end
-  end
-end
-- 
cgit v1.2.3


From 22042797d3111316e977eeee6f70439ae41448f6 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Mon, 20 Feb 2017 22:43:09 +0100
Subject: Convert FormulaLock test to spec.

---
 Library/Homebrew/test/formula_lock_spec.rb | 34 ++++++++++++++++++++++++++++++
 Library/Homebrew/test/formula_lock_test.rb | 23 --------------------
 2 files changed, 34 insertions(+), 23 deletions(-)
 create mode 100644 Library/Homebrew/test/formula_lock_spec.rb
 delete mode 100644 Library/Homebrew/test/formula_lock_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/formula_lock_spec.rb b/Library/Homebrew/test/formula_lock_spec.rb
new file mode 100644
index 000000000..9b5ece813
--- /dev/null
+++ b/Library/Homebrew/test/formula_lock_spec.rb
@@ -0,0 +1,34 @@
+require "formula_lock"
+
+describe FormulaLock do
+  subject { described_class.new("foo") }
+
+  describe "#lock" do
+    it "does not raise an error when already locked" do
+      subject.lock
+
+      expect { subject.lock }.not_to raise_error
+    end
+
+    it "raises an error if a lock already exists" do
+      subject.lock
+
+      expect {
+        described_class.new("foo").lock
+      }.to raise_error(OperationInProgressError)
+    end
+  end
+
+  describe "#unlock" do
+    it "does not raise an error when already unlocked" do
+      expect { subject.unlock }.not_to raise_error
+    end
+
+    it "unlocks a locked Formula" do
+      subject.lock
+      subject.unlock
+
+      expect { described_class.new("foo").lock }.not_to raise_error
+    end
+  end
+end
diff --git a/Library/Homebrew/test/formula_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb
deleted file mode 100644
index 13244555d..000000000
--- a/Library/Homebrew/test/formula_lock_test.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "testing_env"
-require "formula_lock"
-
-class FormulaLockTests < Homebrew::TestCase
-  def setup
-    super
-    @lock = FormulaLock.new("foo")
-    @lock.lock
-  end
-
-  def teardown
-    @lock.unlock
-    super
-  end
-
-  def test_locking_file_with_existing_lock_raises_error
-    assert_raises(OperationInProgressError) { FormulaLock.new("foo").lock }
-  end
-
-  def test_locking_existing_lock_suceeds
-    assert_nothing_raised { @lock.lock }
-  end
-end
-- 
cgit v1.2.3


From e218266aafeacf9b8d0caeabb8dba886b1bb13cc Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 02:23:49 +0100
Subject: Convert Mach-O test to spec.

---
 Library/Homebrew/test/os/mac/mach_spec.rb | 198 ++++++++++++++++++++++++++++
 Library/Homebrew/test/os/mac/mach_test.rb | 211 ------------------------------
 2 files changed, 198 insertions(+), 211 deletions(-)
 create mode 100644 Library/Homebrew/test/os/mac/mach_spec.rb
 delete mode 100644 Library/Homebrew/test/os/mac/mach_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/mach_spec.rb b/Library/Homebrew/test/os/mac/mach_spec.rb
new file mode 100644
index 000000000..5c9aafcbb
--- /dev/null
+++ b/Library/Homebrew/test/os/mac/mach_spec.rb
@@ -0,0 +1,198 @@
+describe "Mach-O Pathname tests" do
+  specify "fat dylib" do
+    pn = dylib_path("fat")
+    expect(pn).to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn.arch).to eq(:universal)
+  end
+
+  specify "i386 dylib" do
+    pn = dylib_path("i386")
+    expect(pn).not_to be_universal
+    expect(pn).to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).not_to be_mach_o_bundle
+  end
+
+  specify "x86_64 dylib" do
+    pn = dylib_path("x86_64")
+    expect(pn).not_to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).not_to be_mach_o_bundle
+  end
+
+  specify "Mach-O executable" do
+    pn = Pathname.new("#{TEST_FIXTURE_DIR}/mach/a.out")
+    expect(pn).to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).not_to be_mach_o_bundle
+  end
+
+  specify "fat bundle" do
+    pn = bundle_path("fat")
+    expect(pn).to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).to be_mach_o_bundle
+  end
+
+  specify "i386 bundle" do
+    pn = bundle_path("i386")
+    expect(pn).not_to be_universal
+    expect(pn).to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).to be_mach_o_bundle
+  end
+
+  specify "x86_64 bundle" do
+    pn = bundle_path("x86_64")
+    expect(pn).not_to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).to be_mach_o_bundle
+  end
+
+  specify "non-Mach-O" do
+    pn = Pathname.new("#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz")
+    expect(pn).not_to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn).not_to be_mach_o_bundle
+    expect(pn.arch).to eq(:dunno)
+  end
+end
+
+describe ArchitectureListExtension do
+  let(:archs) { [:i386, :x86_64, :ppc7400, :ppc64].extend(described_class) }
+
+  specify "universal checks" do
+    expect(archs).to be_universal
+    expect(archs).to be_intel_universal
+    expect(archs).to be_ppc_universal
+    expect(archs).to be_cross_universal
+    expect(archs).to be_fat
+
+    non_universal = [:i386].extend(described_class)
+    expect(non_universal).not_to be_universal
+
+    intel_only = [:i386, :x86_64].extend(described_class)
+    expect(intel_only).to be_universal
+    expect(intel_only).not_to be_ppc_universal
+    expect(intel_only).not_to be_cross_universal
+
+    ppc_only = [:ppc970, :ppc64].extend(described_class)
+    expect(ppc_only).to be_universal
+    expect(ppc_only).not_to be_intel_universal
+    expect(ppc_only).not_to be_cross_universal
+
+    cross = [:ppc7400, :i386].extend(described_class)
+    expect(cross).to be_universal
+    expect(cross).not_to be_intel_universal
+    expect(cross).not_to be_ppc_universal
+  end
+
+  specify "messaging flags" do
+    archs.remove_ppc!
+    expect(archs.length).to eq(2)
+    expect(archs.as_arch_flags).to match(/-arch i386/)
+    expect(archs.as_arch_flags).to match(/-arch x86_64/)
+  end
+
+  specify "architecture flags" do
+    pn = dylib_path("fat")
+    expect(pn.archs).to be_intel_universal
+    expect(pn.archs.as_arch_flags).to eq("-arch x86_64 -arch i386")
+    expect(pn.archs.as_cmake_arch_flags).to eq("x86_64;i386")
+  end
+end
+
+describe "text executables" do
+  let(:pn) { HOMEBREW_PREFIX/"an_executable" }
+
+  after(:each) { pn.unlink }
+
+  specify "simple shebang" do
+    pn.write "#!/bin/sh"
+    expect(pn).not_to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).to be_text_executable
+    expect(pn.archs).to eq([])
+    expect(pn.arch).to eq(:dunno)
+  end
+
+  specify "shebang with options" do
+    pn.write "#! /usr/bin/perl -w"
+    expect(pn).not_to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).to be_text_executable
+    expect(pn.archs).to eq([])
+    expect(pn.arch).to eq(:dunno)
+  end
+
+  specify "malformed shebang" do
+    pn.write " #!"
+    expect(pn).not_to be_universal
+    expect(pn).not_to be_i386
+    expect(pn).not_to be_x86_64
+    expect(pn).not_to be_ppc7400
+    expect(pn).not_to be_ppc64
+    expect(pn).not_to be_dylib
+    expect(pn).not_to be_mach_o_executable
+    expect(pn).not_to be_text_executable
+    expect(pn.archs).to eq([])
+    expect(pn.arch).to eq(:dunno)
+  end
+end
diff --git a/Library/Homebrew/test/os/mac/mach_test.rb b/Library/Homebrew/test/os/mac/mach_test.rb
deleted file mode 100644
index ed0424be6..000000000
--- a/Library/Homebrew/test/os/mac/mach_test.rb
+++ /dev/null
@@ -1,211 +0,0 @@
-require "testing_env"
-
-class MachOPathnameTests < Homebrew::TestCase
-  def test_fat_dylib
-    pn = dylib_path("fat")
-    assert_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    assert_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    assert_equal :universal, pn.arch
-  end
-
-  def test_i386_dylib
-    pn = dylib_path("i386")
-    refute_predicate pn, :universal?
-    assert_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    assert_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    refute_predicate pn, :mach_o_bundle?
-  end
-
-  def test_x86_64_dylib
-    pn = dylib_path("x86_64")
-    refute_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    assert_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    assert_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    refute_predicate pn, :mach_o_bundle?
-  end
-
-  def test_mach_o_executable
-    pn = Pathname.new("#{TEST_FIXTURE_DIR}/mach/a.out")
-    assert_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    assert_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    refute_predicate pn, :mach_o_bundle?
-  end
-
-  def test_fat_bundle
-    pn = bundle_path("fat")
-    assert_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    assert_predicate pn, :mach_o_bundle?
-  end
-
-  def test_i386_bundle
-    pn = bundle_path("i386")
-    refute_predicate pn, :universal?
-    assert_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    assert_predicate pn, :mach_o_bundle?
-  end
-
-  def test_x86_64_bundle
-    pn = bundle_path("x86_64")
-    refute_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    assert_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    assert_predicate pn, :mach_o_bundle?
-  end
-
-  def test_non_mach_o
-    pn = Pathname.new("#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz")
-    refute_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    refute_predicate pn, :mach_o_bundle?
-    assert_equal :dunno, pn.arch
-  end
-end
-
-class ArchitectureListExtensionTests < MachOPathnameTests
-  def setup
-    super
-    @archs = [:i386, :x86_64, :ppc7400, :ppc64].extend(ArchitectureListExtension)
-  end
-
-  def test_architecture_list_extension_universal_checks
-    assert_predicate @archs, :universal?
-    assert_predicate @archs, :intel_universal?
-    assert_predicate @archs, :ppc_universal?
-    assert_predicate @archs, :cross_universal?
-    assert_predicate @archs, :fat?
-
-    non_universal = [:i386].extend ArchitectureListExtension
-    refute_predicate non_universal, :universal?
-
-    intel_only = [:i386, :x86_64].extend ArchitectureListExtension
-    assert_predicate intel_only, :universal?
-    refute_predicate intel_only, :ppc_universal?
-    refute_predicate intel_only, :cross_universal?
-
-    ppc_only = [:ppc970, :ppc64].extend ArchitectureListExtension
-    assert_predicate ppc_only, :universal?
-    refute_predicate ppc_only, :intel_universal?
-    refute_predicate ppc_only, :cross_universal?
-
-    cross = [:ppc7400, :i386].extend ArchitectureListExtension
-    assert_predicate cross, :universal?
-    refute_predicate cross, :intel_universal?
-    refute_predicate cross, :ppc_universal?
-  end
-
-  def test_architecture_list_extension_massaging_flags
-    @archs.remove_ppc!
-    assert_equal 2, @archs.length
-    assert_match(/-arch i386/, @archs.as_arch_flags)
-    assert_match(/-arch x86_64/, @archs.as_arch_flags)
-  end
-
-  def test_architecture_list_arch_flags_methods
-    pn = dylib_path("fat")
-    assert_predicate pn.archs, :intel_universal?
-    assert_equal "-arch x86_64 -arch i386", pn.archs.as_arch_flags
-    assert_equal "x86_64;i386", pn.archs.as_cmake_arch_flags
-  end
-end
-
-class TextExecutableTests < Homebrew::TestCase
-  attr_reader :pn
-
-  def setup
-    super
-    @pn = HOMEBREW_PREFIX.join("an_executable")
-  end
-
-  def teardown
-    HOMEBREW_PREFIX.join("an_executable").unlink
-    super
-  end
-
-  def test_simple_shebang
-    pn.write "#!/bin/sh"
-    refute_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    assert_predicate pn, :text_executable?
-    assert_equal [], pn.archs
-    assert_equal :dunno, pn.arch
-  end
-
-  def test_shebang_with_options
-    pn.write "#! /usr/bin/perl -w"
-    refute_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    assert_predicate pn, :text_executable?
-    assert_equal [], pn.archs
-    assert_equal :dunno, pn.arch
-  end
-
-  def test_malformed_shebang
-    pn.write " #!"
-    refute_predicate pn, :universal?
-    refute_predicate pn, :i386?
-    refute_predicate pn, :x86_64?
-    refute_predicate pn, :ppc7400?
-    refute_predicate pn, :ppc64?
-    refute_predicate pn, :dylib?
-    refute_predicate pn, :mach_o_executable?
-    refute_predicate pn, :text_executable?
-    assert_equal [], pn.archs
-    assert_equal :dunno, pn.arch
-  end
-end
-- 
cgit v1.2.3


From 8bb46baebbc0694130b86483705bfef2c159704e Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Wed, 15 Feb 2017 19:20:38 +0100
Subject: Add RSpec support for integration commands.

---
 Library/Homebrew/test/spec_helper.rb               |  1 +
 .../helper/spec/shared_context/integration_test.rb | 94 ++++++++++++++++++++++
 2 files changed, 95 insertions(+)
 create mode 100644 Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index b58125aec..547ec3f7b 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -16,6 +16,7 @@ require "tap"
 
 require "test/support/helper/shutup"
 require "test/support/helper/fixtures"
+require "test/support/helper/spec/shared_context/integration_test"
 
 TEST_DIRECTORIES = [
   CoreTap.instance.path/"Formula",
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
new file mode 100644
index 000000000..dd2271a3a
--- /dev/null
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -0,0 +1,94 @@
+require "rspec"
+require "open3"
+
+RSpec::Matchers.define_negated_matcher :not_to_output, :output
+RSpec::Matchers.define_negated_matcher :be_a_failure, :be_a_success
+
+RSpec.shared_context "integration test" do
+  extend RSpec::Matchers::DSL
+
+  matcher :be_a_success do
+    match do |actual|
+      status = actual.is_a?(Proc) ? actual.call : actual
+      status.respond_to?(:success?) && status.success?
+    end
+
+    def supports_block_expectations?
+      true
+    end
+
+    # It needs to be nested like this:
+    #
+    #   expect {
+    #     expect {
+    #       # command
+    #     }.to be_a_success
+    #   }.to output(something).to_stdout
+    #
+    # rather than this:
+    #
+    #   expect {
+    #     expect {
+    #       # command
+    #     }.to output(something).to_stdout
+    #   }.to be_a_success
+    #
+    def expects_call_stack_jump?
+      true
+    end
+  end
+
+  before(:each) do
+    (HOMEBREW_PREFIX/"bin").mkpath
+    FileUtils.touch HOMEBREW_PREFIX/"bin/brew"
+  end
+
+  after(:each) do
+    FileUtils.rm HOMEBREW_PREFIX/"bin/brew"
+    FileUtils.rmdir HOMEBREW_PREFIX/"bin"
+  end
+
+  # Generate unique ID to be able to
+  # properly merge coverage results.
+  def command_id_from_args(args)
+    @command_count ||= 0
+    pretty_args = args.join(" ").gsub(TEST_TMPDIR, "@TMPDIR@")
+    file_and_line = caller[1].sub(/(.*\d+):.*/, '\1')
+                             .sub("#{HOMEBREW_LIBRARY_PATH}/test/", "")
+    "#{file_and_line}:brew #{pretty_args}:#{@command_count += 1}"
+  end
+
+  # Runs a `brew` command with the test configuration
+  # and with coverage reporting enabled.
+  def brew(*args)
+    env = args.last.is_a?(Hash) ? args.pop : {}
+
+    env.merge!(
+      "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
+      "HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
+      "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
+      "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"],
+    )
+
+    ruby_args = [
+      "-W0",
+      "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib",
+      "-I", HOMEBREW_LIBRARY_PATH.to_s,
+      "-rconfig"
+    ]
+    ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
+    ruby_args << "-rtest/support/helper/integration_mocks"
+    ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s
+
+    Bundler.with_original_env do
+      stdout, stderr, status = Open3.capture3(env, RUBY_PATH, *ruby_args, *args)
+      $stdout.print stdout
+      $stderr.print stderr
+      status
+    end
+  end
+end
+
+RSpec.configure do |config|
+  config.include_context "integration test", :integration_test
+end
-- 
cgit v1.2.3


From 9ac59b99e462e648013ea3a1cbfba295e80b5837 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 18 Feb 2017 17:38:13 +0100
Subject: Convert `brew analytics` test to spec.

---
 Library/Homebrew/test/analytics_test.rb     | 26 ---------------
 Library/Homebrew/test/cmd/analytics_spec.rb | 52 +++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 26 deletions(-)
 delete mode 100644 Library/Homebrew/test/analytics_test.rb
 create mode 100644 Library/Homebrew/test/cmd/analytics_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/analytics_test.rb b/Library/Homebrew/test/analytics_test.rb
deleted file mode 100644
index 37040f3cd..000000000
--- a/Library/Homebrew/test/analytics_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestAnalytics < IntegrationCommandTestCase
-  def test_analytics
-    HOMEBREW_REPOSITORY.cd do
-      shutup do
-        system "git", "init"
-      end
-    end
-
-    assert_match "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)",
-      cmd("analytics", "HOMEBREW_NO_ANALYTICS" => "1")
-
-    cmd("analytics", "off")
-    assert_match "Analytics is disabled",
-      cmd("analytics", "HOMEBREW_NO_ANALYTICS" => nil)
-
-    cmd("analytics", "on")
-    assert_match "Analytics is enabled", cmd("analytics",
-      "HOMEBREW_NO_ANALYTICS" => nil)
-
-    assert_match "Invalid usage", cmd_fail("analytics", "on", "off")
-    assert_match "Invalid usage", cmd_fail("analytics", "testball")
-    cmd("analytics", "regenerate-uuid")
-  end
-end
diff --git a/Library/Homebrew/test/cmd/analytics_spec.rb b/Library/Homebrew/test/cmd/analytics_spec.rb
new file mode 100644
index 000000000..aed3a7a33
--- /dev/null
+++ b/Library/Homebrew/test/cmd/analytics_spec.rb
@@ -0,0 +1,52 @@
+describe "brew analytics", :integration_test do
+  before(:each) do
+    HOMEBREW_REPOSITORY.cd do
+      shutup do
+        system "git", "init"
+      end
+    end
+  end
+
+  it "is disabled when HOMEBREW_NO_ANALYTICS is set" do
+    expect { brew "analytics", "HOMEBREW_NO_ANALYTICS" => "1" }
+      .to output(/Analytics is disabled \(by HOMEBREW_NO_ANALYTICS\)/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  context "when HOMEBREW_NO_ANALYTICS is unset" do
+    it "is disabled after running `brew analytics off`" do
+      brew "analytics", "off"
+      expect { brew "analytics", "HOMEBREW_NO_ANALYTICS" => nil }
+        .to output(/Analytics is disabled/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+
+    it "is enabled after running `brew analytics on`" do
+      brew "analytics", "on"
+      expect { brew "analytics", "HOMEBREW_NO_ANALYTICS" => nil }
+        .to output(/Analytics is enabled/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+
+  it "fails when running `brew analytics on off`" do
+    expect { brew "analytics", "on", "off" }
+      .to output(/Invalid usage/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "fails when running `brew analytics testball`" do
+    expect { brew "analytics", "testball" }
+      .to output(/Invalid usage/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "can generate a new UUID" do
+    expect { brew "analytics", "regenerate-uuid" }.to be_a_success
+  end
+end
-- 
cgit v1.2.3


From b59bf2ff6410dc3e226f0c6c42a37f16a86b472b Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Tue, 21 Feb 2017 11:31:18 -0800
Subject: Revert "audit: check for version aliases."

---
 Library/Homebrew/dev-cmd/audit.rb | 24 +-----------------------
 Library/Homebrew/readall.rb       | 19 ++++++++++---------
 2 files changed, 11 insertions(+), 32 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 9da5d28b4..9ffef0f99 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -295,27 +295,6 @@ class FormulaAuditor
 
     problem "File should end with a newline" unless text.trailing_newline?
 
-    versioned_formulae = Dir[formula.path.to_s.gsub(/\.rb$/, "@*.rb")]
-    needs_versioned_alias = !versioned_formulae.empty? &&
-                            formula.tap &&
-                            formula.aliases.grep(/.@\d/).empty?
-    if needs_versioned_alias
-      _, last_alias_version = File.basename(versioned_formulae.sort.reverse.first)
-                                  .gsub(/\.rb$/, "")
-                                  .split("@")
-      major, minor, = formula.version.to_s.split(".")
-      alias_name = if last_alias_version.split(".").length == 1
-        "#{formula.name}@#{major}"
-      else
-        "#{formula.name}@#{major}.#{minor}"
-      end
-      problem <<-EOS.undent
-        Formula has other versions so create an alias:
-          cd #{formula.tap.alias_dir}
-          ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name}
-      EOS
-    end
-
     return unless @strict
 
     present = audit_components
@@ -431,8 +410,7 @@ class FormulaAuditor
           problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'."
         end
 
-        if @@aliases.include?(dep.name) &&
-           (core_formula? || !dep_f.versioned_formula?)
+        if @@aliases.include?(dep.name)
           problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
         end
 
diff --git a/Library/Homebrew/readall.rb b/Library/Homebrew/readall.rb
index 52addfa87..3dd7075ec 100644
--- a/Library/Homebrew/readall.rb
+++ b/Library/Homebrew/readall.rb
@@ -24,15 +24,16 @@ module Readall
       !failed
     end
 
-    def valid_aliases?(alias_dir, formula_dir)
-      return false unless alias_dir.directory?
-
+    def valid_aliases?(alias_dirs)
       failed = false
-      alias_dir.each_child do |f|
-        next unless f.symlink?
-        next if f.file? && !(formula_dir/"#{f.basename}.rb").exist?
-        onoe "Broken alias: #{f}"
-        failed = true
+      alias_dirs.each do |alias_dir|
+        next unless alias_dir.directory?
+        alias_dir.children.each do |f|
+          next unless f.symlink?
+          next if f.file?
+          onoe "Broken alias: #{f}"
+          failed = true
+        end
       end
       !failed
     end
@@ -56,7 +57,7 @@ module Readall
     def valid_tap?(tap, options = {})
       failed = false
       if options[:aliases]
-        valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir)
+        valid_aliases = valid_aliases?([tap.alias_dir])
         failed = true unless valid_aliases
       end
       valid_formulae = valid_formulae?(tap.formula_files)
-- 
cgit v1.2.3


From dd99d656a30ec3ce2de7e60c24e6b0a1b506ff1d Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 21:45:34 +0100
Subject: Convert Utils::Bottles test to spec.

---
 Library/Homebrew/test/os/mac/bottle_tag_test.rb    | 79 ---------------------
 Library/Homebrew/test/spec_helper.rb               |  2 +-
 .../Homebrew/test/utils/bottles/bottles_spec.rb    | 80 ++++++++++++++++++++++
 3 files changed, 81 insertions(+), 80 deletions(-)
 delete mode 100644 Library/Homebrew/test/os/mac/bottle_tag_test.rb
 create mode 100644 Library/Homebrew/test/utils/bottles/bottles_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/bottle_tag_test.rb b/Library/Homebrew/test/os/mac/bottle_tag_test.rb
deleted file mode 100644
index 996bd4d53..000000000
--- a/Library/Homebrew/test/os/mac/bottle_tag_test.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-require "testing_env"
-require "utils/bottles"
-
-class OSMacBottleTagTests < Homebrew::TestCase
-  def test_tag_tiger_ppc
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
-    Hardware::CPU.stubs(:type).returns(:ppc)
-    Hardware::CPU.stubs(:family).returns(:foo)
-    MacOS.stubs(:prefer_64_bit?).returns(false)
-    assert_equal :tiger_foo, Utils::Bottles.tag
-  end
-
-  def test_tag_tiger_intel
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
-    Hardware::CPU.stubs(:type).returns(:intel)
-    MacOS.stubs(:prefer_64_bit?).returns(false)
-    assert_equal :tiger, Utils::Bottles.tag
-  end
-
-  def test_tag_tiger_ppc_64
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
-    Hardware::CPU.stubs(:type).returns(:ppc)
-    Hardware::CPU.stubs(:family).returns(:g5)
-    MacOS.stubs(:prefer_64_bit?).returns(true)
-    assert_equal :tiger_g5_64, Utils::Bottles.tag
-  end
-
-  # Note that this will probably never be used
-  def test_tag_tiger_intel_64
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
-    Hardware::CPU.stubs(:type).returns(:intel)
-    MacOS.stubs(:prefer_64_bit?).returns(true)
-    assert_equal :tiger_64, Utils::Bottles.tag
-  end
-
-  def test_tag_leopard_intel
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.5"))
-    Hardware::CPU.stubs(:type).returns(:intel)
-    MacOS.stubs(:prefer_64_bit?).returns(false)
-    assert_equal :leopard, Utils::Bottles.tag
-  end
-
-  def test_tag_leopard_ppc_64
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.5"))
-    Hardware::CPU.stubs(:type).returns(:ppc)
-    Hardware::CPU.stubs(:family).returns(:g5)
-    MacOS.stubs(:prefer_64_bit?).returns(true)
-    assert_equal :leopard_g5_64, Utils::Bottles.tag
-  end
-
-  def test_tag_leopard_intel_64
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.5"))
-    Hardware::CPU.stubs(:type).returns(:intel)
-    MacOS.stubs(:prefer_64_bit?).returns(true)
-    assert_equal :leopard_64, Utils::Bottles.tag
-  end
-
-  def test_tag_snow_leopard_32
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.6"))
-    Hardware::CPU.stubs(:is_64_bit?).returns(false)
-    assert_equal :snow_leopard_32, Utils::Bottles.tag
-  end
-
-  def test_tag_snow_leopard_64
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.6"))
-    Hardware::CPU.stubs(:is_64_bit?).returns(true)
-    assert_equal :snow_leopard, Utils::Bottles.tag
-  end
-
-  def test_tag_lion
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.7"))
-    assert_equal :lion, Utils::Bottles.tag
-  end
-
-  def test_tag_mountain_lion
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.8"))
-    assert_equal :mountain_lion, Utils::Bottles.tag
-  end
-end
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index b58125aec..1396fa946 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -33,7 +33,7 @@ RSpec.configure do |config|
   config.include(Test::Helper::Fixtures)
   config.before(:each) do |example|
     if example.metadata[:needs_macos]
-      skip "not on macOS" unless OS.mac?
+      skip "Not on macOS." unless OS.mac?
     end
 
     if example.metadata[:needs_python]
diff --git a/Library/Homebrew/test/utils/bottles/bottles_spec.rb b/Library/Homebrew/test/utils/bottles/bottles_spec.rb
new file mode 100644
index 000000000..8b54b0b34
--- /dev/null
+++ b/Library/Homebrew/test/utils/bottles/bottles_spec.rb
@@ -0,0 +1,80 @@
+require "utils/bottles"
+
+describe Utils::Bottles do
+  describe "#tag", :needs_macos do
+    it "returns :tiger_foo on Tiger PowerPC" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.4"))
+      allow(Hardware::CPU).to receive(:type).and_return(:ppc)
+      allow(Hardware::CPU).to receive(:family).and_return(:foo)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(false)
+      expect(described_class.tag).to eq(:tiger_foo)
+    end
+
+    it "returns :tiger on Tiger Intel" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.4"))
+      allow(Hardware::CPU).to receive(:type).and_return(:intel)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(false)
+      expect(described_class.tag).to eq(:tiger)
+    end
+
+    it "returns :tiger_g5_64 on Tiger PowerPC 64-bit" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.4"))
+      allow(Hardware::CPU).to receive(:type).and_return(:ppc)
+      allow(Hardware::CPU).to receive(:family).and_return(:g5)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(true)
+      expect(described_class.tag).to eq(:tiger_g5_64)
+    end
+
+    # Note that this will probably never be used
+    it "returns :tiger_64 on Tiger Intel 64-bit" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.4"))
+      allow(Hardware::CPU).to receive(:type).and_return(:intel)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(true)
+      expect(described_class.tag).to eq(:tiger_64)
+    end
+
+    it "returns :leopard on Leopard Intel" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.5"))
+      allow(Hardware::CPU).to receive(:type).and_return(:intel)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(false)
+      expect(described_class.tag).to eq(:leopard)
+    end
+
+    it "returns :leopard_g5_64 on Leopard PowerPC 64-bit" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.5"))
+      allow(Hardware::CPU).to receive(:type).and_return(:ppc)
+      allow(Hardware::CPU).to receive(:family).and_return(:g5)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(true)
+      expect(described_class.tag).to eq(:leopard_g5_64)
+    end
+
+    it "returns :leopard_64 on Leopard Intel 64-bit" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.5"))
+      allow(Hardware::CPU).to receive(:type).and_return(:intel)
+      allow(MacOS).to receive(:prefer_64_bit?).and_return(true)
+      expect(described_class.tag).to eq(:leopard_64)
+    end
+
+    it "returns :snow_leopard_32 on Snow Leopard 32-bit" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.6"))
+      allow(Hardware::CPU).to receive(:is_64_bit?).and_return(false)
+      expect(described_class.tag).to eq(:snow_leopard_32)
+    end
+
+    it "returns :snow_leopard on Snow Leopard 64-bit" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.6"))
+      allow(Hardware::CPU).to receive(:is_64_bit?).and_return(true)
+      expect(described_class.tag).to eq(:snow_leopard)
+    end
+
+    it "returns :lion on Lion" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.7"))
+      expect(described_class.tag).to eq(:lion)
+    end
+
+    it "returns :mountain_lion on Mountain Lion" do
+      allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.8"))
+      expect(described_class.tag).to eq(:mountain_lion)
+    end
+  end
+end
-- 
cgit v1.2.3


From 168a96d91912c9adc19d8729d0cb6ac54aef7590 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 21:55:11 +0100
Subject: Exclude specs with `:needs_macos` tag when not on macOS.

---
 Library/Homebrew/dev-cmd/tests.rb | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index 244fbe027..246b5fa46 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -84,6 +84,8 @@ module Homebrew
         "--format", "ParallelTests::RSpec::RuntimeLogger",
         "--out", "tmp/parallel_runtime_rspec.log"
       ]
+      spec_args << "--tag" << "~needs_macos" unless OS.mac?
+
       run_tests "parallel_rspec", spec_files, spec_args
 
       if (fs_leak_log = HOMEBREW_LIBRARY_PATH/"tmp/fs_leak.log").file?
-- 
cgit v1.2.3


From 42bb19a6317172804cd149024115f6973fa2fd4f Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Tue, 21 Feb 2017 21:29:32 +0000
Subject: formula_installer: detect recursive dependencies.

Detect recursive dependencies and refuse to install them providing
instruction on exactly what is depending on what.

Fixes #1933.
---
 Library/Homebrew/formula_installer.rb | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index c9f478bb1..1f91ad5c4 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -151,6 +151,28 @@ class FormulaInstaller
     recursive_deps = formula.recursive_dependencies
     recursive_formulae = recursive_deps.map(&:to_formula)
 
+    recursive_dependencies = []
+    recursive_formulae.each do |dep|
+      dep_recursive_dependencies = dep.recursive_dependencies.map(&:to_s)
+      if dep_recursive_dependencies.include?(formula.name)
+        recursive_dependencies << "#{formula.full_name} depends on #{dep.full_name}"
+        recursive_dependencies << "#{dep.full_name} depends on #{formula.full_name}"
+      end
+    end
+
+    unless recursive_dependencies.empty?
+      raise CannotInstallFormulaError, <<-EOS.undent
+        #{formula.full_name} contains a recursive dependency on itself:
+          #{recursive_dependencies.join("\n  ")}
+      EOS
+    end
+
+    if recursive_formulae.flat_map(&:recursive_dependencies).map(&:to_s).include?(formula.name)
+      raise CannotInstallFormulaError, <<-EOS.undent
+        #{formula.full_name} contains a recursive dependency on itself!
+      EOS
+    end
+
     if ENV["HOMEBREW_CHECK_RECURSIVE_VERSION_DEPENDENCIES"]
       version_hash = {}
       version_conflicts = Set.new
-- 
cgit v1.2.3


From 88a4a95e69d05010e16920b9e339421ff434754c Mon Sep 17 00:00:00 2001
From: Joshua Liu
Date: Tue, 21 Feb 2017 20:14:21 -0500
Subject: Convert deps test to spec

---
 Library/Homebrew/test/deps_spec.rb | 14 ++++++++++++++
 Library/Homebrew/test/deps_test.rb | 16 ----------------
 2 files changed, 14 insertions(+), 16 deletions(-)
 create mode 100644 Library/Homebrew/test/deps_spec.rb
 delete mode 100644 Library/Homebrew/test/deps_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/deps_spec.rb b/Library/Homebrew/test/deps_spec.rb
new file mode 100644
index 000000000..7d7fe13c3
--- /dev/null
+++ b/Library/Homebrew/test/deps_spec.rb
@@ -0,0 +1,14 @@
+describe Homebrew do
+  describe "#deps" do
+    setup_test_formula "foo"
+    setup_test_formula "bar"
+    setup_test_formula "baz", <<-EOS.undent
+      url "https://example.com/baz-1.0"
+      depends_on "bar"
+    EOS
+
+    expect(cmd("deps", "foo")).to eq("")
+    expect(cmd("deps", "bar")).to eq("foo")
+    expect(cmd("deps", "baz")).to eq("bar\nfoo")
+  end
+end
diff --git a/Library/Homebrew/test/deps_test.rb b/Library/Homebrew/test/deps_test.rb
deleted file mode 100644
index 01639857c..000000000
--- a/Library/Homebrew/test/deps_test.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestDeps < IntegrationCommandTestCase
-  def test_deps
-    setup_test_formula "foo"
-    setup_test_formula "bar"
-    setup_test_formula "baz", <<-EOS.undent
-      url "https://example.com/baz-1.0"
-      depends_on "bar"
-    EOS
-
-    assert_equal "", cmd("deps", "foo")
-    assert_equal "foo", cmd("deps", "bar")
-    assert_equal "bar\nfoo", cmd("deps", "baz")
-  end
-end
-- 
cgit v1.2.3


From 69f361089c8c4793b9aad532c13331a1f09ff92a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Wed, 15 Feb 2017 23:46:01 +0100
Subject: Convert Migrator test to spec.

---
 Library/Homebrew/test/migrator_spec.rb | 264 +++++++++++++++++++++++++++++++++
 Library/Homebrew/test/migrator_test.rb | 251 -------------------------------
 2 files changed, 264 insertions(+), 251 deletions(-)
 create mode 100644 Library/Homebrew/test/migrator_spec.rb
 delete mode 100644 Library/Homebrew/test/migrator_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/migrator_spec.rb b/Library/Homebrew/test/migrator_spec.rb
new file mode 100644
index 000000000..90ee9d8ff
--- /dev/null
+++ b/Library/Homebrew/test/migrator_spec.rb
@@ -0,0 +1,264 @@
+require "migrator"
+require "test/support/fixtures/testball"
+require "tab"
+require "keg"
+
+describe Migrator do
+  subject { described_class.new(new_formula) }
+
+  let(:new_formula) { Testball.new("newname") }
+  let(:old_formula) { Testball.new("oldname") }
+
+  let(:new_keg_record) { HOMEBREW_CELLAR/"newname/0.1" }
+  let(:old_keg_record) { HOMEBREW_CELLAR/"oldname/0.1" }
+
+  let(:old_tab) { Tab.empty }
+
+  let(:keg) { Keg.new(old_keg_record) }
+  let(:old_pin) { HOMEBREW_PINNED_KEGS/"oldname" }
+
+  before(:each) do |example|
+    allow(new_formula).to receive(:oldname).and_return("oldname")
+
+    # do not create directories for error tests
+    next if example.metadata[:description].start_with?("raises an error")
+
+    (old_keg_record/"bin").mkpath
+
+    %w[inside bindir].each do |file|
+      FileUtils.touch old_keg_record/"bin/#{file}"
+    end
+
+    old_tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
+    old_tab.source["path"] = "/oldname"
+    old_tab.write
+
+    keg.link
+    keg.optlink
+
+    old_pin.make_relative_symlink old_keg_record
+
+    subject # needs to be evaluated eagerly
+
+    (HOMEBREW_PREFIX/"bin").mkpath
+  end
+
+  after(:each) do
+    if !old_keg_record.parent.symlink? && old_keg_record.directory?
+      keg.unlink
+    end
+
+    if new_keg_record.directory?
+      new_keg = Keg.new(new_keg_record)
+      new_keg.unlink
+    end
+  end
+
+  describe "::new" do
+    it "raises an error if there is no old name" do
+      expect {
+        described_class.new(old_formula)
+      }.to raise_error(Migrator::MigratorNoOldnameError)
+    end
+
+    it "raises an error if there is no old path" do
+      expect {
+        described_class.new(new_formula)
+      }.to raise_error(Migrator::MigratorNoOldpathError)
+    end
+
+    it "raises an error if the Taps differ" do
+      keg = HOMEBREW_CELLAR/"oldname/0.1"
+      keg.mkpath
+      tab = Tab.empty
+      tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
+      tab.source["tap"] = "homebrew/core"
+      tab.write
+
+      expect {
+        described_class.new(new_formula)
+      }.to raise_error(Migrator::MigratorDifferentTapsError)
+    end
+  end
+
+  specify "#move_to_new_directory" do
+    keg.unlink
+    shutup do
+      subject.move_to_new_directory
+    end
+
+    expect(new_keg_record).to be_a_directory
+    expect(new_keg_record/"bin").to be_a_directory
+    expect(new_keg_record/"bin/inside").to be_a_file
+    expect(new_keg_record/"bin/bindir").to be_a_file
+    expect(old_keg_record).not_to be_a_directory
+  end
+
+  specify "#backup_oldname_cellar" do
+    old_keg_record.parent.rmtree
+    (new_keg_record/"bin").mkpath
+
+    subject.backup_oldname_cellar
+
+    expect(old_keg_record/"bin").to be_a_directory
+    expect(old_keg_record/"bin").to be_a_directory
+  end
+
+  specify "#repin" do
+    (new_keg_record/"bin").mkpath
+    expected_relative = new_keg_record.relative_path_from HOMEBREW_PINNED_KEGS
+
+    subject.repin
+
+    expect(subject.new_pin_record).to be_a_symlink
+    expect(subject.new_pin_record.readlink).to eq(expected_relative)
+    expect(subject.old_pin_record).not_to exist
+  end
+
+  specify "#unlink_oldname" do
+    expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1)
+    expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1)
+
+    shutup do
+      subject.unlink_oldname
+    end
+
+    expect(HOMEBREW_LINKED_KEGS).not_to exist
+    expect(HOMEBREW_LIBRARY/"bin").not_to exist
+  end
+
+  specify "#link_newname" do
+    keg.unlink
+    keg.uninstall
+
+    (new_keg_record/"bin").mkpath
+    %w[inside bindir].each do |file|
+      FileUtils.touch new_keg_record/"bin"/file
+    end
+
+    shutup do
+      subject.link_newname
+    end
+
+    expect(HOMEBREW_LINKED_KEGS.children.count).to eq(1)
+    expect((HOMEBREW_PREFIX/"opt").children.count).to eq(1)
+  end
+
+  specify "#link_oldname_opt" do
+    new_keg_record.mkpath
+    subject.link_oldname_opt
+    expect((HOMEBREW_PREFIX/"opt/oldname").realpath).to eq(new_keg_record.realpath)
+  end
+
+  specify "#link_oldname_cellar" do
+    (new_keg_record/"bin").mkpath
+    keg.unlink
+    keg.uninstall
+    subject.link_oldname_cellar
+    expect((HOMEBREW_CELLAR/"oldname").realpath).to eq(new_keg_record.parent.realpath)
+  end
+
+  specify "#update_tabs" do
+    (new_keg_record/"bin").mkpath
+    tab = Tab.empty
+    tab.tabfile = HOMEBREW_CELLAR/"newname/0.1/INSTALL_RECEIPT.json"
+    tab.source["path"] = "/path/that/must/be/changed/by/update_tabs"
+    tab.write
+    subject.update_tabs
+    expect(Tab.for_keg(new_keg_record).source["path"]).to eq(new_formula.path.to_s)
+  end
+
+  specify "#migrate" do
+    tab = Tab.empty
+    tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
+    tab.source["path"] = old_formula.path.to_s
+    tab.write
+
+    shutup do
+      subject.migrate
+    end
+
+    expect(new_keg_record).to exist
+    expect(old_keg_record.parent).to be_a_symlink
+    expect(HOMEBREW_LINKED_KEGS/"oldname").not_to exist
+    expect((HOMEBREW_LINKED_KEGS/"newname").realpath).to eq(new_keg_record.realpath)
+    expect(old_keg_record.realpath).to eq(new_keg_record.realpath)
+    expect((HOMEBREW_PREFIX/"opt/oldname").realpath).to eq(new_keg_record.realpath)
+    expect((HOMEBREW_CELLAR/"oldname").realpath).to eq(new_keg_record.parent.realpath)
+    expect((HOMEBREW_PINNED_KEGS/"newname").realpath).to eq(new_keg_record.realpath)
+    expect(Tab.for_keg(new_keg_record).source["path"]).to eq(new_formula.path.to_s)
+  end
+
+  specify "#unlinik_oldname_opt" do
+    new_keg_record.mkpath
+    old_opt_record = HOMEBREW_PREFIX/"opt/oldname"
+    old_opt_record.unlink if old_opt_record.symlink?
+    old_opt_record.make_relative_symlink(new_keg_record)
+    subject.unlink_oldname_opt
+    expect(old_opt_record).not_to be_a_symlink
+  end
+
+  specify "#unlink_oldname_cellar" do
+    new_keg_record.mkpath
+    keg.unlink
+    keg.uninstall
+    old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
+    subject.unlink_oldname_cellar
+    expect(old_keg_record.parent).not_to be_a_symlink
+  end
+
+  specify "#backup_oldname_cellar" do
+    (new_keg_record/"bin").mkpath
+    keg.unlink
+    keg.uninstall
+    subject.backup_oldname_cellar
+    expect(old_keg_record.subdirs).not_to be_empty
+  end
+
+  specify "#backup_old_tabs" do
+    tab = Tab.empty
+    tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
+    tab.source["path"] = "/should/be/the/same"
+    tab.write
+    migrator = Migrator.new(new_formula)
+    tab.tabfile.delete
+    migrator.backup_old_tabs
+    expect(Tab.for_keg(old_keg_record).source["path"]).to eq("/should/be/the/same")
+  end
+
+  describe "#backup_oldname" do
+    after(:each) do
+      expect(old_keg_record.parent).to be_a_directory
+      expect(old_keg_record.parent.subdirs).not_to be_empty
+      expect(HOMEBREW_LINKED_KEGS/"oldname").to exist
+      expect(HOMEBREW_PREFIX/"opt/oldname").to exist
+      expect(HOMEBREW_PINNED_KEGS/"oldname").to be_a_symlink
+      expect(keg).to be_linked
+    end
+
+    context "when cellar exists" do
+      it "backs up the old name" do
+        subject.backup_oldname
+      end
+    end
+
+    context "when cellar is removed" do
+      it "backs up the old name" do
+        (new_keg_record/"bin").mkpath
+        keg.unlink
+        keg.uninstall
+        subject.backup_oldname
+      end
+    end
+
+    context "when cellar is linked" do
+      it "backs up the old name" do
+        (new_keg_record/"bin").mkpath
+        keg.unlink
+        keg.uninstall
+        old_keg_record.parent.make_relative_symlink(new_keg_record.parent)
+        subject.backup_oldname
+      end
+    end
+  end
+end
diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb
deleted file mode 100644
index 012ea12bb..000000000
--- a/Library/Homebrew/test/migrator_test.rb
+++ /dev/null
@@ -1,251 +0,0 @@
-require "testing_env"
-require "migrator"
-require "test/support/fixtures/testball"
-require "tab"
-require "keg"
-
-class Formula
-  attr_writer :oldname
-end
-
-class MigratorErrorsTests < Homebrew::TestCase
-  def setup
-    super
-    @new_f = Testball.new("newname")
-    @new_f.oldname = "oldname"
-    @old_f = Testball.new("oldname")
-  end
-
-  def test_no_oldname
-    assert_raises(Migrator::MigratorNoOldnameError) { Migrator.new(@old_f) }
-  end
-
-  def test_no_oldpath
-    assert_raises(Migrator::MigratorNoOldpathError) { Migrator.new(@new_f) }
-  end
-
-  def test_different_taps
-    keg = HOMEBREW_CELLAR/"oldname/0.1"
-    keg.mkpath
-    tab = Tab.empty
-    tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
-    tab.source["tap"] = "homebrew/core"
-    tab.write
-    assert_raises(Migrator::MigratorDifferentTapsError) { Migrator.new(@new_f) }
-  end
-end
-
-class MigratorTests < Homebrew::TestCase
-  include FileUtils
-
-  def setup
-    super
-
-    @new_f = Testball.new("newname")
-    @new_f.oldname = "oldname"
-
-    @old_f = Testball.new("oldname")
-
-    @old_keg_record = HOMEBREW_CELLAR/"oldname/0.1"
-    @old_keg_record.join("bin").mkpath
-    @new_keg_record = HOMEBREW_CELLAR/"newname/0.1"
-
-    %w[inside bindir].each { |file| touch @old_keg_record.join("bin", file) }
-
-    @old_tab = Tab.empty
-    @old_tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
-    @old_tab.source["path"] = "/oldname"
-    @old_tab.write
-
-    @keg = Keg.new(@old_keg_record)
-    @keg.link
-    @keg.optlink
-
-    @old_pin = HOMEBREW_PINNED_KEGS/"oldname"
-    @old_pin.make_relative_symlink @old_keg_record
-
-    @migrator = Migrator.new(@new_f)
-
-    mkpath HOMEBREW_PREFIX/"bin"
-  end
-
-  def teardown
-    if !@old_keg_record.parent.symlink? && @old_keg_record.directory?
-      @keg.unlink
-    end
-
-    if @new_keg_record.directory?
-      new_keg = Keg.new(@new_keg_record)
-      new_keg.unlink
-    end
-
-    super
-  end
-
-  def test_move_cellar
-    @keg.unlink
-    shutup { @migrator.move_to_new_directory }
-    assert_predicate @new_keg_record, :directory?
-    assert_predicate @new_keg_record/"bin", :directory?
-    assert_predicate @new_keg_record/"bin/inside", :file?
-    assert_predicate @new_keg_record/"bin/bindir", :file?
-    refute_predicate @old_keg_record, :directory?
-  end
-
-  def test_backup_cellar
-    @old_keg_record.parent.rmtree
-    @new_keg_record.join("bin").mkpath
-
-    @migrator.backup_oldname_cellar
-
-    assert_predicate @old_keg_record, :directory?
-    assert_predicate @old_keg_record/"bin", :directory?
-  end
-
-  def test_repin
-    @new_keg_record.join("bin").mkpath
-    expected_relative = @new_keg_record.relative_path_from HOMEBREW_PINNED_KEGS
-
-    @migrator.repin
-
-    assert_predicate @migrator.new_pin_record, :symlink?
-    assert_equal expected_relative, @migrator.new_pin_record.readlink
-    refute_predicate @migrator.old_pin_record, :exist?
-  end
-
-  def test_unlink_oldname
-    assert_equal 1, HOMEBREW_LINKED_KEGS.children.size
-    assert_equal 1, (HOMEBREW_PREFIX/"opt").children.size
-
-    shutup { @migrator.unlink_oldname }
-
-    refute_predicate HOMEBREW_LINKED_KEGS, :exist?
-    refute_predicate HOMEBREW_LIBRARY/"bin", :exist?
-  end
-
-  def test_link_newname
-    @keg.unlink
-    @keg.uninstall
-    @new_keg_record.join("bin").mkpath
-    %w[inside bindir].each { |file| touch @new_keg_record.join("bin", file) }
-
-    shutup { @migrator.link_newname }
-
-    assert_equal 1, HOMEBREW_LINKED_KEGS.children.size
-    assert_equal 1, (HOMEBREW_PREFIX/"opt").children.size
-  end
-
-  def test_link_oldname_opt
-    @new_keg_record.mkpath
-    @migrator.link_oldname_opt
-    assert_equal @new_keg_record.realpath, (HOMEBREW_PREFIX/"opt/oldname").realpath
-  end
-
-  def test_link_oldname_cellar
-    @new_keg_record.join("bin").mkpath
-    @keg.unlink
-    @keg.uninstall
-    @migrator.link_oldname_cellar
-    assert_equal @new_keg_record.parent.realpath, (HOMEBREW_CELLAR/"oldname").realpath
-  end
-
-  def test_update_tabs
-    @new_keg_record.join("bin").mkpath
-    tab = Tab.empty
-    tab.tabfile = HOMEBREW_CELLAR/"newname/0.1/INSTALL_RECEIPT.json"
-    tab.source["path"] = "/path/that/must/be/changed/by/update_tabs"
-    tab.write
-    @migrator.update_tabs
-    assert_equal @new_f.path.to_s, Tab.for_keg(@new_keg_record).source["path"]
-  end
-
-  def test_migrate
-    tab = Tab.empty
-    tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
-    tab.source["path"] = @old_f.path.to_s
-    tab.write
-
-    shutup { @migrator.migrate }
-
-    assert_predicate @new_keg_record, :exist?
-    assert_predicate @old_keg_record.parent, :symlink?
-    refute_predicate HOMEBREW_LINKED_KEGS/"oldname", :exist?
-    assert_equal @new_keg_record.realpath, (HOMEBREW_LINKED_KEGS/"newname").realpath
-    assert_equal @new_keg_record.realpath, @old_keg_record.realpath
-    assert_equal @new_keg_record.realpath, (HOMEBREW_PREFIX/"opt/oldname").realpath
-    assert_equal @new_keg_record.parent.realpath, (HOMEBREW_CELLAR/"oldname").realpath
-    assert_equal @new_keg_record.realpath, (HOMEBREW_PINNED_KEGS/"newname").realpath
-    assert_equal @new_f.path.to_s, Tab.for_keg(@new_keg_record).source["path"]
-  end
-
-  def test_unlinik_oldname_opt
-    @new_keg_record.mkpath
-    old_opt_record = HOMEBREW_PREFIX/"opt/oldname"
-    old_opt_record.unlink if old_opt_record.symlink?
-    old_opt_record.make_relative_symlink(@new_keg_record)
-    @migrator.unlink_oldname_opt
-    refute_predicate old_opt_record, :symlink?
-  end
-
-  def test_unlink_oldname_cellar
-    @new_keg_record.mkpath
-    @keg.unlink
-    @keg.uninstall
-    @old_keg_record.parent.make_relative_symlink(@new_keg_record.parent)
-    @migrator.unlink_oldname_cellar
-    refute_predicate @old_keg_record.parent, :symlink?
-  end
-
-  def test_backup_oldname_cellar
-    @new_keg_record.join("bin").mkpath
-    @keg.unlink
-    @keg.uninstall
-    @migrator.backup_oldname_cellar
-    refute_predicate @old_keg_record.subdirs, :empty?
-  end
-
-  def test_backup_old_tabs
-    tab = Tab.empty
-    tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
-    tab.source["path"] = "/should/be/the/same"
-    tab.write
-    migrator = Migrator.new(@new_f)
-    tab.tabfile.delete
-    migrator.backup_old_tabs
-    assert_equal "/should/be/the/same", Tab.for_keg(@old_keg_record).source["path"]
-  end
-
-  # Backup tests are divided into three groups: when oldname Cellar is deleted
-  # and when it still exists and when it's a symlink
-
-  def check_after_backup
-    assert_predicate @old_keg_record.parent, :directory?
-    refute_predicate @old_keg_record.parent.subdirs, :empty?
-    assert_predicate HOMEBREW_LINKED_KEGS/"oldname", :exist?
-    assert_predicate HOMEBREW_PREFIX/"opt/oldname", :exist?
-    assert_predicate HOMEBREW_PINNED_KEGS/"oldname", :symlink?
-    assert_predicate @keg, :linked?
-  end
-
-  def test_backup_cellar_exist
-    @migrator.backup_oldname
-    check_after_backup
-  end
-
-  def test_backup_cellar_removed
-    @new_keg_record.join("bin").mkpath
-    @keg.unlink
-    @keg.uninstall
-    @migrator.backup_oldname
-    check_after_backup
-  end
-
-  def test_backup_cellar_linked
-    @new_keg_record.join("bin").mkpath
-    @keg.unlink
-    @keg.uninstall
-    @old_keg_record.parent.make_relative_symlink(@new_keg_record.parent)
-    @migrator.backup_oldname
-    check_after_backup
-  end
-end
-- 
cgit v1.2.3


From f7151e589fec5cd8caef00798c02e0c54eff5419 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 02:50:52 +0100
Subject: Convert JavaRequirement test to spec.

---
 Library/Homebrew/test/java_requirement_spec.rb | 107 +++++++++++++++++++++++++
 Library/Homebrew/test/java_requirement_test.rb |  50 ------------
 2 files changed, 107 insertions(+), 50 deletions(-)
 create mode 100644 Library/Homebrew/test/java_requirement_spec.rb
 delete mode 100644 Library/Homebrew/test/java_requirement_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/java_requirement_spec.rb b/Library/Homebrew/test/java_requirement_spec.rb
new file mode 100644
index 000000000..5adf64c7c
--- /dev/null
+++ b/Library/Homebrew/test/java_requirement_spec.rb
@@ -0,0 +1,107 @@
+require "requirements/java_requirement"
+
+describe JavaRequirement do
+  subject { described_class.new([]) }
+
+  before(:each) do
+    ENV["JAVA_HOME"] = nil
+  end
+
+  describe "#message" do
+    its(:message) { is_expected.to match(/Java is required to install this formula./) }
+  end
+
+  describe "#inspect" do
+    subject { described_class.new(%w[1.7+]) }
+    its(:inspect) { is_expected.to eq('#') }
+  end
+
+  describe "#display_s" do
+    context "without specific version" do
+      its(:display_s) { is_expected.to eq("java") }
+    end
+
+    context "with version 1.8" do
+      subject { described_class.new(%w[1.8]) }
+      its(:display_s) { is_expected.to eq("java = 1.8") }
+    end
+
+    context "with version 1.8+" do
+      subject { described_class.new(%w[1.8+]) }
+      its(:display_s) { is_expected.to eq("java >= 1.8") }
+    end
+  end
+
+  describe "#satisfied?" do
+    subject { described_class.new(%w[1.8]) }
+
+    it "returns false if no `java` executable can be found" do
+      allow(File).to receive(:executable?).and_return(false)
+      expect(subject).not_to be_satisfied
+    end
+
+    it "returns true if #preferred_java returns a path" do
+      allow(subject).to receive(:preferred_java).and_return(Pathname.new("/usr/bin/java"))
+      expect(subject).to be_satisfied
+    end
+
+    context "when #possible_javas contains paths" do
+      let(:path) { Pathname.new(Dir.mktmpdir) }
+      let(:java) { path/"java" }
+
+      def setup_java_with_version(version)
+        IO.write java, <<-EOS.undent
+          #!/bin/sh
+          echo 'java version "#{version}"'
+        EOS
+        FileUtils.chmod "+x", java
+      end
+
+      before(:each) do
+        allow(subject).to receive(:possible_javas).and_return([java])
+      end
+
+      after(:each) do
+        path.rmtree
+      end
+
+      context "and 1.7 is required" do
+        subject { described_class.new(%w[1.7]) }
+
+        it "returns false if all are lower" do
+          setup_java_with_version "1.6.0_5"
+          expect(subject).not_to be_satisfied
+        end
+
+        it "returns true if one is equal" do
+          setup_java_with_version "1.7.0_5"
+          expect(subject).to be_satisfied
+        end
+
+        it "returns false if all are higher" do
+          setup_java_with_version "1.8.0_5"
+          expect(subject).not_to be_satisfied
+        end
+      end
+
+      context "and 1.7+ is required" do
+        subject { described_class.new(%w[1.7+]) }
+
+        it "returns false if all are lower" do
+          setup_java_with_version "1.6.0_5"
+          expect(subject).not_to be_satisfied
+        end
+
+        it "returns true if one is equal" do
+          setup_java_with_version "1.7.0_5"
+          expect(subject).to be_satisfied
+        end
+
+        it "returns true if one is higher" do
+          setup_java_with_version "1.8.0_5"
+          expect(subject).to be_satisfied
+        end
+      end
+    end
+  end
+end
diff --git a/Library/Homebrew/test/java_requirement_test.rb b/Library/Homebrew/test/java_requirement_test.rb
deleted file mode 100644
index d0b51f92c..000000000
--- a/Library/Homebrew/test/java_requirement_test.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require "testing_env"
-require "requirements/java_requirement"
-
-class JavaRequirementTests < Homebrew::TestCase
-  def setup
-    super
-    ENV["JAVA_HOME"] = nil
-  end
-
-  def test_message
-    a = JavaRequirement.new([])
-    assert_match(/Java is required to install this formula./, a.message)
-  end
-
-  def test_inspect
-    a = JavaRequirement.new(%w[1.7+])
-    assert_equal a.inspect, '#'
-  end
-
-  def test_display_s
-    x = JavaRequirement.new([])
-    assert_equal x.display_s, "java"
-    y = JavaRequirement.new(%w[1.8])
-    assert_equal y.display_s, "java = 1.8"
-    z = JavaRequirement.new(%w[1.8+])
-    assert_equal z.display_s, "java >= 1.8"
-  end
-
-  def test_satisfied?
-    a = JavaRequirement.new(%w[1.8])
-    File.stubs(:executable?).returns(false)
-    refute_predicate a, :satisfied?
-
-    b = JavaRequirement.new([])
-    b.stubs(:preferred_java).returns(Pathname.new("/usr/bin/java"))
-    assert_predicate b, :satisfied?
-
-    c = JavaRequirement.new(%w[1.7+])
-    c.stubs(:possible_javas).returns([Pathname.new("/usr/bin/java")])
-    Utils.stubs(:popen_read).returns('java version "1.6.0_5"')
-    refute_predicate c, :satisfied?
-    Utils.stubs(:popen_read).returns('java version "1.8.0_5"')
-    assert_predicate c, :satisfied?
-
-    d = JavaRequirement.new(%w[1.7])
-    d.stubs(:possible_javas).returns([Pathname.new("/usr/bin/java")])
-    Utils.stubs(:popen_read).returns('java version "1.8.0_5"')
-    refute_predicate d, :satisfied?
-  end
-end
-- 
cgit v1.2.3


From babc375372df635c023977de9f1279a7689e2453 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 20:58:43 +0100
Subject: Convert Resource test to spec.

---
 Library/Homebrew/test/resource_spec.rb | 147 +++++++++++++++++++++++++++++++++
 Library/Homebrew/test/resource_test.rb | 133 -----------------------------
 2 files changed, 147 insertions(+), 133 deletions(-)
 create mode 100644 Library/Homebrew/test/resource_spec.rb
 delete mode 100644 Library/Homebrew/test/resource_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/resource_spec.rb b/Library/Homebrew/test/resource_spec.rb
new file mode 100644
index 000000000..6a0419538
--- /dev/null
+++ b/Library/Homebrew/test/resource_spec.rb
@@ -0,0 +1,147 @@
+require "resource"
+
+describe Resource do
+  subject { described_class.new("test") }
+
+  describe "#url" do
+    it "sets the URL" do
+      subject.url("foo")
+      expect(subject.url).to eq("foo")
+    end
+
+    it "can set the URL with specifications" do
+      subject.url("foo", branch: "master")
+      expect(subject.url).to eq("foo")
+      expect(subject.specs).to eq(branch: "master")
+    end
+
+    it "can set the URL with a custom download strategy class" do
+      strategy = Class.new(AbstractDownloadStrategy)
+      subject.url("foo", using: strategy)
+      expect(subject.url).to eq("foo")
+      expect(subject.download_strategy).to eq(strategy)
+    end
+
+    it "can set the URL with specifications and a custom download strategy class" do
+      strategy = Class.new(AbstractDownloadStrategy)
+      subject.url("foo", using: strategy, branch: "master")
+      expect(subject.url).to eq("foo")
+      expect(subject.specs).to eq(branch: "master")
+      expect(subject.download_strategy).to eq(strategy)
+    end
+
+    it "can set the URL with a custom download strategy symbol" do
+      subject.url("foo", using: :git)
+      expect(subject.url).to eq("foo")
+      expect(subject.download_strategy).to eq(GitDownloadStrategy)
+    end
+
+    it "raises an error if the download strategy class is unkown" do
+      expect { subject.url("foo", using: Class.new) }.to raise_error(TypeError)
+    end
+
+    it "does not mutate the specifications hash" do
+      specs = { using: :git, branch: "master" }
+      subject.url("foo", specs)
+      expect(subject.specs).to eq(branch: "master")
+      expect(subject.using).to eq(:git)
+      expect(specs).to eq(using: :git, branch: "master")
+    end
+  end
+
+  describe "#version" do
+    it "sets the version" do
+      subject.version("1.0")
+      expect(subject.version).to eq(Version.parse("1.0"))
+      expect(subject.version).not_to be_detected_from_url
+    end
+
+    it "can detect the version from a URL" do
+      subject.url("http://example.com/foo-1.0.tar.gz")
+      expect(subject.version).to eq(Version.parse("1.0"))
+      expect(subject.version).to be_detected_from_url
+    end
+
+    it "can set the version with a scheme" do
+      klass = Class.new(Version)
+      subject.version klass.new("1.0")
+      expect(subject.version).to eq(Version.parse("1.0"))
+      expect(subject.version).to be_a(klass)
+    end
+
+    it "can set the version from a tag" do
+      subject.url("http://example.com/foo-1.0.tar.gz", tag: "v1.0.2")
+      expect(subject.version).to eq(Version.parse("1.0.2"))
+      expect(subject.version).to be_detected_from_url
+    end
+
+    it "rejects non-string versions" do
+      expect { subject.version(1) }.to raise_error(TypeError)
+      expect { subject.version(2.0) }.to raise_error(TypeError)
+      expect { subject.version(Object.new) }.to raise_error(TypeError)
+    end
+
+    it "returns nil if unset" do
+      expect(subject.version).to be nil
+    end
+  end
+
+  describe "#mirrors" do
+    it "is empty by defaults" do
+      expect(subject.mirrors).to be_empty
+    end
+
+    it "returns an array of mirrors added with #mirror" do
+      subject.mirror("foo")
+      subject.mirror("bar")
+      expect(subject.mirrors).to eq(%w[foo bar])
+    end
+  end
+
+  describe "#checksum" do
+    it "returns nil if unset" do
+      expect(subject.checksum).to be nil
+    end
+
+    it "returns the checksum set with #sha256" do
+      subject.sha256(TEST_SHA256)
+      expect(subject.checksum).to eq(Checksum.new(:sha256, TEST_SHA256))
+    end
+  end
+
+  describe "#download_strategy" do
+    it "returns the download strategy" do
+      strategy = Object.new
+      expect(DownloadStrategyDetector)
+        .to receive(:detect).with("foo", nil).and_return(strategy)
+      subject.url("foo")
+      expect(subject.download_strategy).to eq(strategy)
+    end
+  end
+
+  specify "#verify_download_integrity_missing" do
+    fn = Pathname.new("test")
+
+    allow(fn).to receive(:file?).and_return(true)
+    expect(fn).to receive(:verify_checksum).and_raise(ChecksumMissingError)
+    expect(fn).to receive(:sha256)
+
+    shutup do
+      subject.verify_download_integrity(fn)
+    end
+  end
+
+  specify "#verify_download_integrity_mismatch" do
+    fn = double(file?: true)
+    checksum = subject.sha256(TEST_SHA256)
+
+    expect(fn).to receive(:verify_checksum).with(checksum)
+      .and_raise(ChecksumMismatchError.new(fn, checksum, Object.new))
+
+    shutup do
+      expect {
+        subject.verify_download_integrity(fn)
+      }.to raise_error(ChecksumMismatchError)
+    end
+  end
+end
diff --git a/Library/Homebrew/test/resource_test.rb b/Library/Homebrew/test/resource_test.rb
deleted file mode 100644
index d982a7c33..000000000
--- a/Library/Homebrew/test/resource_test.rb
+++ /dev/null
@@ -1,133 +0,0 @@
-require "testing_env"
-require "resource"
-
-class ResourceTests < Homebrew::TestCase
-  def setup
-    super
-    @resource = Resource.new("test")
-  end
-
-  def test_url
-    @resource.url("foo")
-    assert_equal "foo", @resource.url
-  end
-
-  def test_url_with_specs
-    @resource.url("foo", branch: "master")
-    assert_equal "foo", @resource.url
-    assert_equal({ branch: "master" }, @resource.specs)
-  end
-
-  def test_url_with_custom_download_strategy_class
-    strategy = Class.new(AbstractDownloadStrategy)
-    @resource.url("foo", using: strategy)
-    assert_equal "foo", @resource.url
-    assert_equal strategy, @resource.download_strategy
-  end
-
-  def test_url_with_specs_and_download_strategy
-    strategy = Class.new(AbstractDownloadStrategy)
-    @resource.url("foo", using: strategy, branch: "master")
-    assert_equal "foo", @resource.url
-    assert_equal({ branch: "master" }, @resource.specs)
-    assert_equal strategy, @resource.download_strategy
-  end
-
-  def test_url_with_custom_download_strategy_symbol
-    @resource.url("foo", using: :git)
-    assert_equal "foo", @resource.url
-    assert_equal GitDownloadStrategy, @resource.download_strategy
-  end
-
-  def test_raises_for_unknown_download_strategy_class
-    assert_raises(TypeError) { @resource.url("foo", using: Class.new) }
-  end
-
-  def test_does_not_mutate_specs_hash
-    specs = { using: :git, branch: "master" }
-    @resource.url("foo", specs)
-    assert_equal({ branch: "master" }, @resource.specs)
-    assert_equal(:git, @resource.using)
-    assert_equal({ using: :git, branch: "master" }, specs)
-  end
-
-  def test_version
-    @resource.version("1.0")
-    assert_version_equal "1.0", @resource.version
-    refute_predicate @resource.version, :detected_from_url?
-  end
-
-  def test_version_from_url
-    @resource.url("http://example.com/foo-1.0.tar.gz")
-    assert_version_equal "1.0", @resource.version
-    assert_predicate @resource.version, :detected_from_url?
-  end
-
-  def test_version_with_scheme
-    klass = Class.new(Version)
-    @resource.version klass.new("1.0")
-    assert_version_equal "1.0", @resource.version
-    assert_instance_of klass, @resource.version
-  end
-
-  def test_version_from_tag
-    @resource.url("http://example.com/foo-1.0.tar.gz", tag: "v1.0.2")
-    assert_version_equal "1.0.2", @resource.version
-    assert_predicate @resource.version, :detected_from_url?
-  end
-
-  def test_rejects_non_string_versions
-    assert_raises(TypeError) { @resource.version(1) }
-    assert_raises(TypeError) { @resource.version(2.0) }
-    assert_raises(TypeError) { @resource.version(Object.new) }
-  end
-
-  def test_version_when_url_is_not_set
-    assert_nil @resource.version
-  end
-
-  def test_mirrors
-    assert_empty @resource.mirrors
-    @resource.mirror("foo")
-    @resource.mirror("bar")
-    assert_equal %w[foo bar], @resource.mirrors
-  end
-
-  def test_checksum_setters
-    assert_nil @resource.checksum
-    @resource.sha256(TEST_SHA256)
-    assert_equal Checksum.new(:sha256, TEST_SHA256), @resource.checksum
-  end
-
-  def test_download_strategy
-    strategy = Object.new
-    DownloadStrategyDetector
-      .expects(:detect).with("foo", nil).returns(strategy)
-    @resource.url("foo")
-    assert_equal strategy, @resource.download_strategy
-  end
-
-  def test_verify_download_integrity_missing
-    fn = Pathname.new("test")
-
-    fn.stubs(file?: true)
-    fn.expects(:verify_checksum).raises(ChecksumMissingError)
-    fn.expects(:sha256)
-
-    shutup { @resource.verify_download_integrity(fn) }
-  end
-
-  def test_verify_download_integrity_mismatch
-    fn = stub(file?: true)
-    checksum = @resource.sha256(TEST_SHA256)
-
-    fn.expects(:verify_checksum).with(checksum)
-      .raises(ChecksumMismatchError.new(fn, checksum, Object.new))
-
-    shutup do
-      assert_raises(ChecksumMismatchError) do
-        @resource.verify_download_integrity(fn)
-      end
-    end
-  end
-end
-- 
cgit v1.2.3


From 7393485b7b2f15b84506d1c7f7d157db545aa18f Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 22:51:37 +0100
Subject: Convert `dependency_expansion` test to spec.

---
 Library/Homebrew/test/dependency_expansion_spec.rb | 136 ++++++++++++++++++++
 Library/Homebrew/test/dependency_expansion_test.rb | 138 ---------------------
 2 files changed, 136 insertions(+), 138 deletions(-)
 create mode 100644 Library/Homebrew/test/dependency_expansion_spec.rb
 delete mode 100644 Library/Homebrew/test/dependency_expansion_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/dependency_expansion_spec.rb b/Library/Homebrew/test/dependency_expansion_spec.rb
new file mode 100644
index 000000000..f955237a9
--- /dev/null
+++ b/Library/Homebrew/test/dependency_expansion_spec.rb
@@ -0,0 +1,136 @@
+require "dependency"
+
+describe Dependency do
+  def build_dep(name, tags = [], deps = [])
+    dep = described_class.new(name.to_s, tags)
+    allow(dep).to receive(:to_formula).and_return(double(deps: deps, name: name))
+    dep
+  end
+
+  let(:foo) { build_dep(:foo) }
+  let(:bar) { build_dep(:bar) }
+  let(:baz) { build_dep(:baz) }
+  let(:qux) { build_dep(:qux) }
+  let(:deps) { [foo, bar, baz, qux] }
+  let(:formula) { double(deps: deps, name: "f") }
+
+  describe "::expand" do
+    it "yields dependent and dependency pairs" do
+      i = 0
+      described_class.expand(formula) do |dependent, dep|
+        expect(dependent).to eq(formula)
+        expect(deps[i]).to eq(dep)
+        i += 1
+      end
+    end
+
+    it "returns the dependencies" do
+      expect(described_class.expand(formula)).to eq(deps)
+    end
+
+    it "prunes all when given a block with ::prune" do
+      expect(described_class.expand(formula) { described_class.prune }).to be_empty
+    end
+
+    it "can prune selectively" do
+      deps = described_class.expand(formula) do |_, dep|
+        described_class.prune if dep.name == "foo"
+      end
+
+      expect(deps).to eq([bar, baz, qux])
+    end
+
+    it "preserves dependency order" do
+      allow(foo).to receive(:to_formula).and_return(double(name: "f", deps: [qux, baz]))
+      expect(described_class.expand(formula)).to eq([qux, baz, foo, bar])
+    end
+  end
+
+  it "skips optionals by default" do
+    deps = [build_dep(:foo, [:optional]), bar, baz, qux]
+    f = double(deps: deps, build: double(with?: false), name: "f")
+    expect(described_class.expand(f)).to eq([bar, baz, qux])
+  end
+
+  it "keeps recommended dependencies by default" do
+    deps = [build_dep(:foo, [:recommended]), bar, baz, qux]
+    f = double(deps: deps, build: double(with?: true), name: "f")
+    expect(described_class.expand(f)).to eq(deps)
+  end
+
+  it "merges repeated dependencies with differing options" do
+    foo2 = build_dep(:foo, ["option"])
+    baz2 = build_dep(:baz, ["option"])
+    deps << foo2 << baz2
+    deps = [foo2, bar, baz2, qux]
+    deps.zip(described_class.expand(formula)) do |expected, actual|
+      expect(expected.tags).to eq(actual.tags)
+      expect(expected).to eq(actual)
+    end
+  end
+
+  it "merges dependencies and perserves env_proc" do
+    env_proc = double
+    dep = described_class.new("foo", [], env_proc)
+    allow(dep).to receive(:to_formula).and_return(double(deps: [], name: "foo"))
+    deps.replace([dep])
+    expect(described_class.expand(formula).first.env_proc).to eq(env_proc)
+  end
+
+  it "merges tags without duplicating them" do
+    foo2 = build_dep(:foo, ["option"])
+    foo3 = build_dep(:foo, ["option"])
+    deps << foo2 << foo3
+
+    expect(described_class.expand(formula).first.tags).to eq(%w[option])
+  end
+
+  it "skips parent but yields children with ::skip" do
+    f = double(
+      name: "f",
+      deps: [
+        build_dep(:foo, [], [bar, baz]),
+        build_dep(:foo, [], [baz]),
+      ],
+    )
+
+    deps = described_class.expand(f) do |_dependent, dep|
+      described_class.skip if %w[foo qux].include? dep.name
+    end
+
+    expect(deps).to eq([bar, baz])
+  end
+
+  it "keeps dependency but prunes recursive dependencies with ::keep_but_prune_recursive_deps" do
+    foo = build_dep(:foo, [:build], bar)
+    baz = build_dep(:baz, [:build])
+    f = double(name: "f", deps: [foo, baz])
+
+    deps = described_class.expand(f) do |_dependent, dep|
+      described_class.keep_but_prune_recursive_deps if dep.build?
+    end
+
+    expect(deps).to eq([foo, baz])
+  end
+
+  it "returns only the dependencies given as a collection as second argument" do
+    expect(formula.deps).to eq([foo, bar, baz, qux])
+    expect(described_class.expand(formula, [bar, baz])).to eq([bar, baz])
+  end
+
+  it "doesn't raise an error when a dependency is cyclic" do
+    foo = build_dep(:foo)
+    bar = build_dep(:bar, [], [foo])
+    allow(foo).to receive(:to_formula).and_return(double(deps: [bar], name: foo.name))
+    f = double(name: "f", deps: [foo, bar])
+    expect { described_class.expand(f) }.not_to raise_error
+  end
+
+  it "cleans the expand stack" do
+    foo = build_dep(:foo)
+    allow(foo).to receive(:to_formula).and_raise(FormulaUnavailableError, foo.name)
+    f = double(name: "f", deps: [foo])
+    expect { described_class.expand(f) }.to raise_error(FormulaUnavailableError)
+    expect(described_class.instance_variable_get(:@expand_stack)).to be_empty
+  end
+end
diff --git a/Library/Homebrew/test/dependency_expansion_test.rb b/Library/Homebrew/test/dependency_expansion_test.rb
deleted file mode 100644
index 58a731121..000000000
--- a/Library/Homebrew/test/dependency_expansion_test.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-require "testing_env"
-require "dependency"
-
-class DependencyExpansionTests < Homebrew::TestCase
-  def build_dep(name, tags = [], deps = [])
-    dep = Dependency.new(name.to_s, tags)
-    dep.stubs(:to_formula).returns(stub(deps: deps, name: name))
-    dep
-  end
-
-  def setup
-    super
-    @foo = build_dep(:foo)
-    @bar = build_dep(:bar)
-    @baz = build_dep(:baz)
-    @qux = build_dep(:qux)
-    @deps = [@foo, @bar, @baz, @qux]
-    @f    = stub(deps: @deps, name: "f")
-  end
-
-  def test_expand_yields_dependent_and_dep_pairs
-    i = 0
-    Dependency.expand(@f) do |dependent, dep|
-      assert_equal @f, dependent
-      assert_equal dep, @deps[i]
-      i += 1
-    end
-  end
-
-  def test_expand_no_block
-    assert_equal @deps, Dependency.expand(@f)
-  end
-
-  def test_expand_prune_all
-    assert_empty Dependency.expand(@f) { Dependency.prune }
-  end
-
-  def test_expand_selective_pruning
-    deps = Dependency.expand(@f) do |_, dep|
-      Dependency.prune if dep.name == "foo"
-    end
-
-    assert_equal [@bar, @baz, @qux], deps
-  end
-
-  def test_expand_preserves_dependency_order
-    @foo.stubs(:to_formula).returns(stub(name: "f", deps: [@qux, @baz]))
-    assert_equal [@qux, @baz, @foo, @bar], Dependency.expand(@f)
-  end
-
-  def test_expand_skips_optionals_by_default
-    deps = [build_dep(:foo, [:optional]), @bar, @baz, @qux]
-    f = stub(deps: deps, build: stub(with?: false), name: "f")
-    assert_equal [@bar, @baz, @qux], Dependency.expand(f)
-  end
-
-  def test_expand_keeps_recommendeds_by_default
-    deps = [build_dep(:foo, [:recommended]), @bar, @baz, @qux]
-    f = stub(deps: deps, build: stub(with?: true), name: "f")
-    assert_equal deps, Dependency.expand(f)
-  end
-
-  def test_merges_repeated_deps_with_differing_options
-    @foo2 = build_dep(:foo, ["option"])
-    @baz2 = build_dep(:baz, ["option"])
-    @deps << @foo2 << @baz2
-    deps = [@foo2, @bar, @baz2, @qux]
-    deps.zip(Dependency.expand(@f)) do |expected, actual|
-      assert_equal expected.tags, actual.tags
-      assert_equal expected, actual
-    end
-  end
-
-  def test_merger_preserves_env_proc
-    env_proc = stub
-    dep = Dependency.new("foo", [], env_proc)
-    dep.stubs(:to_formula).returns(stub(deps: [], name: "foo"))
-    @deps.replace [dep]
-    assert_equal env_proc, Dependency.expand(@f).first.env_proc
-  end
-
-  def test_merged_tags_no_dupes
-    @foo2 = build_dep(:foo, ["option"])
-    @foo3 = build_dep(:foo, ["option"])
-    @deps << @foo2 << @foo3
-
-    assert_equal %w[option], Dependency.expand(@f).first.tags
-  end
-
-  def test_skip_skips_parent_but_yields_children
-    f = stub(
-      name: "f",
-      deps: [
-        build_dep(:foo, [], [@bar, @baz]),
-        build_dep(:foo, [], [@baz]),
-      ],
-    )
-
-    deps = Dependency.expand(f) do |_dependent, dep|
-      Dependency.skip if %w[foo qux].include? dep.name
-    end
-
-    assert_equal [@bar, @baz], deps
-  end
-
-  def test_keep_dep_but_prune_recursive_deps
-    foo = build_dep(:foo, [:build], @bar)
-    baz = build_dep(:baz, [:build])
-    f = stub(name: "f", deps: [foo, baz])
-
-    deps = Dependency.expand(f) do |_dependent, dep|
-      Dependency.keep_but_prune_recursive_deps if dep.build?
-    end
-
-    assert_equal [foo, baz], deps
-  end
-
-  def test_deps_with_collection_argument
-    assert_equal [@foo, @bar, @baz, @qux], @f.deps
-    assert_equal [@bar, @baz], Dependency.expand(@f, [@bar, @baz])
-  end
-
-  def test_cyclic_dependency
-    foo = build_dep(:foo)
-    bar = build_dep(:bar, [], [foo])
-    foo.stubs(:to_formula).returns(stub(deps: [bar], name: "foo"))
-    f = stub(name: "f", deps: [foo, bar])
-    assert_nothing_raised { Dependency.expand(f) }
-  end
-
-  def test_clean_expand_stack
-    foo = build_dep(:foo)
-    foo.stubs(:to_formula).raises(FormulaUnavailableError, "foo")
-    f = stub(name: "f", deps: [foo])
-    assert_raises(FormulaUnavailableError) { Dependency.expand(f) }
-    assert_empty Dependency.instance_variable_get(:@expand_stack)
-  end
-end
-- 
cgit v1.2.3


From b4a2fe502cc8bef717e9f52efe5926cc27d1e9a6 Mon Sep 17 00:00:00 2001
From: Kimmo Lehto
Date: Wed, 22 Feb 2017 09:21:31 +0200
Subject: Proposed changes

---
 Library/Homebrew/requirements/ruby_requirement.rb | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/requirements/ruby_requirement.rb
index 0caedb5ca..327c13170 100644
--- a/Library/Homebrew/requirements/ruby_requirement.rb
+++ b/Library/Homebrew/requirements/ruby_requirement.rb
@@ -8,10 +8,10 @@ class RubyRequirement < Requirement
     super
   end
 
-  satisfy(build_env: false) { suitable_ruby }
+  satisfy(build_env: false) { new_enough_ruby }
 
   env do
-    ENV.prepend_path "PATH", suitable_ruby
+    ENV.prepend_path "PATH", new_enough_ruby
   end
 
   def message
@@ -34,19 +34,20 @@ class RubyRequirement < Requirement
 
   private
 
-  def suitable_ruby
-    rubies.detect { |ruby| suitable?(ruby) }
+  def new_enough_ruby
+    rubies.detect { |ruby| new_enough?(ruby) }
   end
 
   def rubies
     rubies = which_all("ruby")
+    ruby_formula = Formula["ruby"]
     if ruby_formula && ruby_formula.installed?
-      rubies.unshift Pathname.new(ruby_formula.bin/"ruby")
+      rubies.unshift ruby_formula.bin/"ruby"
     end
     rubies.uniq
   end
 
-  def suitable?(ruby)
+  def new_enough?(ruby)
     version = Utils.popen_read(ruby, "-e", "print RUBY_VERSION").strip
     version =~ /^\d+\.\d+/ && Version.create(version) >= min_version
   end
@@ -54,11 +55,4 @@ class RubyRequirement < Requirement
   def min_version
     @min_version ||= Version.create(@version)
   end
-
-  def ruby_formula
-    @ruby_formula ||= Formula["ruby"]
-  rescue FormulaUnavailableError
-    nil
-  end
-
 end
-- 
cgit v1.2.3


From ac5b6b6eeaec7b6ee2fb79a28d69c6036ee49299 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Wed, 22 Feb 2017 08:49:24 +0000
Subject: Revert "audit: fix revision should be removed."

---
 Library/Homebrew/dev-cmd/audit.rb | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index d4d6a6d72..9ffef0f99 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -794,12 +794,10 @@ class FormulaAuditor
 
     return if formula.revision.zero?
     if formula.stable
-      if revision_map = attributes_map[:revision][:stable]
-        stable_revisions = revision_map[formula.stable.version]
-        stable_revisions -= [formula.revision]
-        if stable_revisions.empty?
-          problem "'revision #{formula.revision}' should be removed"
-        end
+      revision_map = attributes_map[:revision][:stable]
+      stable_revisions = revision_map[formula.stable.version] if revision_map
+      if !stable_revisions || stable_revisions.empty?
+        problem "'revision #{formula.revision}' should be removed"
       end
     else # head/devel-only formula
       problem "'revision #{formula.revision}' should be removed"
-- 
cgit v1.2.3


From e793e526611ca4cbc6d0155af8c596c4e826fc41 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Wed, 22 Feb 2017 08:49:49 +0000
Subject: Revert "formula_versions: handle uncommitted formulae."

---
 Library/Homebrew/formula_versions.rb | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index 34b766fde..28c2a3be8 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -15,7 +15,6 @@ class FormulaVersions
     @repository = formula.tap.path
     @entry_name = @path.relative_path_from(repository).to_s
     @max_depth = options[:max_depth]
-    @current_formula = formula
   end
 
   def rev_list(branch)
@@ -65,33 +64,25 @@ class FormulaVersions
 
     attributes.each do |attribute|
       attributes_map[attribute] ||= {}
-      # Set the attributes for the current formula in case it's not been
-      # committed yet.
-      set_attribute_map(attributes_map[attribute], @current_formula, attribute)
     end
 
     rev_list(branch) do |rev|
       formula_at_revision(rev) do |f|
         attributes.each do |attribute|
-          set_attribute_map(attributes_map[attribute], f, attribute)
+          map = attributes_map[attribute]
+          if f.stable
+            map[:stable] ||= {}
+            map[:stable][f.stable.version] ||= []
+            map[:stable][f.stable.version] << f.send(attribute)
+          end
+          next unless f.devel
+          map[:devel] ||= {}
+          map[:devel][f.devel.version] ||= []
+          map[:devel][f.devel.version] << f.send(attribute)
         end
       end
     end
 
     attributes_map
   end
-
-  private
-
-  def set_attribute_map(map, f, attribute)
-    if f.stable
-      map[:stable] ||= {}
-      map[:stable][f.stable.version] ||= []
-      map[:stable][f.stable.version] << f.send(attribute)
-    end
-    return unless f.devel
-    map[:devel] ||= {}
-    map[:devel][f.devel.version] ||= []
-    map[:devel][f.devel.version] << f.send(attribute)
-  end
 end
-- 
cgit v1.2.3


From 48a211fc90d3b53db3fb2f76d454ee64cab0cdf7 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 06:17:06 +0100
Subject: Convert `os/mac/language` test to spec.

---
 Library/Homebrew/dev-cmd/tests.rb             |  4 +---
 Library/Homebrew/test/os/mac/language_test.rb | 19 -------------------
 Library/Homebrew/test/os/mac_spec.rb          | 22 ++++++++++++++++++++++
 3 files changed, 23 insertions(+), 22 deletions(-)
 delete mode 100644 Library/Homebrew/test/os/mac/language_test.rb
 create mode 100644 Library/Homebrew/test/os/mac_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index 244fbe027..9cabb3d61 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -57,9 +57,7 @@ module Homebrew
       ENV["SEED"] = ARGV.next if ARGV.include? "--seed"
 
       files = Dir.glob("test/**/*_{spec,test}.rb")
-                 .reject { |p| !OS.mac? && p.start_with?("test/os/mac/") }
-                 .reject { |p| !OS.mac? && p.start_with?("test/cask/") }
-                 .reject { |p| p.start_with?("test/vendor/bundle/") }
+                 .reject { |p| !OS.mac? && p =~ %r{^test/(os/mac|cask)(/.*|_(test|spec)\.rb)$} }
 
       test_args = []
       test_args << "--trace" if ARGV.include? "--trace"
diff --git a/Library/Homebrew/test/os/mac/language_test.rb b/Library/Homebrew/test/os/mac/language_test.rb
deleted file mode 100644
index e328db5e0..000000000
--- a/Library/Homebrew/test/os/mac/language_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "testing_env"
-require "locale"
-require "os/mac"
-
-class OSMacLanguageTests < Homebrew::TestCase
-  def test_languages_format
-    OS::Mac.languages.each do |language|
-      assert_nothing_raised do
-        Locale.parse(language)
-      end
-    end
-  end
-
-  def test_language_format
-    assert_nothing_raised do
-      Locale.parse(OS::Mac.language)
-    end
-  end
-end
diff --git a/Library/Homebrew/test/os/mac_spec.rb b/Library/Homebrew/test/os/mac_spec.rb
new file mode 100644
index 000000000..641782451
--- /dev/null
+++ b/Library/Homebrew/test/os/mac_spec.rb
@@ -0,0 +1,22 @@
+require "locale"
+require "os/mac"
+
+describe OS::Mac do
+  describe "::languages" do
+    specify "all languages can be parsed by Locale::parse" do
+      subject.languages.each do |language|
+        expect { Locale.parse(language) }.not_to raise_error
+      end
+    end
+  end
+
+  describe "::language" do
+    it "returns the first item from #languages" do
+      expect(subject.language).to eq(subject.languages.first)
+    end
+
+    it "can be parsed by Locale::parse" do
+      expect { Locale.parse(subject.language) }.not_to raise_error
+    end
+  end
+end
-- 
cgit v1.2.3


From 85ff9add185fc24d99b296cf9cca3071b6d865c0 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Wed, 15 Feb 2017 02:02:25 +0100
Subject: Convert Pathname test to spec.

---
 Library/Homebrew/test/pathname_spec.rb | 300 +++++++++++++++++++++++++++++++++
 Library/Homebrew/test/pathname_test.rb | 263 -----------------------------
 2 files changed, 300 insertions(+), 263 deletions(-)
 create mode 100644 Library/Homebrew/test/pathname_spec.rb
 delete mode 100644 Library/Homebrew/test/pathname_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/pathname_spec.rb b/Library/Homebrew/test/pathname_spec.rb
new file mode 100644
index 000000000..da12d4347
--- /dev/null
+++ b/Library/Homebrew/test/pathname_spec.rb
@@ -0,0 +1,300 @@
+require "tmpdir"
+require "extend/pathname"
+require "install_renamed"
+
+describe Pathname do
+  include FileUtils
+
+  let(:src) { Pathname.new(Dir.mktmpdir) }
+  let(:dst) { Pathname.new(Dir.mktmpdir) }
+  let(:file) { src/"foo" }
+  let(:dir) { src/"bar" }
+
+  after(:each) { rm_rf [src, dst] }
+
+  describe DiskUsageExtension do
+    before(:each) do
+      mkdir_p dir/"a-directory"
+      touch [dir/".DS_Store", dir/"a-file"]
+      File.truncate(dir/"a-file", 1_048_576)
+      ln_s dir/"a-file", dir/"a-symlink"
+      ln dir/"a-file", dir/"a-hardlink"
+    end
+
+    describe "#file_count" do
+      it "returns the number of files in a directory" do
+        expect(dir.file_count).to eq(3)
+      end
+    end
+
+    describe "#abv" do
+      context "when called on a directory" do
+        it "returns a string with the file count and disk usage" do
+          expect(dir.abv).to eq("3 files, 1M")
+        end
+      end
+
+      context "when called on a file" do
+        it "returns the disk usage" do
+          expect((dir/"a-file").abv).to eq("1M")
+        end
+      end
+    end
+  end
+
+  describe "#rmdir_if_possible" do
+    before(:each) { mkdir_p dir }
+
+    it "returns true and removes a directory if it doesn't contain files" do
+      expect(dir.rmdir_if_possible).to be true
+      expect(dir).not_to exist
+    end
+
+    it "returns false and doesn't delete a directory if it contains files" do
+      touch dir/"foo"
+      expect(dir.rmdir_if_possible).to be false
+      expect(dir).to be_a_directory
+    end
+
+    it "ignores .DS_Store files" do
+      touch dir/".DS_Store"
+      expect(dir.rmdir_if_possible).to be true
+      expect(dir).not_to exist
+    end
+  end
+
+  describe "#write" do
+    it "creates a file and writes to it" do
+      expect(file).not_to exist
+      file.write("CONTENT")
+      expect(File.read(file)).to eq("CONTENT")
+    end
+
+    it "raises an error if the file already exists" do
+      touch file
+      expect { file.write("CONTENT") }.to raise_error(RuntimeError)
+    end
+  end
+
+  describe "#append_lines" do
+    it "appends lines to a file" do
+      touch file
+
+      file.append_lines("CONTENT")
+      expect(File.read(file)).to eq <<-EOS.undent
+        CONTENT
+      EOS
+
+      file.append_lines("CONTENTS")
+      expect(File.read(file)).to eq <<-EOS.undent
+        CONTENT
+        CONTENTS
+      EOS
+    end
+
+    it "raises an error if the file does not exist" do
+      expect(file).not_to exist
+      expect { file.append_lines("CONTENT") }.to raise_error(RuntimeError)
+    end
+  end
+
+  describe "#atomic_write" do
+    it "atomically replaces a file" do
+      touch file
+      file.atomic_write("CONTENT")
+      expect(File.read(file)).to eq("CONTENT")
+    end
+
+    it "preserves permissions" do
+      File.open(file, "w", 0100777).close
+      file.atomic_write("CONTENT")
+      expect(file.stat.mode).to eq(0100777 & ~File.umask)
+    end
+
+    it "preserves default permissions" do
+      file.atomic_write("CONTENT")
+      sentinel = file.parent.join("sentinel")
+      touch sentinel
+      expect(file.stat.mode).to eq(sentinel.stat.mode)
+    end
+  end
+
+  describe "#ensure_writable" do
+    it "makes a file writable and restores permissions afterwards" do
+      touch file
+      chmod 0555, file
+      expect(file).not_to be_writable
+      file.ensure_writable do
+        expect(file).to be_writable
+      end
+      expect(file).not_to be_writable
+    end
+  end
+
+  describe "#extname" do
+    it "supports common multi-level archives" do
+      expect(Pathname.new("foo-0.1.tar.gz").extname).to eq(".tar.gz")
+      expect(Pathname.new("foo-0.1.cpio.gz").extname).to eq(".cpio.gz")
+    end
+  end
+
+  describe "#stem" do
+    it "returns the basename without double extensions" do
+      expect(Pathname("foo-0.1.tar.gz").stem).to eq("foo-0.1")
+      expect(Pathname("foo-0.1.cpio.gz").stem).to eq("foo-0.1")
+    end
+  end
+
+  describe "#install" do
+    before(:each) do
+      (src/"a.txt").write "This is sample file a."
+      (src/"b.txt").write "This is sample file b."
+    end
+
+    it "raises an error if the file doesn't exist" do
+      expect { dst.install "non_existent_file" }.to raise_error(Errno::ENOENT)
+    end
+
+    it "installs a file to a directory with its basename" do
+      touch file
+      dst.install(file)
+      expect(dst/file.basename).to exist
+      expect(file).not_to exist
+    end
+
+    it "creates intermediate directories" do
+      touch file
+      expect(dir).not_to be_a_directory
+      dir.install(file)
+      expect(dir).to be_a_directory
+    end
+
+    it "can install a file" do
+      dst.install src/"a.txt"
+      expect(dst/"a.txt").to exist, "a.txt was not installed"
+      expect(dst/"b.txt").not_to exist, "b.txt was installed."
+    end
+
+    it "can install an array of files" do
+      dst.install [src/"a.txt", src/"b.txt"]
+
+      expect(dst/"a.txt").to exist, "a.txt was not installed"
+      expect(dst/"b.txt").to exist, "b.txt was not installed"
+    end
+
+    it "can install a directory" do
+      bin = src/"bin"
+      bin.mkpath
+      mv Dir[src/"*.txt"], bin
+      dst.install bin
+
+      expect(dst/"bin/a.txt").to exist, "a.txt was not installed"
+      expect(dst/"bin/b.txt").to exist, "b.txt was not installed"
+    end
+
+    it "supports renaming files" do
+      dst.install src/"a.txt" => "c.txt"
+
+      expect(dst/"c.txt").to exist, "c.txt was not installed"
+      expect(dst/"a.txt").not_to exist, "a.txt was installed but not renamed"
+      expect(dst/"b.txt").not_to exist, "b.txt was installed"
+    end
+
+    it "supports renaming multiple files" do
+      dst.install(src/"a.txt" => "c.txt", src/"b.txt" => "d.txt")
+
+      expect(dst/"c.txt").to exist, "c.txt was not installed"
+      expect(dst/"d.txt").to exist, "d.txt was not installed"
+      expect(dst/"a.txt").not_to exist, "a.txt was installed but not renamed"
+      expect(dst/"b.txt").not_to exist, "b.txt was installed but not renamed"
+    end
+
+    it "supports renaming directories" do
+      bin = src/"bin"
+      bin.mkpath
+      mv Dir[src/"*.txt"], bin
+      dst.install bin => "libexec"
+
+      expect(dst/"bin").not_to exist, "bin was installed but not renamed"
+      expect(dst/"libexec/a.txt").to exist, "a.txt was not installed"
+      expect(dst/"libexec/b.txt").to exist, "b.txt was not installed"
+    end
+
+    it "can install directories as relative symlinks" do
+      bin = src/"bin"
+      bin.mkpath
+      mv Dir[src/"*.txt"], bin
+      dst.install_symlink bin
+
+      expect(dst/"bin").to be_a_symlink
+      expect(dst/"bin").to be_a_directory
+      expect(dst/"bin/a.txt").to exist
+      expect(dst/"bin/b.txt").to exist
+      expect((dst/"bin").readlink).to be_relative
+    end
+
+    it "can install relative paths as symlinks" do
+      dst.install_symlink "foo" => "bar"
+      expect((dst/"bar").readlink).to eq(Pathname.new("foo"))
+    end
+  end
+
+  describe InstallRenamed do
+    before(:each) do
+      dst.extend(InstallRenamed)
+    end
+
+    it "renames the installed file if it already exists" do
+      file.write "a"
+      dst.install file
+
+      file.write "b"
+      dst.install file
+
+      expect(File.read(dst/file.basename)).to eq("a")
+      expect(File.read(dst/"#{file.basename}.default")).to eq("b")
+    end
+
+    it "renames the installed directory" do
+      file.write "a"
+      dst.install src
+      expect(File.read(dst/src.basename/file.basename)).to eq("a")
+    end
+
+    it "recursively renames directories" do
+      (dst/dir.basename).mkpath
+      (dst/dir.basename/"another_file").write "a"
+      dir.mkpath
+      (dir/"another_file").write "b"
+      dst.install dir
+      expect(File.read(dst/dir.basename/"another_file.default")).to eq("b")
+    end
+  end
+
+  describe "#cp_path_sub" do
+    it "copies a file and replaces the given pattern" do
+      file.write "a"
+      file.cp_path_sub src, dst
+      expect(File.read(dst/file.basename)).to eq("a")
+    end
+
+    it "copies a directory and replaces the given pattern" do
+      dir.mkpath
+      dir.cp_path_sub src, dst
+      expect(dst/dir.basename).to be_a_directory
+    end
+  end
+end
+
+describe FileUtils do
+  let(:dst) { Pathname.new(Dir.mktmpdir) }
+
+  describe "#mkdir" do
+    it "creates indermediate directories" do
+      described_class.mkdir dst/"foo/bar/baz" do
+        expect(dst/"foo/bar/baz").to exist, "foo/bar/baz was not created"
+        expect(dst/"foo/bar/baz").to be_a_directory, "foo/bar/baz was not a directory structure"
+      end
+    end
+  end
+end
diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb
deleted file mode 100644
index b48a26fbd..000000000
--- a/Library/Homebrew/test/pathname_test.rb
+++ /dev/null
@@ -1,263 +0,0 @@
-require "testing_env"
-require "tmpdir"
-require "extend/pathname"
-require "install_renamed"
-
-module PathnameTestExtension
-  include FileUtils
-
-  def setup
-    super
-    @src  = Pathname.new(mktmpdir)
-    @dst  = Pathname.new(mktmpdir)
-    @file = @src/"foo"
-    @dir  = @src/"bar"
-  end
-end
-
-class PathnameTests < Homebrew::TestCase
-  include PathnameTestExtension
-
-  def test_disk_usage_extension
-    mkdir_p @dir/"a-directory"
-    touch @dir/".DS_Store"
-    touch @dir/"a-file"
-    File.truncate(@dir/"a-file", 1_048_576)
-    ln_s @dir/"a-file", @dir/"a-symlink"
-    ln @dir/"a-file", @dir/"a-hardlink"
-    assert_equal 3, @dir.file_count
-    assert_equal "3 files, 1M", @dir.abv
-    assert_equal "1M", (@dir/"a-file").abv
-  end
-
-  def test_rmdir_if_possible
-    mkdir_p @dir
-    touch @dir/"foo"
-
-    assert !@dir.rmdir_if_possible
-    assert_predicate @dir, :directory?
-
-    rm_f @dir/"foo"
-    assert @dir.rmdir_if_possible
-    refute_predicate @dir, :exist?
-  end
-
-  def test_rmdir_if_possible_ignore_ds_store
-    mkdir_p @dir
-    touch @dir/".DS_Store"
-    assert @dir.rmdir_if_possible
-    refute_predicate @dir, :exist?
-  end
-
-  def test_write
-    @file.write("CONTENT")
-    assert_equal "CONTENT", File.read(@file)
-  end
-
-  def test_write_does_not_overwrite
-    touch @file
-    assert_raises(RuntimeError) { @file.write("CONTENT") }
-  end
-
-  def test_append_lines
-    touch @file
-    @file.append_lines("CONTENT")
-    assert_equal "CONTENT\n", File.read(@file)
-    @file.append_lines("CONTENTS")
-    assert_equal "CONTENT\nCONTENTS\n", File.read(@file)
-  end
-
-  def test_append_lines_does_not_create
-    assert_raises(RuntimeError) { @file.append_lines("CONTENT") }
-  end
-
-  def test_atomic_write
-    touch @file
-    @file.atomic_write("CONTENT")
-    assert_equal "CONTENT", File.read(@file)
-  end
-
-  def test_atomic_write_preserves_permissions
-    File.open(@file, "w", 0100777) {}
-    @file.atomic_write("CONTENT")
-    assert_equal 0100777 & ~File.umask, @file.stat.mode
-  end
-
-  def test_atomic_write_preserves_default_permissions
-    @file.atomic_write("CONTENT")
-    sentinel = @file.parent.join("sentinel")
-    touch sentinel
-    assert_equal sentinel.stat.mode, @file.stat.mode
-  end
-
-  def test_ensure_writable
-    touch @file
-    chmod 0555, @file
-    @file.ensure_writable { assert_predicate @file, :writable? }
-    refute_predicate @file, :writable?
-  end
-
-  def test_extname
-    assert_equal ".tar.gz", Pathname("foo-0.1.tar.gz").extname
-    assert_equal ".cpio.gz", Pathname("foo-0.1.cpio.gz").extname
-  end
-
-  def test_stem
-    assert_equal "foo-0.1", Pathname("foo-0.1.tar.gz").stem
-    assert_equal "foo-0.1", Pathname("foo-0.1.cpio.gz").stem
-  end
-
-  def test_install_missing_file
-    assert_raises(Errno::ENOENT) { @dst.install "non_existent_file" }
-  end
-
-  def test_install_removes_original
-    touch @file
-    @dst.install(@file)
-
-    assert_predicate @dst/@file.basename, :exist?
-    refute_predicate @file, :exist?
-  end
-
-  def test_install_creates_intermediate_directories
-    touch @file
-    refute_predicate @dir, :directory?
-    @dir.install(@file)
-    assert_predicate @dir, :directory?
-  end
-
-  def test_install_renamed
-    @dst.extend(InstallRenamed)
-
-    @file.write "a"
-    @dst.install @file
-    @file.write "b"
-    @dst.install @file
-
-    assert_equal "a", File.read(@dst/@file.basename)
-    assert_equal "b", File.read(@dst/"#{@file.basename}.default")
-  end
-
-  def test_install_renamed_directory
-    @dst.extend(InstallRenamed)
-    @file.write "a"
-    @dst.install @src
-    assert_equal "a", File.read(@dst/@src.basename/@file.basename)
-  end
-
-  def test_install_renamed_directory_recursive
-    @dst.extend(InstallRenamed)
-    (@dst/@dir.basename).mkpath
-    (@dst/@dir.basename/"another_file").write "a"
-    @dir.mkpath
-    (@dir/"another_file").write "b"
-    @dst.install @dir
-    assert_equal "b", File.read(@dst/@dir.basename/"another_file.default")
-  end
-
-  def test_cp_path_sub_file
-    @file.write "a"
-    @file.cp_path_sub @src, @dst
-    assert_equal "a", File.read(@dst/"foo")
-  end
-
-  def test_cp_path_sub_directory
-    @dir.mkpath
-    @dir.cp_path_sub @src, @dst
-    assert_predicate @dst/@dir.basename, :directory?
-  end
-end
-
-class PathnameInstallTests < Homebrew::TestCase
-  include PathnameTestExtension
-
-  def setup
-    super
-    (@src/"a.txt").write "This is sample file a."
-    (@src/"b.txt").write "This is sample file b."
-  end
-
-  def test_install
-    @dst.install @src/"a.txt"
-
-    assert_predicate @dst/"a.txt", :exist?, "a.txt was not installed"
-    refute_predicate @dst/"b.txt", :exist?, "b.txt was installed."
-  end
-
-  def test_install_list
-    @dst.install [@src/"a.txt", @src/"b.txt"]
-
-    assert_predicate @dst/"a.txt", :exist?, "a.txt was not installed"
-    assert_predicate @dst/"b.txt", :exist?, "b.txt was not installed"
-  end
-
-  def test_install_glob
-    @dst.install Dir[@src/"*.txt"]
-
-    assert_predicate @dst/"a.txt", :exist?, "a.txt was not installed"
-    assert_predicate @dst/"b.txt", :exist?, "b.txt was not installed"
-  end
-
-  def test_install_directory
-    bin = @src/"bin"
-    bin.mkpath
-    mv Dir[@src/"*.txt"], bin
-    @dst.install bin
-
-    assert_predicate @dst/"bin/a.txt", :exist?, "a.txt was not installed"
-    assert_predicate @dst/"bin/b.txt", :exist?, "b.txt was not installed"
-  end
-
-  def test_install_rename
-    @dst.install @src/"a.txt" => "c.txt"
-
-    assert_predicate @dst/"c.txt", :exist?, "c.txt was not installed"
-    refute_predicate @dst/"a.txt", :exist?, "a.txt was installed but not renamed"
-    refute_predicate @dst/"b.txt", :exist?, "b.txt was installed"
-  end
-
-  def test_install_rename_more
-    @dst.install(@src/"a.txt" => "c.txt", @src/"b.txt" => "d.txt")
-
-    assert_predicate @dst/"c.txt", :exist?, "c.txt was not installed"
-    assert_predicate @dst/"d.txt", :exist?, "d.txt was not installed"
-    refute_predicate @dst/"a.txt", :exist?, "a.txt was installed but not renamed"
-    refute_predicate @dst/"b.txt", :exist?, "b.txt was installed but not renamed"
-  end
-
-  def test_install_rename_directory
-    bin = @src/"bin"
-    bin.mkpath
-    mv Dir[@src/"*.txt"], bin
-    @dst.install bin => "libexec"
-
-    refute_predicate @dst/"bin", :exist?, "bin was installed but not renamed"
-    assert_predicate @dst/"libexec/a.txt", :exist?, "a.txt was not installed"
-    assert_predicate @dst/"libexec/b.txt", :exist?, "b.txt was not installed"
-  end
-
-  def test_install_symlink
-    bin = @src/"bin"
-    bin.mkpath
-    mv Dir[@src/"*.txt"], bin
-    @dst.install_symlink bin
-
-    assert_predicate @dst/"bin", :symlink?
-    assert_predicate @dst/"bin", :directory?
-    assert_predicate @dst/"bin/a.txt", :exist?
-    assert_predicate @dst/"bin/b.txt", :exist?
-    assert_predicate((@dst/"bin").readlink, :relative?)
-  end
-
-  def test_install_relative_symlink
-    @dst.install_symlink "foo" => "bar"
-    assert_equal Pathname.new("foo"), (@dst/"bar").readlink
-  end
-
-  def test_mkdir_creates_intermediate_directories
-    mkdir @dst/"foo/bar/baz" do
-      assert_predicate @dst/"foo/bar/baz", :exist?, "foo/bar/baz was not created"
-      assert_predicate @dst/"foo/bar/baz", :directory?, "foo/bar/baz was not a directory structure"
-    end
-  end
-end
-- 
cgit v1.2.3


From ca4fba99c417437aca2efb36cc3c89e871d5f5a0 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Tue, 21 Feb 2017 05:37:08 +0100
Subject: Convert CompilerSelector test to spec.

---
 Library/Homebrew/test/compiler_selector_spec.rb | 122 ++++++++++++++++++++++++
 Library/Homebrew/test/compiler_selector_test.rb | 117 -----------------------
 2 files changed, 122 insertions(+), 117 deletions(-)
 create mode 100644 Library/Homebrew/test/compiler_selector_spec.rb
 delete mode 100644 Library/Homebrew/test/compiler_selector_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/compiler_selector_spec.rb b/Library/Homebrew/test/compiler_selector_spec.rb
new file mode 100644
index 000000000..0f6f6b5f2
--- /dev/null
+++ b/Library/Homebrew/test/compiler_selector_spec.rb
@@ -0,0 +1,122 @@
+require "compilers"
+require "software_spec"
+
+describe CompilerSelector do
+  subject { described_class.new(software_spec, versions, compilers) }
+  let(:compilers) { [:clang, :gcc, :llvm, :gnu] }
+  let(:software_spec) { SoftwareSpec.new }
+  let(:cc) { :clang }
+  let(:versions) do
+    double(
+      gcc_4_0_build_version: Version::NULL,
+      gcc_build_version: Version.create("5666"),
+      llvm_build_version: Version::NULL,
+      clang_build_version: Version.create("425"),
+    )
+  end
+
+  before(:each) do
+    allow(versions).to receive(:non_apple_gcc_version) do |name|
+      case name
+      when "gcc-4.8" then Version.create("4.8.1")
+      when "gcc-4.7" then Version.create("4.7.1")
+      else Version::NULL
+      end
+    end
+  end
+
+  describe "#compiler" do
+    it "raises an error if no matching compiler can be found" do
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(:llvm)
+      software_spec.fails_with(:gcc)
+      software_spec.fails_with(gcc: "4.8")
+      software_spec.fails_with(gcc: "4.7")
+
+      expect { subject.compiler }.to raise_error(CompilerSelectionError)
+    end
+
+    it "defaults to cc" do
+      expect(subject.compiler).to eq(cc)
+    end
+
+    it "returns gcc if it fails with clang" do
+      software_spec.fails_with(:clang)
+      expect(subject.compiler).to eq(:gcc)
+    end
+
+    it "returns clang if it fails with llvm" do
+      software_spec.fails_with(:llvm)
+      expect(subject.compiler).to eq(:clang)
+    end
+
+    it "returns clang if it fails with gcc" do
+      software_spec.fails_with(:gcc)
+      expect(subject.compiler).to eq(:clang)
+    end
+
+    it "returns clang if it fails with non-Apple gcc" do
+      software_spec.fails_with(gcc: "4.8")
+      expect(subject.compiler).to eq(:clang)
+    end
+
+    it "still returns gcc-4.8 if it fails with gcc without a specific version" do
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(:gcc)
+      expect(subject.compiler).to eq("gcc-4.8")
+    end
+
+    it "returns gcc if it fails with clang and llvm" do
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(:llvm)
+      expect(subject.compiler).to eq(:gcc)
+    end
+
+    it "returns clang if it fails with gcc and llvm" do
+      software_spec.fails_with(:gcc)
+      software_spec.fails_with(:llvm)
+      expect(subject.compiler).to eq(:clang)
+    end
+
+    example "returns gcc if it fails with a specific gcc version" do
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(gcc: "4.8")
+      expect(subject.compiler).to eq(:gcc)
+    end
+
+    example "returns a lower version of gcc if it fails with the highest version" do
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(:gcc)
+      software_spec.fails_with(:llvm)
+      software_spec.fails_with(gcc: "4.8")
+      expect(subject.compiler).to eq("gcc-4.7")
+    end
+
+    it "prefers gcc" do
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(:gcc)
+      expect(subject.compiler).to eq("gcc-4.8")
+    end
+
+    it "raises an error when gcc is missing" do
+      allow(versions).to receive(:gcc_build_version).and_return(Version::NULL)
+
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(:llvm)
+      software_spec.fails_with(gcc: "4.8")
+      software_spec.fails_with(gcc: "4.7")
+
+      expect { subject.compiler }.to raise_error(CompilerSelectionError)
+    end
+
+    it "raises an error when llvm and gcc are missing" do
+      allow(versions).to receive(:gcc_build_version).and_return(Version::NULL)
+
+      software_spec.fails_with(:clang)
+      software_spec.fails_with(gcc: "4.8")
+      software_spec.fails_with(gcc: "4.7")
+
+      expect { subject.compiler }.to raise_error(CompilerSelectionError)
+    end
+  end
+end
diff --git a/Library/Homebrew/test/compiler_selector_test.rb b/Library/Homebrew/test/compiler_selector_test.rb
deleted file mode 100644
index aa1a6f97e..000000000
--- a/Library/Homebrew/test/compiler_selector_test.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-require "testing_env"
-require "compilers"
-require "software_spec"
-
-class CompilerSelectorTests < Homebrew::TestCase
-  class Double < SoftwareSpec
-    def <<(cc)
-      fails_with(cc)
-      self
-    end
-  end
-
-  class CompilerVersions
-    attr_accessor :gcc_4_0_build_version, :gcc_build_version,
-      :clang_build_version
-
-    def initialize
-      @gcc_4_0_build_version = Version::NULL
-      @gcc_build_version = Version.create("5666")
-      @llvm_build_version = Version::NULL
-      @clang_build_version = Version.create("425")
-    end
-
-    def non_apple_gcc_version(name)
-      case name
-      when "gcc-4.8" then Version.create("4.8.1")
-      when "gcc-4.7" then Version.create("4.7.1")
-      else Version::NULL
-      end
-    end
-  end
-
-  def setup
-    super
-    @f  = Double.new
-    @cc = :clang
-    @versions = CompilerVersions.new
-    @selector = CompilerSelector.new(
-      @f, @versions, [:clang, :gcc, :llvm, :gnu]
-    )
-  end
-
-  def actual_cc
-    @selector.compiler
-  end
-
-  def test_all_compiler_failures
-    @f << :clang << :llvm << :gcc << { gcc: "4.8" } << { gcc: "4.7" }
-    assert_raises(CompilerSelectionError) { actual_cc }
-  end
-
-  def test_no_compiler_failures
-    assert_equal @cc, actual_cc
-  end
-
-  def test_fails_with_clang
-    @f << :clang
-    assert_equal :gcc, actual_cc
-  end
-
-  def test_fails_with_llvm
-    @f << :llvm
-    assert_equal :clang, actual_cc
-  end
-
-  def test_fails_with_gcc
-    @f << :gcc
-    assert_equal :clang, actual_cc
-  end
-
-  def test_fails_with_non_apple_gcc
-    @f << { gcc: "4.8" }
-    assert_equal :clang, actual_cc
-  end
-
-  def test_mixed_failures_1
-    @f << :clang << :gcc
-    assert_equal "gcc-4.8", actual_cc
-  end
-
-  def test_mixed_failures_2
-    @f << :clang << :llvm
-    assert_equal :gcc, actual_cc
-  end
-
-  def test_mixed_failures_3
-    @f << :gcc << :llvm
-    assert_equal :clang, actual_cc
-  end
-
-  def test_mixed_failures_4
-    @f << :clang << { gcc: "4.8" }
-    assert_equal :gcc, actual_cc
-  end
-
-  def test_mixed_failures_5
-    @f << :clang << :gcc << :llvm << { gcc: "4.8" }
-    assert_equal "gcc-4.7", actual_cc
-  end
-
-  def test_gcc_precedence
-    @f << :clang << :gcc
-    assert_equal "gcc-4.8", actual_cc
-  end
-
-  def test_missing_gcc
-    @versions.gcc_build_version = Version::NULL
-    @f << :clang << :llvm << { gcc: "4.8" } << { gcc: "4.7" }
-    assert_raises(CompilerSelectionError) { actual_cc }
-  end
-
-  def test_missing_llvm_and_gcc
-    @versions.gcc_build_version = Version::NULL
-    @f << :clang << { gcc: "4.8" } << { gcc: "4.7" }
-    assert_raises(CompilerSelectionError) { actual_cc }
-  end
-end
-- 
cgit v1.2.3


From 4063f4159dfa36132db4045e8ec4f7f722cdf9bb Mon Sep 17 00:00:00 2001
From: Joshua Liu
Date: Thu, 23 Feb 2017 01:54:44 -0500
Subject: Updated deps_spec to match style

---
 Library/Homebrew/test/deps_spec.rb | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/deps_spec.rb b/Library/Homebrew/test/deps_spec.rb
index 7d7fe13c3..61a0d1174 100644
--- a/Library/Homebrew/test/deps_spec.rb
+++ b/Library/Homebrew/test/deps_spec.rb
@@ -1,14 +1,28 @@
-describe Homebrew do
-  describe "#deps" do
+describe "brew deps", :integration_test do
+  before(:each) do
     setup_test_formula "foo"
     setup_test_formula "bar"
     setup_test_formula "baz", <<-EOS.undent
       url "https://example.com/baz-1.0"
       depends_on "bar"
     EOS
+  end
+
+  it "outputs nothing for formula foo" do
+    expect { brew "deps", "foo" }.to output("").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "outputs foo for formula bar" do
+    expect { brew "deps", "bar" }.to output("foo\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
 
-    expect(cmd("deps", "foo")).to eq("")
-    expect(cmd("deps", "bar")).to eq("foo")
-    expect(cmd("deps", "baz")).to eq("bar\nfoo")
+  it "outputs formulae bar and foo for formula baz" do
+    expect { brew "deps", "baz" }.to output("bar\nfoo\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
   end
 end
-- 
cgit v1.2.3


From 9dda84ad6be7fbc48c10e54f9c1af0c3a6b4afa6 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Wed, 22 Feb 2017 07:19:16 +0100
Subject: Add integration test helper methods.

---
 Library/Homebrew/extend/pathname.rb                |  2 +-
 Library/Homebrew/test/spec_helper.rb               |  4 ++
 .../helper/spec/shared_context/integration_test.rb | 74 ++++++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index cfb028704..9f6861a9a 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -335,7 +335,7 @@ class Pathname
   alias to_str to_s unless method_defined?(:to_str)
 
   def cd
-    Dir.chdir(self) { yield }
+    Dir.chdir(self) { yield self }
   end
 
   def subdirs
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 547ec3f7b..48ddc975c 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -37,6 +37,10 @@ RSpec.configure do |config|
       skip "not on macOS" unless OS.mac?
     end
 
+    if example.metadata[:needs_official_cmd_taps]
+      skip "Needs official command Taps." unless ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
+    end
+
     if example.metadata[:needs_python]
       skip "Python not installed." unless which("python")
     end
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
index dd2271a3a..fc7b49fa4 100644
--- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -87,6 +87,80 @@ RSpec.shared_context "integration test" do
       status
     end
   end
+
+  def setup_test_formula(name, content = nil)
+    case name
+    when /^testball/
+      content = <<-EOS.undent
+        desc "Some test"
+        homepage "https://example.com/#{name}"
+        url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
+        sha256 "#{TESTBALL_SHA256}"
+
+        option "with-foo", "Build with foo"
+
+        def install
+          (prefix/"foo"/"test").write("test") if build.with? "foo"
+          prefix.install Dir["*"]
+          (buildpath/"test.c").write \
+            "#include \\nint main(){return printf(\\"test\\");}"
+          bin.mkpath
+          system ENV.cc, "test.c", "-o", bin/"test"
+        end
+
+        #{content}
+
+        # something here
+      EOS
+    when "foo"
+      content = <<-EOS.undent
+        url "https://example.com/#{name}-1.0"
+      EOS
+    when "bar"
+      content = <<-EOS.undent
+        url "https://example.com/#{name}-1.0"
+        depends_on "foo"
+      EOS
+    end
+
+    Formulary.core_path(name).tap do |formula_path|
+      formula_path.write <<-EOS.undent
+        class #{Formulary.class_s(name)} < Formula
+          #{content}
+        end
+      EOS
+    end
+  end
+
+  def setup_remote_tap(name)
+    Tap.fetch(name).tap do |tap|
+      tap.install(full_clone: false, quiet: true) unless tap.installed?
+    end
+  end
+
+  def install_and_rename_coretap_formula(old_name, new_name)
+    shutup do
+      CoreTap.instance.path.cd do |tap_path|
+        system "git", "init"
+        system "git", "add", "--all"
+        system "git", "commit", "-m",
+          "#{old_name.capitalize} has not yet been renamed"
+
+        brew "install", old_name
+
+        (tap_path/"Formula/#{old_name}.rb").unlink
+        (tap_path/"formula_renames.json").write JSON.generate(old_name => new_name)
+
+        system "git", "add", "--all"
+        system "git", "commit", "-m",
+          "#{old_name.capitalize} has been renamed to #{new_name.capitalize}"
+      end
+    end
+  end
+
+  def testball
+    "#{TEST_FIXTURE_DIR}/testball.rb"
+  end
 end
 
 RSpec.configure do |config|
-- 
cgit v1.2.3


From b8d50beba209ed1b4b1436576b71bea4aab82251 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:02:59 +0100
Subject: Convert `brew desc` test to spec.

---
 Library/Homebrew/test/cmd/desc_spec.rb | 40 ++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/desc_test.rb     | 17 ---------------
 2 files changed, 40 insertions(+), 17 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/desc_spec.rb
 delete mode 100644 Library/Homebrew/test/desc_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/desc_spec.rb b/Library/Homebrew/test/cmd/desc_spec.rb
new file mode 100644
index 000000000..b09819d81
--- /dev/null
+++ b/Library/Homebrew/test/cmd/desc_spec.rb
@@ -0,0 +1,40 @@
+describe "brew desc", :integration_test do
+  let(:desc_cache) { HOMEBREW_CACHE/"desc_cache.json" }
+
+  it "shows a given Formula's description" do
+    setup_test_formula "testball"
+
+    expect { brew "desc", "testball" }
+      .to output("testball: Some test\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "fails when both --search and --name are specified" do
+    expect { brew "desc", "--search", "--name" }
+      .to output(/Pick one, and only one/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  describe "--search" do
+    it "fails when no search term is given" do
+      expect { brew "desc", "--search" }
+        .to output(/You must provide a search term/).to_stderr
+        .and not_to_output.to_stdout
+        .and be_a_failure
+    end
+  end
+
+  describe "--description" do
+    it "creates a description cache" do
+      expect(desc_cache).not_to exist
+
+      shutup do
+        expect { brew "desc", "--description", "testball" }.to be_a_success
+      end
+
+      expect(desc_cache).to exist
+    end
+  end
+end
diff --git a/Library/Homebrew/test/desc_test.rb b/Library/Homebrew/test/desc_test.rb
deleted file mode 100644
index 2ba498135..000000000
--- a/Library/Homebrew/test/desc_test.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestDesc < IntegrationCommandTestCase
-  def test_desc
-    setup_test_formula "testball"
-
-    assert_equal "testball: Some test", cmd("desc", "testball")
-    assert_match "Pick one, and only one", cmd_fail("desc", "--search", "--name")
-    assert_match "You must provide a search term", cmd_fail("desc", "--search")
-
-    desc_cache = HOMEBREW_CACHE/"desc_cache.json"
-    refute_predicate desc_cache, :exist?, "Cached file should not exist"
-
-    cmd("desc", "--description", "testball")
-    assert_predicate desc_cache, :exist?, "Cached file should not exist"
-  end
-end
-- 
cgit v1.2.3


From 5390897883f11fe2257e57bd5547cb1bbb144fb0 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Thu, 23 Feb 2017 09:09:33 +0000
Subject: audit: refactor http content checks.

---
 Library/Homebrew/dev-cmd/audit.rb | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index b63d39905..aa9dd775a 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1492,7 +1492,7 @@ class ResourceAuditor
     urls.each do |url|
       strategy = DownloadStrategyDetector.detect(url)
       if strategy <= CurlDownloadStrategy && !url.start_with?("file")
-        check_http_mirror url
+        check_http_content url
       elsif strategy <= GitDownloadStrategy
         unless Utils.git_remote_exists url
           problem "The URL #{url} is not a valid git URL"
@@ -1505,7 +1505,7 @@ class ResourceAuditor
     end
   end
 
-  def check_http_mirror(url)
+  def check_http_content(url)
     details = get_content_details(url)
 
     if details[:status].nil?
@@ -1519,10 +1519,16 @@ class ResourceAuditor
     secure_url = url.sub "http", "https"
     secure_details = get_content_details(secure_url)
 
-    return if !details[:status].start_with?("2") || !secure_details[:status].start_with?("2")
+    if !details[:status].to_s.start_with?("2") ||
+       !secure_details[:status].to_s.start_with?("2")
+      return
+    end
 
-    etag_match = details[:etag] && details[:etag] == secure_details[:etag]
-    content_length_match = details[:content_length] && details[:content_length] == secure_details[:content_length]
+    etag_match = details[:etag] &&
+                 details[:etag] == secure_details[:etag]
+    content_length_match =
+      details[:content_length] &&
+      details[:content_length] == secure_details[:content_length]
     file_match = details[:file_hash] == secure_details[:file_hash]
 
     return if !etag_match && !content_length_match && !file_match
-- 
cgit v1.2.3


From 5e9057500419d1a2b41efe784e9f12ae232e7f6e Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Thu, 23 Feb 2017 09:09:58 +0000
Subject: audit: handle redirects in get_content_details.

---
 Library/Homebrew/dev-cmd/audit.rb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index aa9dd775a..493f1eb09 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1542,12 +1542,16 @@ class ResourceAuditor
   def get_content_details(url)
     out = {}
     output, = curl_output "--connect-timeout", "15", "--include", url
-    split = output.partition("\r\n\r\n")
-    headers = split.first
-    out[:status] = headers[%r{HTTP\/.* (\d+)}, 1]
+    status_code = :unknown
+    while status_code == :unknown || status_code.to_s.start_with?("3")
+      headers, _, output = output.partition("\r\n\r\n")
+      status_code = headers[%r{HTTP\/.* (\d+)}, 1]
+    end
+
+    out[:status] = status_code
     out[:etag] = headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2]
     out[:content_length] = headers[/Content-Length: (\d+)/, 1]
-    out[:file_hash] = Digest::SHA256.digest split.last
+    out[:file_hash] = Digest::SHA256.digest output
     out
   end
 end
-- 
cgit v1.2.3


From 96a8f8f1727e3d6445d42570d287f4f7013d5ea1 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Thu, 23 Feb 2017 09:14:54 +0000
Subject: audit: check for version aliases.

Current version aliases should be provided for versioned formulae so
people can `brew install foo@1.2` to provide pin-like behaviour.
---
 Library/Homebrew/dev-cmd/audit.rb | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 9ffef0f99..9da5d28b4 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -295,6 +295,27 @@ class FormulaAuditor
 
     problem "File should end with a newline" unless text.trailing_newline?
 
+    versioned_formulae = Dir[formula.path.to_s.gsub(/\.rb$/, "@*.rb")]
+    needs_versioned_alias = !versioned_formulae.empty? &&
+                            formula.tap &&
+                            formula.aliases.grep(/.@\d/).empty?
+    if needs_versioned_alias
+      _, last_alias_version = File.basename(versioned_formulae.sort.reverse.first)
+                                  .gsub(/\.rb$/, "")
+                                  .split("@")
+      major, minor, = formula.version.to_s.split(".")
+      alias_name = if last_alias_version.split(".").length == 1
+        "#{formula.name}@#{major}"
+      else
+        "#{formula.name}@#{major}.#{minor}"
+      end
+      problem <<-EOS.undent
+        Formula has other versions so create an alias:
+          cd #{formula.tap.alias_dir}
+          ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name}
+      EOS
+    end
+
     return unless @strict
 
     present = audit_components
@@ -410,7 +431,8 @@ class FormulaAuditor
           problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'."
         end
 
-        if @@aliases.include?(dep.name)
+        if @@aliases.include?(dep.name) &&
+           (core_formula? || !dep_f.versioned_formula?)
           problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
         end
 
-- 
cgit v1.2.3


From 1d7fde515b9cce2e3fc4dddce1c34f5e410bca87 Mon Sep 17 00:00:00 2001
From: Joshua Liu
Date: Thu, 23 Feb 2017 05:02:41 -0500
Subject: Update deps_spec descriptions

---
 Library/Homebrew/test/deps_spec.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/deps_spec.rb b/Library/Homebrew/test/deps_spec.rb
index 61a0d1174..ec7964b76 100644
--- a/Library/Homebrew/test/deps_spec.rb
+++ b/Library/Homebrew/test/deps_spec.rb
@@ -8,19 +8,19 @@ describe "brew deps", :integration_test do
     EOS
   end
 
-  it "outputs nothing for formula foo" do
+  it "outputs no dependencies for a Formula that has no dependencies" do
     expect { brew "deps", "foo" }.to output("").to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
   end
 
-  it "outputs foo for formula bar" do
+  it "outputs a dependency for a Formula that has one dependency" do
     expect { brew "deps", "bar" }.to output("foo\n").to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
   end
 
-  it "outputs formulae bar and foo for formula baz" do
+  it "outputs dependencies on separate lines for a Formula that has multiple dependencies" do
     expect { brew "deps", "baz" }.to output("bar\nfoo\n").to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
-- 
cgit v1.2.3


From 9fa014710d22e30c0be05bddc78e073373def5bd Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Thu, 23 Feb 2017 10:15:06 +0000
Subject: audit: further refactor http content checks.

Check homepages and don’t check mirrors unless `—strict`.
---
 Library/Homebrew/dev-cmd/audit.rb | 144 ++++++++++++++++++--------------------
 1 file changed, 69 insertions(+), 75 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 493f1eb09..65b109f3b 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -174,30 +174,62 @@ class FormulaAuditor
     @specs = %w[stable devel head].map { |s| formula.send(s) }.compact
   end
 
-  def url_status_code(url, range: false)
-    # The system Curl is too old and unreliable with HTTPS homepages on
-    # Yosemite and below.
-    return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
+  def self.check_http_content(url, user_agents: [:default])
+    details = nil
+    user_agent = nil
+    user_agents.each do |ua|
+      details = http_content_headers_and_checksum(url, user_agent: ua)
+      user_agent = ua
+      break if details[:status].to_s.start_with?("2")
+    end
 
-    extra_args = [
-      "--connect-timeout", "15",
-      "--output", "/dev/null",
-      "--write-out", "%{http_code}"
-    ]
-    extra_args << "--range" << "0-0" if range
-    extra_args << url
-
-    status_code = nil
-    [:browser, :default].each do |user_agent|
-      args = curl_args(
-        extra_args: extra_args,
-        show_output: true,
-        user_agent: user_agent,
-      )
-      status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
-      break if status_code.start_with? "2"
-    end
-    status_code
+    return "The URL #{url} is not reachable" unless details[:status]
+    unless details[:status].start_with? "2"
+      return "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
+    end
+
+    return unless url.start_with? "http:"
+
+    secure_url = url.sub "http", "https"
+    secure_details =
+      http_content_headers_and_checksum(secure_url, user_agent: user_agent)
+
+    if !details[:status].to_s.start_with?("2") ||
+       !secure_details[:status].to_s.start_with?("2")
+      return
+    end
+
+    etag_match = details[:etag] &&
+                 details[:etag] == secure_details[:etag]
+    content_length_match =
+      details[:content_length] &&
+      details[:content_length] == secure_details[:content_length]
+    file_match = details[:file_hash] == secure_details[:file_hash]
+
+    return if !etag_match && !content_length_match && !file_match
+    "The URL #{url} could use HTTPS rather than HTTP"
+  end
+
+  def self.http_content_headers_and_checksum(url, user_agent: :default)
+    args = curl_args(
+      extra_args: ["--connect-timeout", "15", "--include", url],
+      show_output: true,
+      user_agent: user_agent,
+    )
+    output = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
+
+    status_code = :unknown
+    while status_code == :unknown || status_code.to_s.start_with?("3")
+      headers, _, output = output.partition("\r\n\r\n")
+      status_code = headers[%r{HTTP\/.* (\d+)}, 1]
+    end
+
+    {
+      status: status_code,
+      etag: headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2],
+      content_length: headers[/Content-Length: (\d+)/, 1],
+      file_hash: Digest::SHA256.digest(output),
+    }
   end
 
   def audit_style
@@ -619,9 +651,13 @@ class FormulaAuditor
 
     return unless @online
 
-    status_code = url_status_code(homepage)
-    return if status_code.start_with? "2"
-    problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
+    # The system Curl is too old and unreliable with HTTPS homepages on
+    # Yosemite and below.
+    return unless DevelopmentTools.curl_handles_most_https_homepages?
+    if http_content_problem = FormulaAuditor.check_http_content(homepage,
+                                             user_agents: [:browser, :default])
+      problem http_content_problem
+    end
   end
 
   def audit_bottle_spec
@@ -671,11 +707,11 @@ class FormulaAuditor
     %w[Stable Devel HEAD].each do |name|
       next unless spec = formula.send(name.downcase)
 
-      ra = ResourceAuditor.new(spec, online: @online).audit
+      ra = ResourceAuditor.new(spec, online: @online, strict: @strict).audit
       problems.concat ra.problems.map { |problem| "#{name}: #{problem}" }
 
       spec.resources.each_value do |resource|
-        ra = ResourceAuditor.new(resource, online: @online).audit
+        ra = ResourceAuditor.new(resource, online: @online, strict: @strict).audit
         problems.concat ra.problems.map { |problem|
           "#{name} resource #{resource.name.inspect}: #{problem}"
         }
@@ -1231,6 +1267,7 @@ class ResourceAuditor
     @using    = resource.using
     @specs    = resource.specs
     @online   = options[:online]
+    @strict   = options[:strict]
     @problems = []
   end
 
@@ -1492,7 +1529,10 @@ class ResourceAuditor
     urls.each do |url|
       strategy = DownloadStrategyDetector.detect(url)
       if strategy <= CurlDownloadStrategy && !url.start_with?("file")
-        check_http_content url
+        next if !@strict && mirrors.include?(url)
+        if http_content_problem = FormulaAuditor.check_http_content(url)
+          problem http_content_problem
+        end
       elsif strategy <= GitDownloadStrategy
         unless Utils.git_remote_exists url
           problem "The URL #{url} is not a valid git URL"
@@ -1505,53 +1545,7 @@ class ResourceAuditor
     end
   end
 
-  def check_http_content(url)
-    details = get_content_details(url)
-
-    if details[:status].nil?
-      problem "The URL #{url} is not reachable"
-    elsif !details[:status].start_with? "2"
-      problem "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
-    end
-
-    return unless url.start_with? "http:"
-
-    secure_url = url.sub "http", "https"
-    secure_details = get_content_details(secure_url)
-
-    if !details[:status].to_s.start_with?("2") ||
-       !secure_details[:status].to_s.start_with?("2")
-      return
-    end
-
-    etag_match = details[:etag] &&
-                 details[:etag] == secure_details[:etag]
-    content_length_match =
-      details[:content_length] &&
-      details[:content_length] == secure_details[:content_length]
-    file_match = details[:file_hash] == secure_details[:file_hash]
-
-    return if !etag_match && !content_length_match && !file_match
-    problem "The URL #{url} could use HTTPS rather than HTTP"
-  end
-
   def problem(text)
     @problems << text
   end
-
-  def get_content_details(url)
-    out = {}
-    output, = curl_output "--connect-timeout", "15", "--include", url
-    status_code = :unknown
-    while status_code == :unknown || status_code.to_s.start_with?("3")
-      headers, _, output = output.partition("\r\n\r\n")
-      status_code = headers[%r{HTTP\/.* (\d+)}, 1]
-    end
-
-    out[:status] = status_code
-    out[:etag] = headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2]
-    out[:content_length] = headers[/Content-Length: (\d+)/, 1]
-    out[:file_hash] = Digest::SHA256.digest output
-    out
-  end
 end
-- 
cgit v1.2.3


From b2795bc90239fc94dffdc0d1995bf0e8c844f28d Mon Sep 17 00:00:00 2001
From: Joshua Liu
Date: Thu, 23 Feb 2017 05:25:24 -0500
Subject: Corrected deps_spec descriptions and small formatting changes

---
 Library/Homebrew/test/deps_spec.rb | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/deps_spec.rb b/Library/Homebrew/test/deps_spec.rb
index ec7964b76..c83577716 100644
--- a/Library/Homebrew/test/deps_spec.rb
+++ b/Library/Homebrew/test/deps_spec.rb
@@ -9,19 +9,22 @@ describe "brew deps", :integration_test do
   end
 
   it "outputs no dependencies for a Formula that has no dependencies" do
-    expect { brew "deps", "foo" }.to output("").to_stdout
+    expect { brew "deps", "foo" }
+      .to output("").to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
   end
 
   it "outputs a dependency for a Formula that has one dependency" do
-    expect { brew "deps", "bar" }.to output("foo\n").to_stdout
+    expect { brew "deps", "bar" }
+      .to output("foo\n").to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
   end
 
-  it "outputs dependencies on separate lines for a Formula that has multiple dependencies" do
-    expect { brew "deps", "baz" }.to output("bar\nfoo\n").to_stdout
+  it "outputs all of a Formula's dependencies and their dependencies on separate lines" do
+    expect { brew "deps", "baz" }
+      .to output("bar\nfoo\n").to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
   end
-- 
cgit v1.2.3


From 7e642117652df082a4af2b460f69a8e5aad61130 Mon Sep 17 00:00:00 2001
From: Shaun Jackman
Date: Thu, 23 Feb 2017 09:40:57 -0800
Subject: Add needs :cxx14

---
 Library/Homebrew/compilers.rb | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb
index 628e71e9b..36e50a177 100644
--- a/Library/Homebrew/compilers.rb
+++ b/Library/Homebrew/compilers.rb
@@ -75,6 +75,17 @@ class CompilerFailure
       create(gcc: "4.5"),
       create(gcc: "4.6"),
     ],
+    cxx14: [
+      create(:clang) { build 600 },
+      create(:gcc_4_0),
+      create(:gcc_4_2),
+      create(gcc: "4.3"),
+      create(gcc: "4.4"),
+      create(gcc: "4.5"),
+      create(gcc: "4.6"),
+      create(gcc: "4.7"),
+      create(gcc: "4.8"),
+    ],
     openmp: [
       create(:clang),
     ],
-- 
cgit v1.2.3


From 73be5ed950f13715f5a2168875f9cc63ea051627 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:07:53 +0100
Subject: Convert `brew pin` and `brew unpin` test to spec.

---
 Library/Homebrew/test/cmd/pin_spec.rb   | 13 +++++++++++++
 Library/Homebrew/test/cmd/unpin_spec.rb | 14 ++++++++++++++
 Library/Homebrew/test/pin_unpin_test.rb | 18 ------------------
 3 files changed, 27 insertions(+), 18 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/pin_spec.rb
 create mode 100644 Library/Homebrew/test/cmd/unpin_spec.rb
 delete mode 100644 Library/Homebrew/test/pin_unpin_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/pin_spec.rb b/Library/Homebrew/test/cmd/pin_spec.rb
new file mode 100644
index 000000000..9ffc052c3
--- /dev/null
+++ b/Library/Homebrew/test/cmd/pin_spec.rb
@@ -0,0 +1,13 @@
+describe "brew pin", :integration_test do
+  it "pins a Formula's version" do
+    setup_test_formula "testball"
+    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+    shutup do
+      expect { brew "pin", "testball" }.to be_a_success
+      expect { brew "upgrade" }.to be_a_success
+    end
+
+    expect(HOMEBREW_CELLAR/"testball/0.1").not_to be_a_directory
+  end
+end
diff --git a/Library/Homebrew/test/cmd/unpin_spec.rb b/Library/Homebrew/test/cmd/unpin_spec.rb
new file mode 100644
index 000000000..4f14626d8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/unpin_spec.rb
@@ -0,0 +1,14 @@
+describe "brew unpin", :integration_test do
+  it "unpins a Formula's version" do
+    setup_test_formula "testball"
+    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+    shutup do
+      expect { brew "pin", "testball" }.to be_a_success
+      expect { brew "unpin", "testball" }.to be_a_success
+      expect { brew "upgrade" }.to be_a_success
+    end
+
+    expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
+  end
+end
diff --git a/Library/Homebrew/test/pin_unpin_test.rb b/Library/Homebrew/test/pin_unpin_test.rb
deleted file mode 100644
index 65fb9e4da..000000000
--- a/Library/Homebrew/test/pin_unpin_test.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestPinUnpin < IntegrationCommandTestCase
-  def test_pin_unpin
-    setup_test_formula "testball"
-    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
-
-    cmd("pin", "testball")
-    cmd("upgrade")
-    refute((HOMEBREW_CELLAR/"testball/0.1").directory?,
-      "The latest version directory should NOT be created")
-
-    cmd("unpin", "testball")
-    cmd("upgrade")
-    assert((HOMEBREW_CELLAR/"testball/0.1").directory?,
-      "The latest version directory should be created")
-  end
-end
-- 
cgit v1.2.3


From 86529534cef24db7a5090e14c8e4b8594ec9a6fc Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:07:24 +0100
Subject: Convert `brew services` test to spec.

---
 Library/Homebrew/test/cmd/services_spec.rb | 10 ++++++++++
 Library/Homebrew/test/services_test.rb     | 11 -----------
 2 files changed, 10 insertions(+), 11 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/services_spec.rb
 delete mode 100644 Library/Homebrew/test/services_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/services_spec.rb b/Library/Homebrew/test/cmd/services_spec.rb
new file mode 100644
index 000000000..c456fea17
--- /dev/null
+++ b/Library/Homebrew/test/cmd/services_spec.rb
@@ -0,0 +1,10 @@
+describe "brew services", :integration_test, :needs_macos, :needs_official_cmd_taps do
+  it "allows controlling services" do
+    setup_remote_tap "homebrew/services"
+
+    expect { brew "services", "list" }
+      .to output("Warning: No services available to control with `brew services`\n").to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/services_test.rb b/Library/Homebrew/test/services_test.rb
deleted file mode 100644
index 280aeb9f4..000000000
--- a/Library/Homebrew/test/services_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestServices < IntegrationCommandTestCase
-  def test_services
-    needs_test_cmd_taps
-    needs_macos
-    setup_remote_tap("homebrew/services")
-    assert_equal "Warning: No services available to control with `brew services`",
-      cmd("services", "list")
-  end
-end
-- 
cgit v1.2.3


From 4b57017a9011e656f016f826a3a7d09b7cacf9ad Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:07:14 +0100
Subject: Convert `brew migrate` test to spec.

---
 Library/Homebrew/test/cmd/migrate_spec.rb | 46 +++++++++++++++++++++++++++++++
 Library/Homebrew/test/migrate_test.rb     | 18 ------------
 2 files changed, 46 insertions(+), 18 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/migrate_spec.rb
 delete mode 100644 Library/Homebrew/test/migrate_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/migrate_spec.rb b/Library/Homebrew/test/cmd/migrate_spec.rb
new file mode 100644
index 000000000..18c94fa01
--- /dev/null
+++ b/Library/Homebrew/test/cmd/migrate_spec.rb
@@ -0,0 +1,46 @@
+describe "brew migrate", :integration_test do
+  before(:each) do
+    setup_test_formula "testball1"
+    setup_test_formula "testball2"
+  end
+
+  it "fails when no argument is given" do
+    expect { brew "migrate" }
+      .to output(/Invalid usage/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "fails when a given Formula doesn't exist" do
+    expect { brew "migrate", "testball" }
+      .to output(/No available formula with the name "testball"/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "fails if a given Formula doesn't replace another one" do
+    expect { brew "migrate", "testball1" }
+      .to output(/testball1 doesn't replace any formula/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "migrates a renamed Formula" do
+    install_and_rename_coretap_formula "testball1", "testball2"
+
+    expect { brew "migrate", "testball1" }
+      .to output(/Migrating testball1 to testball2/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "fails if a given Formula is not installed" do
+    install_and_rename_coretap_formula "testball1", "testball2"
+    (HOMEBREW_CELLAR/"testball1").rmtree
+
+    expect { brew "migrate", "testball1" }
+      .to output(/Error: No such keg/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+end
diff --git a/Library/Homebrew/test/migrate_test.rb b/Library/Homebrew/test/migrate_test.rb
deleted file mode 100644
index 17929d038..000000000
--- a/Library/Homebrew/test/migrate_test.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestMigrate < IntegrationCommandTestCase
-  def test_migrate
-    setup_test_formula "testball1"
-    setup_test_formula "testball2"
-    assert_match "Invalid usage", cmd_fail("migrate")
-    assert_match "No available formula with the name \"testball\"",
-      cmd_fail("migrate", "testball")
-    assert_match "testball1 doesn't replace any formula",
-      cmd_fail("migrate", "testball1")
-
-    install_and_rename_coretap_formula "testball1", "testball2"
-    assert_match "Migrating testball1 to testball2", cmd("migrate", "testball1")
-    (HOMEBREW_CELLAR/"testball1").unlink
-    assert_match "Error: No such keg", cmd_fail("migrate", "testball1")
-  end
-end
-- 
cgit v1.2.3


From d85eb55f1cd36b9573f4a1a5a6e42233eb8c4751 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:07:07 +0100
Subject: Convert `brew list` test to spec.

---
 Library/Homebrew/test/cmd/list_spec.rb | 14 ++++++++++++++
 Library/Homebrew/test/list_test.rb     | 13 -------------
 2 files changed, 14 insertions(+), 13 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/list_spec.rb
 delete mode 100644 Library/Homebrew/test/list_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/list_spec.rb b/Library/Homebrew/test/cmd/list_spec.rb
new file mode 100644
index 000000000..df7394d7b
--- /dev/null
+++ b/Library/Homebrew/test/cmd/list_spec.rb
@@ -0,0 +1,14 @@
+describe "brew list", :integration_test do
+  let(:formulae) { %w[bar foo qux] }
+
+  it "prints all installed Formulae" do
+    formulae.each do |f|
+      (HOMEBREW_CELLAR/f/"1.0/somedir").mkpath
+    end
+
+    expect { brew "list" }
+      .to output("#{formulae.join("\n")}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/list_test.rb b/Library/Homebrew/test/list_test.rb
deleted file mode 100644
index 3c691e3ad..000000000
--- a/Library/Homebrew/test/list_test.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestList < IntegrationCommandTestCase
-  def test_list
-    formulae = %w[bar foo qux]
-    formulae.each do |f|
-      (HOMEBREW_CELLAR/"#{f}/1.0/somedir").mkpath
-    end
-
-    assert_equal formulae.join("\n"),
-                 cmd("list")
-  end
-end
-- 
cgit v1.2.3


From 76dfbde4475d3a39ac7764fc674291eed5f76529 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:07:01 +0100
Subject: Convert `brew upgrade` test to spec.

---
 Library/Homebrew/test/cmd/upgrade_spec.rb | 12 ++++++++++++
 Library/Homebrew/test/upgrade_test.rb     | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/upgrade_spec.rb
 delete mode 100644 Library/Homebrew/test/upgrade_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/upgrade_spec.rb b/Library/Homebrew/test/cmd/upgrade_spec.rb
new file mode 100644
index 000000000..84f5c09f4
--- /dev/null
+++ b/Library/Homebrew/test/cmd/upgrade_spec.rb
@@ -0,0 +1,12 @@
+describe "brew upgrade", :integration_test do
+  it "upgrades a Formula to the latest version" do
+    setup_test_formula "testball"
+    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+    shutup do
+      expect { brew "upgrade" }.to be_a_success
+    end
+
+    expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
+  end
+end
diff --git a/Library/Homebrew/test/upgrade_test.rb b/Library/Homebrew/test/upgrade_test.rb
deleted file mode 100644
index f3f5dccc7..000000000
--- a/Library/Homebrew/test/upgrade_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestUpgrade < IntegrationCommandTestCase
-  def test_upgrade
-    setup_test_formula "testball"
-    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
-
-    cmd("upgrade")
-    assert((HOMEBREW_CELLAR/"testball/0.1").directory?,
-      "The latest version directory should be created")
-  end
-end
-- 
cgit v1.2.3


From d9b2fdbea63730281964d71f968c0cb0aaf8e5ad Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:55 +0100
Subject: Convert `brew log` test to spec.

---
 Library/Homebrew/test/cmd/log_spec.rb     | 41 +++++++++++++++++++++++++++++++
 Library/Homebrew/test/log_formula_test.rb | 27 --------------------
 Library/Homebrew/test/log_test.rb         | 13 ----------
 3 files changed, 41 insertions(+), 40 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/log_spec.rb
 delete mode 100644 Library/Homebrew/test/log_formula_test.rb
 delete mode 100644 Library/Homebrew/test/log_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/log_spec.rb b/Library/Homebrew/test/cmd/log_spec.rb
new file mode 100644
index 000000000..bdbca8912
--- /dev/null
+++ b/Library/Homebrew/test/cmd/log_spec.rb
@@ -0,0 +1,41 @@
+describe "brew log", :integration_test do
+  it "shows the Git log for the Homebrew repository when no argument is given" do
+    HOMEBREW_REPOSITORY.cd do
+      shutup do
+        system "git", "init"
+        system "git", "commit", "--allow-empty", "-m", "This is a test commit"
+      end
+    end
+
+    expect { brew "log" }
+      .to output(/This is a test commit/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "shows the Git log for a given Formula" do
+    setup_test_formula "testball"
+
+    core_tap = CoreTap.new
+    core_tap.path.cd do
+      shutup do
+        system "git", "init"
+        system "git", "add", "--all"
+        system "git", "commit", "-m", "This is a test commit for Testball"
+      end
+    end
+
+    core_tap_url = "file://#{core_tap.path}"
+    shallow_tap = Tap.fetch("homebrew", "shallow")
+    shutup do
+      system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
+    end
+
+    expect { brew "log", "#{shallow_tap}/testball" }
+      .to output(/This is a test commit for Testball/).to_stdout
+      .and output(/Warning: The git repository is a shallow clone/).to_stderr
+      .and be_a_success
+
+    expect(shallow_tap.path/".git/shallow").to exist, "A shallow clone should have been created."
+  end
+end
diff --git a/Library/Homebrew/test/log_formula_test.rb b/Library/Homebrew/test/log_formula_test.rb
deleted file mode 100644
index bb6a1f661..000000000
--- a/Library/Homebrew/test/log_formula_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLogFormula < IntegrationCommandTestCase
-  def test_log_formula
-    core_tap = CoreTap.new
-    setup_test_formula "testball"
-
-    core_tap.path.cd do
-      shutup do
-        system "git", "init"
-        system "git", "add", "--all"
-        system "git", "commit", "-m", "This is a test commit for Testball"
-      end
-    end
-
-    core_tap_url = "file://#{core_tap.path}"
-    shallow_tap = Tap.fetch("homebrew", "shallow")
-    shutup do
-      system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
-    end
-
-    assert_match "This is a test commit for Testball",
-                 cmd("log", "#{shallow_tap}/testball")
-    assert_predicate shallow_tap.path/".git/shallow", :exist?,
-                     "A shallow clone should have been created."
-  end
-end
diff --git a/Library/Homebrew/test/log_test.rb b/Library/Homebrew/test/log_test.rb
deleted file mode 100644
index b2e150ccd..000000000
--- a/Library/Homebrew/test/log_test.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLog < IntegrationCommandTestCase
-  def test_log
-    FileUtils.cd HOMEBREW_REPOSITORY do
-      shutup do
-        system "git", "init"
-        system "git", "commit", "--allow-empty", "-m", "This is a test commit"
-      end
-    end
-    assert_match "This is a test commit", cmd("log")
-  end
-end
-- 
cgit v1.2.3


From f955f8d384bccb27a6aa664ab77bb05645c970a9 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:48 +0100
Subject: Convert `brew info` test to spec.

---
 Library/Homebrew/test/cmd/info_spec.rb | 10 ++++++++++
 Library/Homebrew/test/info_test.rb     |  9 ---------
 2 files changed, 10 insertions(+), 9 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/info_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/info_spec.rb b/Library/Homebrew/test/cmd/info_spec.rb
new file mode 100644
index 000000000..d33035972
--- /dev/null
+++ b/Library/Homebrew/test/cmd/info_spec.rb
@@ -0,0 +1,10 @@
+describe "brew info", :integration_test do
+  it "prints information about a given Formula" do
+    setup_test_formula "testball"
+
+    expect { brew "info", "testball" }
+      .to output(/testball: stable 0.1/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/info_test.rb b/Library/Homebrew/test/info_test.rb
index f71044bf0..d8a0f7904 100644
--- a/Library/Homebrew/test/info_test.rb
+++ b/Library/Homebrew/test/info_test.rb
@@ -3,15 +3,6 @@ require "cmd/info"
 require "formula"
 require "testing_env"
 
-class IntegrationCommandTestInfo < IntegrationCommandTestCase
-  def test_info
-    setup_test_formula "testball"
-
-    assert_match "testball: stable 0.1",
-                 cmd("info", "testball")
-  end
-end
-
 class InfoCommandTests < Homebrew::TestCase
   def test_github_remote_path
     remote = "https://github.com/Homebrew/homebrew-core"
-- 
cgit v1.2.3


From 7045b50f3a3cf067c5455e23c5b34e177cfd6f22 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:42 +0100
Subject: Convert `brew uninstall` test to spec.

---
 Library/Homebrew/test/cmd/uninstall_spec.rb | 12 ++++++++++++
 Library/Homebrew/test/uninstall_test.rb     |  7 -------
 2 files changed, 12 insertions(+), 7 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/uninstall_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/uninstall_spec.rb b/Library/Homebrew/test/cmd/uninstall_spec.rb
new file mode 100644
index 000000000..65f69e802
--- /dev/null
+++ b/Library/Homebrew/test/cmd/uninstall_spec.rb
@@ -0,0 +1,12 @@
+describe "brew uninstall", :integration_test do
+  it "uninstalls a given Formula" do
+    shutup do
+      expect { brew "install", testball }.to be_a_success
+    end
+
+    expect { brew "uninstall", "--force", testball }
+      .to output(/Uninstalling testball/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb
index 2f8bf4fff..a9230ffac 100644
--- a/Library/Homebrew/test/uninstall_test.rb
+++ b/Library/Homebrew/test/uninstall_test.rb
@@ -60,10 +60,3 @@ class UninstallTests < Homebrew::TestCase
     end
   end
 end
-
-class IntegrationCommandTestUninstall < IntegrationCommandTestCase
-  def test_uninstall
-    cmd("install", testball)
-    assert_match "Uninstalling testball", cmd("uninstall", "--force", testball)
-  end
-end
-- 
cgit v1.2.3


From afb49d36c490fc64e331eb67b2043236eaac07cf Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:33 +0100
Subject: Convert `brew switch` test to spec.

---
 Library/Homebrew/test/cmd/switch_spec.rb | 34 ++++++++++++++++++++++++++++++++
 Library/Homebrew/test/switch_test.rb     | 20 -------------------
 2 files changed, 34 insertions(+), 20 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/switch_spec.rb
 delete mode 100644 Library/Homebrew/test/switch_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/switch_spec.rb b/Library/Homebrew/test/cmd/switch_spec.rb
new file mode 100644
index 000000000..c27c96c14
--- /dev/null
+++ b/Library/Homebrew/test/cmd/switch_spec.rb
@@ -0,0 +1,34 @@
+describe "brew switch", :integration_test do
+  it "allows switching between Formula versions" do
+    expect { brew "switch" }
+      .to output(/Usage: brew switch  /).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "switch", "testball", "0.1" }
+      .to output(/testball not found/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    setup_test_formula "testball", <<-EOS.undent
+      keg_only "just because"
+    EOS
+
+    shutup do
+      expect { brew "install", "testball" }.to be_a_success
+    end
+
+    testball_rack = HOMEBREW_CELLAR/"testball"
+    FileUtils.cp_r testball_rack/"0.1", testball_rack/"0.2"
+
+    expect { brew "switch", "testball", "0.2" }
+      .to output(/link created/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "switch", "testball", "0.3" }
+      .to output("Versions available: 0.1, 0.2\n").to_stdout
+      .and output(/testball does not have a version "0.3"/).to_stderr
+      .and be_a_failure
+  end
+end
diff --git a/Library/Homebrew/test/switch_test.rb b/Library/Homebrew/test/switch_test.rb
deleted file mode 100644
index af1926c39..000000000
--- a/Library/Homebrew/test/switch_test.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestSwitch < IntegrationCommandTestCase
-  def test_switch
-    assert_match "Usage: brew switch  ", cmd_fail("switch")
-    assert_match "testball not found", cmd_fail("switch", "testball", "0.1")
-
-    setup_test_formula "testball", <<-EOS.undent
-      keg_only "just because"
-    EOS
-
-    cmd("install", "testball")
-    testball_rack = HOMEBREW_CELLAR/"testball"
-    FileUtils.cp_r testball_rack/"0.1", testball_rack/"0.2"
-
-    cmd("switch", "testball", "0.2")
-    assert_match "testball does not have a version \"0.3\"",
-      cmd_fail("switch", "testball", "0.3")
-  end
-end
-- 
cgit v1.2.3


From 5bf70805d8c134174dfb55791c25066239d9bc0e Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:26 +0100
Subject: Convert `brew linkapps` test to spec.

---
 Library/Homebrew/test/cmd/linkapps_spec.rb | 24 ++++++++++++++++++++++++
 Library/Homebrew/test/linkapps_test.rb     | 15 ---------------
 2 files changed, 24 insertions(+), 15 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/linkapps_spec.rb
 delete mode 100644 Library/Homebrew/test/linkapps_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/linkapps_spec.rb b/Library/Homebrew/test/cmd/linkapps_spec.rb
new file mode 100644
index 000000000..42118a215
--- /dev/null
+++ b/Library/Homebrew/test/cmd/linkapps_spec.rb
@@ -0,0 +1,24 @@
+describe "brew linkapps", :integration_test do
+  let(:home_dir) { @home_dir = Pathname.new(Dir.mktmpdir) }
+  let(:apps_dir) { home_dir/"Applications" }
+
+  after(:each) do
+    home_dir.rmtree unless @home_dir.nil?
+  end
+
+  it "symlinks applications" do
+    apps_dir.mkpath
+
+    setup_test_formula "testball"
+
+    source_app = HOMEBREW_CELLAR/"testball/0.1/TestBall.app"
+    source_app.mkpath
+
+    expect { brew "linkapps", "--local", "HOME" => home_dir }
+      .to output(/Linking: #{Regexp.escape(source_app)}/).to_stdout
+      .and output(/`brew linkapps` has been deprecated/).to_stderr
+      .and be_a_success
+
+    expect(apps_dir/"TestBall.app").to be_a_symlink
+  end
+end
diff --git a/Library/Homebrew/test/linkapps_test.rb b/Library/Homebrew/test/linkapps_test.rb
deleted file mode 100644
index 4c5b8ec13..000000000
--- a/Library/Homebrew/test/linkapps_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLinkapps < IntegrationCommandTestCase
-  def test_linkapps
-    home_dir = Pathname.new(mktmpdir)
-    (home_dir/"Applications").mkpath
-
-    setup_test_formula "testball"
-
-    source_dir = HOMEBREW_CELLAR/"testball/0.1/TestBall.app"
-    source_dir.mkpath
-    assert_match "Linking: #{source_dir}",
-      cmd("linkapps", "--local", "HOME" => home_dir)
-  end
-end
-- 
cgit v1.2.3


From 6db95a8f79b6f5e2245929c2c7587bf11d5cff8f Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:19 +0100
Subject: Convert `brew unlink` test to spec.

---
 Library/Homebrew/test/cmd/unlink_spec.rb | 14 ++++++++++++++
 Library/Homebrew/test/unlink_test.rb     | 10 ----------
 2 files changed, 14 insertions(+), 10 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/unlink_spec.rb
 delete mode 100644 Library/Homebrew/test/unlink_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/unlink_spec.rb b/Library/Homebrew/test/cmd/unlink_spec.rb
new file mode 100644
index 000000000..5961651fe
--- /dev/null
+++ b/Library/Homebrew/test/cmd/unlink_spec.rb
@@ -0,0 +1,14 @@
+describe "brew unlink", :integration_test do
+  it "unlinks a Formula" do
+    setup_test_formula "testball"
+
+    shutup do
+      expect { brew "install", "testball" }.to be_a_success
+    end
+
+    expect { brew "unlink", "--dry-run", "testball" }
+      .to output(/Would remove/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/unlink_test.rb b/Library/Homebrew/test/unlink_test.rb
deleted file mode 100644
index 6d5cefc67..000000000
--- a/Library/Homebrew/test/unlink_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestUnlink < IntegrationCommandTestCase
-  def test_unlink
-    setup_test_formula "testball"
-
-    cmd("install", "testball")
-    assert_match "Would remove", cmd("unlink", "--dry-run", "testball")
-  end
-end
-- 
cgit v1.2.3


From b07f0d1038c4d4af5416a00330e3f4aba0d2056a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:11 +0100
Subject: Convert `brew unlinkapps` test to spec.

---
 Library/Homebrew/test/cmd/unlinkapps_spec.rb | 24 ++++++++++++++++++++++++
 Library/Homebrew/test/unlinkapps_test.rb     | 19 -------------------
 2 files changed, 24 insertions(+), 19 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/unlinkapps_spec.rb
 delete mode 100644 Library/Homebrew/test/unlinkapps_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/unlinkapps_spec.rb b/Library/Homebrew/test/cmd/unlinkapps_spec.rb
new file mode 100644
index 000000000..1e21bd851
--- /dev/null
+++ b/Library/Homebrew/test/cmd/unlinkapps_spec.rb
@@ -0,0 +1,24 @@
+describe "brew unlinkapps", :integration_test do
+  let(:home_dir) { @home_dir = Pathname.new(Dir.mktmpdir) }
+  let(:apps_dir) { home_dir/"Applications" }
+
+  after(:each) do
+    home_dir.rmtree unless @home_dir.nil?
+  end
+
+  it "unlinks symlinked applications" do
+    apps_dir.mkpath
+
+    setup_test_formula "testball"
+
+    source_app = HOMEBREW_CELLAR/"testball/0.1/TestBall.app"
+    source_app.mkpath
+
+    FileUtils.ln_s source_app, apps_dir/"TestBall.app"
+
+    expect { brew "unlinkapps", "--local", "HOME" => home_dir }
+      .to output(%r{Unlinking: #{Regexp.escape(apps_dir)}/TestBall.app}).to_stdout
+      .and output(/`brew unlinkapps` has been deprecated/).to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/unlinkapps_test.rb b/Library/Homebrew/test/unlinkapps_test.rb
deleted file mode 100644
index 9d9672199..000000000
--- a/Library/Homebrew/test/unlinkapps_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestUnlinkapps < IntegrationCommandTestCase
-  def test_unlinkapps
-    home_dir = Pathname.new(mktmpdir)
-    apps_dir = home_dir/"Applications"
-    apps_dir.mkpath
-
-    setup_test_formula "testball"
-
-    source_app = (HOMEBREW_CELLAR/"testball/0.1/TestBall.app")
-    source_app.mkpath
-
-    FileUtils.ln_s source_app, "#{apps_dir}/TestBall.app"
-
-    assert_match "Unlinking: #{apps_dir}/TestBall.app",
-      cmd("unlinkapps", "--local", "HOME" => home_dir)
-  end
-end
-- 
cgit v1.2.3


From e7b3cfd51633329b67928f81c06b68ef98bfba87 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:56 +0100
Subject: Convert `brew uses` test to spec.

---
 Library/Homebrew/test/cmd/uses_spec.rb | 25 +++++++++++++++++++++++++
 Library/Homebrew/test/uses_test.rb     | 16 ----------------
 2 files changed, 25 insertions(+), 16 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/uses_spec.rb
 delete mode 100644 Library/Homebrew/test/uses_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/uses_spec.rb b/Library/Homebrew/test/cmd/uses_spec.rb
new file mode 100644
index 000000000..2a6f48cb7
--- /dev/null
+++ b/Library/Homebrew/test/cmd/uses_spec.rb
@@ -0,0 +1,25 @@
+describe "brew uses", :integration_test do
+  it "prints the Formulae a given Formula is used by" do
+    setup_test_formula "foo"
+    setup_test_formula "bar"
+    setup_test_formula "baz", <<-EOS.undent
+      url "https://example.com/baz-1.0"
+      depends_on "bar"
+    EOS
+
+    expect { brew "uses", "baz" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+
+    expect { brew "uses", "bar" }
+      .to output("baz\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "uses", "--recursive", "foo" }
+      .to output(/(bar\nbaz|baz\nbar)/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/uses_test.rb b/Library/Homebrew/test/uses_test.rb
deleted file mode 100644
index 1fad0da28..000000000
--- a/Library/Homebrew/test/uses_test.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestUses < IntegrationCommandTestCase
-  def test_uses
-    setup_test_formula "foo"
-    setup_test_formula "bar"
-    setup_test_formula "baz", <<-EOS.undent
-      url "https://example.com/baz-1.0"
-      depends_on "bar"
-    EOS
-
-    assert_equal "", cmd("uses", "baz")
-    assert_equal "baz", cmd("uses", "bar")
-    assert_match(/(bar\nbaz|baz\nbar)/, cmd("uses", "--recursive", "foo"))
-  end
-end
-- 
cgit v1.2.3


From be498acf4fee38912a497b26e2beed97ee1f8b9a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:47 +0100
Subject: Convert `brew unpack` test to spec.

---
 Library/Homebrew/test/cmd/unpack_spec.rb | 16 ++++++++++++++++
 Library/Homebrew/test/unpack_test.rb     | 13 -------------
 2 files changed, 16 insertions(+), 13 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/unpack_spec.rb
 delete mode 100644 Library/Homebrew/test/unpack_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/unpack_spec.rb b/Library/Homebrew/test/cmd/unpack_spec.rb
new file mode 100644
index 000000000..244fc0852
--- /dev/null
+++ b/Library/Homebrew/test/cmd/unpack_spec.rb
@@ -0,0 +1,16 @@
+describe "brew unpack", :integration_test do
+  it "unpacks a given Formula's archive" do
+    setup_test_formula "testball"
+
+    Dir.mktmpdir do |path|
+      path = Pathname.new(path)
+
+      shutup do
+        expect { brew "unpack", "testball", "--destdir=#{path}" }
+          .to be_a_success
+      end
+
+      expect(path/"testball-0.1").to be_a_directory
+    end
+  end
+end
diff --git a/Library/Homebrew/test/unpack_test.rb b/Library/Homebrew/test/unpack_test.rb
deleted file mode 100644
index bbff6ad1c..000000000
--- a/Library/Homebrew/test/unpack_test.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestUnpack < IntegrationCommandTestCase
-  def test_unpack
-    setup_test_formula "testball"
-
-    mktmpdir do |path|
-      cmd "unpack", "testball", "--destdir=#{path}"
-      assert File.directory?("#{path}/testball-0.1"),
-        "The tarball should be unpacked"
-    end
-  end
-end
-- 
cgit v1.2.3


From 2b9c81b225e549bc07295e4c6e24699b8d353e01 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:40 +0100
Subject: Convert `brew doctor` test to spec.

---
 Library/Homebrew/test/cmd/doctor_spec.rb | 6 ++++++
 Library/Homebrew/test/doctor_test.rb     | 8 --------
 2 files changed, 6 insertions(+), 8 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/doctor_spec.rb
 delete mode 100644 Library/Homebrew/test/doctor_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/doctor_spec.rb b/Library/Homebrew/test/cmd/doctor_spec.rb
new file mode 100644
index 000000000..530adcd98
--- /dev/null
+++ b/Library/Homebrew/test/cmd/doctor_spec.rb
@@ -0,0 +1,6 @@
+describe "brew doctor", :integration_test do
+  specify "check_integration_test" do
+    expect { brew "doctor", "check_integration_test" }
+      .to output(/This is an integration test/).to_stderr
+  end
+end
diff --git a/Library/Homebrew/test/doctor_test.rb b/Library/Homebrew/test/doctor_test.rb
deleted file mode 100644
index d2dc871f4..000000000
--- a/Library/Homebrew/test/doctor_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestDoctor < IntegrationCommandTestCase
-  def test_doctor
-    assert_match "This is an integration test",
-                 cmd_fail("doctor", "check_integration_test")
-  end
-end
-- 
cgit v1.2.3


From 91601ae3d9454d300db43a4f483bfc1a14ff3cfb Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:33 +0100
Subject: Convert `brew fetch` test to spec.

---
 Library/Homebrew/test/cmd/fetch_spec.rb | 13 +++++++++++++
 Library/Homebrew/test/fetch_test.rb     | 11 -----------
 2 files changed, 13 insertions(+), 11 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/fetch_spec.rb
 delete mode 100644 Library/Homebrew/test/fetch_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/fetch_spec.rb b/Library/Homebrew/test/cmd/fetch_spec.rb
new file mode 100644
index 000000000..111d9f85c
--- /dev/null
+++ b/Library/Homebrew/test/cmd/fetch_spec.rb
@@ -0,0 +1,13 @@
+describe "brew fetch", :integration_test do
+  it "downloads the Formula's URL" do
+    setup_test_formula "testball"
+
+    expect(HOMEBREW_CACHE/"testball-0.1.tbz").not_to exist
+
+    shutup do
+      expect { brew "fetch", "testball" }.to be_a_success
+    end
+
+    expect(HOMEBREW_CACHE/"testball-0.1.tbz").to exist
+  end
+end
diff --git a/Library/Homebrew/test/fetch_test.rb b/Library/Homebrew/test/fetch_test.rb
deleted file mode 100644
index e08e545e3..000000000
--- a/Library/Homebrew/test/fetch_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestFetch < IntegrationCommandTestCase
-  def test_fetch
-    setup_test_formula "testball"
-
-    cmd("fetch", "testball")
-    assert((HOMEBREW_CACHE/"testball-0.1.tbz").exist?,
-      "The tarball should have been cached")
-  end
-end
-- 
cgit v1.2.3


From c37dbb79b669fc0c4088415d7269a6618f1ccb3c Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:26 +0100
Subject: Convert `brew help` test to spec.

---
 Library/Homebrew/test/cmd/help_spec.rb | 47 ++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/help_test.rb     | 21 ---------------
 2 files changed, 47 insertions(+), 21 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/help_spec.rb
 delete mode 100644 Library/Homebrew/test/help_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/help_spec.rb b/Library/Homebrew/test/cmd/help_spec.rb
new file mode 100644
index 000000000..6d94d7444
--- /dev/null
+++ b/Library/Homebrew/test/cmd/help_spec.rb
@@ -0,0 +1,47 @@
+describe "brew", :integration_test do
+  it "prints help when no argument is given" do
+    expect { brew }
+      .to output(/Example usage:\n/).to_stderr
+      .and be_a_failure
+  end
+
+  describe "help" do
+    it "prints help" do
+      expect { brew "help" }
+        .to output(/Example usage:\n/).to_stdout
+        .and be_a_success
+    end
+
+    it "prints help for a documented Ruby command" do
+      expect { brew "help", "cat" }
+        .to output(/^brew cat/).to_stdout
+        .and be_a_success
+    end
+
+    it "prints help for a documented shell command" do
+      expect { brew "help", "update" }
+        .to output(/^brew update/).to_stdout
+        .and be_a_success
+    end
+
+    it "prints help for a documented Ruby developer command" do
+      expect { brew "help", "update-test" }
+        .to output(/^brew update-test/).to_stdout
+        .and be_a_success
+    end
+
+    it "fails when given an unknown command" do
+      expect { brew "help", "command-that-does-not-exist" }
+        .to output(/Unknown command: command-that-does-not-exist/).to_stderr
+        .and be_a_failure
+    end
+  end
+
+  describe "cat" do
+    it "prints help when no argument is given" do
+      expect { brew "cat" }
+        .to output(/^brew cat/).to_stderr
+        .and be_a_failure
+    end
+  end
+end
diff --git a/Library/Homebrew/test/help_test.rb b/Library/Homebrew/test/help_test.rb
deleted file mode 100644
index 92dd99721..000000000
--- a/Library/Homebrew/test/help_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestHelp < IntegrationCommandTestCase
-  def test_help
-    assert_match "Example usage:\n",
-                 cmd_fail # Generic help (empty argument list).
-    assert_match "Unknown command: command-that-does-not-exist",
-                 cmd_fail("help", "command-that-does-not-exist")
-    assert_match(/^brew cat /,
-                 cmd_fail("cat")) # Missing formula argument triggers help.
-
-    assert_match "Example usage:\n",
-                 cmd("help") # Generic help.
-    assert_match(/^brew cat /,
-                 cmd("help", "cat")) # Internal command (documented, Ruby).
-    assert_match(/^brew update /,
-                 cmd("help", "update")) # Internal command (documented, Shell).
-    assert_match(/^brew update-test /,
-                 cmd("help", "update-test")) # Internal developer command (documented, Ruby).
-  end
-end
-- 
cgit v1.2.3


From be2645b04f3b001069daf353289a19155afaf00c Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:20 +0100
Subject: Convert `brew options` test to spec.

---
 Library/Homebrew/test/cmd/options_spec.rb | 12 ++++++++++++
 Library/Homebrew/test/options_test.rb     | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/options_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/options_spec.rb b/Library/Homebrew/test/cmd/options_spec.rb
new file mode 100644
index 000000000..33fe8b107
--- /dev/null
+++ b/Library/Homebrew/test/cmd/options_spec.rb
@@ -0,0 +1,12 @@
+describe "brew options", :integration_test do
+  it "prints a given Formula's options" do
+    setup_test_formula "testball", <<-EOS.undent
+      depends_on "bar" => :recommended
+    EOS
+
+    expect { brew "options", "testball" }
+      .to output("--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support\n\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb
index 09ea14180..0a6e198d3 100644
--- a/Library/Homebrew/test/options_test.rb
+++ b/Library/Homebrew/test/options_test.rb
@@ -1,17 +1,5 @@
 require "testing_env"
 require "options"
-require "testing_env"
-
-class IntegrationCommandTestOptions < IntegrationCommandTestCase
-  def test_options
-    setup_test_formula "testball", <<-EOS.undent
-      depends_on "bar" => :recommended
-    EOS
-
-    assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support",
-      cmd("options", "testball").chomp
-  end
-end
 
 class OptionTests < Homebrew::TestCase
   def setup
-- 
cgit v1.2.3


From 0248b5e357de99654b6a2f4ee5fd20829c8481e6 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:05:13 +0100
Subject: Convert `brew test` test to spec.

---
 Library/Homebrew/test/dev-cmd/test_spec.rb | 56 ++++++++++++++++++++++++++++++
 Library/Homebrew/test/test_formula_test.rb | 30 ----------------
 2 files changed, 56 insertions(+), 30 deletions(-)
 create mode 100644 Library/Homebrew/test/dev-cmd/test_spec.rb
 delete mode 100644 Library/Homebrew/test/test_formula_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/dev-cmd/test_spec.rb b/Library/Homebrew/test/dev-cmd/test_spec.rb
new file mode 100644
index 000000000..b73d042e4
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/test_spec.rb
@@ -0,0 +1,56 @@
+describe "brew test", :integration_test do
+  it "fails when no argument is given" do
+    expect { brew "test" }
+      .to output(/This command requires a formula argument/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "fails when a Formula is not installed" do
+    expect { brew "test", testball }
+      .to output(/Testing requires the latest version of testball/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "fails when a Formula has no test" do
+    shutup do
+      expect { brew "install", testball }.to be_a_success
+    end
+
+    expect { brew "test", testball }
+      .to output(/testball defines no test/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "tests a given Formula" do
+    setup_test_formula "testball", <<-EOS.undent
+      head "https://github.com/example/testball2.git"
+
+      devel do
+        url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
+        sha256 "#{TESTBALL_SHA256}"
+      end
+
+      keg_only "just because"
+
+      test do
+      end
+    EOS
+
+    shutup do
+      expect { brew "install", "testball" }.to be_a_success
+    end
+
+    expect { brew "test", "--HEAD", "testball" }
+      .to output(/Testing testball/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "test", "--devel", "testball" }
+      .to output(/Testing testball/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/test_formula_test.rb b/Library/Homebrew/test/test_formula_test.rb
deleted file mode 100644
index 5ad2db9e9..000000000
--- a/Library/Homebrew/test/test_formula_test.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestTestFormula < IntegrationCommandTestCase
-  def test_test_formula
-    assert_match "This command requires a formula argument", cmd_fail("test")
-    assert_match "Testing requires the latest version of testball",
-      cmd_fail("test", testball)
-
-    cmd("install", testball)
-    assert_match "testball defines no test", cmd_fail("test", testball)
-
-    setup_test_formula "testball_copy", <<-EOS.undent
-      head "https://github.com/example/testball2.git"
-
-      devel do
-        url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
-        sha256 "#{TESTBALL_SHA256}"
-      end
-
-      keg_only "just because"
-
-      test do
-      end
-    EOS
-
-    cmd("install", "testball_copy")
-    assert_match "Testing testball_copy", cmd("test", "--HEAD", "testball_copy")
-    assert_match "Testing testball_copy", cmd("test", "--devel", "testball_copy")
-  end
-end
-- 
cgit v1.2.3


From 1c4203fee7baf1648b172f51cd626148c1b885ae Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:59 +0100
Subject: Convert `brew search` test to spec.

---
 Library/Homebrew/test/cmd/search_spec.rb | 57 ++++++++++++++++++++++++++++++++
 Library/Homebrew/test/search_test.rb     | 30 -----------------
 2 files changed, 57 insertions(+), 30 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/search_spec.rb
 delete mode 100644 Library/Homebrew/test/search_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/search_spec.rb b/Library/Homebrew/test/cmd/search_spec.rb
new file mode 100644
index 000000000..06b7073d8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/search_spec.rb
@@ -0,0 +1,57 @@
+describe "brew search", :integration_test do
+  before(:each) do
+    setup_test_formula "testball"
+  end
+
+  it "lists all available Formulae when no argument is given" do
+    expect { brew "search" }
+      .to output(/testball/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "supports searching by name" do
+    expect { brew "search", "testball" }
+      .to output(/testball/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "supports searching a fully-qualified name " do
+    expect { brew "search", "homebrew/homebrew-core/testball" }
+      .to output(/testball/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  describe "--desc" do
+    let(:desc_cache) { HOMEBREW_CACHE/"desc_cache.json" }
+
+    it "supports searching in descriptions and creates a description cache" do
+      expect(desc_cache).not_to exist
+
+      expect { brew "search", "--desc", "Some test" }
+        .to output(/testball/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+
+      expect(desc_cache).to exist
+    end
+  end
+
+  {
+    "macports" => "https://www.macports.org/ports.php?by=name&substr=testball",
+    "fink" => "http://pdb.finkproject.org/pdb/browse.php?summary=testball",
+    "debian" => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all§ion=all",
+    "opensuse" => "https://software.opensuse.org/search?q=testball",
+    "fedora" => "https://admin.fedoraproject.org/pkgdb/packages/%2Atestball%2A/",
+    "ubuntu" => "http://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all§ion=all",
+  }.each do |flag, url|
+    specify "--#{flag}" do
+      expect { brew "search", "--#{flag}", "testball", "HOMEBREW_BROWSER" => "echo" }
+        .to output("#{url}\n").to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+end
diff --git a/Library/Homebrew/test/search_test.rb b/Library/Homebrew/test/search_test.rb
deleted file mode 100644
index 70b6f01fb..000000000
--- a/Library/Homebrew/test/search_test.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestSearch < IntegrationCommandTestCase
-  def test_search
-    setup_test_formula "testball"
-    desc_cache = HOMEBREW_CACHE/"desc_cache.json"
-    refute_predicate desc_cache, :exist?, "Cached file should not exist"
-
-    assert_match "testball", cmd("search")
-    assert_match "testball", cmd("search", "testball")
-    assert_match "testball", cmd("search", "homebrew/homebrew-core/testball")
-    assert_match "testball", cmd("search", "--desc", "Some test")
-
-    flags = {
-      "macports" => "https://www.macports.org/ports.php?by=name&substr=testball",
-      "fink" => "http://pdb.finkproject.org/pdb/browse.php?summary=testball",
-      "debian" => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all§ion=all",
-      "opensuse" => "https://software.opensuse.org/search?q=testball",
-      "fedora" => "https://admin.fedoraproject.org/pkgdb/packages/%2Atestball%2A/",
-      "ubuntu" => "http://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all§ion=all",
-    }
-
-    flags.each do |flag, url|
-      assert_equal url, cmd("search", "--#{flag}",
-        "testball", "HOMEBREW_BROWSER" => "echo")
-    end
-
-    assert_predicate desc_cache, :exist?, "Cached file should exist"
-  end
-end
-- 
cgit v1.2.3


From 2439df40592111a4480367dd988af213cabab70a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:47 +0100
Subject: Convert `brew home` test to spec.

---
 Library/Homebrew/test/cmd/home_spec.rb | 17 +++++++++++++++++
 Library/Homebrew/test/home_test.rb     | 12 ------------
 2 files changed, 17 insertions(+), 12 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/home_spec.rb
 delete mode 100644 Library/Homebrew/test/home_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/home_spec.rb b/Library/Homebrew/test/cmd/home_spec.rb
new file mode 100644
index 000000000..5a4070492
--- /dev/null
+++ b/Library/Homebrew/test/cmd/home_spec.rb
@@ -0,0 +1,17 @@
+describe "brew home", :integration_test do
+  it "opens the Homebrew homepage when no argument is given" do
+    expect { brew "home", "HOMEBREW_BROWSER" => "echo" }
+      .to output("#{HOMEBREW_WWW}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "opens the homepage for a given Formula" do
+    setup_test_formula "testball"
+
+    expect { brew "home", "testball", "HOMEBREW_BROWSER" => "echo" }
+      .to output("#{Formula["testball"].homepage}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/home_test.rb b/Library/Homebrew/test/home_test.rb
deleted file mode 100644
index ff06b72c1..000000000
--- a/Library/Homebrew/test/home_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestHome < IntegrationCommandTestCase
-  def test_home
-    setup_test_formula "testball"
-
-    assert_equal HOMEBREW_WWW,
-                 cmd("home", "HOMEBREW_BROWSER" => "echo")
-    assert_equal Formula["testball"].homepage,
-                 cmd("home", "testball", "HOMEBREW_BROWSER" => "echo")
-  end
-end
-- 
cgit v1.2.3


From 782a7d006737c3003cdbafd94487d43b749f0b6c Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:40 +0100
Subject: Convert `brew tap-new` test to spec.

---
 Library/Homebrew/test/cmd/tap-new_spec.rb | 10 ++++++++++
 Library/Homebrew/test/tap_new_test.rb     |  9 ---------
 2 files changed, 10 insertions(+), 9 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/tap-new_spec.rb
 delete mode 100644 Library/Homebrew/test/tap_new_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/tap-new_spec.rb b/Library/Homebrew/test/cmd/tap-new_spec.rb
new file mode 100644
index 000000000..ea4b8aa73
--- /dev/null
+++ b/Library/Homebrew/test/cmd/tap-new_spec.rb
@@ -0,0 +1,10 @@
+describe "brew tap-new", :integration_test do
+  it "initializes a new Tap with a ReadMe file" do
+    expect { brew "tap-new", "homebrew/foo", "--verbose" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+
+    expect(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md").to exist
+  end
+end
diff --git a/Library/Homebrew/test/tap_new_test.rb b/Library/Homebrew/test/tap_new_test.rb
deleted file mode 100644
index 261a334f0..000000000
--- a/Library/Homebrew/test/tap_new_test.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestTapNew < IntegrationCommandTestCase
-  def test_tap_readme
-    assert_equal "", cmd("tap-new", "homebrew/foo", "--verbose")
-    readme = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md"
-    assert readme.exist?, "The README should be created"
-  end
-end
-- 
cgit v1.2.3


From 9d512be63ca1ab039e8e46ba44efa6454008bb7e Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:32 +0100
Subject: Convert `brew irb` test to spec.

---
 Library/Homebrew/cmd/irb.rb           |  1 +
 Library/Homebrew/test/cmd/irb_spec.rb | 24 ++++++++++++++++++++++++
 Library/Homebrew/test/irb_test.rb     | 19 -------------------
 3 files changed, 25 insertions(+), 19 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/irb_spec.rb
 delete mode 100644 Library/Homebrew/test/irb_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/cmd/irb.rb b/Library/Homebrew/cmd/irb.rb
index d162e3f4a..5561845e7 100644
--- a/Library/Homebrew/cmd/irb.rb
+++ b/Library/Homebrew/cmd/irb.rb
@@ -12,6 +12,7 @@ class Symbol
     Formulary.factory(to_s, *args)
   end
 end
+
 class String
   def f(*args)
     Formulary.factory(self, *args)
diff --git a/Library/Homebrew/test/cmd/irb_spec.rb b/Library/Homebrew/test/cmd/irb_spec.rb
new file mode 100644
index 000000000..44410fabe
--- /dev/null
+++ b/Library/Homebrew/test/cmd/irb_spec.rb
@@ -0,0 +1,24 @@
+describe "brew irb", :integration_test do
+  it "starts an interactive Homebrew shell session" do
+    setup_test_formula "testball"
+
+    irb_test = HOMEBREW_TEMP/"irb-test.rb"
+    irb_test.write <<-EOS.undent
+      "testball".f
+      :testball.f
+      exit
+    EOS
+
+    expect { brew "irb", irb_test }
+      .to output(/Interactive Homebrew Shell/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  specify "--examples" do
+    expect { brew "irb", "--examples" }
+      .to output(/'v8'\.f # => instance of the v8 formula/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/irb_test.rb b/Library/Homebrew/test/irb_test.rb
deleted file mode 100644
index 832ca39a5..000000000
--- a/Library/Homebrew/test/irb_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestIrb < IntegrationCommandTestCase
-  def test_irb
-    assert_match "'v8'.f # => instance of the v8 formula",
-      cmd("irb", "--examples")
-
-    setup_test_formula "testball"
-
-    irb_test = HOMEBREW_TEMP/"irb-test.rb"
-    irb_test.write <<-EOS.undent
-      "testball".f
-      :testball.f
-      exit
-    EOS
-
-    assert_match "Interactive Homebrew Shell", cmd("irb", irb_test)
-  end
-end
-- 
cgit v1.2.3


From eb6fe0019e8cf0b255df82e42fbce9ebc9c27a92 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:19 +0100
Subject: Convert `brew sh` test to spec.

---
 Library/Homebrew/test/cmd/sh_spec.rb | 8 ++++++++
 Library/Homebrew/test/sh_test.rb     | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/sh_spec.rb
 delete mode 100644 Library/Homebrew/test/sh_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/sh_spec.rb b/Library/Homebrew/test/cmd/sh_spec.rb
new file mode 100644
index 000000000..5260ddb75
--- /dev/null
+++ b/Library/Homebrew/test/cmd/sh_spec.rb
@@ -0,0 +1,8 @@
+describe "brew sh", :integration_test do
+  it "runs a shell with the Homebrew environment" do
+    expect { brew "sh", "SHELL" => which("true") }
+      .to output(/Your shell has been configured/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/sh_test.rb b/Library/Homebrew/test/sh_test.rb
deleted file mode 100644
index 48fcdc54a..000000000
--- a/Library/Homebrew/test/sh_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestSh < IntegrationCommandTestCase
-  def test_sh
-    assert_match "Your shell has been configured",
-                 cmd("sh", "SHELL" => which("true"))
-  end
-end
-- 
cgit v1.2.3


From 4ca6be4513ef6bd895b6c5b14c2b760afcf62a24 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:11 +0100
Subject: Convert `brew missing` test to spec.

---
 Library/Homebrew/test/cmd/missing_spec.rb | 41 +++++++++++++++++++++++++++++++
 Library/Homebrew/test/missing_test.rb     | 34 -------------------------
 2 files changed, 41 insertions(+), 34 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/missing_spec.rb
 delete mode 100644 Library/Homebrew/test/missing_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/missing_spec.rb b/Library/Homebrew/test/cmd/missing_spec.rb
new file mode 100644
index 000000000..4668e72e0
--- /dev/null
+++ b/Library/Homebrew/test/cmd/missing_spec.rb
@@ -0,0 +1,41 @@
+describe "brew missing", :integration_test do
+  before(:each) do
+    setup_test_formula "foo"
+    setup_test_formula "bar"
+  end
+
+  def make_prefix(name)
+    (HOMEBREW_CELLAR/name/"1.0").mkpath
+  end
+
+  it "prints missing dependencies" do
+    make_prefix "bar"
+
+    expect { brew "missing" }
+      .to output("foo\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "prints nothing if all dependencies are installed" do
+    make_prefix "foo"
+    make_prefix "bar"
+
+    expect { brew "missing" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+  end
+
+  describe "--hide=" do
+    it "pretends that the specified Formulae are not installed" do
+      make_prefix "foo"
+      make_prefix "bar"
+
+      expect { brew "missing", "--hide=foo" }
+        .to output("bar: foo\n").to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+end
diff --git a/Library/Homebrew/test/missing_test.rb b/Library/Homebrew/test/missing_test.rb
deleted file mode 100644
index 4f20d8a7a..000000000
--- a/Library/Homebrew/test/missing_test.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestMissing < IntegrationCommandTestCase
-  def setup
-    super
-
-    setup_test_formula "foo"
-    setup_test_formula "bar"
-  end
-
-  def make_prefix(name)
-    (HOMEBREW_CELLAR/name/"1.0").mkpath
-  end
-
-  def test_missing_missing
-    make_prefix "bar"
-
-    assert_match "foo", cmd("missing")
-  end
-
-  def test_missing_not_missing
-    make_prefix "foo"
-    make_prefix "bar"
-
-    assert_empty cmd("missing")
-  end
-
-  def test_missing_hide
-    make_prefix "foo"
-    make_prefix "bar"
-
-    assert_match "foo", cmd("missing", "--hide=foo")
-  end
-end
-- 
cgit v1.2.3


From 657d3f2adebcf60ac09b9bb98b28d366923e1fea Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:04:02 +0100
Subject: Convert `brew reinstall` test to spec.

---
 Library/Homebrew/test/cmd/reinstall_spec.rb    | 47 ++++++++++++++++++++++++++
 Library/Homebrew/test/reinstall_pinned_test.rb | 15 --------
 Library/Homebrew/test/reinstall_test.rb        | 24 -------------
 3 files changed, 47 insertions(+), 39 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/reinstall_spec.rb
 delete mode 100644 Library/Homebrew/test/reinstall_pinned_test.rb
 delete mode 100644 Library/Homebrew/test/reinstall_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/reinstall_spec.rb b/Library/Homebrew/test/cmd/reinstall_spec.rb
new file mode 100644
index 000000000..74d36bbb8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/reinstall_spec.rb
@@ -0,0 +1,47 @@
+require "extend/ENV"
+
+describe "brew reinstall", :integration_test do
+  let(:bin) { (HOMEBREW_PREFIX/"bin").realpath }
+  let(:path) { "#{bin}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
+
+  before(:each) do
+    setup_test_formula "testball"
+
+    shutup do
+      expect { brew "install", "testball", "--with-foo" }.to be_a_success
+    end
+  end
+
+  it "reinstalls a Formula" do
+    foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo"
+    expect(foo_dir).to exist
+    foo_dir.rmtree
+
+    expect { brew "reinstall", "testball", "PATH" => path }
+      .to output(/Reinstalling testball --with-foo/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect(foo_dir).to exist
+  end
+
+  it "reinstalls a Formula even when one of the options is invalid" do
+    expect { brew "reinstall", "testball", "--with-fo", "PATH" => path }
+      .to output(/Reinstalling testball --with-foo/).to_stdout
+      .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr
+      .and be_a_success
+  end
+
+  it "refuses to reinstall a pinned Formula, but doesn't fail" do
+    (HOMEBREW_CELLAR/"testball/0.1").mkpath
+    HOMEBREW_PINNED_KEGS.mkpath
+    FileUtils.ln_s HOMEBREW_CELLAR/"testball/0.1", HOMEBREW_PINNED_KEGS/"testball"
+
+    expect { brew "reinstall", "testball" }
+      .to output(/testball is pinned. You must unpin it to reinstall./).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_success
+
+    HOMEBREW_PINNED_KEGS.rmtree
+  end
+end
diff --git a/Library/Homebrew/test/reinstall_pinned_test.rb b/Library/Homebrew/test/reinstall_pinned_test.rb
deleted file mode 100644
index 80f5518ea..000000000
--- a/Library/Homebrew/test/reinstall_pinned_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReinstallPinned < IntegrationCommandTestCase
-  def test_reinstall_pinned
-    setup_test_formula "testball"
-
-    HOMEBREW_CELLAR.join("testball/0.1").mkpath
-    HOMEBREW_PINNED_KEGS.mkpath
-    FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_PINNED_KEGS/"testball"
-
-    assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball")
-
-    HOMEBREW_PINNED_KEGS.rmtree
-  end
-end
diff --git a/Library/Homebrew/test/reinstall_test.rb b/Library/Homebrew/test/reinstall_test.rb
deleted file mode 100644
index 2906983c3..000000000
--- a/Library/Homebrew/test/reinstall_test.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReinstall < IntegrationCommandTestCase
-  def test_reinstall
-    setup_test_formula "testball"
-
-    cmd("install", "testball", "--with-foo")
-    foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo"
-    assert foo_dir.exist?
-    foo_dir.rmtree
-    assert_match "Reinstalling testball --with-foo",
-      cmd("reinstall", "testball")
-    assert foo_dir.exist?
-  end
-
-  def test_reinstall_with_invalid_option
-    setup_test_formula "testball"
-
-    cmd("install", "testball", "--with-foo")
-
-    assert_match "testball: this formula has no --with-fo option so it will be ignored!",
-      cmd("reinstall", "testball", "--with-fo")
-  end
-end
-- 
cgit v1.2.3


From a59868c8be7fcf16c51fdfccaa4bc9fc57ec83ee Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:03:50 +0100
Subject: Convert `brew outdated` test to spec.

---
 Library/Homebrew/test/cmd/outdated_spec.rb | 11 +++++++++++
 Library/Homebrew/test/outdated_test.rb     | 10 ----------
 2 files changed, 11 insertions(+), 10 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/outdated_spec.rb
 delete mode 100644 Library/Homebrew/test/outdated_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/outdated_spec.rb b/Library/Homebrew/test/cmd/outdated_spec.rb
new file mode 100644
index 000000000..2ce0825e8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/outdated_spec.rb
@@ -0,0 +1,11 @@
+describe "brew outdated", :integration_test do
+  it "prints outdated Formulae" do
+    setup_test_formula "testball"
+    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+    expect { brew "outdated" }
+      .to output("testball\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/outdated_test.rb b/Library/Homebrew/test/outdated_test.rb
deleted file mode 100644
index 3e7148ded..000000000
--- a/Library/Homebrew/test/outdated_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestOutdated < IntegrationCommandTestCase
-  def test_outdated
-    setup_test_formula "testball"
-    (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
-
-    assert_equal "testball", cmd("outdated")
-  end
-end
-- 
cgit v1.2.3


From c1f70cedcb76ee53b9c7dd056a7a0cab34654fbc Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:03:40 +0100
Subject: Convert `brew leaves` test to spec.

---
 Library/Homebrew/test/cmd/leaves_spec.rb | 23 +++++++++++++++++++++++
 Library/Homebrew/test/leaves_test.rb     | 15 ---------------
 2 files changed, 23 insertions(+), 15 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/leaves_spec.rb
 delete mode 100644 Library/Homebrew/test/leaves_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/leaves_spec.rb b/Library/Homebrew/test/cmd/leaves_spec.rb
new file mode 100644
index 000000000..cd93d7e3d
--- /dev/null
+++ b/Library/Homebrew/test/cmd/leaves_spec.rb
@@ -0,0 +1,23 @@
+describe "brew leaves", :integration_test do
+  it "prints all Formulae that are not dependencies of other Formulae" do
+    setup_test_formula "foo"
+    setup_test_formula "bar"
+
+    expect { brew "leaves" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+
+    (HOMEBREW_CELLAR/"foo/0.1/somedir").mkpath
+    expect { brew "leaves" }
+      .to output("foo\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    (HOMEBREW_CELLAR/"bar/0.1/somedir").mkpath
+    expect { brew "leaves" }
+      .to output("bar\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/leaves_test.rb b/Library/Homebrew/test/leaves_test.rb
deleted file mode 100644
index f73fba1ea..000000000
--- a/Library/Homebrew/test/leaves_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLeaves < IntegrationCommandTestCase
-  def test_leaves
-    setup_test_formula "foo"
-    setup_test_formula "bar"
-    assert_equal "", cmd("leaves")
-
-    (HOMEBREW_CELLAR/"foo/0.1/somedir").mkpath
-    assert_equal "foo", cmd("leaves")
-
-    (HOMEBREW_CELLAR/"bar/0.1/somedir").mkpath
-    assert_equal "bar", cmd("leaves")
-  end
-end
-- 
cgit v1.2.3


From ada6a1b09e04ed3ab6758adfb231bc31b332442c Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:03:33 +0100
Subject: Convert `brew link` test to spec.

---
 Library/Homebrew/test/cmd/link_spec.rb | 56 ++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/link_test.rb     | 23 --------------
 2 files changed, 56 insertions(+), 23 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/link_spec.rb
 delete mode 100644 Library/Homebrew/test/link_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/link_spec.rb b/Library/Homebrew/test/cmd/link_spec.rb
new file mode 100644
index 000000000..7b85c96dc
--- /dev/null
+++ b/Library/Homebrew/test/cmd/link_spec.rb
@@ -0,0 +1,56 @@
+describe "brew link", :integration_test do
+  it "fails when no argument is given" do
+    expect { brew "link" }
+      .to output(/This command requires a keg argument/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "does not fail if the given Formula is already linked" do
+    setup_test_formula "testball1"
+
+    shutup do
+      expect { brew "install", "testball1" }.to be_a_success
+      expect { brew "link", "testball1" }.to be_a_success
+    end
+  end
+
+  it "links a given Formula" do
+    setup_test_formula "testball1"
+
+    shutup do
+      expect { brew "install", "testball1" }.to be_a_success
+      expect { brew "unlink", "testball1" }.to be_a_success
+    end
+
+    expect { brew "link", "--dry-run", "testball1" }
+      .to output(/Would link/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "link", "--dry-run", "--overwrite", "testball1" }
+      .to output(/Would remove/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "link", "testball1" }
+      .to output(/Linking/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "refuses to link keg-only Formulae" do
+    setup_test_formula "testball1", <<-EOS.undent
+      keg_only "just because"
+    EOS
+
+    shutup do
+      expect { brew "install", "testball1" }.to be_a_success
+    end
+
+    expect { brew "link", "testball1" }
+      .to output(/testball1 is keg-only/).to_stderr
+      .and output(/Note that doing so can interfere with building software\./).to_stdout
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/link_test.rb b/Library/Homebrew/test/link_test.rb
deleted file mode 100644
index 062caa0c0..000000000
--- a/Library/Homebrew/test/link_test.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLink < IntegrationCommandTestCase
-  def test_link
-    assert_match "This command requires a keg argument", cmd_fail("link")
-
-    setup_test_formula "testball1"
-    cmd("install", "testball1")
-    cmd("link", "testball1")
-
-    cmd("unlink", "testball1")
-    assert_match "Would link", cmd("link", "--dry-run", "testball1")
-    assert_match "Would remove",
-      cmd("link", "--dry-run", "--overwrite", "testball1")
-    assert_match "Linking", cmd("link", "testball1")
-
-    setup_test_formula "testball2", <<-EOS.undent
-      keg_only "just because"
-    EOS
-    cmd("install", "testball2")
-    assert_match "testball2 is keg-only", cmd("link", "testball2")
-  end
-end
-- 
cgit v1.2.3


From 0458dce15b68fa4a48cae31555d28f5445e6d725 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:03:25 +0100
Subject: Convert `brew readall` test to spec.

---
 Library/Homebrew/test/cmd/readall_spec.rb | 20 ++++++++++++++++++++
 Library/Homebrew/test/readall_test.rb     | 12 ------------
 2 files changed, 20 insertions(+), 12 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/readall_spec.rb
 delete mode 100644 Library/Homebrew/test/readall_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/readall_spec.rb b/Library/Homebrew/test/cmd/readall_spec.rb
new file mode 100644
index 000000000..9165e0cb0
--- /dev/null
+++ b/Library/Homebrew/test/cmd/readall_spec.rb
@@ -0,0 +1,20 @@
+describe "brew readall", :integration_test do
+  it "imports all Formulae for a given Tap" do
+    formula_file = setup_test_formula "testball"
+
+    alias_file = CoreTap.new.alias_dir/"foobar"
+    alias_file.parent.mkpath
+
+    FileUtils.ln_s formula_file, alias_file
+
+    expect { brew "readall", "--aliases", "--syntax" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+
+    expect { brew "readall", "homebrew/core" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+  end
+end
diff --git a/Library/Homebrew/test/readall_test.rb b/Library/Homebrew/test/readall_test.rb
deleted file mode 100644
index 3eec79dd8..000000000
--- a/Library/Homebrew/test/readall_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReadall < IntegrationCommandTestCase
-  def test_readall
-    formula_file = setup_test_formula "testball"
-    alias_file = CoreTap.new.alias_dir/"foobar"
-    alias_file.parent.mkpath
-    FileUtils.ln_s formula_file, alias_file
-    cmd("readall", "--aliases", "--syntax")
-    cmd("readall", "homebrew/core")
-  end
-end
-- 
cgit v1.2.3


From b927bfc4c0727aa06b6c9a757aa26231da580798 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:03:16 +0100
Subject: Convert `brew prune` test to spec.

---
 Library/Homebrew/test/cmd/prune_spec.rb | 28 ++++++++++++++++++++++++++++
 Library/Homebrew/test/prune_test.rb     | 21 ---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/prune_spec.rb
 delete mode 100644 Library/Homebrew/test/prune_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/prune_spec.rb b/Library/Homebrew/test/cmd/prune_spec.rb
new file mode 100644
index 000000000..c5a9df70c
--- /dev/null
+++ b/Library/Homebrew/test/cmd/prune_spec.rb
@@ -0,0 +1,28 @@
+describe "brew prune", :integration_test do
+  it "removes empty directories and broken symlinks" do
+    share = (HOMEBREW_PREFIX/"share")
+
+    (share/"pruneable/directory/here").mkpath
+    (share/"notpruneable/file").write "I'm here"
+    FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink"
+
+    expect { brew "prune", "--dry-run" }
+      .to output(%r{Would remove \(empty directory\): .*/pruneable/directory/here}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "prune" }
+      .to output(/Pruned 1 symbolic links and 3 directories/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect(share/"pruneable").not_to be_a_directory
+    expect(share/"notpruneable").to be_a_directory
+    expect(share/"pruneable_symlink").not_to be_a_symlink
+
+    expect { brew "prune", "--verbose" }
+      .to output(/Nothing pruned/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/prune_test.rb b/Library/Homebrew/test/prune_test.rb
deleted file mode 100644
index 8fa5df7b7..000000000
--- a/Library/Homebrew/test/prune_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestPrune < IntegrationCommandTestCase
-  def test_prune
-    share = (HOMEBREW_PREFIX/"share")
-
-    (share/"pruneable/directory/here").mkpath
-    (share/"notpruneable/file").write "I'm here"
-    FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink"
-
-    assert_match %r{Would remove \(empty directory\): .*/pruneable/directory/here},
-      cmd("prune", "--dry-run")
-    assert_match "Pruned 1 symbolic links and 3 directories",
-      cmd("prune")
-    refute((share/"pruneable").directory?)
-    assert((share/"notpruneable").directory?)
-    refute((share/"pruneable_symlink").symlink?)
-
-    assert_match "Nothing pruned", cmd("prune", "--verbose")
-  end
-end
-- 
cgit v1.2.3


From a7f1dde24afaeacd2684c3746980111580d9fb26 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:03:08 +0100
Subject: Convert `brew tap` test to spec.

---
 Library/Homebrew/test/dev-cmd/tap_spec.rb | 75 +++++++++++++++++++++++++++++++
 Library/Homebrew/test/tap_test.rb         | 30 -------------
 2 files changed, 75 insertions(+), 30 deletions(-)
 create mode 100644 Library/Homebrew/test/dev-cmd/tap_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/dev-cmd/tap_spec.rb b/Library/Homebrew/test/dev-cmd/tap_spec.rb
new file mode 100644
index 000000000..a24c67aae
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/tap_spec.rb
@@ -0,0 +1,75 @@
+describe "brew tap", :integration_test do
+  it "taps a given Tap" do
+    path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
+    path.mkpath
+    path.cd do
+      shutup do
+        system "git", "init"
+        system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
+        FileUtils.touch "readme"
+        system "git", "add", "--all"
+        system "git", "commit", "-m", "init"
+      end
+    end
+
+    expect { brew "tap" }
+      .to output(%r{homebrew/foo}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap", "--list-official" }
+      .to output(%r{homebrew/science}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap-info" }
+      .to output(/2 taps/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap-info", "homebrew/foo" }
+      .to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap-info", "--json=v1", "--installed" }
+      .to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap-pin", "homebrew/foo" }
+      .to output(%r{Pinned homebrew/foo}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap", "--list-pinned" }
+      .to output(%r{homebrew/foo}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap-unpin", "homebrew/foo" }
+      .to output(%r{Unpinned homebrew/foo}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap", "homebrew/bar", path/".git" }
+      .to output(/Tapped/).to_stdout
+      .and output(/Cloning/).to_stderr
+      .and be_a_success
+
+    expect { brew "untap", "homebrew/bar" }
+      .to output(/Untapped/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "tap", "homebrew/bar", path/".git", "-q", "--full" }
+      .to be_a_success
+      .and not_to_output.to_stdout
+      .and not_to_output.to_stderr
+
+    expect { brew "untap", "homebrew/bar" }
+      .to output(/Untapped/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb
index 578326cea..729fc8198 100644
--- a/Library/Homebrew/test/tap_test.rb
+++ b/Library/Homebrew/test/tap_test.rb
@@ -1,34 +1,4 @@
 require "testing_env"
-require "testing_env"
-
-class IntegrationCommandTestTap < IntegrationCommandTestCase
-  def test_tap
-    path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
-    path.mkpath
-    path.cd do
-      shutup do
-        system "git", "init"
-        system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
-        FileUtils.touch "readme"
-        system "git", "add", "--all"
-        system "git", "commit", "-m", "init"
-      end
-    end
-
-    assert_match "homebrew/foo", cmd("tap")
-    assert_match "homebrew/science", cmd("tap", "--list-official")
-    assert_match "2 taps", cmd("tap-info")
-    assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo")
-    assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed")
-    assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo")
-    assert_match "homebrew/foo", cmd("tap", "--list-pinned")
-    assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo")
-    assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git")
-    assert_match "Untapped", cmd("untap", "homebrew/bar")
-    assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full")
-    assert_match "Untapped", cmd("untap", "homebrew/bar")
-  end
-end
 
 class TapTest < Homebrew::TestCase
   include FileUtils
-- 
cgit v1.2.3


From dc417042d50fca1305317375a58f4942cde73f6e Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:02:51 +0100
Subject: Convert `brew custom-external-command` test to spec.

---
 .../test/cmd/custom-external-command_spec.rb        | 21 +++++++++++++++++++++
 Library/Homebrew/test/custom_command_test.rb        | 18 ------------------
 2 files changed, 21 insertions(+), 18 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/custom-external-command_spec.rb
 delete mode 100644 Library/Homebrew/test/custom_command_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/custom-external-command_spec.rb b/Library/Homebrew/test/cmd/custom-external-command_spec.rb
new file mode 100644
index 000000000..8ccc21fa7
--- /dev/null
+++ b/Library/Homebrew/test/cmd/custom-external-command_spec.rb
@@ -0,0 +1,21 @@
+describe "brew custom-external-command", :integration_test do
+  it "is supported" do
+    Dir.mktmpdir do |path|
+      path = Pathname.new(path)
+
+      cmd = "custom-external-command-#{rand}"
+      file = path/"brew-#{cmd}"
+
+      file.write <<-EOS.undent
+        #!/bin/sh
+        echo 'I am #{cmd}.'
+      EOS
+      FileUtils.chmod "+x", file
+
+      expect { brew cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
+        .to output("I am #{cmd}.\n").to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+end
diff --git a/Library/Homebrew/test/custom_command_test.rb b/Library/Homebrew/test/custom_command_test.rb
deleted file mode 100644
index 8d05bc6c7..000000000
--- a/Library/Homebrew/test/custom_command_test.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCustomCommand < IntegrationCommandTestCase
-  def test_custom_command
-    mktmpdir do |path|
-      cmd = "int-test-#{rand}"
-      file = "#{path}/brew-#{cmd}"
-
-      File.open(file, "w") do |f|
-        f.write "#!/bin/sh\necho 'I am #{cmd}'\n"
-      end
-      FileUtils.chmod 0777, file
-
-      assert_match "I am #{cmd}",
-        cmd(cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}")
-    end
-  end
-end
-- 
cgit v1.2.3


From 0fa544313bd295bbfb2c2aa4788cfa565378c8c9 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:02:34 +0100
Subject: Convert `brew --version` test to spec.

---
 Library/Homebrew/test/cmd/--version_spec.rb | 8 ++++++++
 Library/Homebrew/test/version_test.rb       | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/--version_spec.rb
 delete mode 100644 Library/Homebrew/test/version_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/--version_spec.rb b/Library/Homebrew/test/cmd/--version_spec.rb
new file mode 100644
index 000000000..8992629d7
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--version_spec.rb
@@ -0,0 +1,8 @@
+describe "brew --version", :integration_test do
+  it "prints the Homebrew version" do
+    expect { brew "--version" }
+      .to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION.to_s)}\n/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/version_test.rb b/Library/Homebrew/test/version_test.rb
deleted file mode 100644
index e7ffbc4f6..000000000
--- a/Library/Homebrew/test/version_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestVersion < IntegrationCommandTestCase
-  def test_version
-    assert_match HOMEBREW_VERSION.to_s,
-                 cmd("--version")
-  end
-end
-- 
cgit v1.2.3


From 9818b82b1bf0142f9f64d3707587ea4684b94dcd Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:02:17 +0100
Subject: Convert `brew --repository` test to spec.

---
 Library/Homebrew/test/cmd/--repository_spec.rb | 15 +++++++++++++++
 Library/Homebrew/test/repository_test.rb       | 10 ----------
 2 files changed, 15 insertions(+), 10 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/--repository_spec.rb
 delete mode 100644 Library/Homebrew/test/repository_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/--repository_spec.rb b/Library/Homebrew/test/cmd/--repository_spec.rb
new file mode 100644
index 000000000..d3e531f7b
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--repository_spec.rb
@@ -0,0 +1,15 @@
+describe "brew --repository", :integration_test do
+  it "prints the path of the Homebrew repository" do
+    expect { brew "--repository" }
+      .to output("#{HOMEBREW_REPOSITORY}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "prints the path of a given Tap" do
+    expect { brew "--repository", "foo/bar" }
+      .to output("#{HOMEBREW_LIBRARY}/Taps/foo/homebrew-bar\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/repository_test.rb b/Library/Homebrew/test/repository_test.rb
deleted file mode 100644
index 77967a58d..000000000
--- a/Library/Homebrew/test/repository_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestRepository < IntegrationCommandTestCase
-  def test_repository
-    assert_match HOMEBREW_REPOSITORY.to_s,
-                 cmd("--repository")
-    assert_match "#{HOMEBREW_LIBRARY}/Taps/foo/homebrew-bar",
-                 cmd("--repository", "foo/bar")
-  end
-end
-- 
cgit v1.2.3


From 201f3abea033bf02b71de6ec907624a600309042 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:01:53 +0100
Subject: Convert `brew --prefix` test to spec.

---
 Library/Homebrew/test/cmd/--prefix_spec.rb   | 15 +++++++++++++++
 Library/Homebrew/test/prefix_formula_test.rb |  8 --------
 Library/Homebrew/test/prefix_test.rb         |  8 --------
 3 files changed, 15 insertions(+), 16 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/--prefix_spec.rb
 delete mode 100644 Library/Homebrew/test/prefix_formula_test.rb
 delete mode 100644 Library/Homebrew/test/prefix_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/--prefix_spec.rb b/Library/Homebrew/test/cmd/--prefix_spec.rb
new file mode 100644
index 000000000..80ef73a97
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--prefix_spec.rb
@@ -0,0 +1,15 @@
+describe "brew --prefix", :integration_test do
+  it "prints the Homebrew prefix when no argument is given" do
+    expect { brew "--prefix" }
+      .to output("#{HOMEBREW_PREFIX}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "prints a given Formula's prefix" do
+    expect { brew "--prefix", testball }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/prefix_formula_test.rb b/Library/Homebrew/test/prefix_formula_test.rb
deleted file mode 100644
index eb5970d3e..000000000
--- a/Library/Homebrew/test/prefix_formula_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestPrefixFormula < IntegrationCommandTestCase
-  def test_prefix_formula
-    assert_match "#{HOMEBREW_CELLAR}/testball",
-                 cmd("--prefix", testball)
-  end
-end
diff --git a/Library/Homebrew/test/prefix_test.rb b/Library/Homebrew/test/prefix_test.rb
deleted file mode 100644
index a3ae75542..000000000
--- a/Library/Homebrew/test/prefix_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestPrefix < IntegrationCommandTestCase
-  def test_prefix
-    assert_equal HOMEBREW_PREFIX.to_s,
-                 cmd("--prefix")
-  end
-end
-- 
cgit v1.2.3


From 540a1360d675332cf18f1e293a74c08490dd1cb0 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:01:43 +0100
Subject: Convert `brew config` test to spec.

---
 Library/Homebrew/test/cmd/config_spec.rb | 8 ++++++++
 Library/Homebrew/test/config_test.rb     | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/config_spec.rb
 delete mode 100644 Library/Homebrew/test/config_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/config_spec.rb b/Library/Homebrew/test/cmd/config_spec.rb
new file mode 100644
index 000000000..7687fcdc7
--- /dev/null
+++ b/Library/Homebrew/test/cmd/config_spec.rb
@@ -0,0 +1,8 @@
+describe "brew config", :integration_test do
+  it "prints information about the current Homebrew configuration" do
+    expect { brew "config" }
+      .to output(/HOMEBREW_VERSION: #{HOMEBREW_VERSION}/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/config_test.rb b/Library/Homebrew/test/config_test.rb
deleted file mode 100644
index 81da4660a..000000000
--- a/Library/Homebrew/test/config_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestConfig < IntegrationCommandTestCase
-  def test_config
-    assert_match "HOMEBREW_VERSION: #{HOMEBREW_VERSION}",
-                 cmd("config")
-  end
-end
-- 
cgit v1.2.3


From f4fb0615de48b239555a891dc04e278341ce1c48 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:01:35 +0100
Subject: Convert `brew commands` test to spec.

---
 Library/Homebrew/test/cmd/commands_spec.rb | 7 +++++++
 Library/Homebrew/test/commands_test.rb     | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/commands_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/commands_spec.rb b/Library/Homebrew/test/cmd/commands_spec.rb
new file mode 100644
index 000000000..f42072956
--- /dev/null
+++ b/Library/Homebrew/test/cmd/commands_spec.rb
@@ -0,0 +1,7 @@
+describe "brew commands", :integration_test do
+  it "prints a list of all available commands" do
+    expect { brew "commands" }
+      .to output(/Built-in commands/).to_stdout
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb
index 5f5dc9586..da88ee2d5 100644
--- a/Library/Homebrew/test/commands_test.rb
+++ b/Library/Homebrew/test/commands_test.rb
@@ -4,13 +4,6 @@ require "cmd/commands"
 require "fileutils"
 require "testing_env"
 
-class IntegrationCommandTestCommands < IntegrationCommandTestCase
-  def test_commands
-    assert_match "Built-in commands",
-                 cmd("commands")
-  end
-end
-
 class CommandsTests < Homebrew::TestCase
   def setup
     super
-- 
cgit v1.2.3


From 36d36b5334abc978157cddf599615893ebb44d74 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:01:23 +0100
Subject: Convert `brew command` test to spec.

---
 Library/Homebrew/test/cmd/command_spec.rb | 13 +++++++++++++
 Library/Homebrew/test/command_test.rb     | 11 -----------
 2 files changed, 13 insertions(+), 11 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/command_spec.rb
 delete mode 100644 Library/Homebrew/test/command_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/command_spec.rb b/Library/Homebrew/test/cmd/command_spec.rb
new file mode 100644
index 000000000..5d6a67b70
--- /dev/null
+++ b/Library/Homebrew/test/cmd/command_spec.rb
@@ -0,0 +1,13 @@
+describe "brew command", :integration_test do
+  it "returns the file for a given command" do
+    expect { brew "command", "info" }
+      .to output(%r{#{Regexp.escape(HOMEBREW_LIBRARY_PATH)}/cmd/info.rb}).to_stdout
+      .and be_a_success
+  end
+
+  it "fails when the given command is unknown" do
+    expect { brew "command", "does-not-exist" }
+      .to output(/Unknown command/).to_stderr
+      .and be_a_failure
+  end
+end
diff --git a/Library/Homebrew/test/command_test.rb b/Library/Homebrew/test/command_test.rb
deleted file mode 100644
index d5c7aaa88..000000000
--- a/Library/Homebrew/test/command_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCommand < IntegrationCommandTestCase
-  def test_command
-    assert_equal "#{HOMEBREW_LIBRARY_PATH}/cmd/info.rb",
-                 cmd("command", "info")
-
-    assert_match "Unknown command",
-                 cmd_fail("command", "I-don't-exist")
-  end
-end
-- 
cgit v1.2.3


From 17dca9b4d5bca04951e622a42fc8206e08ae9dfc Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:01:13 +0100
Subject: Convert `brew pull` test to spec.

---
 Library/Homebrew/test/dev-cmd/pull_spec.rb | 60 ++++++++++++++++++++++++++++++
 Library/Homebrew/test/pull_offline_test.rb | 10 -----
 Library/Homebrew/test/pull_test.rb         | 27 --------------
 3 files changed, 60 insertions(+), 37 deletions(-)
 create mode 100644 Library/Homebrew/test/dev-cmd/pull_spec.rb
 delete mode 100644 Library/Homebrew/test/pull_offline_test.rb
 delete mode 100644 Library/Homebrew/test/pull_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/dev-cmd/pull_spec.rb b/Library/Homebrew/test/dev-cmd/pull_spec.rb
new file mode 100644
index 000000000..3c0108df2
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/pull_spec.rb
@@ -0,0 +1,60 @@
+describe "brew pull", :integration_test do
+  it "fails when no argument is given" do
+    expect { brew "pull" }
+      .to output(/This command requires at least one argument/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+
+  it "fetches a patch from a GitHub commit or pull request and applies it" do
+    skip "Requires network connection." if ENV["HOMEBREW_NO_GITHUB_API"]
+
+    CoreTap.instance.path.cd do
+      shutup do
+        system "git", "init"
+        system "git", "checkout", "-b", "new-branch"
+      end
+    end
+
+    expect { brew "pull", "https://bot.brew.sh/job/Homebrew\%20Testing/1028/" }
+      .to output(/Testing URLs require `\-\-bottle`!/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "pull", "1" }
+      .to output(/Fetching patch/).to_stdout
+      .and output(/Current branch is new\-branch/).to_stderr
+      .and be_a_failure
+
+    expect { brew "pull", "--bump", "8" }
+      .to output(/Fetching patch/).to_stdout
+      .and output(/No changed formulae found to bump/).to_stderr
+      .and be_a_failure
+
+    expect { brew "pull", "--bump", "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122" }
+      .to output(/Fetching patch/).to_stdout
+      .and output(/Can only bump one changed formula/).to_stderr
+      .and be_a_failure
+
+    expect { brew "pull", "https://github.com/Homebrew/homebrew-core/pull/1" }
+      .to output(/Fetching patch/).to_stdout
+      .and output(/Patch failed to apply/).to_stderr
+      .and be_a_failure
+  end
+
+  describe "--rebase" do
+    it "fails" do
+      expect { brew "pull", "--rebase" }
+        .to output(/You meant `git pull --rebase`./).to_stderr
+        .and not_to_output.to_stdout
+        .and be_a_failure
+    end
+  end
+
+  it "fails when given 0" do
+    expect { brew "pull", "0" }
+      .to output(/Not a GitHub pull request or commit/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+  end
+end
diff --git a/Library/Homebrew/test/pull_offline_test.rb b/Library/Homebrew/test/pull_offline_test.rb
deleted file mode 100644
index c9d46cd74..000000000
--- a/Library/Homebrew/test/pull_offline_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestPullOffline < IntegrationCommandTestCase
-  def test_pull_offline
-    assert_match "You meant `git pull --rebase`.", cmd_fail("pull", "--rebase")
-    assert_match "This command requires at least one argument", cmd_fail("pull")
-    assert_match "Not a GitHub pull request or commit",
-      cmd_fail("pull", "0")
-  end
-end
diff --git a/Library/Homebrew/test/pull_test.rb b/Library/Homebrew/test/pull_test.rb
deleted file mode 100644
index 445d73cb1..000000000
--- a/Library/Homebrew/test/pull_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestPull < IntegrationCommandTestCase
-  def test_pull
-    skip "Requires network connection" if ENV["HOMEBREW_NO_GITHUB_API"]
-
-    core_tap = CoreTap.new
-    core_tap.path.cd do
-      shutup do
-        system "git", "init"
-        system "git", "checkout", "-b", "new-branch"
-      end
-    end
-
-    assert_match "Testing URLs require `--bottle`!",
-      cmd_fail("pull", "https://bot.brew.sh/job/Homebrew\%20Testing/1028/")
-    assert_match "Current branch is new-branch",
-      cmd_fail("pull", "1")
-    assert_match "No changed formulae found to bump",
-      cmd_fail("pull", "--bump", "8")
-    assert_match "Can only bump one changed formula",
-      cmd_fail("pull", "--bump",
-        "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122")
-    assert_match "Patch failed to apply",
-      cmd_fail("pull", "https://github.com/Homebrew/homebrew-core/pull/1")
-  end
-end
-- 
cgit v1.2.3


From a3b2ae1fa12216200bd6399269f20d0a420aca49 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:01:02 +0100
Subject: Convert `brew formula` test to spec.

---
 Library/Homebrew/test/dev-cmd/formula_spec.rb | 10 ++++++++++
 Library/Homebrew/test/formula_cmd_test.rb     |  8 --------
 2 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 Library/Homebrew/test/dev-cmd/formula_spec.rb
 delete mode 100644 Library/Homebrew/test/formula_cmd_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/dev-cmd/formula_spec.rb b/Library/Homebrew/test/dev-cmd/formula_spec.rb
new file mode 100644
index 000000000..cc5b3e9e8
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/formula_spec.rb
@@ -0,0 +1,10 @@
+describe "brew formula", :integration_test do
+  it "prints a given Formula's path" do
+    formula_file = setup_test_formula "testball"
+
+    expect { brew "formula", "testball" }
+      .to output("#{formula_file}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/formula_cmd_test.rb b/Library/Homebrew/test/formula_cmd_test.rb
deleted file mode 100644
index abbe42d98..000000000
--- a/Library/Homebrew/test/formula_cmd_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestFormula < IntegrationCommandTestCase
-  def test_formula
-    formula_file = setup_test_formula "testball"
-    assert_equal formula_file.to_s, cmd("formula", "testball")
-  end
-end
-- 
cgit v1.2.3


From bdbb74816902e8318f0d5231d9fb81234d361e90 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:00:54 +0100
Subject: Convert `brew edit` test to spec.

---
 Library/Homebrew/test/dev-cmd/edit_spec.rb | 16 ++++++++++++++++
 Library/Homebrew/test/edit_test.rb         | 11 -----------
 2 files changed, 16 insertions(+), 11 deletions(-)
 create mode 100644 Library/Homebrew/test/dev-cmd/edit_spec.rb
 delete mode 100644 Library/Homebrew/test/edit_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/dev-cmd/edit_spec.rb b/Library/Homebrew/test/dev-cmd/edit_spec.rb
new file mode 100644
index 000000000..5cedb0524
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/edit_spec.rb
@@ -0,0 +1,16 @@
+describe "brew edit", :integration_test do
+  it "opens a given Formula in an editor" do
+    HOMEBREW_REPOSITORY.cd do
+      shutup do
+        system "git", "init"
+      end
+    end
+
+    setup_test_formula "testball"
+
+    expect { brew "edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat" }
+      .to output(/# something here/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
diff --git a/Library/Homebrew/test/edit_test.rb b/Library/Homebrew/test/edit_test.rb
deleted file mode 100644
index 9b6ded651..000000000
--- a/Library/Homebrew/test/edit_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestEdit < IntegrationCommandTestCase
-  def test_edit
-    (HOMEBREW_REPOSITORY/".git").mkpath
-    setup_test_formula "testball"
-
-    assert_match "# something here",
-                 cmd("edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat")
-  end
-end
-- 
cgit v1.2.3


From 7f8cd184936e3419a5bf960121f76098505d6811 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:00:46 +0100
Subject: Convert `brew create` test to spec.

---
 Library/Homebrew/test/create_test.rb         | 12 ------------
 Library/Homebrew/test/dev-cmd/create_spec.rb | 13 +++++++++++++
 2 files changed, 13 insertions(+), 12 deletions(-)
 delete mode 100644 Library/Homebrew/test/create_test.rb
 create mode 100644 Library/Homebrew/test/dev-cmd/create_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/create_test.rb b/Library/Homebrew/test/create_test.rb
deleted file mode 100644
index aeee428aa..000000000
--- a/Library/Homebrew/test/create_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCreate < IntegrationCommandTestCase
-  def test_create
-    url = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
-    cmd("create", url, "HOMEBREW_EDITOR" => "/bin/cat")
-
-    formula_file = CoreTap.new.formula_dir/"testball.rb"
-    assert formula_file.exist?, "The formula source should have been created"
-    assert_match %Q(sha256 "#{TESTBALL_SHA256}"), formula_file.read
-  end
-end
diff --git a/Library/Homebrew/test/dev-cmd/create_spec.rb b/Library/Homebrew/test/dev-cmd/create_spec.rb
new file mode 100644
index 000000000..b7f96ec7f
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/create_spec.rb
@@ -0,0 +1,13 @@
+describe "brew create", :integration_test do
+  let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
+  let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" }
+
+  it "creates a new Formula file for a given URL" do
+    shutup do
+      brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
+    end
+
+    expect(formula_file).to exist
+    expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}"))
+  end
+end
-- 
cgit v1.2.3


From d9b2974e02e4fce3d265f4b279c6d250bb46daf6 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:00:23 +0100
Subject: Convert `brew --env` test to spec.

---
 Library/Homebrew/test/ENV_test.rb       | 27 --------------------
 Library/Homebrew/test/cmd/--env_spec.rb | 44 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 27 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/--env_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb
index cbfd01e25..66b59d8a4 100644
--- a/Library/Homebrew/test/ENV_test.rb
+++ b/Library/Homebrew/test/ENV_test.rb
@@ -2,33 +2,6 @@ require "testing_env"
 require "extend/ENV"
 require "testing_env"
 
-class IntegrationCommandTestEnv < IntegrationCommandTestCase
-  def test_env
-    assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/,
-                 cmd("--env"))
-  end
-
-  def test_env_fish
-    assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/,
-                 cmd("--env", "--shell=fish"))
-  end
-
-  def test_env_csh
-    assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/,
-                 cmd("--env", "--shell=tcsh"))
-  end
-
-  def test_env_bash
-    assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/,
-                 cmd("--env", "--shell=bash"))
-  end
-
-  def test_env_plain
-    assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/,
-                 cmd("--env", "--plain"))
-  end
-end
-
 module SharedEnvTests
   def setup
     super
diff --git a/Library/Homebrew/test/cmd/--env_spec.rb b/Library/Homebrew/test/cmd/--env_spec.rb
new file mode 100644
index 000000000..7dd84132a
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--env_spec.rb
@@ -0,0 +1,44 @@
+describe "brew --env", :integration_test do
+  it "prints the Homebrew build environment variables" do
+    expect { brew "--env" }
+      .to output(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  describe "--shell=bash" do
+    it "prints the Homebrew build environment variables in Bash syntax" do
+      expect { brew "--env", "--shell=bash" }
+        .to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+
+  describe "--shell=fish" do
+    it "prints the Homebrew build environment variables in Fish syntax" do
+      expect { brew "--env", "--shell=fish" }
+        .to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+
+  describe "--shell=tcsh" do
+    it "prints the Homebrew build environment variables in Tcsh syntax" do
+      expect { brew "--env", "--shell=tcsh" }
+        .to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+
+  describe "--plain" do
+    it "prints the Homebrew build environment variables without quotes" do
+      expect { brew "--env", "--plain" }
+        .to output(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+end
-- 
cgit v1.2.3


From e7190b9ae2ec39c98e9eb05e33edd1098f8f9085 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:00:11 +0100
Subject: Convert `brew cleanup` test to spec.

---
 Library/Homebrew/test/cleanup_test.rb     |  7 -------
 Library/Homebrew/test/cmd/cleanup_spec.rb | 12 ++++++++++++
 2 files changed, 12 insertions(+), 7 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/cleanup_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb
index e6fc31dfe..bc7a6713c 100644
--- a/Library/Homebrew/test/cleanup_test.rb
+++ b/Library/Homebrew/test/cleanup_test.rb
@@ -5,13 +5,6 @@ require "fileutils"
 require "pathname"
 require "testing_env"
 
-class IntegrationCommandTestCleanup < IntegrationCommandTestCase
-  def test_cleanup
-    (HOMEBREW_CACHE/"test").write "test"
-    assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all")
-  end
-end
-
 class CleanupTests < Homebrew::TestCase
   def setup
     super
diff --git a/Library/Homebrew/test/cmd/cleanup_spec.rb b/Library/Homebrew/test/cmd/cleanup_spec.rb
new file mode 100644
index 000000000..9e2cf493f
--- /dev/null
+++ b/Library/Homebrew/test/cmd/cleanup_spec.rb
@@ -0,0 +1,12 @@
+describe "brew cleanup", :integration_test do
+  describe "--prune=all" do
+    it "removes all files in Homebrew's cache" do
+      (HOMEBREW_CACHE/"test").write "test"
+
+      expect { brew "cleanup", "--prune=all" }
+        .to output(%r{#{Regexp.escape(HOMEBREW_CACHE)}/test}).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    end
+  end
+end
-- 
cgit v1.2.3


From d914c41b9d05fd1c010ea26d43559e9961d6e95a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:00:01 +0100
Subject: Convert `brew cat` test to spec.

---
 Library/Homebrew/test/cat_test.rb     |  8 --------
 Library/Homebrew/test/cmd/cat_spec.rb | 11 +++++++++++
 2 files changed, 11 insertions(+), 8 deletions(-)
 delete mode 100644 Library/Homebrew/test/cat_test.rb
 create mode 100644 Library/Homebrew/test/cmd/cat_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cat_test.rb b/Library/Homebrew/test/cat_test.rb
deleted file mode 100644
index bb37b5fde..000000000
--- a/Library/Homebrew/test/cat_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCat < IntegrationCommandTestCase
-  def test_cat
-    formula_file = setup_test_formula "testball"
-    assert_equal formula_file.read.chomp, cmd("cat", "testball")
-  end
-end
diff --git a/Library/Homebrew/test/cmd/cat_spec.rb b/Library/Homebrew/test/cmd/cat_spec.rb
new file mode 100644
index 000000000..8c230abee
--- /dev/null
+++ b/Library/Homebrew/test/cmd/cat_spec.rb
@@ -0,0 +1,11 @@
+describe "brew cat", :integration_test do
+  it "prints the content of a given Formula" do
+    formula_file = setup_test_formula "testball"
+    content = formula_file.read
+
+    expect { brew "cat", "testball" }
+      .to output(content).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
-- 
cgit v1.2.3


From bf2a03086d77fe34c771a9e2b846a43c467a45b0 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 05:59:55 +0100
Subject: Convert `brew cask` test to spec.

---
 Library/Homebrew/test/cask_test.rb     | 10 ----------
 Library/Homebrew/test/cmd/cask_spec.rb |  8 ++++++++
 2 files changed, 8 insertions(+), 10 deletions(-)
 delete mode 100644 Library/Homebrew/test/cask_test.rb
 create mode 100644 Library/Homebrew/test/cmd/cask_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cask_test.rb b/Library/Homebrew/test/cask_test.rb
deleted file mode 100644
index d5b81facb..000000000
--- a/Library/Homebrew/test/cask_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCask < IntegrationCommandTestCase
-  def test_cask
-    needs_test_cmd_taps
-    needs_macos
-    setup_remote_tap("caskroom/cask")
-    cmd("cask", "list", "--caskroom=#{HOMEBREW_PREFIX}/Caskroom")
-  end
-end
diff --git a/Library/Homebrew/test/cmd/cask_spec.rb b/Library/Homebrew/test/cmd/cask_spec.rb
new file mode 100644
index 000000000..e46843cab
--- /dev/null
+++ b/Library/Homebrew/test/cmd/cask_spec.rb
@@ -0,0 +1,8 @@
+describe "brew cask", :integration_test, :needs_macos, :needs_official_cmd_taps do
+  describe "list" do
+    it "returns a list of installed Casks" do
+      setup_remote_tap("caskroom/cask")
+      expect { brew "cask", "list" }.to be_a_success
+    end
+  end
+end
-- 
cgit v1.2.3


From eeee7127b53eb01fd2cd9d959b3fa9d6743d6af1 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 05:59:26 +0100
Subject: Convert `brew --cellar` test to spec.

---
 Library/Homebrew/test/cellar_formula_test.rb |  8 --------
 Library/Homebrew/test/cellar_test.rb         |  8 --------
 Library/Homebrew/test/cmd/--cellar_spec.rb   | 15 +++++++++++++++
 3 files changed, 15 insertions(+), 16 deletions(-)
 delete mode 100644 Library/Homebrew/test/cellar_formula_test.rb
 delete mode 100644 Library/Homebrew/test/cellar_test.rb
 create mode 100644 Library/Homebrew/test/cmd/--cellar_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cellar_formula_test.rb b/Library/Homebrew/test/cellar_formula_test.rb
deleted file mode 100644
index 38a934a7b..000000000
--- a/Library/Homebrew/test/cellar_formula_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCellarFormula < IntegrationCommandTestCase
-  def test_cellar_formula
-    assert_match "#{HOMEBREW_CELLAR}/testball",
-                 cmd("--cellar", testball)
-  end
-end
diff --git a/Library/Homebrew/test/cellar_test.rb b/Library/Homebrew/test/cellar_test.rb
deleted file mode 100644
index 74d5389f8..000000000
--- a/Library/Homebrew/test/cellar_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCellar < IntegrationCommandTestCase
-  def test_cellar
-    assert_equal HOMEBREW_CELLAR.to_s,
-                 cmd("--cellar")
-  end
-end
diff --git a/Library/Homebrew/test/cmd/--cellar_spec.rb b/Library/Homebrew/test/cmd/--cellar_spec.rb
new file mode 100644
index 000000000..6c8d7dea6
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--cellar_spec.rb
@@ -0,0 +1,15 @@
+describe "brew --cellar", :integration_test do
+  it "print the location of Homebrew's Cellar when no argument is given" do
+    expect { brew "--cellar" }
+      .to output("#{HOMEBREW_CELLAR}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "returns the Cellar subdirectory for a given Formula" do
+    expect { brew "--cellar", testball }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
-- 
cgit v1.2.3


From 2bdeb8d0523ee2a2576026c309d342bcb9ef08c9 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 05:59:16 +0100
Subject: Convert `brew --cache` test to spec.

---
 Library/Homebrew/test/cache_formula_test.rb |  8 --------
 Library/Homebrew/test/cache_test.rb         |  8 --------
 Library/Homebrew/test/cmd/--cache_spec.rb   | 15 +++++++++++++++
 3 files changed, 15 insertions(+), 16 deletions(-)
 delete mode 100644 Library/Homebrew/test/cache_formula_test.rb
 delete mode 100644 Library/Homebrew/test/cache_test.rb
 create mode 100644 Library/Homebrew/test/cmd/--cache_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cache_formula_test.rb b/Library/Homebrew/test/cache_formula_test.rb
deleted file mode 100644
index 6dcb6a745..000000000
--- a/Library/Homebrew/test/cache_formula_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCacheFormula < IntegrationCommandTestCase
-  def test_cache_formula
-    assert_match %r{#{HOMEBREW_CACHE}/testball-},
-                 cmd("--cache", testball)
-  end
-end
diff --git a/Library/Homebrew/test/cache_test.rb b/Library/Homebrew/test/cache_test.rb
deleted file mode 100644
index 3a9e6b011..000000000
--- a/Library/Homebrew/test/cache_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCache < IntegrationCommandTestCase
-  def test_cache
-    assert_equal HOMEBREW_CACHE.to_s,
-                 cmd("--cache")
-  end
-end
diff --git a/Library/Homebrew/test/cmd/--cache_spec.rb b/Library/Homebrew/test/cmd/--cache_spec.rb
new file mode 100644
index 000000000..fb3c9cee6
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--cache_spec.rb
@@ -0,0 +1,15 @@
+describe "brew --cache", :integration_test do
+  it "print the location of Homebrew's cache when no argument is given" do
+    expect { brew "--cache" }
+      .to output("#{HOMEBREW_CACHE}\n").to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "prints all cache files for a given Formula" do
+    expect { brew "--cache", testball }
+      .to output(%r{#{HOMEBREW_CACHE}/testball-}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+end
-- 
cgit v1.2.3


From b54ba26dde9aad5c1b5fe4f8f1254ed33c100f7a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 05:59:04 +0100
Subject: Convert `brew bundle` test to spec.

---
 Library/Homebrew/test/bundle_test.rb     | 22 ----------------------
 Library/Homebrew/test/cmd/bundle_spec.rb | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 22 deletions(-)
 delete mode 100644 Library/Homebrew/test/bundle_test.rb
 create mode 100644 Library/Homebrew/test/cmd/bundle_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/bundle_test.rb b/Library/Homebrew/test/bundle_test.rb
deleted file mode 100644
index ae47977d8..000000000
--- a/Library/Homebrew/test/bundle_test.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestBundle < IntegrationCommandTestCase
-  def test_bundle
-    needs_test_cmd_taps
-    setup_remote_tap("homebrew/bundle")
-    HOMEBREW_REPOSITORY.cd do
-      shutup do
-        system "git", "init"
-        system "git", "commit", "--allow-empty", "-m", "This is a test commit"
-      end
-    end
-
-    mktmpdir do |path|
-      FileUtils.touch "#{path}/Brewfile"
-      Dir.chdir path do
-        assert_equal "The Brewfile's dependencies are satisfied.",
-          cmd("bundle", "check")
-      end
-    end
-  end
-end
diff --git a/Library/Homebrew/test/cmd/bundle_spec.rb b/Library/Homebrew/test/cmd/bundle_spec.rb
new file mode 100644
index 000000000..755f9ab3d
--- /dev/null
+++ b/Library/Homebrew/test/cmd/bundle_spec.rb
@@ -0,0 +1,24 @@
+describe "brew bundle", :integration_test, :needs_test_cmd_taps do
+  describe "check" do
+    it "checks if a Brewfile's dependencies are satisfied" do
+      setup_remote_tap "homebrew/bundle"
+
+      HOMEBREW_REPOSITORY.cd do
+        shutup do
+          system "git", "init"
+          system "git", "commit", "--allow-empty", "-m", "This is a test commit"
+        end
+      end
+
+      Dir.mktmpdir do |path|
+        FileUtils.touch "#{path}/Brewfile"
+        Dir.chdir path do
+          expect { brew "bundle", "check" }
+            .to output("The Brewfile's dependencies are satisfied.\n").to_stdout
+            .and not_to_output.to_stderr
+            .and be_a_success
+        end
+      end
+    end
+  end
+end
-- 
cgit v1.2.3


From 4e1516ce2c278a654bb192933eadaab1625affb7 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 05:58:30 +0100
Subject: Convert `brew bottle` test to spec.

---
 Library/Homebrew/test/bottle_test.rb         | 21 -------------------
 Library/Homebrew/test/dev-cmd/bottle_spec.rb | 30 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 21 deletions(-)
 delete mode 100644 Library/Homebrew/test/bottle_test.rb
 create mode 100644 Library/Homebrew/test/dev-cmd/bottle_spec.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/bottle_test.rb b/Library/Homebrew/test/bottle_test.rb
deleted file mode 100644
index 7981ccf79..000000000
--- a/Library/Homebrew/test/bottle_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestBottle < IntegrationCommandTestCase
-  def test_bottle
-    cmd("install", "--build-bottle", testball)
-    assert_match "Formula not from core or any taps",
-                 cmd_fail("bottle", "--no-rebuild", testball)
-
-    setup_test_formula "testball"
-
-    # `brew bottle` should not fail with dead symlink
-    # https://github.com/Homebrew/legacy-homebrew/issues/49007
-    (HOMEBREW_CELLAR/"testball/0.1").cd do
-      FileUtils.ln_s "not-exist", "symlink"
-    end
-    assert_match(/testball-0\.1.*\.bottle\.tar\.gz/,
-                  cmd("bottle", "--no-rebuild", "testball"))
-  ensure
-    FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"]
-  end
-end
diff --git a/Library/Homebrew/test/dev-cmd/bottle_spec.rb b/Library/Homebrew/test/dev-cmd/bottle_spec.rb
new file mode 100644
index 000000000..468ef2e90
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/bottle_spec.rb
@@ -0,0 +1,30 @@
+describe "brew bottle", :integration_test do
+  it "builds a bottle for the given Formula" do
+    begin
+      shutup do
+        expect { brew "install", "--build-bottle", testball }
+          .to be_a_success
+      end
+
+      expect { brew "bottle", "--no-rebuild", testball }
+        .to output(/Formula not from core or any taps/).to_stderr
+        .and not_to_output.to_stdout
+        .and be_a_failure
+
+      setup_test_formula "testball"
+
+      # `brew bottle` should not fail with dead symlink
+      # https://github.com/Homebrew/legacy-homebrew/issues/49007
+      (HOMEBREW_CELLAR/"testball/0.1").cd do
+        FileUtils.ln_s "not-exist", "symlink"
+      end
+
+      expect { brew "bottle", "--no-rebuild", "testball" }
+        .to output(/testball-0\.1.*\.bottle\.tar\.gz/).to_stdout
+        .and not_to_output.to_stderr
+        .and be_a_success
+    ensure
+      FileUtils.rm_f Dir.glob("testball-0.1*.bottle.tar.gz")
+    end
+  end
+end
-- 
cgit v1.2.3


From b984be675ddd07ccbf7151355a22096de47c5c50 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Fri, 24 Feb 2017 08:45:39 +0000
Subject: audit: use using for HTTPS detection.

---
 Library/Homebrew/dev-cmd/audit.rb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 65b109f3b..cf5bdcdc4 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1527,9 +1527,10 @@ class ResourceAuditor
 
     return unless @online
     urls.each do |url|
-      strategy = DownloadStrategyDetector.detect(url)
+      next if !@strict && mirrors.include?(url)
+
+      strategy = DownloadStrategyDetector.detect(url, using)
       if strategy <= CurlDownloadStrategy && !url.start_with?("file")
-        next if !@strict && mirrors.include?(url)
         if http_content_problem = FormulaAuditor.check_http_content(url)
           problem http_content_problem
         end
-- 
cgit v1.2.3


From 1284f29561d944e069d201db9043489417b85ff4 Mon Sep 17 00:00:00 2001
From: Mike McQuaid
Date: Fri, 24 Feb 2017 08:51:15 +0000
Subject: audit: don't try to HTTP check non-HTTP content.

---
 Library/Homebrew/dev-cmd/audit.rb   | 2 ++
 Library/Homebrew/test/audit_test.rb | 5 ++---
 2 files changed, 4 insertions(+), 3 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index cf5bdcdc4..e49f65dd2 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -175,6 +175,8 @@ class FormulaAuditor
   end
 
   def self.check_http_content(url, user_agents: [:default])
+    return unless url.start_with? "http"
+
     details = nil
     user_agent = nil
     user_agents.each do |ua|
diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb
index 9165edef1..1d93c31e0 100644
--- a/Library/Homebrew/test/audit_test.rb
+++ b/Library/Homebrew/test/audit_test.rb
@@ -419,9 +419,8 @@ class FormulaAuditorTests < Homebrew::TestCase
     EOS
 
     fa.audit_homepage
-    assert_equal ["The homepage should start with http or https " \
-      "(URL is #{fa.formula.homepage}).", "The homepage #{fa.formula.homepage} is not reachable " \
-      "(HTTP status code 000)"], fa.problems
+    assert_equal ["The homepage should start with http or https (URL is #{fa.formula.homepage})."],
+      fa.problems
 
     formula_homepages = {
       "bar" => "http://www.freedesktop.org/wiki/bar",
-- 
cgit v1.2.3


From ed72e02bbadaf2164bf359bf7e8eac9ffcbd0b9e Mon Sep 17 00:00:00 2001
From: Joshua Liu
Date: Fri, 24 Feb 2017 17:21:50 -0500
Subject: Change deps_spec expect ordering

---
 Library/Homebrew/test/deps_spec.rb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/deps_spec.rb b/Library/Homebrew/test/deps_spec.rb
index c83577716..4c892c93d 100644
--- a/Library/Homebrew/test/deps_spec.rb
+++ b/Library/Homebrew/test/deps_spec.rb
@@ -10,22 +10,22 @@ describe "brew deps", :integration_test do
 
   it "outputs no dependencies for a Formula that has no dependencies" do
     expect { brew "deps", "foo" }
-      .to output("").to_stdout
+      .to be_a_success
+      .and not_to_output.to_stdout
       .and not_to_output.to_stderr
-      .and be_a_success
   end
 
   it "outputs a dependency for a Formula that has one dependency" do
     expect { brew "deps", "bar" }
-      .to output("foo\n").to_stdout
+      .to be_a_success
+      .and output("foo\n").to_stdout
       .and not_to_output.to_stderr
-      .and be_a_success
   end
 
   it "outputs all of a Formula's dependencies and their dependencies on separate lines" do
     expect { brew "deps", "baz" }
-      .to output("bar\nfoo\n").to_stdout
+      .to be_a_success
+      .and output("bar\nfoo\n").to_stdout
       .and not_to_output.to_stderr
-      .and be_a_success
   end
 end
-- 
cgit v1.2.3


From a2b4ee1ecd9ac5c91f9b5b3a6710f926cc237d15 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Thu, 23 Feb 2017 06:06:02 +0100
Subject: Convert `brew install` test to spec.

---
 Library/Homebrew/test/cmd/install_spec.rb | 243 ++++++++++++++++++++++++++++++
 Library/Homebrew/test/install_test.rb     | 136 -----------------
 2 files changed, 243 insertions(+), 136 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/install_spec.rb
 delete mode 100644 Library/Homebrew/test/install_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb
new file mode 100644
index 000000000..e5b5ec631
--- /dev/null
+++ b/Library/Homebrew/test/cmd/install_spec.rb
@@ -0,0 +1,243 @@
+describe "brew install", :integration_test do
+  it "installs Formulae" do
+    setup_test_formula "testball1"
+
+    expect { brew "install", "testball1", "--head" }
+      .to output(/Specify `\-\-HEAD`/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "install", "testball1", "--HEAD" }
+      .to output(/No head is defined/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "install", "testball1", "--devel" }
+      .to output(/No devel block/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "install", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+
+    expect { brew "install", "testball1" }
+      .to output(/testball1\-0\.1 already installed/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_success
+
+    expect { brew "install", "macruby" }
+      .to output(/MacRuby is not packaged/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "install", "formula" }
+      .to output(/No available formula/).to_stderr
+      .and output(/Searching for similarly named formulae/).to_stdout
+      .and be_a_failure
+
+    expect { brew "install", "testball" }
+      .to output(/This similarly named formula was found/).to_stdout
+      .and output(/No available formula/).to_stderr
+      .and be_a_failure
+
+    setup_test_formula "testball2"
+    expect { brew "install", "testball" }
+      .to output(/These similarly named formulae were found/).to_stdout
+      .and output(/No available formula/).to_stderr
+      .and be_a_failure
+
+    install_and_rename_coretap_formula "testball1", "testball2"
+    expect { brew "install", "testball2" }
+      .to output(/testball1 already installed, it's just not migrated/).to_stderr
+      .and output(/You can migrate formula with `brew migrate testball2`/).to_stdout
+      .and be_a_success
+  end
+
+  specify "install failures" do
+    path = setup_test_formula "testball1", <<-EOS.undent
+      version "1.0"
+    EOS
+
+    expect { brew "install", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+
+    FileUtils.rm path
+    setup_test_formula "testball1", <<-EOS.undent
+      version "2.0"
+
+      devel do
+        url "#{Formulary.factory("testball1").stable.url}"
+        sha256 "#{TESTBALL_SHA256}"
+        version "3.0"
+      end
+    EOS
+
+    expect { brew "install", "testball1" }
+      .to output(/first `brew unlink testball1`/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_failure
+
+    expect { brew "unlink", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "install", "testball1", "--devel" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+
+    expect { brew "unlink", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "install", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+
+    shutup do
+      expect { brew "switch", "testball1", "3.0" }.to be_a_success
+    end
+
+    expect { brew "install", "testball1" }
+      .to output(/already installed, however linked version is/).to_stderr
+      .and output(/`brew switch testball1 2.0`/).to_stdout
+      .and be_a_success
+
+    expect { brew "unlink", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "install", "testball1" }
+      .to output(/just not linked/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_success
+  end
+
+  it "can install keg-only Formulae" do
+    path_keg_only = setup_test_formula "testball1", <<-EOS.undent
+      version "1.0"
+
+      keg_only "test reason"
+    EOS
+
+    expect { brew "install", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    FileUtils.rm path_keg_only
+    setup_test_formula "testball1", <<-EOS.undent
+      version "2.0"
+
+      keg_only "test reason"
+    EOS
+
+    expect { brew "install", "testball1" }
+      .to output(/keg-only and another version is linked to opt/).to_stderr
+      .and output(/Use `brew install --force`/).to_stdout
+      .and be_a_success
+
+    expect { brew "install", "testball1", "--force" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+  end
+
+  it "can install HEAD Formulae" do
+    repo_path = HOMEBREW_CACHE.join("repo")
+    repo_path.join("bin").mkpath
+
+    repo_path.cd do
+      shutup do
+        system "git", "init"
+        system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
+        FileUtils.touch "bin/something.bin"
+        FileUtils.touch "README"
+        system "git", "add", "--all"
+        system "git", "commit", "-m", "Initial repo commit"
+      end
+    end
+
+    setup_test_formula "testball1", <<-EOS.undent
+      version "1.0"
+
+      head "file://#{repo_path}", :using => :git
+
+      def install
+        prefix.install Dir["*"]
+      end
+    EOS
+
+    # Ignore dependencies, because we'll try to resolve requirements in build.rb
+    # and there will be the git requirement, but we cannot instantiate git
+    # formula since we only have testball1 formula.
+    expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+
+    expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
+      .to output(/testball1\-HEAD\-d5eb689 already installed/).to_stderr
+      .and not_to_output.to_stdout
+      .and be_a_success
+
+    expect { brew "unlink", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout
+      .and not_to_output.to_stderr
+      .and be_a_success
+
+    expect { brew "install", "testball1" }
+      .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+  end
+
+  it "ignores invalid options" do
+    setup_test_formula "testball1"
+    expect { brew "install", "testball1", "--with-fo" }
+      .to output(/testball1: this formula has no \-\-with\-fo option so it will be ignored!/).to_stderr
+      .and output(/Downloading file/).to_stdout
+      .and be_a_success
+  end
+
+  it "succeeds when a non-fatal requirement isn't satisfied" do
+    setup_test_formula "testball1", <<-EOS.undent
+      class NonFatalRequirement < Requirement
+        satisfy { false }
+      end
+
+      depends_on NonFatalRequirement
+    EOS
+
+    # FIXME: This should output to STDERR.
+    expect { brew "install", "testball1" }
+      .to output(/NonFatalRequirement unsatisfied!/).to_stdout
+      .and output(/not in your PATH/).to_stderr
+      .and be_a_success
+  end
+
+  it "fails when a fatal requirement isn't satisfied" do
+    setup_test_formula "testball1", <<-EOS.undent
+      class FatalRequirement < Requirement
+        fatal true
+        satisfy { false }
+      end
+
+      depends_on FatalRequirement
+    EOS
+
+    # FIXME: This should output to STDERR.
+    expect { brew "install", "testball1" }
+      .to output(/FatalRequirement unsatisfied!/).to_stdout
+      .and output(/An unsatisfied requirement failed this build./).to_stderr
+      .and be_a_failure
+  end
+end
diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb
deleted file mode 100644
index da6c1863f..000000000
--- a/Library/Homebrew/test/install_test.rb
+++ /dev/null
@@ -1,136 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestInstall < IntegrationCommandTestCase
-  def test_install
-    setup_test_formula "testball1"
-    assert_match "Specify `--HEAD`", cmd_fail("install", "testball1", "--head")
-    assert_match "No head is defined", cmd_fail("install", "testball1", "--HEAD")
-    assert_match "No devel block", cmd_fail("install", "testball1", "--devel")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/0.1", cmd("install", "testball1")
-    assert_match "testball1-0.1 already installed", cmd("install", "testball1")
-    assert_match "MacRuby is not packaged", cmd_fail("install", "macruby")
-    assert_match "No available formula", cmd_fail("install", "formula")
-    assert_match "This similarly named formula was found",
-      cmd_fail("install", "testball")
-
-    setup_test_formula "testball2"
-    assert_match "These similarly named formulae were found",
-      cmd_fail("install", "testball")
-
-    install_and_rename_coretap_formula "testball1", "testball2"
-    assert_match "testball1 already installed, it's just not migrated",
-      cmd("install", "testball2")
-  end
-
-  def test_install_failures
-    path = setup_test_formula "testball1", "version \"1.0\""
-    devel_content = <<-EOS.undent
-      version "3.0"
-      devel do
-        url "#{Formulary.factory("testball1").stable.url}"
-        sha256 "#{TESTBALL_SHA256}"
-        version "2.0"
-      end
-    EOS
-
-    assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
-
-    FileUtils.rm path
-    setup_test_formula "testball1", devel_content
-
-    assert_match "first `brew unlink testball1`", cmd_fail("install", "testball1")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("unlink", "testball1")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/2.0", cmd("install", "testball1", "--devel")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/2.0", cmd("unlink", "testball1")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/3.0", cmd("install", "testball1")
-
-    cmd("switch", "testball1", "2.0")
-    assert_match "already installed, however linked version is",
-      cmd("install", "testball1")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/2.0", cmd("unlink", "testball1")
-    assert_match "just not linked", cmd("install", "testball1")
-  end
-
-  def test_install_keg_only_outdated
-    path_keg_only = setup_test_formula "testball1", <<-EOS.undent
-    version "1.0"
-    keg_only "test reason"
-    EOS
-
-    assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
-
-    FileUtils.rm path_keg_only
-    setup_test_formula "testball1", <<-EOS.undent
-      version "2.0"
-      keg_only "test reason"
-    EOS
-
-    assert_match "keg-only and another version is linked to opt",
-      cmd("install", "testball1")
-
-    assert_match "#{HOMEBREW_CELLAR}/testball1/2.0",
-      cmd("install", "testball1", "--force")
-  end
-
-  def test_install_head_installed
-    repo_path = HOMEBREW_CACHE.join("repo")
-    repo_path.join("bin").mkpath
-
-    repo_path.cd do
-      shutup do
-        system "git", "init"
-        system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
-        FileUtils.touch "bin/something.bin"
-        FileUtils.touch "README"
-        system "git", "add", "--all"
-        system "git", "commit", "-m", "Initial repo commit"
-      end
-    end
-
-    setup_test_formula "testball1", <<-EOS.undent
-      version "1.0"
-      head "file://#{repo_path}", :using => :git
-      def install
-        prefix.install Dir["*"]
-      end
-    EOS
-
-    # Ignore dependencies, because we'll try to resolve requirements in build.rb
-    # and there will be the git requirement, but we cannot instantiate git
-    # formula since we only have testball1 formula.
-    assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
-    assert_match "testball1-HEAD-d5eb689 already installed",
-      cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("unlink", "testball1")
-    assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
-  end
-
-  def test_install_with_invalid_option
-    setup_test_formula "testball1"
-    assert_match "testball1: this formula has no --with-fo option so it will be ignored!",
-      cmd("install", "testball1", "--with-fo")
-  end
-
-  def test_install_with_nonfatal_requirement
-    setup_test_formula "testball1", <<-EOS.undent
-      class NonFatalRequirement < Requirement
-        satisfy { false }
-      end
-      depends_on NonFatalRequirement
-    EOS
-    message = "NonFatalRequirement unsatisfied!"
-    assert_equal 1, cmd("install", "testball1").scan(message).size
-  end
-
-  def test_install_with_fatal_requirement
-    setup_test_formula "testball1", <<-EOS.undent
-      class FatalRequirement < Requirement
-        fatal true
-        satisfy { false }
-      end
-      depends_on FatalRequirement
-    EOS
-    message = "FatalRequirement unsatisfied!"
-    assert_equal 1, cmd_fail("install", "testball1").scan(message).size
-  end
-end
-- 
cgit v1.2.3


From ec0f2187a24fcbed41ee58719e0928dfe9155bba Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 09:01:24 +0100
Subject: Avoid warnings when HOMEBREW_PREFIX/bin is not in PATH.

---
 Library/Homebrew/test/cmd/install_spec.rb                  | 14 +++++++-------
 Library/Homebrew/test/cmd/reinstall_spec.rb                |  7 ++-----
 .../support/helper/spec/shared_context/integration_test.rb |  8 ++++++++
 3 files changed, 17 insertions(+), 12 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb
index e5b5ec631..c1240a30e 100644
--- a/Library/Homebrew/test/cmd/install_spec.rb
+++ b/Library/Homebrew/test/cmd/install_spec.rb
@@ -19,7 +19,7 @@ describe "brew install", :integration_test do
 
     expect { brew "install", "testball1" }
       .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and not_to_output.to_stderr
       .and be_a_success
 
     expect { brew "install", "testball1" }
@@ -62,7 +62,7 @@ describe "brew install", :integration_test do
 
     expect { brew "install", "testball1" }
       .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and not_to_output.to_stderr
       .and be_a_success
 
     FileUtils.rm path
@@ -88,7 +88,7 @@ describe "brew install", :integration_test do
 
     expect { brew "install", "testball1", "--devel" }
       .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and not_to_output.to_stderr
       .and be_a_success
 
     expect { brew "unlink", "testball1" }
@@ -98,7 +98,7 @@ describe "brew install", :integration_test do
 
     expect { brew "install", "testball1" }
       .to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and not_to_output.to_stderr
       .and be_a_success
 
     shutup do
@@ -181,7 +181,7 @@ describe "brew install", :integration_test do
     # formula since we only have testball1 formula.
     expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
       .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and output(/Cloning into/).to_stderr
       .and be_a_success
 
     expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
@@ -196,7 +196,7 @@ describe "brew install", :integration_test do
 
     expect { brew "install", "testball1" }
       .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and not_to_output.to_stderr
       .and be_a_success
   end
 
@@ -220,7 +220,7 @@ describe "brew install", :integration_test do
     # FIXME: This should output to STDERR.
     expect { brew "install", "testball1" }
       .to output(/NonFatalRequirement unsatisfied!/).to_stdout
-      .and output(/not in your PATH/).to_stderr
+      .and not_to_output.to_stderr
       .and be_a_success
   end
 
diff --git a/Library/Homebrew/test/cmd/reinstall_spec.rb b/Library/Homebrew/test/cmd/reinstall_spec.rb
index 74d36bbb8..63584e6be 100644
--- a/Library/Homebrew/test/cmd/reinstall_spec.rb
+++ b/Library/Homebrew/test/cmd/reinstall_spec.rb
@@ -1,9 +1,6 @@
 require "extend/ENV"
 
 describe "brew reinstall", :integration_test do
-  let(:bin) { (HOMEBREW_PREFIX/"bin").realpath }
-  let(:path) { "#{bin}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
-
   before(:each) do
     setup_test_formula "testball"
 
@@ -17,7 +14,7 @@ describe "brew reinstall", :integration_test do
     expect(foo_dir).to exist
     foo_dir.rmtree
 
-    expect { brew "reinstall", "testball", "PATH" => path }
+    expect { brew "reinstall", "testball" }
       .to output(/Reinstalling testball --with-foo/).to_stdout
       .and not_to_output.to_stderr
       .and be_a_success
@@ -26,7 +23,7 @@ describe "brew reinstall", :integration_test do
   end
 
   it "reinstalls a Formula even when one of the options is invalid" do
-    expect { brew "reinstall", "testball", "--with-fo", "PATH" => path }
+    expect { brew "reinstall", "testball", "--with-fo" }
       .to output(/Reinstalling testball --with-foo/).to_stdout
       .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr
       .and be_a_success
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
index fc7b49fa4..2eb98826a 100644
--- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -63,7 +63,15 @@ RSpec.shared_context "integration test" do
   def brew(*args)
     env = args.last.is_a?(Hash) ? args.pop : {}
 
+    # Avoid warnings when HOMEBREW_PREFIX/bin is not in PATH.
+    path = [
+      env["PATH"],
+      (HOMEBREW_PREFIX/"bin").realpath.to_s,
+      ENV["PATH"],
+    ].compact.join(File::PATH_SEPARATOR)
+
     env.merge!(
+      "PATH" => path,
       "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
       "HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
       "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
-- 
cgit v1.2.3


From 7cc4ca41bcf2b47787548a0a725605fde5a83ca0 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 10:19:27 +0100
Subject: Convert `os/mac/diagnostic` test to spec.

---
 Library/Homebrew/test/os/mac/diagnostic_spec.rb | 42 +++++++++++++++++++++++
 Library/Homebrew/test/os/mac/diagnostic_test.rb | 45 -------------------------
 2 files changed, 42 insertions(+), 45 deletions(-)
 create mode 100644 Library/Homebrew/test/os/mac/diagnostic_spec.rb
 delete mode 100644 Library/Homebrew/test/os/mac/diagnostic_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb
new file mode 100644
index 000000000..d2b38a332
--- /dev/null
+++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb
@@ -0,0 +1,42 @@
+require "diagnostic"
+
+describe Homebrew::Diagnostic::Checks do
+  specify "#check_for_other_package_managers" do
+    allow(MacOS).to receive(:macports_or_fink).and_return(["fink"])
+    expect(subject.check_for_other_package_managers)
+      .to match("You have MacPorts or Fink installed:")
+  end
+
+  specify "#check_for_unsupported_macos" do
+    ENV.delete("HOMEBREW_DEVELOPER")
+    allow(OS::Mac).to receive(:prerelease?).and_return(true)
+
+    expect(subject.check_for_unsupported_macos)
+      .to match("We do not provide support for this pre-release version.")
+  end
+
+  specify "#check_for_unsupported_curl_vars" do
+    allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.10"))
+    ENV["SSL_CERT_DIR"] = "/some/path"
+
+    expect(subject.check_for_unsupported_curl_vars)
+      .to match("SSL_CERT_DIR support was removed from Apple's curl.")
+  end
+
+  specify "#check_for_beta_xquartz" do
+    allow(MacOS::XQuartz).to receive(:version).and_return("2.7.10_beta2")
+
+    expect(subject.check_for_beta_xquartz)
+      .to match("The following beta release of XQuartz is installed: 2.7.10_beta2")
+  end
+
+  specify "#check_xcode_8_without_clt_on_el_capitan" do
+    allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.11"))
+    allow(MacOS::Xcode).to receive(:installed?).and_return(true)
+    allow(MacOS::Xcode).to receive(:version).and_return("8.0")
+    allow(MacOS::Xcode).to receive(:without_clt?).and_return(true)
+
+    expect(subject.check_xcode_8_without_clt_on_el_capitan)
+      .to match("You have Xcode 8 installed without the CLT")
+  end
+end
diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb
deleted file mode 100644
index 704235b01..000000000
--- a/Library/Homebrew/test/os/mac/diagnostic_test.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require "testing_env"
-require "fileutils"
-require "pathname"
-require "diagnostic"
-
-class OSMacDiagnosticChecksTest < Homebrew::TestCase
-  def setup
-    super
-    @checks = Homebrew::Diagnostic::Checks.new
-  end
-
-  def test_check_for_other_package_managers
-    MacOS.stubs(:macports_or_fink).returns ["fink"]
-    assert_match "You have MacPorts or Fink installed:",
-      @checks.check_for_other_package_managers
-  end
-
-  def test_check_for_unsupported_macos
-    ENV.delete("HOMEBREW_DEVELOPER")
-    OS::Mac.stubs(:prerelease?).returns true
-    assert_match "We do not provide support for this pre-release version.",
-      @checks.check_for_unsupported_macos
-  end
-
-  def test_check_for_unsupported_curl_vars
-    MacOS.stubs(:version).returns OS::Mac::Version.new("10.10")
-    ENV["SSL_CERT_DIR"] = "/some/path"
-
-    assert_match "SSL_CERT_DIR support was removed from Apple's curl.",
-      @checks.check_for_unsupported_curl_vars
-  end
-
-  def test_check_for_beta_xquartz
-    MacOS::XQuartz.stubs(:version).returns("2.7.10_beta2")
-    assert_match "The following beta release of XQuartz is installed: 2.7.10_beta2", @checks.check_for_beta_xquartz
-  end
-
-  def test_check_xcode_8_without_clt_on_el_capitan
-    MacOS.stubs(:version).returns OS::Mac::Version.new("10.11")
-    MacOS::Xcode.stubs(:installed?).returns true
-    MacOS::Xcode.stubs(:version).returns "8.0"
-    MacOS::Xcode.stubs(:without_clt?).returns true
-    assert_match "You have Xcode 8 installed without the CLT", @checks.check_xcode_8_without_clt_on_el_capitan
-  end
-end
-- 
cgit v1.2.3


From 89a4a7a7104bac84a4589e1efff1b2d2002e9a48 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 10:32:58 +0100
Subject: Convert `os/mac/dependency_collector` test to spec.

---
 .../test/os/mac/dependency_collector_spec.rb       | 50 ++++++++++++++++++
 .../test/os/mac/dependency_collector_test.rb       | 59 ----------------------
 2 files changed, 50 insertions(+), 59 deletions(-)
 create mode 100644 Library/Homebrew/test/os/mac/dependency_collector_spec.rb
 delete mode 100644 Library/Homebrew/test/os/mac/dependency_collector_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb
new file mode 100644
index 000000000..21b15cd99
--- /dev/null
+++ b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb
@@ -0,0 +1,50 @@
+require "dependency_collector"
+
+RSpec::Matchers.alias_matcher :need_tar_xz_dependency, :be_tar_needs_xz_dependency
+
+describe DependencyCollector do
+  after(:each) do
+    described_class.clear_cache
+  end
+
+  specify "#tar_needs_xz_dependency?" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.9"))
+    expect(described_class).not_to need_tar_xz_dependency
+  end
+
+  specify "LD64 pre-Leopard dependency" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.4"))
+    expect(subject.build(:ld64)).to eq(LD64Dependency.new)
+  end
+
+  specify "LD64 Leopard or newer dependency" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.5"))
+    expect(subject.build(:ld64)).to be nil
+  end
+
+  specify "ant Mavericks or newer dependency" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.9"))
+    subject.add ant: :build
+    expect(subject.deps.find { |dep| dep.name == "ant" }).to eq(Dependency.new("ant", [:build]))
+  end
+
+  specify "ant pre-Mavericks dependency" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.7"))
+    subject.add ant: :build
+    expect(subject.deps.find { |dep| dep.name == "ant" }).to be nil
+  end
+
+  specify "Resource xz pre-Mavericks dependency" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.8"))
+    resource = Resource.new
+    resource.url("http://example.com/foo.tar.xz")
+    expect(subject.add(resource)).to eq(Dependency.new("xz", [:build]))
+  end
+
+  specify "Resource xz Mavericks or newer dependency" do
+    allow(MacOS).to receive(:version).and_return(MacOS::Version.new("10.9"))
+    resource = Resource.new
+    resource.url("http://example.com/foo.tar.xz")
+    expect(subject.add(resource)).to be nil
+  end
+end
diff --git a/Library/Homebrew/test/os/mac/dependency_collector_test.rb b/Library/Homebrew/test/os/mac/dependency_collector_test.rb
deleted file mode 100644
index 1033df9ab..000000000
--- a/Library/Homebrew/test/os/mac/dependency_collector_test.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require "testing_env"
-require "dependency_collector"
-
-class OSMacDependencyCollectorTests < Homebrew::TestCase
-  def find_dependency(name)
-    @d.deps.find { |dep| dep.name == name }
-  end
-
-  def setup
-    super
-    @d = DependencyCollector.new
-  end
-
-  def teardown
-    DependencyCollector.clear_cache
-    super
-  end
-
-  def test_tar_needs_xz_dependency
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.9"))
-    refute DependencyCollector.tar_needs_xz_dependency?
-  end
-
-  def test_ld64_dep_pre_leopard
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
-    assert_equal LD64Dependency.new, @d.build(:ld64)
-  end
-
-  def test_ld64_dep_leopard_or_newer
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.5"))
-    assert_nil @d.build(:ld64)
-  end
-
-  def test_ant_dep_mavericks_or_newer
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.9"))
-    @d.add ant: :build
-    assert_equal find_dependency("ant"), Dependency.new("ant", [:build])
-  end
-
-  def test_ant_dep_pre_mavericks
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.7"))
-    @d.add ant: :build
-    assert_nil find_dependency("ant")
-  end
-
-  def test_resource_dep_xz_pre_mavericks
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.8"))
-    resource = Resource.new
-    resource.url("http://example.com/foo.tar.xz")
-    assert_equal Dependency.new("xz", [:build]), @d.add(resource)
-  end
-
-  def test_resource_dep_xz_mavericks_or_newer
-    MacOS.stubs(:version).returns(MacOS::Version.new("10.9"))
-    resource = Resource.new
-    resource.url("http://example.com/foo.tar.xz")
-    assert_nil @d.add(resource)
-  end
-end
-- 
cgit v1.2.3


From af65b07ac944082f5c9a84803690189e403b854a Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 11:12:05 +0100
Subject: Convert `patching` test to spec.

---
 Library/Homebrew/test/patching_spec.rb | 289 +++++++++++++++++++++++++++++++++
 Library/Homebrew/test/patching_test.rb | 248 ----------------------------
 2 files changed, 289 insertions(+), 248 deletions(-)
 create mode 100644 Library/Homebrew/test/patching_spec.rb
 delete mode 100644 Library/Homebrew/test/patching_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/patching_spec.rb b/Library/Homebrew/test/patching_spec.rb
new file mode 100644
index 000000000..dd849ca92
--- /dev/null
+++ b/Library/Homebrew/test/patching_spec.rb
@@ -0,0 +1,289 @@
+require "formula"
+
+describe "patching" do
+  TESTBALL_URL = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz".freeze
+  TESTBALL_PATCHES_URL = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1-patches.tgz".freeze
+  PATCH_URL_A = "file://#{TEST_FIXTURE_DIR}/patches/noop-a.diff".freeze
+  PATCH_URL_B = "file://#{TEST_FIXTURE_DIR}/patches/noop-b.diff".freeze
+  PATCH_A_CONTENTS = File.read "#{TEST_FIXTURE_DIR}/patches/noop-a.diff"
+  PATCH_B_CONTENTS = File.read "#{TEST_FIXTURE_DIR}/patches/noop-b.diff"
+  APPLY_A = "noop-a.diff".freeze
+  APPLY_B = "noop-b.diff".freeze
+  APPLY_C = "noop-c.diff".freeze
+
+  def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block)
+    Class.new(Formula) {
+      url TESTBALL_URL
+      sha256 TESTBALL_SHA256
+      class_eval(&block)
+    }.new(name, path, spec, alias_path: alias_path)
+  end
+
+  matcher :be_patched do
+    match do |formula|
+      shutup do
+        formula.brew do
+          formula.patch
+          s = File.read("libexec/NOOP")
+          expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected"
+          expect(s).to include("ABCD"), "libexec/NOOP was not patched as expected"
+        end
+      end
+    end
+  end
+
+  matcher :be_sequentially_patched do
+    match do |formula|
+      shutup do
+        formula.brew do
+          formula.patch
+          s = File.read("libexec/NOOP")
+          expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected"
+          expect(s).not_to include("ABCD"), "libexec/NOOP was not patched as expected"
+          expect(s).to include("1234"), "libexec/NOOP was not patched as expected"
+        end
+      end
+    end
+  end
+
+  matcher :miss_apply do
+    match do |formula|
+      expect {
+        shutup do
+          formula.brew do
+            formula.patch
+          end
+        end
+      }.to raise_error(MissingApplyError)
+    end
+  end
+
+  specify "single_patch" do
+    expect(
+      formula do
+        def patches
+          PATCH_URL_A
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "single_patch_dsl" do
+    expect(
+      formula do
+        patch do
+          url PATCH_URL_A
+          sha256 PATCH_A_SHA256
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "single_patch_dsl_with_apply" do
+    expect(
+      formula do
+        patch do
+          url TESTBALL_PATCHES_URL
+          sha256 TESTBALL_PATCHES_SHA256
+          apply APPLY_A
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "single_patch_dsl_with_sequential_apply" do
+    expect(
+      formula do
+        patch do
+          url TESTBALL_PATCHES_URL
+          sha256 TESTBALL_PATCHES_SHA256
+          apply APPLY_A, APPLY_C
+        end
+      end,
+    ).to be_sequentially_patched
+  end
+
+  specify "single_patch_dsl_with_strip" do
+    expect(
+      formula do
+        patch :p1 do
+          url PATCH_URL_A
+          sha256 PATCH_A_SHA256
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "single_patch_dsl_with_strip_with_apply" do
+    expect(
+      formula do
+        patch :p1 do
+          url TESTBALL_PATCHES_URL
+          sha256 TESTBALL_PATCHES_SHA256
+          apply APPLY_A
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "single_patch_dsl_with_incorrect_strip" do
+    expect {
+      shutup do
+        f = formula do
+          patch :p0 do
+            url PATCH_URL_A
+            sha256 PATCH_A_SHA256
+          end
+        end
+
+        f.brew { |formula, _staging| formula.patch }
+      end
+    }.to raise_error(ErrorDuringExecution)
+  end
+
+  specify "single_patch_dsl_with_incorrect_strip_with_apply" do
+    expect {
+      shutup do
+        f = formula do
+          patch :p0 do
+            url TESTBALL_PATCHES_URL
+            sha256 TESTBALL_PATCHES_SHA256
+            apply APPLY_A
+          end
+        end
+
+        f.brew { |formula, _staging| formula.patch }
+      end
+    }.to raise_error(ErrorDuringExecution)
+  end
+
+  specify "patch_p0_dsl" do
+    expect(
+      formula do
+        patch :p0 do
+          url PATCH_URL_B
+          sha256 PATCH_B_SHA256
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "patch_p0_dsl_with_apply" do
+    expect(
+      formula do
+        patch :p0 do
+          url TESTBALL_PATCHES_URL
+          sha256 TESTBALL_PATCHES_SHA256
+          apply APPLY_B
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "patch_p0" do
+    expect(
+      formula do
+        def patches
+          { p0: PATCH_URL_B }
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "patch_array" do
+    expect(
+      formula do
+        def patches
+          [PATCH_URL_A]
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "patch_hash" do
+    expect(
+      formula do
+        def patches
+          { p1: PATCH_URL_A }
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "patch_hash_array" do
+    expect(
+      formula do
+        def patches
+          { p1: [PATCH_URL_A] }
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "patch_string" do
+    expect(formula { patch PATCH_A_CONTENTS }).to be_patched
+  end
+
+  specify "patch_string_with_strip" do
+    expect(formula { patch :p0, PATCH_B_CONTENTS }).to be_patched
+  end
+
+  specify "patch_data_constant" do
+    expect(
+      formula("test", path: Pathname.new(__FILE__).expand_path) do
+        def patches
+          :DATA
+        end
+      end,
+    ).to be_patched
+  end
+
+  specify "single_patch_missing_apply_fail" do
+    expect(
+      formula do
+        def patches
+          TESTBALL_PATCHES_URL
+        end
+      end,
+    ).to miss_apply
+  end
+
+  specify "single_patch_dsl_missing_apply_fail" do
+    expect(
+      formula do
+        patch do
+          url TESTBALL_PATCHES_URL
+          sha256 TESTBALL_PATCHES_SHA256
+        end
+      end,
+    ).to miss_apply
+  end
+
+  specify "single_patch_dsl_with_apply_enoent_fail" do
+    expect {
+      shutup do
+        f = formula do
+          patch do
+            url TESTBALL_PATCHES_URL
+            sha256 TESTBALL_PATCHES_SHA256
+            apply "patches/#{APPLY_A}"
+          end
+        end
+
+        f.brew { |formula, _staging| formula.patch }
+      end
+    }.to raise_error(ErrorDuringExecution)
+  end
+end
+
+__END__
+diff --git a/libexec/NOOP b/libexec/NOOP
+index bfdda4c..e08d8f4 100755
+--- a/libexec/NOOP
++++ b/libexec/NOOP
+@@ -1,2 +1,2 @@
+ #!/bin/bash
+-echo NOOP
+\ No newline at end of file
++echo ABCD
+\ No newline at end of file
diff --git a/Library/Homebrew/test/patching_test.rb b/Library/Homebrew/test/patching_test.rb
deleted file mode 100644
index 3dacc0818..000000000
--- a/Library/Homebrew/test/patching_test.rb
+++ /dev/null
@@ -1,248 +0,0 @@
-require "testing_env"
-require "formula"
-
-class PatchingTests < Homebrew::TestCase
-  TESTBALL_URL = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz".freeze
-  TESTBALL_PATCHES_URL = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1-patches.tgz".freeze
-  PATCH_URL_A = "file://#{TEST_FIXTURE_DIR}/patches/noop-a.diff".freeze
-  PATCH_URL_B = "file://#{TEST_FIXTURE_DIR}/patches/noop-b.diff".freeze
-  PATCH_A_CONTENTS = File.read "#{TEST_FIXTURE_DIR}/patches/noop-a.diff"
-  PATCH_B_CONTENTS = File.read "#{TEST_FIXTURE_DIR}/patches/noop-b.diff"
-  APPLY_A = "noop-a.diff".freeze
-  APPLY_B = "noop-b.diff".freeze
-  APPLY_C = "noop-c.diff".freeze
-
-  def formula(*args, &block)
-    super do
-      url TESTBALL_URL
-      sha256 TESTBALL_SHA256
-      class_eval(&block)
-    end
-  end
-
-  def assert_patched(formula)
-    shutup do
-      formula.brew do
-        formula.patch
-        s = File.read("libexec/NOOP")
-        refute_includes s, "NOOP", "libexec/NOOP was not patched as expected"
-        assert_includes s, "ABCD", "libexec/NOOP was not patched as expected"
-      end
-    end
-  end
-
-  def assert_sequentially_patched(formula)
-    shutup do
-      formula.brew do
-        formula.patch
-        s = File.read("libexec/NOOP")
-        refute_includes s, "NOOP", "libexec/NOOP was not patched as expected"
-        refute_includes s, "ABCD", "libexec/NOOP was not patched as expected"
-        assert_includes s, "1234", "libexec/NOOP was not patched as expected"
-      end
-    end
-  end
-
-  def assert_missing_apply_fail(formula)
-    assert_raises(MissingApplyError) do
-      shutup do
-        formula.brew do
-          formula.patch
-        end
-      end
-    end
-  end
-
-  def test_single_patch
-    assert_patched formula {
-      def patches
-        PATCH_URL_A
-      end
-    }
-  end
-
-  def test_single_patch_dsl
-    assert_patched formula {
-      patch do
-        url PATCH_URL_A
-        sha256 PATCH_A_SHA256
-      end
-    }
-  end
-
-  def test_single_patch_dsl_with_apply
-    assert_patched formula {
-      patch do
-        url TESTBALL_PATCHES_URL
-        sha256 TESTBALL_PATCHES_SHA256
-        apply APPLY_A
-      end
-    }
-  end
-
-  def test_single_patch_dsl_with_sequential_apply
-    assert_sequentially_patched formula {
-      patch do
-        url TESTBALL_PATCHES_URL
-        sha256 TESTBALL_PATCHES_SHA256
-        apply APPLY_A, APPLY_C
-      end
-    }
-  end
-
-  def test_single_patch_dsl_with_strip
-    assert_patched formula {
-      patch :p1 do
-        url PATCH_URL_A
-        sha256 PATCH_A_SHA256
-      end
-    }
-  end
-
-  def test_single_patch_dsl_with_strip_with_apply
-    assert_patched formula {
-      patch :p1 do
-        url TESTBALL_PATCHES_URL
-        sha256 TESTBALL_PATCHES_SHA256
-        apply APPLY_A
-      end
-    }
-  end
-
-  def test_single_patch_dsl_with_incorrect_strip
-    assert_raises(ErrorDuringExecution) do
-      shutup do
-        formula do
-          patch :p0 do
-            url PATCH_URL_A
-            sha256 PATCH_A_SHA256
-          end
-        end.brew { |f, _staging| f.patch }
-      end
-    end
-  end
-
-  def test_single_patch_dsl_with_incorrect_strip_with_apply
-    assert_raises(ErrorDuringExecution) do
-      shutup do
-        formula do
-          patch :p0 do
-            url TESTBALL_PATCHES_URL
-            sha256 TESTBALL_PATCHES_SHA256
-            apply APPLY_A
-          end
-        end.brew { |f, _staging| f.patch }
-      end
-    end
-  end
-
-  def test_patch_p0_dsl
-    assert_patched formula {
-      patch :p0 do
-        url PATCH_URL_B
-        sha256 PATCH_B_SHA256
-      end
-    }
-  end
-
-  def test_patch_p0_dsl_with_apply
-    assert_patched formula {
-      patch :p0 do
-        url TESTBALL_PATCHES_URL
-        sha256 TESTBALL_PATCHES_SHA256
-        apply APPLY_B
-      end
-    }
-  end
-
-  def test_patch_p0
-    assert_patched formula {
-      def patches
-        { p0: PATCH_URL_B }
-      end
-    }
-  end
-
-  def test_patch_array
-    assert_patched formula {
-      def patches
-        [PATCH_URL_A]
-      end
-    }
-  end
-
-  def test_patch_hash
-    assert_patched formula {
-      def patches
-        { p1: PATCH_URL_A }
-      end
-    }
-  end
-
-  def test_patch_hash_array
-    assert_patched formula {
-      def patches
-        { p1: [PATCH_URL_A] }
-      end
-    }
-  end
-
-  def test_patch_string
-    assert_patched formula { patch PATCH_A_CONTENTS }
-  end
-
-  def test_patch_string_with_strip
-    assert_patched formula { patch :p0, PATCH_B_CONTENTS }
-  end
-
-  def test_patch_data_constant
-    assert_patched formula("test", Pathname.new(__FILE__).expand_path) {
-      def patches
-        :DATA
-      end
-    }
-  end
-
-  def test_single_patch_missing_apply_fail
-    assert_missing_apply_fail formula {
-      def patches
-        TESTBALL_PATCHES_URL
-      end
-    }
-  end
-
-  def test_single_patch_dsl_missing_apply_fail
-    assert_missing_apply_fail formula {
-      patch do
-        url TESTBALL_PATCHES_URL
-        sha256 TESTBALL_PATCHES_SHA256
-      end
-    }
-  end
-
-  def test_single_patch_dsl_with_apply_enoent_fail
-    assert_raises(ErrorDuringExecution) do
-      shutup do
-        formula do
-          patch do
-            url TESTBALL_PATCHES_URL
-            sha256 TESTBALL_PATCHES_SHA256
-            apply "patches/#{APPLY_A}"
-          end
-        end.brew { |f, _staging| f.patch }
-      end
-    end
-  end
-end
-
-__END__
-diff --git a/libexec/NOOP b/libexec/NOOP
-index bfdda4c..e08d8f4 100755
---- a/libexec/NOOP
-+++ b/libexec/NOOP
-@@ -1,2 +1,2 @@
- #!/bin/bash
--echo NOOP
-\ No newline at end of file
-+echo ABCD
-\ No newline at end of file
-- 
cgit v1.2.3


From 75724c5b5da769faa682803a55b29e2de9bad741 Mon Sep 17 00:00:00 2001
From: ilovezfs
Date: Sat, 25 Feb 2017 03:03:37 -0800
Subject: audit: whitelist more unstable versions already in core

These were imported from homebrew/games.
---
 Library/Homebrew/dev-cmd/audit.rb | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index e49f65dd2..ab7abf1e6 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -740,6 +740,7 @@ class FormulaAuditor
 
     unstable_whitelist = %w[
       aalib 1.4rc5
+      angolmois 2.0.0alpha2
       automysqlbackup 3.0-rc6
       aview 1.3.0rc1
       distcc 3.2rc1
@@ -747,6 +748,8 @@ class FormulaAuditor
       ftgl 2.1.3-rc5
       hidapi 0.8.0-rc1
       libcaca 0.99b19
+      nethack4 4.3.0-beta2
+      opensyobon 1.0rc2
       premake 4.4-beta5
       pwnat 0.3-beta
       pxz 4.999.9
-- 
cgit v1.2.3


From ebaf3cdc6a8cf637ec8f8b8a7e289a8d0dfd8f88 Mon Sep 17 00:00:00 2001
From: Jeppe Toustrup
Date: Sat, 25 Feb 2017 11:09:57 +0000
Subject: Add 'B' for bytes to cleanup command output

When `brew cleanup` is run it prints out a message like the following:

> This operation has freed approximately 222M of disk space.

The '222M' refers to megabytes but the normal acronym for megabytes would be
'MB'. The 'B' is also missing from kilobytes and gigabytes in the output, so
that's what this commit adds.
---
 Library/Homebrew/test/pathname_spec.rb | 4 ++--
 Library/Homebrew/test/utils_spec.rb    | 8 ++++----
 Library/Homebrew/utils.rb              | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/test/pathname_spec.rb b/Library/Homebrew/test/pathname_spec.rb
index da12d4347..6e7dc34aa 100644
--- a/Library/Homebrew/test/pathname_spec.rb
+++ b/Library/Homebrew/test/pathname_spec.rb
@@ -30,13 +30,13 @@ describe Pathname do
     describe "#abv" do
       context "when called on a directory" do
         it "returns a string with the file count and disk usage" do
-          expect(dir.abv).to eq("3 files, 1M")
+          expect(dir.abv).to eq("3 files, 1MB")
         end
       end
 
       context "when called on a file" do
         it "returns the disk usage" do
-          expect((dir/"a-file").abv).to eq("1M")
+          expect((dir/"a-file").abv).to eq("1MB")
         end
       end
     end
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index 040ad630b..b3fdedcb9 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -232,10 +232,10 @@ describe "globally-scoped helper methods" do
   specify "#disk_usage_readable" do
     expect(disk_usage_readable(1)).to eq("1B")
     expect(disk_usage_readable(1000)).to eq("1000B")
-    expect(disk_usage_readable(1024)).to eq("1K")
-    expect(disk_usage_readable(1025)).to eq("1K")
-    expect(disk_usage_readable(4_404_020)).to eq("4.2M")
-    expect(disk_usage_readable(4_509_715_660)).to eq("4.2G")
+    expect(disk_usage_readable(1024)).to eq("1KB")
+    expect(disk_usage_readable(1025)).to eq("1KB")
+    expect(disk_usage_readable(4_404_020)).to eq("4.2MB")
+    expect(disk_usage_readable(4_509_715_660)).to eq("4.2GB")
   end
 
   describe "#number_readable" do
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index b129c7328..56ddfd611 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -422,13 +422,13 @@ end
 def disk_usage_readable(size_in_bytes)
   if size_in_bytes >= 1_073_741_824
     size = size_in_bytes.to_f / 1_073_741_824
-    unit = "G"
+    unit = "GB"
   elsif size_in_bytes >= 1_048_576
     size = size_in_bytes.to_f / 1_048_576
-    unit = "M"
+    unit = "MB"
   elsif size_in_bytes >= 1_024
     size = size_in_bytes.to_f / 1_024
-    unit = "K"
+    unit = "KB"
   else
     size = size_in_bytes
     unit = "B"
-- 
cgit v1.2.3


From 004e8175c6ceb58f026e79e6bbd0ddac9e8380f6 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 13:26:50 +0100
Subject: Add `formula` spec helper.

---
 Library/Homebrew/test/spec_helper.rb            |  2 ++
 Library/Homebrew/test/support/helper/formula.rb | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 Library/Homebrew/test/support/helper/formula.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 3724e4256..9a4dbe026 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -16,6 +16,7 @@ require "tap"
 
 require "test/support/helper/shutup"
 require "test/support/helper/fixtures"
+require "test/support/helper/formula"
 require "test/support/helper/spec/shared_context/integration_test"
 
 TEST_DIRECTORIES = [
@@ -32,6 +33,7 @@ RSpec.configure do |config|
   config.order = :random
   config.include(Test::Helper::Shutup)
   config.include(Test::Helper::Fixtures)
+  config.include(Test::Helper::Formula)
   config.before(:each) do |example|
     if example.metadata[:needs_macos]
       skip "Not on macOS." unless OS.mac?
diff --git a/Library/Homebrew/test/support/helper/formula.rb b/Library/Homebrew/test/support/helper/formula.rb
new file mode 100644
index 000000000..7f55f4b66
--- /dev/null
+++ b/Library/Homebrew/test/support/helper/formula.rb
@@ -0,0 +1,19 @@
+require "formulary"
+
+module Test
+  module Helper
+    module Formula
+      def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block)
+        Class.new(::Formula, &block).new(name, path, spec, alias_path: alias_path)
+      end
+
+      # Use a stubbed {Formulary::FormulaLoader} to make a given formula be found
+      # when loading from {Formulary} with `ref`.
+      def stub_formula_loader(formula, ref = formula.full_name)
+        loader = double(get_formula: formula)
+        allow(Formulary).to receive(:loader_for).with(ref, from: :keg).and_return(loader)
+        allow(Formulary).to receive(:loader_for).with(ref, from: nil).and_return(loader)
+      end
+    end
+  end
+end
-- 
cgit v1.2.3


From 890631dc29cbf0035566d5c5d1e74ddf43684bc2 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 10:09:26 +0100
Subject: Convert ENV test to spec.

---
 Library/Homebrew/test/ARGV_spec.rb |   2 +-
 Library/Homebrew/test/ENV_spec.rb  | 189 +++++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/ENV_test.rb  | 175 ----------------------------------
 3 files changed, 190 insertions(+), 176 deletions(-)
 create mode 100644 Library/Homebrew/test/ENV_spec.rb
 delete mode 100644 Library/Homebrew/test/ENV_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/ARGV_spec.rb b/Library/Homebrew/test/ARGV_spec.rb
index bcb7c3f70..89ef9cabc 100644
--- a/Library/Homebrew/test/ARGV_spec.rb
+++ b/Library/Homebrew/test/ARGV_spec.rb
@@ -1,7 +1,7 @@
 require "extend/ARGV"
 
 describe HomebrewArgvExtension do
-  subject { argv.extend(HomebrewArgvExtension) }
+  subject { argv.extend(described_class) }
   let(:argv) { ["mxcl"] }
 
   describe "#formulae" do
diff --git a/Library/Homebrew/test/ENV_spec.rb b/Library/Homebrew/test/ENV_spec.rb
new file mode 100644
index 000000000..7b50ca1d4
--- /dev/null
+++ b/Library/Homebrew/test/ENV_spec.rb
@@ -0,0 +1,189 @@
+require "extend/ENV"
+
+shared_examples EnvActivation do
+  subject { env.extend(described_class) }
+  let(:env) { {}.extend(EnvActivation) }
+
+  it "supports switching compilers" do
+    subject.clang
+    expect(subject["LD"]).to be nil
+    expect(subject["CC"]).to eq(subject["OBJC"])
+  end
+
+  describe "#with_build_environment" do
+    it "restores the environment" do
+      before = subject.dup
+
+      subject.with_build_environment do
+        subject["foo"] = "bar"
+      end
+
+      expect(subject["foo"]).to be nil
+      expect(subject).to eq(before)
+    end
+
+    it "ensures the environment is restored" do
+      before = subject.dup
+
+      expect {
+        subject.with_build_environment do
+          subject["foo"] = "bar"
+          raise StandardError
+        end
+      }.to raise_error(StandardError)
+
+      expect(subject["foo"]).to be nil
+      expect(subject).to eq(before)
+    end
+
+    it "returns the value of the block" do
+      expect(subject.with_build_environment { 1 }).to eq(1)
+    end
+
+    it "does not mutate the interface" do
+      expected = subject.methods
+
+      subject.with_build_environment do
+        expect(subject.methods).to eq(expected)
+      end
+
+      expect(subject.methods).to eq(expected)
+    end
+  end
+
+  describe "#append" do
+    it "appends to an existing key" do
+      subject["foo"] = "bar"
+      subject.append "foo", "1"
+      expect(subject["foo"]).to eq("bar 1")
+    end
+
+    it "appends to an existing empty key" do
+      subject["foo"] = ""
+      subject.append "foo", "1"
+      expect(subject["foo"]).to eq("1")
+    end
+
+    it "appends to a non-existant key" do
+      subject.append "foo", "1"
+      expect(subject["foo"]).to eq("1")
+    end
+
+    # NOTE: this may be a wrong behavior; we should probably reject objects that
+    # do not respond to #to_str. For now this documents existing behavior.
+    it "coerces a value to a string" do
+      subject.append "foo", 42
+      expect(subject["foo"]).to eq("42")
+    end
+  end
+
+  describe "#prepend" do
+    it "prepends to an existing key" do
+      subject["foo"] = "bar"
+      subject.prepend "foo", "1"
+      expect(subject["foo"]).to eq("1 bar")
+    end
+
+    it "prepends to an existing empty key" do
+      subject["foo"] = ""
+      subject.prepend "foo", "1"
+      expect(subject["foo"]).to eq("1")
+    end
+
+    it "prepends to a non-existant key" do
+      subject.prepend "foo", "1"
+      expect(subject["foo"]).to eq("1")
+    end
+
+    # NOTE: this may be a wrong behavior; we should probably reject objects that
+    # do not respond to #to_str. For now this documents existing behavior.
+    it "coerces a value to a string" do
+      subject.prepend "foo", 42
+      expect(subject["foo"]).to eq("42")
+    end
+  end
+
+  describe "#append_path" do
+    it "appends to a path" do
+      subject.append_path "FOO", "/usr/bin"
+      expect(subject["FOO"]).to eq("/usr/bin")
+
+      subject.append_path "FOO", "/bin"
+      expect(subject["FOO"]).to eq("/usr/bin#{File::PATH_SEPARATOR}/bin")
+    end
+  end
+
+  describe "#prepend_path" do
+    it "prepends to a path" do
+      subject.prepend_path "FOO", "/usr/bin"
+      expect(subject["FOO"]).to eq("/usr/bin")
+
+      subject.prepend_path "FOO", "/bin"
+      expect(subject["FOO"]).to eq("/bin#{File::PATH_SEPARATOR}/usr/bin")
+    end
+  end
+
+  describe "#compiler" do
+    it "allows switching compilers" do
+      [:clang, :gcc_4_2, :gcc_4_0].each do |compiler|
+        subject.public_send(compiler)
+        expect(subject.compiler).to eq(compiler)
+      end
+    end
+  end
+
+  example "deparallelize_block_form_restores_makeflags" do
+    subject["MAKEFLAGS"] = "-j4"
+
+    subject.deparallelize do
+      expect(subject["MAKEFLAGS"]).to be nil
+    end
+
+    expect(subject["MAKEFLAGS"]).to eq("-j4")
+  end
+end
+
+describe Stdenv do
+  include_examples EnvActivation
+end
+
+describe Superenv do
+  include_examples EnvActivation
+
+  it "initializes deps" do
+    expect(subject.deps).to eq([])
+    expect(subject.keg_only_deps).to eq([])
+  end
+
+  describe "#cxx11" do
+    it "raises an error when the compiler isn't supported" do
+      %w[gcc gcc-4.7].each do |compiler|
+        subject["HOMEBREW_CC"] = compiler
+
+        expect { subject.cxx11 }
+          .to raise_error(/The selected compiler doesn't support C\+\+11:/)
+
+        expect(subject["HOMEBREW_CCCFG"]).to be nil
+      end
+    end
+
+    it "supports gcc-5" do
+      subject["HOMEBREW_CC"] = "gcc-5"
+      subject.cxx11
+      expect(subject["HOMEBREW_CCCFG"]).to include("x")
+    end
+
+    example "supports gcc-6" do
+      subject["HOMEBREW_CC"] = "gcc-6"
+      subject.cxx11
+      expect(subject["HOMEBREW_CCCFG"]).to include("x")
+    end
+
+    it "supports clang" do
+      subject["HOMEBREW_CC"] = "clang"
+      subject.cxx11
+      expect(subject["HOMEBREW_CCCFG"]).to include("x")
+      expect(subject["HOMEBREW_CCCFG"]).to include("g")
+    end
+  end
+end
diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb
deleted file mode 100644
index 66b59d8a4..000000000
--- a/Library/Homebrew/test/ENV_test.rb
+++ /dev/null
@@ -1,175 +0,0 @@
-require "testing_env"
-require "extend/ENV"
-require "testing_env"
-
-module SharedEnvTests
-  def setup
-    super
-    @env = {}.extend(EnvActivation)
-  end
-
-  def test_switching_compilers
-    @env.clang
-    assert_nil @env["LD"]
-    assert_equal @env["OBJC"], @env["CC"]
-  end
-
-  def test_with_build_environment_restores_env
-    before = @env.dup
-    @env.with_build_environment do
-      @env["foo"] = "bar"
-    end
-    assert_nil @env["foo"]
-    assert_equal before, @env
-  end
-
-  def test_with_build_environment_ensures_env_restored
-    before = @env.dup
-    begin
-      @env.with_build_environment do
-        @env["foo"] = "bar"
-        raise Exception
-      end
-    rescue Exception
-    end
-    assert_nil @env["foo"]
-    assert_equal before, @env
-  end
-
-  def test_with_build_environment_returns_block_value
-    assert_equal 1, @env.with_build_environment { 1 }
-  end
-
-  def test_with_build_environment_does_not_mutate_interface
-    expected = @env.methods
-    @env.with_build_environment { assert_equal expected, @env.methods }
-    assert_equal expected, @env.methods
-  end
-
-  def test_append_existing_key
-    @env["foo"] = "bar"
-    @env.append "foo", "1"
-    assert_equal "bar 1", @env["foo"]
-  end
-
-  def test_append_existing_key_empty
-    @env["foo"] = ""
-    @env.append "foo", "1"
-    assert_equal "1", @env["foo"]
-  end
-
-  def test_append_missing_key
-    @env.append "foo", "1"
-    assert_equal "1", @env["foo"]
-  end
-
-  def test_prepend_existing_key
-    @env["foo"] = "bar"
-    @env.prepend "foo", "1"
-    assert_equal "1 bar", @env["foo"]
-  end
-
-  def test_prepend_existing_key_empty
-    @env["foo"] = ""
-    @env.prepend "foo", "1"
-    assert_equal "1", @env["foo"]
-  end
-
-  def test_prepend_missing_key
-    @env.prepend "foo", "1"
-    assert_equal "1", @env["foo"]
-  end
-
-  # NOTE: this may be a wrong behavior; we should probably reject objects that
-  # do not respond to #to_str. For now this documents existing behavior.
-  def test_append_coerces_value_to_string
-    @env.append "foo", 42
-    assert_equal "42", @env["foo"]
-  end
-
-  def test_prepend_coerces_value_to_string
-    @env.prepend "foo", 42
-    assert_equal "42", @env["foo"]
-  end
-
-  def test_append_path
-    @env.append_path "FOO", "/usr/bin"
-    assert_equal "/usr/bin", @env["FOO"]
-    @env.append_path "FOO", "/bin"
-    assert_equal "/usr/bin#{File::PATH_SEPARATOR}/bin", @env["FOO"]
-  end
-
-  def test_prepend_path
-    @env.prepend_path "FOO", "/usr/bin"
-    assert_equal "/usr/bin", @env["FOO"]
-    @env.prepend_path "FOO", "/bin"
-    assert_equal "/bin#{File::PATH_SEPARATOR}/usr/bin", @env["FOO"]
-  end
-
-  def test_switching_compilers_updates_compiler
-    [:clang, :gcc_4_2, :gcc_4_0].each do |compiler|
-      @env.send(compiler)
-      assert_equal compiler, @env.compiler
-    end
-  end
-
-  def test_deparallelize_block_form_restores_makeflags
-    @env["MAKEFLAGS"] = "-j4"
-    @env.deparallelize do
-      assert_nil @env["MAKEFLAGS"]
-    end
-    assert_equal "-j4", @env["MAKEFLAGS"]
-  end
-end
-
-class StdenvTests < Homebrew::TestCase
-  include SharedEnvTests
-
-  def setup
-    super
-    @env.extend(Stdenv)
-  end
-end
-
-class SuperenvTests < Homebrew::TestCase
-  include SharedEnvTests
-
-  def setup
-    super
-    @env.extend(Superenv)
-  end
-
-  def test_initializes_deps
-    assert_equal [], @env.deps
-    assert_equal [], @env.keg_only_deps
-  end
-
-  def test_unsupported_cxx11
-    %w[gcc gcc-4.7].each do |compiler|
-      @env["HOMEBREW_CC"] = compiler
-      assert_raises do
-        @env.cxx11
-      end
-      refute_match "x", @env["HOMEBREW_CCCFG"]
-    end
-  end
-
-  def test_supported_cxx11_gcc_5
-    @env["HOMEBREW_CC"] = "gcc-5"
-    @env.cxx11
-    assert_match "x", @env["HOMEBREW_CCCFG"]
-  end
-
-  def test_supported_cxx11_gcc_6
-    @env["HOMEBREW_CC"] = "gcc-6"
-    @env.cxx11
-    assert_match "x", @env["HOMEBREW_CCCFG"]
-  end
-
-  def test_supported_cxx11_clang
-    @env["HOMEBREW_CC"] = "clang"
-    @env.cxx11
-    assert_match "x", @env["HOMEBREW_CCCFG"]
-    assert_match "g", @env["HOMEBREW_CCCFG"]
-  end
-end
-- 
cgit v1.2.3


From e03caebaedf579d5330c5c908b2d3ffa927ea5c3 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 13:26:21 +0100
Subject: Convert Tab test to spec.

---
 Library/Homebrew/test/tab_spec.rb | 341 ++++++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/tab_test.rb | 318 -----------------------------------
 2 files changed, 341 insertions(+), 318 deletions(-)
 create mode 100644 Library/Homebrew/test/tab_spec.rb
 delete mode 100644 Library/Homebrew/test/tab_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb
new file mode 100644
index 000000000..32a06a681
--- /dev/null
+++ b/Library/Homebrew/test/tab_spec.rb
@@ -0,0 +1,341 @@
+require "tab"
+require "formula"
+
+RSpec::Matchers.alias_matcher :have_option_with, :be_with
+
+describe Tab do
+  matcher :be_poured_from_bottle do
+    match do |actual|
+      actual.poured_from_bottle == true
+    end
+  end
+
+  matcher :be_built_as_bottle do
+    match do |actual|
+      actual.built_as_bottle == true
+    end
+  end
+
+  subject {
+    described_class.new(
+      "homebrew_version" => HOMEBREW_VERSION,
+      "used_options"         => used_options.as_flags,
+      "unused_options"       => unused_options.as_flags,
+      "built_as_bottle"      => false,
+      "poured_from_bottle"   => true,
+      "changed_files"        => [],
+      "time"                 => time,
+      "source_modified_time" => 0,
+      "HEAD"                 => TEST_SHA1,
+      "compiler"             => "clang",
+      "stdlib"               => "libcxx",
+      "runtime_dependencies" => [],
+      "source"               => {
+        "tap" => CoreTap.instance.to_s,
+        "path" => CoreTap.instance.path.to_s,
+        "spec" => "stable",
+        "versions" => {
+          "stable" => "0.10",
+          "devel" => "0.14",
+          "head" => "HEAD-1111111",
+        },
+      },
+    )
+  }
+  let(:time) { Time.now.to_i }
+  let(:unused_options) { Options.create(%w[--with-baz --without-qux]) }
+  let(:used_options) { Options.create(%w[--with-foo --without-bar]) }
+
+  let(:f) { formula { url "foo-1.0" } }
+  let(:f_tab_path) { f.prefix/"INSTALL_RECEIPT.json" }
+  let(:f_tab_content) { (TEST_FIXTURE_DIR/"receipt.json").read }
+
+  specify "defaults" do
+    tab = described_class.empty
+
+    expect(tab.homebrew_version).to eq(HOMEBREW_VERSION)
+    expect(tab.unused_options).to be_empty
+    expect(tab.used_options).to be_empty
+    expect(tab.changed_files).to be nil
+    expect(tab).not_to be_built_as_bottle
+    expect(tab).not_to be_poured_from_bottle
+    expect(tab).to be_stable
+    expect(tab).not_to be_devel
+    expect(tab).not_to be_head
+    expect(tab.tap).to be nil
+    expect(tab.time).to be nil
+    expect(tab.HEAD).to be nil
+    expect(tab.runtime_dependencies).to be_empty
+    expect(tab.stable_version).to be nil
+    expect(tab.devel_version).to be nil
+    expect(tab.head_version).to be nil
+    expect(tab.cxxstdlib.compiler).to eq(DevelopmentTools.default_compiler)
+    expect(tab.cxxstdlib.type).to be nil
+    expect(tab.source["path"]).to be nil
+  end
+
+  specify "#include?" do
+    expect(subject).to include("with-foo")
+    expect(subject).to include("without-bar")
+  end
+
+  specify "#with?" do
+    expect(subject).to have_option_with("foo")
+    expect(subject).to have_option_with("qux")
+    expect(subject).not_to have_option_with("bar")
+    expect(subject).not_to have_option_with("baz")
+  end
+
+  specify "#universal?" do
+    tab = described_class.new(used_options: %w[--universal])
+    expect(tab).to be_universal
+  end
+
+  specify "#parsed_homebrew_version" do
+    tab = described_class.new
+    expect(tab.parsed_homebrew_version).to be Version::NULL
+
+    tab = described_class.new(homebrew_version: "1.2.3")
+    expect(tab.parsed_homebrew_version).to eq("1.2.3")
+    expect(tab.parsed_homebrew_version).to be < "1.2.3-1-g12789abdf"
+    expect(tab.parsed_homebrew_version).to be_kind_of(Version)
+
+    tab.homebrew_version = "1.2.4-567-g12789abdf"
+    expect(tab.parsed_homebrew_version).to be > "1.2.4"
+    expect(tab.parsed_homebrew_version).to be > "1.2.4-566-g21789abdf"
+    expect(tab.parsed_homebrew_version).to be < "1.2.4-568-g01789abdf"
+
+    tab = described_class.new(homebrew_version: "2.0.0-134-gabcdefabc-dirty")
+    expect(tab.parsed_homebrew_version).to be > "2.0.0"
+    expect(tab.parsed_homebrew_version).to be > "2.0.0-133-g21789abdf"
+    expect(tab.parsed_homebrew_version).to be < "2.0.0-135-g01789abdf"
+  end
+
+  specify "#runtime_dependencies" do
+    tab = described_class.new
+    expect(tab.runtime_dependencies).to be nil
+
+    tab.homebrew_version = "1.1.6"
+    expect(tab.runtime_dependencies).to be nil
+
+    tab.runtime_dependencies = []
+    expect(tab.runtime_dependencies).not_to be nil
+
+    tab.homebrew_version = "1.1.5"
+    expect(tab.runtime_dependencies).to be nil
+
+    tab.homebrew_version = "1.1.7"
+    expect(tab.runtime_dependencies).not_to be nil
+
+    tab.homebrew_version = "1.1.10"
+    expect(tab.runtime_dependencies).not_to be nil
+
+    tab.runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }]
+    expect(tab.runtime_dependencies).not_to be nil
+  end
+
+  specify "#cxxstdlib" do
+    expect(subject.cxxstdlib.compiler).to eq(:clang)
+    expect(subject.cxxstdlib.type).to eq(:libcxx)
+  end
+
+  specify "other attributes" do
+    expect(subject.HEAD).to eq(TEST_SHA1)
+    expect(subject.tap.name).to eq("homebrew/core")
+    expect(subject.time).to eq(time)
+    expect(subject).not_to be_built_as_bottle
+    expect(subject).to be_poured_from_bottle
+  end
+
+  describe "::from_file" do
+    it "parses a Tab from a file" do
+      path = Pathname.new("#{TEST_FIXTURE_DIR}/receipt.json")
+      tab = described_class.from_file(path)
+      source_path = "/usr/local/Library/Taps/homebrew/homebrew-core/Formula/foo.rb"
+      runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }]
+      changed_files = %w[INSTALL_RECEIPT.json bin/foo]
+
+      expect(tab.used_options.sort).to eq(used_options.sort)
+      expect(tab.unused_options.sort).to eq(unused_options.sort)
+      expect(tab.changed_files).to eq(changed_files)
+      expect(tab).not_to be_built_as_bottle
+      expect(tab).to be_poured_from_bottle
+      expect(tab).to be_stable
+      expect(tab).not_to be_devel
+      expect(tab).not_to be_head
+      expect(tab.tap.name).to eq("homebrew/core")
+      expect(tab.spec).to eq(:stable)
+      expect(tab.time).to eq(Time.at(1_403_827_774).to_i)
+      expect(tab.HEAD).to eq(TEST_SHA1)
+      expect(tab.cxxstdlib.compiler).to eq(:clang)
+      expect(tab.cxxstdlib.type).to eq(:libcxx)
+      expect(tab.runtime_dependencies).to eq(runtime_dependencies)
+      expect(tab.stable_version.to_s).to eq("2.14")
+      expect(tab.devel_version.to_s).to eq("2.15")
+      expect(tab.head_version.to_s).to eq("HEAD-0000000")
+      expect(tab.source["path"]).to eq(source_path)
+    end
+
+    it "can parse an old Tab file" do
+      path = Pathname.new("#{TEST_FIXTURE_DIR}/receipt_old.json")
+      tab = described_class.from_file(path)
+
+      expect(tab.used_options.sort).to eq(used_options.sort)
+      expect(tab.unused_options.sort).to eq(unused_options.sort)
+      expect(tab).not_to be_built_as_bottle
+      expect(tab).to be_poured_from_bottle
+      expect(tab).to be_stable
+      expect(tab).not_to be_devel
+      expect(tab).not_to be_head
+      expect(tab.tap.name).to eq("homebrew/core")
+      expect(tab.spec).to eq(:stable)
+      expect(tab.time).to eq(Time.at(1_403_827_774).to_i)
+      expect(tab.HEAD).to eq(TEST_SHA1)
+      expect(tab.cxxstdlib.compiler).to eq(:clang)
+      expect(tab.cxxstdlib.type).to eq(:libcxx)
+      expect(tab.runtime_dependencies).to be nil
+    end
+  end
+
+  describe "::create" do
+    it "creates a Tab" do
+      f = formula do
+        url "foo-1.0"
+        depends_on "bar"
+        depends_on "user/repo/from_tap"
+        depends_on "baz" => :build
+      end
+
+      tap = Tap.new("user", "repo")
+      from_tap = formula("from_tap", path: tap.path/"Formula/from_tap.rb") do
+        url "from_tap-1.0"
+      end
+      stub_formula_loader from_tap
+
+      stub_formula_loader formula("bar") { url "bar-2.0" }
+      stub_formula_loader formula("baz") { url "baz-3.0" }
+
+      compiler = DevelopmentTools.default_compiler
+      stdlib = :libcxx
+      tab = described_class.create(f, compiler, stdlib)
+
+      runtime_dependencies = [
+        { "full_name" => "bar", "version" => "2.0" },
+        { "full_name" => "user/repo/from_tap", "version" => "1.0" },
+      ]
+
+      expect(tab.runtime_dependencies).to eq(runtime_dependencies)
+      expect(tab.source["path"]).to eq(f.path.to_s)
+    end
+
+    it "can create a Tab from an alias" do
+      alias_path = CoreTap.instance.alias_dir/"bar"
+      f = formula(alias_path: alias_path) { url "foo-1.0" }
+      compiler = DevelopmentTools.default_compiler
+      stdlib = :libcxx
+      tab = described_class.create(f, compiler, stdlib)
+
+      expect(tab.source["path"]).to eq(f.alias_path.to_s)
+    end
+  end
+
+  describe "::for_keg" do
+    subject { described_class.for_keg(f.prefix) }
+
+    it "creates a Tab for a given Keg" do
+      f.prefix.mkpath
+      f_tab_path.write f_tab_content
+
+      expect(subject.tabfile).to eq(f_tab_path)
+    end
+
+    it "can create a Tab for a non-existant Keg" do
+      f.prefix.mkpath
+
+      expect(subject.tabfile).to be nil
+    end
+  end
+
+  describe "::for_formula" do
+    it "creates a Tab for a given Formula" do
+      tab = described_class.for_formula(f)
+      expect(tab.source["path"]).to eq(f.path.to_s)
+    end
+
+    it "can create a Tab for for a Formula from an alias" do
+      alias_path = CoreTap.instance.alias_dir/"bar"
+      f = formula(alias_path: alias_path) { url "foo-1.0" }
+
+      tab = described_class.for_formula(f)
+      expect(tab.source["path"]).to eq(alias_path.to_s)
+    end
+
+    it "creates a Tab for a given Formula" do
+      f.prefix.mkpath
+      f_tab_path.write f_tab_content
+
+      tab = described_class.for_formula(f)
+      expect(tab.tabfile).to eq(f_tab_path)
+    end
+
+    it "can create a Tab for a non-existant Formula" do
+      f.prefix.mkpath
+
+      tab = described_class.for_formula(f)
+      expect(tab.tabfile).to be nil
+    end
+
+    it "can create a Tab for a Formula with multiple Kegs" do
+      f.prefix.mkpath
+      f_tab_path.write f_tab_content
+
+      f2 = formula { url "foo-2.0" }
+      f2.prefix.mkpath
+
+      expect(f2.rack).to eq(f.rack)
+      expect(f.installed_prefixes.length).to eq(2)
+
+      tab = described_class.for_formula(f)
+      expect(tab.tabfile).to eq(f_tab_path)
+    end
+
+    it "can create a Tab for a Formula with an outdated Kegs" do
+      f_tab_path.write f_tab_content
+
+      f2 = formula { url "foo-2.0" }
+
+      expect(f2.rack).to eq(f.rack)
+      expect(f.installed_prefixes.length).to eq(1)
+
+      tab = described_class.for_formula(f)
+      expect(tab.tabfile).to eq(f_tab_path)
+    end
+  end
+
+  specify "#to_json" do
+    tab = described_class.new(JSON.parse(subject.to_json))
+    expect(tab.used_options.sort).to eq(subject.used_options.sort)
+    expect(tab.unused_options.sort).to eq(subject.unused_options.sort)
+    expect(tab.built_as_bottle).to eq(subject.built_as_bottle)
+    expect(tab.poured_from_bottle).to eq(subject.poured_from_bottle)
+    expect(tab.changed_files).to eq(subject.changed_files)
+    expect(tab.tap).to eq(subject.tap)
+    expect(tab.spec).to eq(subject.spec)
+    expect(tab.time).to eq(subject.time)
+    expect(tab.HEAD).to eq(subject.HEAD)
+    expect(tab.compiler).to eq(subject.compiler)
+    expect(tab.stdlib).to eq(subject.stdlib)
+    expect(tab.runtime_dependencies).to eq(subject.runtime_dependencies)
+    expect(tab.stable_version).to eq(subject.stable_version)
+    expect(tab.devel_version).to eq(subject.devel_version)
+    expect(tab.head_version).to eq(subject.head_version)
+    expect(tab.source["path"]).to eq(subject.source["path"])
+  end
+
+  specify "::remap_deprecated_options" do
+    deprecated_options = [DeprecatedOption.new("with-foo", "with-foo-new")]
+    remapped_options = described_class.remap_deprecated_options(deprecated_options, subject.used_options)
+    expect(remapped_options).to include(Option.new("without-bar"))
+    expect(remapped_options).to include(Option.new("with-foo-new"))
+  end
+end
diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb
deleted file mode 100644
index 08d45ee90..000000000
--- a/Library/Homebrew/test/tab_test.rb
+++ /dev/null
@@ -1,318 +0,0 @@
-require "testing_env"
-require "tab"
-require "formula"
-
-class TabTests < Homebrew::TestCase
-  def setup
-    super
-
-    @time = Time.now.to_i
-    @used = Options.create(%w[--with-foo --without-bar])
-    @unused = Options.create(%w[--with-baz --without-qux])
-
-    @tab = Tab.new(
-      "homebrew_version" => HOMEBREW_VERSION,
-      "used_options"         => @used.as_flags,
-      "unused_options"       => @unused.as_flags,
-      "built_as_bottle"      => false,
-      "poured_from_bottle"   => true,
-      "changed_files"        => [],
-      "time"                 => @time,
-      "source_modified_time" => 0,
-      "HEAD"                 => TEST_SHA1,
-      "compiler"             => "clang",
-      "stdlib"               => "libcxx",
-      "runtime_dependencies" => [],
-      "source"               => {
-        "tap" => CoreTap.instance.to_s,
-        "path" => CoreTap.instance.path.to_s,
-        "spec" => "stable",
-        "versions" => {
-          "stable" => "0.10",
-          "devel" => "0.14",
-          "head" => "HEAD-1111111",
-        },
-      },
-    )
-  end
-
-  def test_defaults
-    tab = Tab.empty
-
-    assert_equal HOMEBREW_VERSION, tab.homebrew_version
-    assert_empty tab.unused_options
-    assert_empty tab.used_options
-    assert_nil tab.changed_files
-    refute_predicate tab, :built_as_bottle
-    refute_predicate tab, :poured_from_bottle
-    assert_predicate tab, :stable?
-    refute_predicate tab, :devel?
-    refute_predicate tab, :head?
-    assert_nil tab.tap
-    assert_nil tab.time
-    assert_nil tab.HEAD
-    assert_empty tab.runtime_dependencies
-    assert_nil tab.stable_version
-    assert_nil tab.devel_version
-    assert_nil tab.head_version
-    assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler
-    assert_nil tab.cxxstdlib.type
-    assert_nil tab.source["path"]
-  end
-
-  def test_include?
-    assert_includes @tab, "with-foo"
-    assert_includes @tab, "without-bar"
-  end
-
-  def test_with?
-    assert @tab.with?("foo")
-    assert @tab.with?("qux")
-    refute @tab.with?("bar")
-    refute @tab.with?("baz")
-  end
-
-  def test_universal?
-    tab = Tab.new(used_options: %w[--universal])
-    assert_predicate tab, :universal?
-  end
-
-  def test_parsed_homebrew_version
-    tab = Tab.new
-    assert_same Version::NULL, tab.parsed_homebrew_version
-
-    tab = Tab.new(homebrew_version: "1.2.3")
-    assert_equal "1.2.3", tab.parsed_homebrew_version
-    assert tab.parsed_homebrew_version < "1.2.3-1-g12789abdf"
-    assert_kind_of Version, tab.parsed_homebrew_version
-
-    tab.homebrew_version = "1.2.4-567-g12789abdf"
-    assert tab.parsed_homebrew_version > "1.2.4"
-    assert tab.parsed_homebrew_version > "1.2.4-566-g21789abdf"
-    assert tab.parsed_homebrew_version < "1.2.4-568-g01789abdf"
-
-    tab = Tab.new(homebrew_version: "2.0.0-134-gabcdefabc-dirty")
-    assert tab.parsed_homebrew_version > "2.0.0"
-    assert tab.parsed_homebrew_version > "2.0.0-133-g21789abdf"
-    assert tab.parsed_homebrew_version < "2.0.0-135-g01789abdf"
-  end
-
-  def test_runtime_dependencies
-    tab = Tab.new
-    assert_nil tab.runtime_dependencies
-
-    tab.homebrew_version = "1.1.6"
-    assert_nil tab.runtime_dependencies
-
-    tab.runtime_dependencies = []
-    refute_nil tab.runtime_dependencies
-
-    tab.homebrew_version = "1.1.5"
-    assert_nil tab.runtime_dependencies
-
-    tab.homebrew_version = "1.1.7"
-    refute_nil tab.runtime_dependencies
-
-    tab.homebrew_version = "1.1.10"
-    refute_nil tab.runtime_dependencies
-
-    tab.runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }]
-    refute_nil tab.runtime_dependencies
-  end
-
-  def test_cxxstdlib
-    assert_equal :clang, @tab.cxxstdlib.compiler
-    assert_equal :libcxx, @tab.cxxstdlib.type
-  end
-
-  def test_other_attributes
-    assert_equal TEST_SHA1, @tab.HEAD
-    assert_equal "homebrew/core", @tab.tap.name
-    assert_equal @time, @tab.time
-    refute_predicate @tab, :built_as_bottle
-    assert_predicate @tab, :poured_from_bottle
-  end
-
-  def test_from_old_version_file
-    path = Pathname.new("#{TEST_FIXTURE_DIR}/receipt_old.json")
-    tab = Tab.from_file(path)
-
-    assert_equal @used.sort, tab.used_options.sort
-    assert_equal @unused.sort, tab.unused_options.sort
-    refute_predicate tab, :built_as_bottle
-    assert_predicate tab, :poured_from_bottle
-    assert_predicate tab, :stable?
-    refute_predicate tab, :devel?
-    refute_predicate tab, :head?
-    assert_equal "homebrew/core", tab.tap.name
-    assert_equal :stable, tab.spec
-    refute_nil tab.time
-    assert_equal TEST_SHA1, tab.HEAD
-    assert_equal :clang, tab.cxxstdlib.compiler
-    assert_equal :libcxx, tab.cxxstdlib.type
-    assert_nil tab.runtime_dependencies
-  end
-
-  def test_from_file
-    path = Pathname.new("#{TEST_FIXTURE_DIR}/receipt.json")
-    tab = Tab.from_file(path)
-    source_path = "/usr/local/Library/Taps/homebrew/homebrew-core/Formula/foo.rb"
-    runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }]
-    changed_files = %w[INSTALL_RECEIPT.json bin/foo]
-
-    assert_equal @used.sort, tab.used_options.sort
-    assert_equal @unused.sort, tab.unused_options.sort
-    assert_equal changed_files, tab.changed_files
-    refute_predicate tab, :built_as_bottle
-    assert_predicate tab, :poured_from_bottle
-    assert_predicate tab, :stable?
-    refute_predicate tab, :devel?
-    refute_predicate tab, :head?
-    assert_equal "homebrew/core", tab.tap.name
-    assert_equal :stable, tab.spec
-    refute_nil tab.time
-    assert_equal TEST_SHA1, tab.HEAD
-    assert_equal :clang, tab.cxxstdlib.compiler
-    assert_equal :libcxx, tab.cxxstdlib.type
-    assert_equal runtime_dependencies, tab.runtime_dependencies
-    assert_equal "2.14", tab.stable_version.to_s
-    assert_equal "2.15", tab.devel_version.to_s
-    assert_equal "HEAD-0000000", tab.head_version.to_s
-    assert_equal source_path, tab.source["path"]
-  end
-
-  def test_create
-    f = formula do
-      url "foo-1.0"
-      depends_on "bar"
-      depends_on "user/repo/from_tap"
-      depends_on "baz" => :build
-    end
-
-    tap = Tap.new("user", "repo")
-    from_tap = formula("from_tap", tap.path/"Formula/from_tap.rb") do
-      url "from_tap-1.0"
-    end
-    stub_formula_loader from_tap
-
-    stub_formula_loader formula("bar") { url "bar-2.0" }
-    stub_formula_loader formula("baz") { url "baz-3.0" }
-
-    compiler = DevelopmentTools.default_compiler
-    stdlib = :libcxx
-    tab = Tab.create(f, compiler, stdlib)
-
-    runtime_dependencies = [
-      { "full_name" => "bar", "version" => "2.0" },
-      { "full_name" => "user/repo/from_tap", "version" => "1.0" },
-    ]
-
-    assert_equal runtime_dependencies, tab.runtime_dependencies
-    assert_equal f.path.to_s, tab.source["path"]
-  end
-
-  def test_create_from_alias
-    alias_path = CoreTap.instance.alias_dir/"bar"
-    f = formula(alias_path: alias_path) { url "foo-1.0" }
-    compiler = DevelopmentTools.default_compiler
-    stdlib = :libcxx
-    tab = Tab.create(f, compiler, stdlib)
-
-    assert_equal f.alias_path.to_s, tab.source["path"]
-  end
-
-  def test_for_formula
-    f = formula { url "foo-1.0" }
-    tab = Tab.for_formula(f)
-
-    assert_equal f.path.to_s, tab.source["path"]
-  end
-
-  def test_for_formula_from_alias
-    alias_path = CoreTap.instance.alias_dir/"bar"
-    f = formula(alias_path: alias_path) { url "foo-1.0" }
-    tab = Tab.for_formula(f)
-
-    assert_equal alias_path.to_s, tab.source["path"]
-  end
-
-  def test_to_json
-    tab = Tab.new(JSON.parse(@tab.to_json))
-    assert_equal @tab.used_options.sort, tab.used_options.sort
-    assert_equal @tab.unused_options.sort, tab.unused_options.sort
-    assert_equal @tab.built_as_bottle, tab.built_as_bottle
-    assert_equal @tab.poured_from_bottle, tab.poured_from_bottle
-    assert_equal @tab.changed_files, tab.changed_files
-    assert_equal @tab.tap, tab.tap
-    assert_equal @tab.spec, tab.spec
-    assert_equal @tab.time, tab.time
-    assert_equal @tab.HEAD, tab.HEAD
-    assert_equal @tab.compiler, tab.compiler
-    assert_equal @tab.stdlib, tab.stdlib
-    assert_equal @tab.runtime_dependencies, tab.runtime_dependencies
-    assert_equal @tab.stable_version, tab.stable_version
-    assert_equal @tab.devel_version, tab.devel_version
-    assert_equal @tab.head_version, tab.head_version
-    assert_equal @tab.source["path"], tab.source["path"]
-  end
-
-  def test_remap_deprecated_options
-    deprecated_options = [DeprecatedOption.new("with-foo", "with-foo-new")]
-    remapped_options = Tab.remap_deprecated_options(deprecated_options, @tab.used_options)
-    assert_includes remapped_options, Option.new("without-bar")
-    assert_includes remapped_options, Option.new("with-foo-new")
-  end
-end
-
-class TabLoadingTests < Homebrew::TestCase
-  def setup
-    super
-    @f = formula { url "foo-1.0" }
-    @f.prefix.mkpath
-    @path = @f.prefix.join(Tab::FILENAME)
-    @path.write TEST_FIXTURE_DIR.join("receipt.json").read
-  end
-
-  def test_for_keg
-    tab = Tab.for_keg(@f.prefix)
-    assert_equal @path, tab.tabfile
-  end
-
-  def test_for_keg_nonexistent_path
-    @path.unlink
-    tab = Tab.for_keg(@f.prefix)
-    assert_nil tab.tabfile
-  end
-
-  def test_for_formula
-    tab = Tab.for_formula(@f)
-    assert_equal @path, tab.tabfile
-  end
-
-  def test_for_formula_nonexistent_path
-    @path.unlink
-    tab = Tab.for_formula(@f)
-    assert_nil tab.tabfile
-  end
-
-  def test_for_formula_multiple_kegs
-    f2 = formula { url "foo-2.0" }
-    f2.prefix.mkpath
-
-    assert_equal @f.rack, f2.rack
-    assert_equal 2, @f.installed_prefixes.length
-
-    tab = Tab.for_formula(@f)
-    assert_equal @path, tab.tabfile
-  end
-
-  def test_for_formula_outdated_keg
-    f2 = formula { url "foo-2.0" }
-
-    assert_equal @f.rack, f2.rack
-    assert_equal 1, @f.installed_prefixes.length
-
-    tab = Tab.for_formula(f2)
-    assert_equal @path, tab.tabfile
-  end
-end
-- 
cgit v1.2.3


From b0cd1c732d25b112e75facf48325f7841c8b6ac3 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Wed, 22 Feb 2017 00:37:42 +0100
Subject: Convert Formula test to spec.

---
 Library/Homebrew/test/formula_spec.rb   | 1295 +++++++++++++++++++++++++++++++
 Library/Homebrew/test/formula_test.rb   | 1205 ----------------------------
 Library/Homebrew/test/formulary_spec.rb |    8 +
 3 files changed, 1303 insertions(+), 1205 deletions(-)
 create mode 100644 Library/Homebrew/test/formula_spec.rb
 delete mode 100644 Library/Homebrew/test/formula_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb
new file mode 100644
index 000000000..1e064912f
--- /dev/null
+++ b/Library/Homebrew/test/formula_spec.rb
@@ -0,0 +1,1295 @@
+require "test/support/fixtures/testball"
+require "formula"
+
+RSpec::Matchers.alias_matcher :follow_installed_alias, :be_follow_installed_alias
+RSpec::Matchers.alias_matcher :have_any_version_installed, :be_any_version_installed
+RSpec::Matchers.alias_matcher :need_migration, :be_migration_needed
+
+RSpec::Matchers.alias_matcher :have_changed_installed_alias_target, :be_installed_alias_target_changed
+RSpec::Matchers.alias_matcher :supersede_an_installed_formula, :be_supersedes_an_installed_formula
+RSpec::Matchers.alias_matcher :have_changed_alias, :be_alias_changed
+
+RSpec::Matchers.alias_matcher :have_option_defined, :be_option_defined
+RSpec::Matchers.alias_matcher :have_post_install_defined, :be_post_install_defined
+RSpec::Matchers.alias_matcher :have_test_defined, :be_test_defined
+RSpec::Matchers.alias_matcher :pour_bottle, :be_pour_bottle
+
+describe Formula do
+  describe "::new" do
+    let(:klass) do
+      Class.new(described_class) do
+        url "http://example.com/foo-1.0.tar.gz"
+      end
+    end
+
+    let(:name) { "formula_name" }
+    let(:path) { Formulary.core_path(name) }
+    let(:spec) { :stable }
+    let(:alias_name) { "baz@1" }
+    let(:alias_path) { CoreTap.instance.alias_dir/alias_name }
+    let(:f) { klass.new(name, path, spec) }
+    let(:f_alias) { klass.new(name, path, spec, alias_path: alias_path) }
+
+    specify "formula instantiation" do
+      expect(f.name).to eq(name)
+      expect(f.specified_name).to eq(name)
+      expect(f.full_name).to eq(name)
+      expect(f.full_specified_name).to eq(name)
+      expect(f.path).to eq(path)
+      expect(f.alias_path).to be nil
+      expect(f.alias_name).to be nil
+      expect(f.full_alias_name).to be nil
+      expect { klass.new }.to raise_error(ArgumentError)
+    end
+
+    specify "formula instantiation with alias" do
+      expect(f_alias.name).to eq(name)
+      expect(f_alias.full_name).to eq(name)
+      expect(f_alias.path).to eq(path)
+      expect(f_alias.alias_path).to eq(alias_path)
+      expect(f_alias.alias_name).to eq(alias_name)
+      expect(f_alias.specified_name).to eq(alias_name)
+      expect(f_alias.full_alias_name).to eq(alias_name)
+      expect(f_alias.full_specified_name).to eq(alias_name)
+      expect { klass.new }.to raise_error(ArgumentError)
+    end
+
+    context "in a Tap" do
+      let(:tap) { Tap.new("foo", "bar") }
+      let(:path) { (tap.path/"Formula/#{name}.rb") }
+      let(:full_name) { "#{tap.user}/#{tap.repo}/#{name}" }
+      let(:full_alias_name) { "#{tap.user}/#{tap.repo}/#{alias_name}" }
+
+      specify "formula instantiation" do
+        expect(f.name).to eq(name)
+        expect(f.specified_name).to eq(name)
+        expect(f.full_name).to eq(full_name)
+        expect(f.full_specified_name).to eq(full_name)
+        expect(f.path).to eq(path)
+        expect(f.alias_path).to be nil
+        expect(f.alias_name).to be nil
+        expect(f.full_alias_name).to be nil
+        expect { klass.new }.to raise_error(ArgumentError)
+      end
+
+      specify "formula instantiation with alias" do
+        expect(f_alias.name).to eq(name)
+        expect(f_alias.full_name).to eq(full_name)
+        expect(f_alias.path).to eq(path)
+        expect(f_alias.alias_path).to eq(alias_path)
+        expect(f_alias.alias_name).to eq(alias_name)
+        expect(f_alias.specified_name).to eq(alias_name)
+        expect(f_alias.full_alias_name).to eq(full_alias_name)
+        expect(f_alias.full_specified_name).to eq(full_alias_name)
+        expect { klass.new }.to raise_error(ArgumentError)
+      end
+    end
+  end
+
+  describe "#follow_installed_alias?" do
+    let(:f) do
+      formula do
+        url "foo-1.0"
+      end
+    end
+
+    it "returns true by default" do
+      expect(f).to follow_installed_alias
+    end
+
+    it "can be set to true" do
+      f.follow_installed_alias = true
+      expect(f).to follow_installed_alias
+    end
+
+    it "can be set to false" do
+      f.follow_installed_alias = false
+      expect(f).not_to follow_installed_alias
+    end
+  end
+
+  example "installed alias with core" do
+    f = formula do
+      url "foo-1.0"
+    end
+
+    build_values_with_no_installed_alias = [
+      nil,
+      BuildOptions.new({}, {}),
+      Tab.new(source: { "path" => f.path.to_s }),
+    ]
+    build_values_with_no_installed_alias.each do |build|
+      f.build = build
+      expect(f.installed_alias_path).to be nil
+      expect(f.installed_alias_name).to be nil
+      expect(f.full_installed_alias_name).to be nil
+      expect(f.installed_specified_name).to eq(f.name)
+      expect(f.full_installed_specified_name).to eq(f.name)
+    end
+
+    alias_name = "bar"
+    alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
+
+    f.build = Tab.new(source: { "path" => alias_path })
+
+    expect(f.installed_alias_path).to eq(alias_path)
+    expect(f.installed_alias_name).to eq(alias_name)
+    expect(f.full_installed_alias_name).to eq(alias_name)
+    expect(f.installed_specified_name).to eq(alias_name)
+    expect(f.full_installed_specified_name).to eq(alias_name)
+  end
+
+  example "installed alias with tap" do
+    tap = Tap.new("user", "repo")
+    name = "foo"
+    path = "#{tap.path}/Formula/#{name}.rb"
+    f = formula name, path: path do
+      url "foo-1.0"
+    end
+
+    build_values_with_no_installed_alias = [nil, BuildOptions.new({}, {}), Tab.new(source: { "path" => f.path })]
+    build_values_with_no_installed_alias.each do |build|
+      f.build = build
+      expect(f.installed_alias_path).to be nil
+      expect(f.installed_alias_name).to be nil
+      expect(f.full_installed_alias_name).to be nil
+      expect(f.installed_specified_name).to eq(f.name)
+      expect(f.full_installed_specified_name).to eq(f.full_name)
+    end
+
+    alias_name = "bar"
+    full_alias_name = "#{tap.user}/#{tap.repo}/#{alias_name}"
+    alias_path = "#{tap.alias_dir}/#{alias_name}"
+
+    f.build = Tab.new(source: { "path" => alias_path })
+
+    expect(f.installed_alias_path).to eq(alias_path)
+    expect(f.installed_alias_name).to eq(alias_name)
+    expect(f.full_installed_alias_name).to eq(full_alias_name)
+    expect(f.installed_specified_name).to eq(alias_name)
+    expect(f.full_installed_specified_name).to eq(full_alias_name)
+  end
+
+  specify "#prefix" do
+    f = Testball.new
+    expect(f.prefix).to eq(HOMEBREW_CELLAR/f.name/"0.1")
+    expect(f.prefix).to be_kind_of(Pathname)
+  end
+
+  example "revised prefix" do
+    f = Class.new(Testball) { revision(1) }.new
+    expect(f.prefix).to eq(HOMEBREW_CELLAR/f.name/"0.1_1")
+  end
+
+  specify "#any_version_installed?" do
+    f = formula do
+      url "foo"
+      version "1.0"
+    end
+
+    expect(f).not_to have_any_version_installed
+
+    prefix = HOMEBREW_CELLAR/f.name/"0.1"
+    prefix.mkpath
+    FileUtils.touch prefix/Tab::FILENAME
+
+    expect(f).to have_any_version_installed
+  end
+
+  specify "#migration_needed" do
+    f = Testball.new("newname")
+    f.instance_variable_set(:@oldname, "oldname")
+    f.instance_variable_set(:@tap, CoreTap.instance)
+
+    oldname_prefix = (HOMEBREW_CELLAR/"oldname/2.20")
+    newname_prefix = (HOMEBREW_CELLAR/"newname/2.10")
+
+    oldname_prefix.mkpath
+    oldname_tab = Tab.empty
+    oldname_tab.tabfile = oldname_prefix/Tab::FILENAME
+    oldname_tab.write
+
+    expect(f).not_to need_migration
+
+    oldname_tab.tabfile.unlink
+    oldname_tab.source["tap"] = "homebrew/core"
+    oldname_tab.write
+
+    expect(f).to need_migration
+
+    newname_prefix.mkpath
+
+    expect(f).not_to need_migration
+  end
+
+  describe "#installed?" do
+    let(:f) { Testball.new }
+
+    it "returns false if the #installed_prefix is not a directory" do
+      allow(f).to receive(:installed_prefix).and_return(double(directory?: false))
+      expect(f).not_to be_installed
+    end
+
+    it "returns false if the #installed_prefix does not have children" do
+      allow(f).to receive(:installed_prefix).and_return(double(directory?: true, children: []))
+      expect(f).not_to be_installed
+    end
+
+    it "returns true if the #installed_prefix has children" do
+      allow(f).to receive(:installed_prefix).and_return(double(directory?: true, children: [double]))
+      expect(f).to be_installed
+    end
+  end
+
+  describe "#installed prefix" do
+    let(:f) do
+      formula do
+        url "foo"
+        version "1.9"
+
+        head "foo"
+
+        devel do
+          url "foo"
+          version "2.1-devel"
+        end
+      end
+    end
+
+    let(:stable_prefix) { HOMEBREW_CELLAR/f.name/f.version }
+    let(:devel_prefix) { HOMEBREW_CELLAR/f.name/f.devel.version }
+    let(:head_prefix) { HOMEBREW_CELLAR/f.name/f.head.version }
+
+    it "is the same as #prefix by default" do
+      expect(f.installed_prefix).to eq(f.prefix)
+    end
+
+    it "returns the stable prefix if it is installed" do
+      stable_prefix.mkpath
+      expect(f.installed_prefix).to eq(stable_prefix)
+    end
+
+    it "returns the devel prefix if it is installed" do
+      devel_prefix.mkpath
+      expect(f.installed_prefix).to eq(devel_prefix)
+    end
+
+    it "returns the head prefix if it is installed" do
+      head_prefix.mkpath
+      expect(f.installed_prefix).to eq(head_prefix)
+    end
+
+    it "returns the stable prefix if head is outdated" do
+      head_prefix.mkpath
+
+      tab = Tab.empty
+      tab.tabfile = head_prefix/Tab::FILENAME
+      tab.source["versions"] = { "stable" => "1.0" }
+      tab.write
+
+      expect(f.installed_prefix).to eq(stable_prefix)
+    end
+
+    it "returns the stable prefix if head and devel are outdated" do
+      head_prefix.mkpath
+
+      tab = Tab.empty
+      tab.tabfile = head_prefix/Tab::FILENAME
+      tab.source["versions"] = { "stable" => "1.9", "devel" => "2.0" }
+      tab.write
+
+      expect(f.installed_prefix).to eq(stable_prefix)
+    end
+
+    it "returns the devel prefix if the active specification is :devel" do
+      f.active_spec = :devel
+      expect(f.installed_prefix).to eq(devel_prefix)
+    end
+
+    it "returns the head prefix if the active specification is :head" do
+      f.active_spec = :head
+      expect(f.installed_prefix).to eq(head_prefix)
+    end
+  end
+
+  describe "#latest_head_prefix" do
+    let(:f) { Testball.new }
+
+    it "returns the latest head prefix" do
+      stamps_with_revisions = [
+        [111111, 1],
+        [222222, 0],
+        [222222, 1],
+        [222222, 2],
+      ]
+
+      stamps_with_revisions.each do |stamp, revision|
+        version = "HEAD-#{stamp}"
+        version << "_#{revision}" unless revision.zero?
+
+        prefix = f.rack/version
+        prefix.mkpath
+
+        tab = Tab.empty
+        tab.tabfile = prefix/Tab::FILENAME
+        tab.source_modified_time = stamp
+        tab.write
+      end
+
+      prefix = HOMEBREW_CELLAR/f.name/"HEAD-222222_2"
+
+      expect(f.latest_head_prefix).to eq(prefix)
+    end
+  end
+
+  specify "equality" do
+    x = Testball.new
+    y = Testball.new
+
+    expect(x).to eq(y)
+    expect(x).to eql(y)
+    expect(x.hash).to eq(y.hash)
+  end
+
+  specify "inequality" do
+    x = Testball.new("foo")
+    y = Testball.new("bar")
+
+    expect(x).not_to eq(y)
+    expect(x).not_to eql(y)
+    expect(x.hash).not_to eq(y.hash)
+  end
+
+  specify "comparison with non formula objects does not raise" do
+    expect(Object.new).not_to eq(Testball.new)
+  end
+
+  specify "#<=>" do
+    expect(Testball.new <=> Object.new).to be nil
+  end
+
+  describe "#installed_alias_path" do
+    example "alias paths with build options" do
+      alias_path = (CoreTap.instance.alias_dir/"another_name")
+
+      f = formula alias_path: alias_path do
+        url "foo-1.0"
+      end
+      f.build = BuildOptions.new({}, {})
+
+      expect(f.alias_path).to eq(alias_path)
+      expect(f.installed_alias_path).to be nil
+    end
+
+    example "alias paths with tab with non alias source path" do
+      alias_path = (CoreTap.instance.alias_dir/"another_name")
+      source_path = (CoreTap.instance.formula_dir/"another_other_name")
+
+      f = formula alias_path: alias_path do
+        url "foo-1.0"
+      end
+      f.build = Tab.new(source: { "path" => source_path.to_s })
+
+      expect(f.alias_path).to eq(alias_path)
+      expect(f.installed_alias_path).to be nil
+    end
+
+    example "alias paths with tab with alias source path" do
+      alias_path = (CoreTap.instance.alias_dir/"another_name")
+      source_path = (CoreTap.instance.alias_dir/"another_other_name")
+
+      f = formula alias_path: alias_path do
+        url "foo-1.0"
+      end
+      f.build = Tab.new(source: { "path" => source_path.to_s })
+
+      expect(f.alias_path).to eq(alias_path)
+      expect(f.installed_alias_path).to eq(source_path.to_s)
+    end
+  end
+
+  describe "::installed_with_alias_path" do
+    specify "with alias path with nil" do
+      expect(described_class.installed_with_alias_path(nil)).to be_empty
+    end
+
+    specify "with alias path with a path" do
+      alias_path = "#{CoreTap.instance.alias_dir}/alias"
+      different_alias_path = "#{CoreTap.instance.alias_dir}/another_alias"
+
+      formula_with_alias = formula "foo" do
+        url "foo-1.0"
+      end
+      formula_with_alias.build = Tab.empty
+      formula_with_alias.build.source["path"] = alias_path
+
+      formula_without_alias = formula "bar" do
+        url "bar-1.0"
+      end
+      formula_without_alias.build = Tab.empty
+      formula_without_alias.build.source["path"] = formula_without_alias.path.to_s
+
+      formula_with_different_alias = formula "baz" do
+        url "baz-1.0"
+      end
+      formula_with_different_alias.build = Tab.empty
+      formula_with_different_alias.build.source["path"] = different_alias_path
+
+      formulae = [
+        formula_with_alias,
+        formula_without_alias,
+        formula_with_different_alias,
+      ]
+
+      allow(described_class).to receive(:installed).and_return(formulae)
+
+      expect(described_class.installed_with_alias_path(alias_path))
+        .to eq([formula_with_alias])
+    end
+  end
+
+  specify "spec integration" do
+    f = formula do
+      homepage "http://example.com"
+
+      url "http://example.com/test-0.1.tbz"
+      mirror "http://example.org/test-0.1.tbz"
+      sha256 TEST_SHA256
+
+      head "http://example.com/test.git", tag: "foo"
+
+      devel do
+        url "http://example.com/test-0.2.tbz"
+        mirror "http://example.org/test-0.2.tbz"
+        sha256 TEST_SHA256
+      end
+    end
+
+    expect(f.homepage).to eq("http://example.com")
+    expect(f.version).to eq(Version.create("0.1"))
+    expect(f).to be_stable
+    expect(f.stable.version).to eq(Version.create("0.1"))
+    expect(f.devel.version).to eq(Version.create("0.2"))
+    expect(f.head.version).to eq(Version.create("HEAD"))
+  end
+
+  specify "#active_spec=" do
+    f = formula do
+      url "foo"
+      version "1.0"
+      revision 1
+
+      devel do
+        url "foo"
+        version "1.0beta"
+      end
+    end
+
+    expect(f.active_spec_sym).to eq(:stable)
+    expect(f.send(:active_spec)).to eq(f.stable)
+    expect(f.pkg_version.to_s).to eq("1.0_1")
+
+    f.active_spec = :devel
+
+    expect(f.active_spec_sym).to eq(:devel)
+    expect(f.send(:active_spec)).to eq(f.devel)
+    expect(f.pkg_version.to_s).to eq("1.0beta_1")
+    expect { f.active_spec = :head }.to raise_error(FormulaSpecificationError)
+  end
+
+  specify "class specs are always initialized" do
+    f = formula do
+      url "foo-1.0"
+    end
+
+    expect(f.class.stable).to be_kind_of(SoftwareSpec)
+    expect(f.class.devel).to be_kind_of(SoftwareSpec)
+    expect(f.class.head).to be_kind_of(SoftwareSpec)
+  end
+
+  specify "incomplete instance specs are not accessible" do
+    f = formula do
+      url "foo-1.0"
+    end
+
+    expect(f.devel).to be nil
+    expect(f.head).to be nil
+  end
+
+  it "honors attributes declared before specs" do
+    f = formula do
+      url "foo-1.0"
+
+      depends_on "foo"
+
+      devel do
+        url "foo-1.1"
+      end
+    end
+
+    expect(f.class.stable.deps.first.name).to eq("foo")
+    expect(f.class.devel.deps.first.name).to eq("foo")
+    expect(f.class.head.deps.first.name).to eq("foo")
+  end
+
+  describe "#pkg_version" do
+    specify "simple version" do
+      f = formula do
+        url "foo-1.0.bar"
+      end
+
+      expect(f.pkg_version).to eq(PkgVersion.parse("1.0"))
+    end
+
+    specify "version with revision" do
+      f = formula do
+        url "foo-1.0.bar"
+        revision 1
+      end
+
+      expect(f.pkg_version).to eq(PkgVersion.parse("1.0_1"))
+    end
+
+    specify "head uses revisions" do
+      f = formula "test", spec: :head do
+        url "foo-1.0.bar"
+        revision 1
+
+        head "foo"
+      end
+
+      expect(f.pkg_version).to eq(PkgVersion.parse("HEAD_1"))
+    end
+  end
+
+  specify "#update_head_version" do
+    f = formula do
+      head "foo", using: :git
+    end
+
+    cached_location = f.head.downloader.cached_location
+    cached_location.mkpath
+    cached_location.cd do
+      FileUtils.touch "LICENSE"
+
+      shutup do
+        system("git", "init")
+        system("git", "add", "--all")
+        system("git", "commit", "-m", "Initial commit")
+      end
+    end
+
+    f.update_head_version
+
+    expect(f.head.version).to eq(Version.create("HEAD-5658946"))
+  end
+
+  specify "legacy options" do
+    f = formula do
+      url "foo-1.0"
+
+      def options
+        [
+          ["--foo", "desc"],
+          ["--bar", "desc"],
+        ]
+      end
+
+      option("baz")
+    end
+
+    expect(f).to have_option_defined("foo")
+    expect(f).to have_option_defined("bar")
+    expect(f).to have_option_defined("baz")
+  end
+
+  specify "#desc" do
+    f = formula do
+      desc "a formula"
+
+      url "foo-1.0"
+    end
+
+    expect(f.desc).to eq("a formula")
+  end
+
+  specify "#post_install_defined?" do
+    f1 = formula do
+      url "foo-1.0"
+
+      def post_install
+        # do nothing
+      end
+    end
+
+    f2 = formula do
+      url "foo-1.0"
+    end
+
+    expect(f1).to have_post_install_defined
+    expect(f2).not_to have_post_install_defined
+  end
+
+  specify "#test_defined?" do
+    f1 = formula do
+      url "foo-1.0"
+
+      def test
+        # do nothing
+      end
+    end
+
+    f2 = formula do
+      url "foo-1.0"
+    end
+
+    expect(f1).to have_test_defined
+    expect(f2).not_to have_test_defined
+  end
+
+  specify "test fixtures" do
+    f1 = formula do
+      url "foo-1.0"
+    end
+
+    expect(f1.test_fixtures("foo")).to eq(Pathname.new("#{HOMEBREW_LIBRARY_PATH}/test/support/fixtures/foo"))
+  end
+
+  specify "dependencies" do
+    f1 = formula "f1" do
+      url "f1-1.0"
+    end
+
+    f2 = formula "f2" do
+      url "f2-1.0"
+    end
+
+    f3 = formula "f3" do
+      url "f3-1.0"
+
+      depends_on "f1" => :build
+      depends_on "f2"
+    end
+
+    f4 = formula "f4" do
+      url "f4-1.0"
+
+      depends_on "f1"
+    end
+
+    stub_formula_loader(f1)
+    stub_formula_loader(f2)
+    stub_formula_loader(f3)
+    stub_formula_loader(f4)
+
+    f5 = formula "f5" do
+      url "f5-1.0"
+
+      depends_on "f3" => :build
+      depends_on "f4"
+    end
+
+    expect(f5.deps.map(&:name)).to eq(["f3", "f4"])
+    expect(f5.recursive_dependencies.map(&:name)).to eq(["f1", "f2", "f3", "f4"])
+    expect(f5.runtime_dependencies.map(&:name)).to eq(["f1", "f4"])
+  end
+
+  specify "runtime dependencies with optional deps from tap" do
+    tap_loader = double
+
+    allow(tap_loader).to receive(:get_formula).and_raise(RuntimeError, "tried resolving tap formula")
+    allow(Formulary).to receive(:loader_for).with("foo/bar/f1", from: nil).and_return(tap_loader)
+    stub_formula_loader(formula("f2") { url("f2-1.0") }, "baz/qux/f2")
+
+    f3 = formula "f3" do
+      url "f3-1.0"
+
+      depends_on "foo/bar/f1" => :optional
+      depends_on "baz/qux/f2"
+    end
+
+    expect(f3.runtime_dependencies.map(&:name)).to eq(["baz/qux/f2"])
+
+    stub_formula_loader(formula("f1") { url("f1-1.0") }, "foo/bar/f1")
+    f3.build = BuildOptions.new(Options.create(["--with-f1"]), f3.options)
+
+    expect(f3.runtime_dependencies.map(&:name)).to eq(["foo/bar/f1", "baz/qux/f2"])
+  end
+
+  specify "requirements" do
+    f1 = formula "f1" do
+      url "f1-1"
+
+      depends_on :python
+      depends_on x11: :recommended
+      depends_on xcode: ["1.0", :optional]
+    end
+    stub_formula_loader(f1)
+
+    python = PythonRequirement.new
+    x11 = X11Requirement.new("x11", [:recommended])
+    xcode = XcodeRequirement.new(["1.0", :optional])
+
+    expect(Set.new(f1.recursive_requirements)).to eq(Set[python, x11])
+
+    f1.build = BuildOptions.new(["--with-xcode", "--without-x11"], f1.options)
+
+    expect(Set.new(f1.recursive_requirements)).to eq(Set[python, xcode])
+
+    f1.build = f1.stable.build
+    f2 = formula "f2" do
+      url "f2-1"
+
+      depends_on "f1"
+    end
+
+    expect(Set.new(f2.recursive_requirements)).to eq(Set[python, x11])
+    expect(Set.new(f2.recursive_requirements {})).to eq(Set[python, x11, xcode])
+
+    requirements = f2.recursive_requirements do |_dependent, requirement|
+      Requirement.prune if requirement.is_a?(PythonRequirement)
+    end
+
+    expect(Set.new(requirements)).to eq(Set[x11, xcode])
+  end
+
+  specify "#to_hash" do
+    f1 = formula "foo" do
+      url "foo-1.0"
+
+      bottle do
+        cellar(:any)
+        sha256(TEST_SHA256 => Utils::Bottles.tag)
+      end
+    end
+
+    h = f1.to_hash
+
+    expect(h).to be_a(Hash)
+    expect(h["name"]).to eq("foo")
+    expect(h["full_name"]).to eq("foo")
+    expect(h["versions"]["stable"]).to eq("1.0")
+    expect(h["versions"]["bottle"]).to be_truthy
+  end
+
+  describe "#eligible_kegs_for_cleanup" do
+    it "returns Kegs eligible for cleanup" do
+      f1 = Class.new(Testball) do
+        version("1.0")
+      end.new
+
+      f2 = Class.new(Testball) do
+        version("0.2")
+        version_scheme(1)
+      end.new
+
+      f3 = Class.new(Testball) do
+        version("0.3")
+        version_scheme(1)
+      end.new
+
+      f4 = Class.new(Testball) do
+        version("0.1")
+        version_scheme(2)
+      end.new
+
+      shutup do
+        [f1, f2, f3, f4].each do |f|
+          f.brew { f.install }
+          Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
+        end
+      end
+
+      expect(f1).to be_installed
+      expect(f2).to be_installed
+      expect(f3).to be_installed
+      expect(f4).to be_installed
+      expect(f3.eligible_kegs_for_cleanup.sort_by(&:version))
+        .to eq([f2, f1].map { |f| Keg.new(f.prefix) })
+    end
+
+    specify "with pinned Keg" do
+      f1 = Class.new(Testball) { version("0.1") }.new
+      f2 = Class.new(Testball) { version("0.2") }.new
+      f3 = Class.new(Testball) { version("0.3") }.new
+
+      shutup do
+        f1.brew { f1.install }
+        f1.pin
+        f2.brew { f2.install }
+        f3.brew { f3.install }
+      end
+
+      expect(f1.prefix).to eq((HOMEBREW_PINNED_KEGS/f1.name).resolved_path)
+      expect(f1).to be_installed
+      expect(f2).to be_installed
+      expect(f3).to be_installed
+      expect(shutup { f3.eligible_kegs_for_cleanup }).to eq([Keg.new(f2.prefix)])
+    end
+
+    specify "with HEAD installed" do
+      f = formula do
+        version("0.1")
+        head("foo")
+      end
+
+      stable_prefix = f.installed_prefix
+      stable_prefix.mkpath
+
+      [["000000_1", 1], ["111111", 2], ["111111_1", 2]].each do |pkg_version_suffix, stamp|
+        prefix = f.prefix("HEAD-#{pkg_version_suffix}")
+        prefix.mkpath
+        tab = Tab.empty
+        tab.tabfile = prefix/Tab::FILENAME
+        tab.source_modified_time = stamp
+        tab.write
+      end
+
+      eligible_kegs = f.installed_kegs - [Keg.new(f.prefix("HEAD-111111_1"))]
+      expect(f.eligible_kegs_for_cleanup).to eq(eligible_kegs)
+    end
+  end
+
+  describe "#pour_bottle?" do
+    it "returns false if set to false" do
+      f = formula "foo" do
+        url "foo-1.0"
+
+        def pour_bottle?
+          false
+        end
+      end
+
+      expect(f).not_to pour_bottle
+    end
+
+    it "returns true if set to true" do
+      f = formula "foo" do
+        url "foo-1.0"
+
+        def pour_bottle?
+          true
+        end
+      end
+
+      expect(f).to pour_bottle
+    end
+
+    it "returns false if set to false via DSL" do
+      f = formula "foo" do
+        url "foo-1.0"
+
+        pour_bottle? do
+          reason "false reason"
+          satisfy { (var == etc) }
+        end
+      end
+
+      expect(f).not_to pour_bottle
+    end
+
+    it "returns true if set to true via DSL" do
+      f = formula "foo" do
+        url "foo-1.0"
+
+        pour_bottle? do
+          reason "true reason"
+          satisfy { true }
+        end
+      end
+
+      expect(f).to pour_bottle
+    end
+  end
+
+  describe "alias changes" do
+    let(:f) do
+      formula "formula_name", alias_path: alias_path do
+        url "foo-1.0"
+      end
+    end
+
+    let(:new_formula) do
+      formula "new_formula_name", alias_path: alias_path do
+        url "foo-1.1"
+      end
+    end
+
+    let(:tab) { Tab.empty }
+    let(:alias_path) { "#{CoreTap.instance.alias_dir}/bar" }
+
+    before(:each) do
+      allow(described_class).to receive(:installed).and_return([f])
+
+      f.build = tab
+      new_formula.build = tab
+    end
+
+    specify "alias changes when not installed with alias" do
+      tab.source["path"] = Formulary.core_path(f.name).to_s
+
+      expect(f.current_installed_alias_target).to be nil
+      expect(f.latest_formula).to eq(f)
+      expect(f).not_to have_changed_installed_alias_target
+      expect(f).not_to supersede_an_installed_formula
+      expect(f).not_to have_changed_alias
+      expect(f.old_installed_formulae).to be_empty
+    end
+
+    specify "alias changes when not changed" do
+      tab.source["path"] = alias_path
+      stub_formula_loader(f, alias_path)
+
+      expect(f.current_installed_alias_target).to eq(f)
+      expect(f.latest_formula).to eq(f)
+      expect(f).not_to have_changed_installed_alias_target
+      expect(f).not_to supersede_an_installed_formula
+      expect(f).not_to have_changed_alias
+      expect(f.old_installed_formulae).to be_empty
+    end
+
+    specify "alias changes when new alias target" do
+      tab.source["path"] = alias_path
+      stub_formula_loader(new_formula, alias_path)
+
+      expect(f.current_installed_alias_target).to eq(new_formula)
+      expect(f.latest_formula).to eq(new_formula)
+      expect(f).to have_changed_installed_alias_target
+      expect(f).not_to supersede_an_installed_formula
+      expect(f).to have_changed_alias
+      expect(f.old_installed_formulae).to be_empty
+    end
+
+    specify "alias changes when old formulae installed" do
+      tab.source["path"] = alias_path
+      stub_formula_loader(new_formula, alias_path)
+
+      expect(new_formula.current_installed_alias_target).to eq(new_formula)
+      expect(new_formula.latest_formula).to eq(new_formula)
+      expect(new_formula).not_to have_changed_installed_alias_target
+      expect(new_formula).to supersede_an_installed_formula
+      expect(new_formula).to have_changed_alias
+      expect(new_formula.old_installed_formulae).to eq([f])
+    end
+  end
+
+  describe "#outdated_kegs" do
+    let(:outdated_prefix) { (HOMEBREW_CELLAR/"#{f.name}/1.11") }
+    let(:same_prefix) { (HOMEBREW_CELLAR/"#{f.name}/1.20") }
+    let(:greater_prefix) { (HOMEBREW_CELLAR/"#{f.name}/1.21") }
+    let(:head_prefix) { (HOMEBREW_CELLAR/"#{f.name}/HEAD") }
+    let(:old_alias_target_prefix) { (HOMEBREW_CELLAR/"#{old_formula.name}/1.0") }
+
+    let(:f) do
+      formula do
+        url "foo"
+        version "1.20"
+      end
+    end
+
+    let(:old_formula) do
+      formula "foo@1" do
+        url "foo-1.0"
+      end
+    end
+
+    let(:new_formula) do
+      formula "foo@2" do
+        url "foo-2.0"
+      end
+    end
+
+    let(:alias_path) { "#{f.tap.alias_dir}/bar" }
+
+    def setup_tab_for_prefix(prefix, options = {})
+      prefix.mkpath
+      tab = Tab.empty
+      tab.tabfile = prefix/Tab::FILENAME
+      tab.source["path"] = options[:path].to_s if options[:path]
+      tab.source["tap"] = options[:tap] if options[:tap]
+      tab.source["versions"] = options[:versions] if options[:versions]
+      tab.source_modified_time = options[:source_modified_time].to_i
+      tab.write unless options[:no_write]
+      tab
+    end
+
+    def reset_outdated_kegs
+      f.instance_variable_set(:@outdated_kegs, nil)
+    end
+
+    example "greater different tap installed" do
+      setup_tab_for_prefix(greater_prefix, tap: "user/repo")
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "greater same tap installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+      setup_tab_for_prefix(greater_prefix, tap: "homebrew/core")
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated different tap installed" do
+      setup_tab_for_prefix(outdated_prefix, tap: "user/repo")
+      expect(f.outdated_kegs).not_to be_empty
+    end
+
+    example "outdated same tap installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+      setup_tab_for_prefix(outdated_prefix, tap: "homebrew/core")
+      expect(f.outdated_kegs).not_to be_empty
+    end
+
+    example "outdated follow alias and alias unchanged" do
+      f.follow_installed_alias = true
+      f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
+      stub_formula_loader(f, alias_path)
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated follow alias and alias changed and new target not installed" do
+      f.follow_installed_alias = true
+      f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
+      stub_formula_loader(new_formula, alias_path)
+      expect(f.outdated_kegs).not_to be_empty
+    end
+
+    example "outdated follow alias and alias changed and new target installed" do
+      f.follow_installed_alias = true
+      f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
+      stub_formula_loader(new_formula, alias_path)
+      setup_tab_for_prefix(new_formula.prefix)
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated no follow alias and alias unchanged" do
+      f.follow_installed_alias = false
+      f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
+      stub_formula_loader(f, alias_path)
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated no follow alias and alias changed" do
+      f.follow_installed_alias = false
+      f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
+
+      f2 = formula "foo@2" do
+        url "foo-2.0"
+      end
+
+      stub_formula_loader(f2, alias_path)
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated old alias targets installed" do
+      f = formula alias_path: alias_path do
+        url "foo-1.0"
+      end
+
+      tab = setup_tab_for_prefix(old_alias_target_prefix, path: alias_path)
+      old_formula.build = tab
+      allow(described_class).to receive(:installed).and_return([old_formula])
+      expect(f.outdated_kegs).not_to be_empty
+    end
+
+    example "outdated old alias targets not installed" do
+      f = formula alias_path: alias_path do
+        url "foo-1.0"
+      end
+
+      tab = setup_tab_for_prefix(old_alias_target_prefix, path: old_formula.path)
+      old_formula.build = tab
+      allow(described_class).to receive(:installed).and_return([old_formula])
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated same head installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+      setup_tab_for_prefix(head_prefix, tap: "homebrew/core")
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated different head installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+      setup_tab_for_prefix(head_prefix, tap: "user/repo")
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated mixed taps greater version installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+      setup_tab_for_prefix(outdated_prefix, tap: "homebrew/core")
+      setup_tab_for_prefix(greater_prefix, tap: "user/repo")
+
+      expect(f.outdated_kegs).to be_empty
+
+      setup_tab_for_prefix(greater_prefix, tap: "homebrew/core")
+      reset_outdated_kegs
+
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated mixed taps outdated version installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+
+      extra_outdated_prefix = HOMEBREW_CELLAR/f.name/"1.0"
+
+      setup_tab_for_prefix(outdated_prefix)
+      setup_tab_for_prefix(extra_outdated_prefix, tap: "homebrew/core")
+      reset_outdated_kegs
+
+      expect(f.outdated_kegs).not_to be_empty
+
+      setup_tab_for_prefix(outdated_prefix, tap: "user/repo")
+      reset_outdated_kegs
+
+      expect(f.outdated_kegs).not_to be_empty
+    end
+
+    example "outdated same version tap installed" do
+      f.instance_variable_set(:@tap, CoreTap.instance)
+      setup_tab_for_prefix(same_prefix, tap: "homebrew/core")
+
+      expect(f.outdated_kegs).to be_empty
+
+      setup_tab_for_prefix(same_prefix, tap: "user/repo")
+      reset_outdated_kegs
+
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    example "outdated installed head less than stable" do
+      tab = setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0" })
+
+      expect(f.outdated_kegs).not_to be_empty
+
+      tab.source["versions"] = { "stable" => f.version.to_s }
+      tab.write
+      reset_outdated_kegs
+
+      expect(f.outdated_kegs).to be_empty
+    end
+
+    describe ":fetch_head" do
+      let(:f) do
+        repo = testball_repo
+        formula "testball" do
+          url "foo"
+          version "2.10"
+          head "file://#{repo}", using: :git
+        end
+      end
+      let(:testball_repo) { HOMEBREW_PREFIX/"testball_repo" }
+
+      example do
+        begin
+          outdated_stable_prefix = HOMEBREW_CELLAR/"testball/1.0"
+          head_prefix_a = HOMEBREW_CELLAR/"testball/HEAD"
+          head_prefix_b = HOMEBREW_CELLAR/"testball/HEAD-aaaaaaa_1"
+          head_prefix_c = HOMEBREW_CELLAR/"testball/HEAD-18a7103"
+
+          setup_tab_for_prefix(outdated_stable_prefix)
+          tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" })
+          setup_tab_for_prefix(head_prefix_b)
+
+          testball_repo.mkdir
+          testball_repo.cd do
+            FileUtils.touch "LICENSE"
+
+            shutup do
+              system("git", "init")
+              system("git", "add", "--all")
+              system("git", "commit", "-m", "Initial commit")
+            end
+          end
+
+          expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
+
+          tab_a.source["versions"] = { "stable" => f.version.to_s }
+          tab_a.write
+          reset_outdated_kegs
+          expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
+
+          head_prefix_a.rmtree
+          reset_outdated_kegs
+          expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
+
+          setup_tab_for_prefix(head_prefix_c, source_modified_time: 1)
+          reset_outdated_kegs
+          expect(f.outdated_kegs(fetch_head: true)).to be_empty
+        ensure
+          testball_repo.rmtree if testball_repo.exist?
+        end
+      end
+    end
+
+    describe "with changed version scheme" do
+      let(:f) do
+        formula "testball" do
+          url "foo"
+          version "20141010"
+          version_scheme 1
+        end
+      end
+
+      example do
+        prefix = HOMEBREW_CELLAR/"testball/0.1"
+        setup_tab_for_prefix(prefix, versions: { "stable" => "0.1" })
+
+        expect(f.outdated_kegs).not_to be_empty
+      end
+    end
+
+    describe "with mixed version schemes" do
+      let(:f) do
+        formula "testball" do
+          url "foo"
+          version "20141010"
+          version_scheme 3
+        end
+      end
+
+      example do
+        prefix_a = HOMEBREW_CELLAR/"testball/20141009"
+        setup_tab_for_prefix(prefix_a, versions: { "stable" => "20141009", "version_scheme" => 1 })
+
+        prefix_b = HOMEBREW_CELLAR/"testball/2.14"
+        setup_tab_for_prefix(prefix_b, versions: { "stable" => "2.14", "version_scheme" => 2 })
+
+        expect(f.outdated_kegs).not_to be_empty
+        reset_outdated_kegs
+
+        prefix_c = HOMEBREW_CELLAR/"testball/20141009"
+        setup_tab_for_prefix(prefix_c, versions: { "stable" => "20141009", "version_scheme" => 3 })
+
+        expect(f.outdated_kegs).not_to be_empty
+        reset_outdated_kegs
+
+        prefix_d = HOMEBREW_CELLAR/"testball/20141011"
+        setup_tab_for_prefix(prefix_d, versions: { "stable" => "20141009", "version_scheme" => 3 })
+        expect(f.outdated_kegs).to be_empty
+      end
+    end
+
+    describe "with version scheme" do
+      let(:f) do
+        formula "testball" do
+          url "foo"
+          version "1.0"
+          version_scheme 2
+        end
+      end
+
+      example do
+        head_prefix = HOMEBREW_CELLAR/"testball/HEAD"
+
+        setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 1 })
+        expect(f.outdated_kegs).not_to be_empty
+
+        reset_outdated_kegs
+        head_prefix.rmtree
+
+        setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 2 })
+        expect(f.outdated_kegs).to be_empty
+      end
+    end
+  end
+end
diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb
deleted file mode 100644
index 318175d49..000000000
--- a/Library/Homebrew/test/formula_test.rb
+++ /dev/null
@@ -1,1205 +0,0 @@
-require "testing_env"
-require "test/support/fixtures/testball"
-require "formula"
-
-class FormulaTests < Homebrew::TestCase
-  def test_formula_instantiation
-    klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" }
-    name = "formula_name"
-    path = Formulary.core_path(name)
-    spec = :stable
-
-    f = klass.new(name, path, spec)
-    assert_equal name, f.name
-    assert_equal name, f.specified_name
-    assert_equal name, f.full_name
-    assert_equal name, f.full_specified_name
-    assert_equal path, f.path
-    assert_nil f.alias_path
-    assert_nil f.alias_name
-    assert_nil f.full_alias_name
-    assert_raises(ArgumentError) { klass.new }
-  end
-
-  def test_formula_instantiation_with_alias
-    klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" }
-    name = "formula_name"
-    path = Formulary.core_path(name)
-    spec = :stable
-    alias_name = "baz@1"
-    alias_path = CoreTap.instance.alias_dir/alias_name
-
-    f = klass.new(name, path, spec, alias_path: alias_path)
-    assert_equal name, f.name
-    assert_equal name, f.full_name
-    assert_equal path, f.path
-    assert_equal alias_path, f.alias_path
-    assert_equal alias_name, f.alias_name
-    assert_equal alias_name, f.specified_name
-    assert_equal alias_name, f.full_alias_name
-    assert_equal alias_name, f.full_specified_name
-    assert_raises(ArgumentError) { klass.new }
-  end
-
-  def test_tap_formula_instantiation
-    tap = Tap.new("foo", "bar")
-    klass = Class.new(Formula) { url "baz-1.0" }
-    name = "baz"
-    full_name = "#{tap.user}/#{tap.repo}/#{name}"
-    path = tap.path/"Formula/#{name}.rb"
-    spec = :stable
-
-    f = klass.new(name, path, spec)
-    assert_equal name, f.name
-    assert_equal name, f.specified_name
-    assert_equal full_name, f.full_name
-    assert_equal full_name, f.full_specified_name
-    assert_equal path, f.path
-    assert_nil f.alias_path
-    assert_nil f.alias_name
-    assert_nil f.full_alias_name
-    assert_raises(ArgumentError) { klass.new }
-  end
-
-  def test_tap_formula_instantiation_with_alias
-    tap = Tap.new("foo", "bar")
-    klass = Class.new(Formula) { url "baz-1.0" }
-    name = "baz"
-    full_name = "#{tap.user}/#{tap.repo}/#{name}"
-    path = tap.path/"Formula/#{name}.rb"
-    spec = :stable
-    alias_name = "baz@1"
-    full_alias_name = "#{tap.user}/#{tap.repo}/#{alias_name}"
-    alias_path = CoreTap.instance.alias_dir/alias_name
-
-    f = klass.new(name, path, spec, alias_path: alias_path)
-    assert_equal name, f.name
-    assert_equal full_name, f.full_name
-    assert_equal path, f.path
-    assert_equal alias_path, f.alias_path
-    assert_equal alias_name, f.alias_name
-    assert_equal alias_name, f.specified_name
-    assert_equal full_alias_name, f.full_alias_name
-    assert_equal full_alias_name, f.full_specified_name
-    assert_raises(ArgumentError) { klass.new }
-  end
-
-  def test_follow_installed_alias
-    f = formula { url "foo-1.0" }
-    assert_predicate f, :follow_installed_alias?
-
-    f.follow_installed_alias = true
-    assert_predicate f, :follow_installed_alias?
-
-    f.follow_installed_alias = false
-    refute_predicate f, :follow_installed_alias?
-  end
-
-  def test_installed_alias_with_core
-    f = formula { url "foo-1.0" }
-
-    build_values_with_no_installed_alias = [
-      nil,
-      BuildOptions.new({}, {}),
-      Tab.new(source: { "path" => f.path.to_s }),
-    ]
-
-    build_values_with_no_installed_alias.each do |build|
-      f.build = build
-      assert_nil f.installed_alias_path
-      assert_nil f.installed_alias_name
-      assert_nil f.full_installed_alias_name
-      assert_equal f.name, f.installed_specified_name
-      assert_equal f.name, f.full_installed_specified_name
-    end
-
-    alias_name = "bar"
-    alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
-    f.build = Tab.new(source: { "path" => alias_path })
-    assert_equal alias_path, f.installed_alias_path
-    assert_equal alias_name, f.installed_alias_name
-    assert_equal alias_name, f.full_installed_alias_name
-    assert_equal alias_name, f.installed_specified_name
-    assert_equal alias_name, f.full_installed_specified_name
-  end
-
-  def test_installed_alias_with_tap
-    tap = Tap.new("user", "repo")
-    name = "foo"
-    path = "#{tap.path}/Formula/#{name}.rb"
-    f = formula(name, path) { url "foo-1.0" }
-
-    build_values_with_no_installed_alias = [
-      nil,
-      BuildOptions.new({}, {}),
-      Tab.new(source: { "path" => f.path }),
-    ]
-
-    build_values_with_no_installed_alias.each do |build|
-      f.build = build
-      assert_nil f.installed_alias_path
-      assert_nil f.installed_alias_name
-      assert_nil f.full_installed_alias_name
-      assert_equal f.name, f.installed_specified_name
-      assert_equal f.full_name, f.full_installed_specified_name
-    end
-
-    alias_name = "bar"
-    full_alias_name = "#{tap.user}/#{tap.repo}/#{alias_name}"
-    alias_path = "#{tap.alias_dir}/#{alias_name}"
-    f.build = Tab.new(source: { "path" => alias_path })
-    assert_equal alias_path, f.installed_alias_path
-    assert_equal alias_name, f.installed_alias_name
-    assert_equal full_alias_name, f.full_installed_alias_name
-    assert_equal alias_name, f.installed_specified_name
-    assert_equal full_alias_name, f.full_installed_specified_name
-  end
-
-  def test_prefix
-    f = Testball.new
-    assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix
-    assert_kind_of Pathname, f.prefix
-  end
-
-  def test_revised_prefix
-    f = Class.new(Testball) { revision 1 }.new
-    assert_equal HOMEBREW_CELLAR/f.name/"0.1_1", f.prefix
-  end
-
-  def test_any_version_installed?
-    f = formula do
-      url "foo"
-      version "1.0"
-    end
-    refute_predicate f, :any_version_installed?
-    prefix = HOMEBREW_CELLAR+f.name+"0.1"
-    prefix.mkpath
-    FileUtils.touch prefix+Tab::FILENAME
-    assert_predicate f, :any_version_installed?
-  end
-
-  def test_migration_needed
-    f = Testball.new("newname")
-    f.instance_variable_set(:@oldname, "oldname")
-    f.instance_variable_set(:@tap, CoreTap.instance)
-
-    oldname_prefix = HOMEBREW_CELLAR/"oldname/2.20"
-    newname_prefix = HOMEBREW_CELLAR/"newname/2.10"
-    oldname_prefix.mkpath
-    oldname_tab = Tab.empty
-    oldname_tab.tabfile = oldname_prefix.join("INSTALL_RECEIPT.json")
-    oldname_tab.write
-
-    refute_predicate f, :migration_needed?
-
-    oldname_tab.tabfile.unlink
-    oldname_tab.source["tap"] = "homebrew/core"
-    oldname_tab.write
-
-    assert_predicate f, :migration_needed?
-
-    newname_prefix.mkpath
-
-    refute_predicate f, :migration_needed?
-  end
-
-  def test_installed?
-    f = Testball.new
-    f.stubs(:installed_prefix).returns(stub(directory?: false))
-    refute_predicate f, :installed?
-
-    f.stubs(:installed_prefix).returns(
-      stub(directory?: true, children: []),
-    )
-    refute_predicate f, :installed?
-
-    f.stubs(:installed_prefix).returns(
-      stub(directory?: true, children: [stub]),
-    )
-    assert_predicate f, :installed?
-  end
-
-  def test_installed_prefix
-    f = Testball.new
-    assert_equal f.prefix, f.installed_prefix
-  end
-
-  def test_installed_prefix_head_installed
-    f = formula do
-      head "foo"
-      devel do
-        url "foo"
-        version "1.0"
-      end
-    end
-    prefix = HOMEBREW_CELLAR+f.name+f.head.version
-    prefix.mkpath
-    assert_equal prefix, f.installed_prefix
-  end
-
-  def test_installed_prefix_devel_installed
-    f = formula do
-      head "foo"
-      devel do
-        url "foo"
-        version "1.0"
-      end
-    end
-    prefix = HOMEBREW_CELLAR+f.name+f.devel.version
-    prefix.mkpath
-    assert_equal prefix, f.installed_prefix
-  end
-
-  def test_installed_prefix_stable_installed
-    f = formula do
-      head "foo"
-      devel do
-        url "foo"
-        version "1.0-devel"
-      end
-    end
-    prefix = HOMEBREW_CELLAR+f.name+f.version
-    prefix.mkpath
-    assert_equal prefix, f.installed_prefix
-  end
-
-  def test_installed_prefix_outdated_stable_head_installed
-    f = formula do
-      url "foo"
-      version "1.9"
-      head "foo"
-    end
-
-    head_prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD"
-    head_prefix.mkpath
-    tab = Tab.empty
-    tab.tabfile = head_prefix.join("INSTALL_RECEIPT.json")
-    tab.source["versions"] = { "stable" => "1.0" }
-    tab.write
-
-    assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix
-  end
-
-  def test_installed_prefix_outdated_devel_head_installed
-    f = formula do
-      url "foo"
-      version "1.9"
-      devel do
-        url "foo"
-        version "2.1"
-      end
-    end
-
-    head_prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD"
-    head_prefix.mkpath
-    tab = Tab.empty
-    tab.tabfile = head_prefix.join("INSTALL_RECEIPT.json")
-    tab.source["versions"] = { "stable" => "1.9", "devel" => "2.0" }
-    tab.write
-
-    assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix
-  end
-
-  def test_installed_prefix_head
-    f = formula("test", Pathname.new(__FILE__).expand_path, :head) do
-      head "foo"
-      devel do
-        url "foo"
-        version "1.0-devel"
-      end
-    end
-    prefix = HOMEBREW_CELLAR+f.name+f.head.version
-    assert_equal prefix, f.installed_prefix
-  end
-
-  def test_installed_prefix_devel
-    f = formula("test", Pathname.new(__FILE__).expand_path, :devel) do
-      head "foo"
-      devel do
-        url "foo"
-        version "1.0-devel"
-      end
-    end
-    prefix = HOMEBREW_CELLAR+f.name+f.devel.version
-    assert_equal prefix, f.installed_prefix
-  end
-
-  def test_latest_head_prefix
-    f = Testball.new
-
-    stamps_with_revisions = [[111111, 1], [222222, 1], [222222, 2], [222222, 0]]
-
-    stamps_with_revisions.each do |stamp, revision|
-      version = "HEAD-#{stamp}"
-      version += "_#{revision}" if revision > 0
-      prefix = f.rack.join(version)
-      prefix.mkpath
-
-      tab = Tab.empty
-      tab.tabfile = prefix.join("INSTALL_RECEIPT.json")
-      tab.source_modified_time = stamp
-      tab.write
-    end
-
-    prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD-222222_2"
-    assert_equal prefix, f.latest_head_prefix
-  end
-
-  def test_equality
-    x = Testball.new
-    y = Testball.new
-    assert_equal x, y
-    assert_eql x, y
-    assert_equal x.hash, y.hash
-  end
-
-  def test_inequality
-    x = Testball.new("foo")
-    y = Testball.new("bar")
-    refute_equal x, y
-    refute_eql x, y
-    refute_equal x.hash, y.hash
-  end
-
-  def test_comparison_with_non_formula_objects_does_not_raise
-    refute_equal Testball.new, Object.new
-  end
-
-  def test_sort_operator
-    assert_nil Testball.new <=> Object.new
-  end
-
-  def test_alias_paths_with_build_options
-    alias_path = CoreTap.instance.alias_dir/"another_name"
-    f = formula(alias_path: alias_path) { url "foo-1.0" }
-    f.build = BuildOptions.new({}, {})
-    assert_equal alias_path, f.alias_path
-    assert_nil f.installed_alias_path
-  end
-
-  def test_alias_paths_with_tab_with_non_alias_source_path
-    alias_path = CoreTap.instance.alias_dir/"another_name"
-    source_path = CoreTap.instance.formula_dir/"another_other_name"
-    f = formula(alias_path: alias_path) { url "foo-1.0" }
-    f.build = Tab.new(source: { "path" => source_path.to_s })
-    assert_equal alias_path, f.alias_path
-    assert_nil f.installed_alias_path
-  end
-
-  def test_alias_paths_with_tab_with_alias_source_path
-    alias_path = CoreTap.instance.alias_dir/"another_name"
-    source_path = CoreTap.instance.alias_dir/"another_other_name"
-    f = formula(alias_path: alias_path) { url "foo-1.0" }
-    f.build = Tab.new(source: { "path" => source_path.to_s })
-    assert_equal alias_path, f.alias_path
-    assert_equal source_path.to_s, f.installed_alias_path
-  end
-
-  def test_installed_with_alias_path_with_nil
-    assert_predicate Formula.installed_with_alias_path(nil), :empty?
-  end
-
-  def test_installed_with_alias_path_with_a_path
-    alias_path = "#{CoreTap.instance.alias_dir}/alias"
-    different_alias_path = "#{CoreTap.instance.alias_dir}/another_alias"
-
-    formula_with_alias = formula("foo") { url "foo-1.0" }
-    formula_with_alias.build = Tab.empty
-    formula_with_alias.build.source["path"] = alias_path
-
-    formula_without_alias = formula("bar") { url "bar-1.0" }
-    formula_without_alias.build = Tab.empty
-    formula_without_alias.build.source["path"] = formula_without_alias.path.to_s
-
-    formula_with_different_alias = formula("baz") { url "baz-1.0" }
-    formula_with_different_alias.build = Tab.empty
-    formula_with_different_alias.build.source["path"] = different_alias_path
-
-    formulae = [
-      formula_with_alias,
-      formula_without_alias,
-      formula_with_different_alias,
-    ]
-
-    Formula.stubs(:installed).returns(formulae)
-    assert_equal [formula_with_alias], Formula.installed_with_alias_path(alias_path)
-  end
-
-  def test_formula_spec_integration
-    f = formula do
-      homepage "http://example.com"
-      url "http://example.com/test-0.1.tbz"
-      mirror "http://example.org/test-0.1.tbz"
-      sha256 TEST_SHA256
-
-      head "http://example.com/test.git", tag: "foo"
-
-      devel do
-        url "http://example.com/test-0.2.tbz"
-        mirror "http://example.org/test-0.2.tbz"
-        sha256 TEST_SHA256
-      end
-    end
-
-    assert_equal "http://example.com", f.homepage
-    assert_version_equal "0.1", f.version
-    assert_predicate f, :stable?
-
-    assert_version_equal "0.1", f.stable.version
-    assert_version_equal "0.2", f.devel.version
-    assert_version_equal "HEAD", f.head.version
-  end
-
-  def test_formula_active_spec=
-    f = formula do
-      url "foo"
-      version "1.0"
-      revision 1
-
-      devel do
-        url "foo"
-        version "1.0beta"
-      end
-    end
-    assert_equal :stable, f.active_spec_sym
-    assert_equal f.stable, f.send(:active_spec)
-    assert_equal "1.0_1", f.pkg_version.to_s
-    f.active_spec = :devel
-    assert_equal :devel, f.active_spec_sym
-    assert_equal f.devel, f.send(:active_spec)
-    assert_equal "1.0beta_1", f.pkg_version.to_s
-    assert_raises(FormulaSpecificationError) { f.active_spec = :head }
-  end
-
-  def test_path
-    name = "foo-bar"
-    assert_equal Pathname.new("#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/Formula/#{name}.rb"), Formulary.core_path(name)
-  end
-
-  def test_class_specs_are_always_initialized
-    f = formula { url "foo-1.0" }
-
-    %w[stable devel head].each do |spec|
-      assert_kind_of SoftwareSpec, f.class.send(spec)
-    end
-  end
-
-  def test_incomplete_instance_specs_are_not_accessible
-    f = formula { url "foo-1.0" }
-
-    %w[devel head].each { |spec| assert_nil f.send(spec) }
-  end
-
-  def test_honors_attributes_declared_before_specs
-    f = formula do
-      url "foo-1.0"
-      depends_on "foo"
-      devel { url "foo-1.1" }
-    end
-
-    %w[stable devel head].each do |spec|
-      assert_equal "foo", f.class.send(spec).deps.first.name
-    end
-  end
-
-  def test_simple_version
-    assert_equal PkgVersion.parse("1.0"), formula { url "foo-1.0.bar" }.pkg_version
-  end
-
-  def test_version_with_revision
-    f = formula do
-      url "foo-1.0.bar"
-      revision 1
-    end
-
-    assert_equal PkgVersion.parse("1.0_1"), f.pkg_version
-  end
-
-  def test_head_uses_revisions
-    f = formula("test", Pathname.new(__FILE__).expand_path, :head) do
-      url "foo-1.0.bar"
-      revision 1
-      head "foo"
-    end
-
-    assert_equal PkgVersion.parse("HEAD_1"), f.pkg_version
-  end
-
-  def test_update_head_version
-    f = formula do
-      head "foo", using: :git
-    end
-
-    cached_location = f.head.downloader.cached_location
-    cached_location.mkpath
-
-    cached_location.cd do
-      FileUtils.touch "LICENSE"
-      shutup do
-        system "git", "init"
-        system "git", "add", "--all"
-        system "git", "commit", "-m", "Initial commit"
-      end
-    end
-
-    f.update_head_version
-    assert_equal Version.create("HEAD-5658946"), f.head.version
-  end
-
-  def test_legacy_options
-    f = formula do
-      url "foo-1.0"
-
-      def options
-        [["--foo", "desc"], ["--bar", "desc"]]
-      end
-
-      option "baz"
-    end
-
-    assert f.option_defined?("foo")
-    assert f.option_defined?("bar")
-    assert f.option_defined?("baz")
-  end
-
-  def test_desc
-    f = formula do
-      desc "a formula"
-      url "foo-1.0"
-    end
-
-    assert_equal "a formula", f.desc
-  end
-
-  def test_post_install_defined
-    f1 = formula do
-      url "foo-1.0"
-
-      def post_install; end
-    end
-
-    f2 = formula do
-      url "foo-1.0"
-    end
-
-    assert f1.post_install_defined?
-    refute f2.post_install_defined?
-  end
-
-  def test_test_defined
-    f1 = formula do
-      url "foo-1.0"
-
-      def test; end
-    end
-
-    f2 = formula do
-      url "foo-1.0"
-    end
-
-    assert f1.test_defined?
-    refute f2.test_defined?
-  end
-
-  def test_test_fixtures
-    f1 = formula do
-      url "foo-1.0"
-    end
-
-    assert_equal Pathname.new("#{HOMEBREW_LIBRARY_PATH}/test/support/fixtures/foo"),
-      f1.test_fixtures("foo")
-  end
-
-  def test_dependencies
-    stub_formula_loader formula("f1") { url "f1-1.0" }
-    stub_formula_loader formula("f2") { url "f2-1.0" }
-
-    f3 = formula("f3") do
-      url "f3-1.0"
-      depends_on "f1" => :build
-      depends_on "f2"
-    end
-    stub_formula_loader f3
-
-    f4 = formula("f4") do
-      url "f4-1.0"
-      depends_on "f1"
-    end
-    stub_formula_loader f4
-
-    f5 = formula("f5") do
-      url "f5-1.0"
-      depends_on "f3" => :build
-      depends_on "f4"
-    end
-
-    assert_equal %w[f3 f4], f5.deps.map(&:name)
-    assert_equal %w[f1 f2 f3 f4], f5.recursive_dependencies.map(&:name)
-    assert_equal %w[f1 f4], f5.runtime_dependencies.map(&:name)
-  end
-
-  def test_runtime_dependencies_with_optional_deps_from_tap
-    tap_loader = mock
-    tap_loader.stubs(:get_formula).raises(RuntimeError, "tried resolving tap formula")
-    Formulary.stubs(:loader_for).with("foo/bar/f1", from: nil).returns(tap_loader)
-
-    stub_formula_loader formula("f2") { url "f2-1.0" }, "baz/qux/f2"
-
-    f3 = formula("f3") do
-      url "f3-1.0"
-      depends_on "foo/bar/f1" => :optional
-      depends_on "baz/qux/f2"
-    end
-
-    # f1 shouldn't be loaded by default.
-    # If it is, an exception will be raised.
-    assert_equal %w[baz/qux/f2], f3.runtime_dependencies.map(&:name)
-
-    # If --with-f1, f1 should be loaded.
-    stub_formula_loader formula("f1") { url "f1-1.0" }, "foo/bar/f1"
-    f3.build = BuildOptions.new(Options.create(%w[--with-f1]), f3.options)
-    assert_equal %w[foo/bar/f1 baz/qux/f2], f3.runtime_dependencies.map(&:name)
-  end
-
-  def test_requirements
-    f1 = formula("f1") do
-      url "f1-1"
-
-      depends_on :python
-      depends_on x11: :recommended
-      depends_on xcode: ["1.0", :optional]
-    end
-    stub_formula_loader f1
-
-    python = PythonRequirement.new
-    x11 = X11Requirement.new("x11", [:recommended])
-    xcode = XcodeRequirement.new(["1.0", :optional])
-
-    # Default block should filter out deps that aren't being used
-    assert_equal Set[python, x11], Set.new(f1.recursive_requirements)
-
-    f1.build = BuildOptions.new(["--with-xcode", "--without-x11"], f1.options)
-    assert_equal Set[python, xcode], Set.new(f1.recursive_requirements)
-    f1.build = f1.stable.build
-
-    f2 = formula("f2") do
-      url "f2-1"
-      depends_on "f1"
-    end
-
-    assert_equal Set[python, x11], Set.new(f2.recursive_requirements)
-
-    # Empty block should allow all requirements
-    assert_equal Set[python, x11, xcode], Set.new(f2.recursive_requirements {})
-
-    # Requirements can be pruned
-    requirements = f2.recursive_requirements do |_dependent, requirement|
-      Requirement.prune if requirement.is_a?(PythonRequirement)
-    end
-    assert_equal Set[x11, xcode], Set.new(requirements)
-  end
-
-  def test_to_hash
-    f1 = formula("foo") do
-      url "foo-1.0"
-    end
-
-    h = f1.to_hash
-    assert h.is_a?(Hash), "Formula#to_hash should return a Hash"
-    assert_equal "foo", h["name"]
-    assert_equal "foo", h["full_name"]
-    assert_equal "1.0", h["versions"]["stable"]
-  end
-
-  def test_to_hash_bottle
-    f1 = formula("foo") do
-      url "foo-1.0"
-
-      bottle do
-        cellar :any
-        sha256 TEST_SHA256 => Utils::Bottles.tag
-      end
-    end
-
-    h = f1.to_hash
-    assert h.is_a?(Hash), "Formula#to_hash should return a Hash"
-    assert h["versions"]["bottle"], "The hash should say the formula is bottled"
-  end
-
-  def test_eligible_kegs_for_cleanup
-    f1 = Class.new(Testball) do
-      version "1.0"
-    end.new
-    f2 = Class.new(Testball) do
-      version "0.2"
-      version_scheme 1
-    end.new
-    f3 = Class.new(Testball) do
-      version "0.3"
-      version_scheme 1
-    end.new
-    f4 = Class.new(Testball) do
-      version "0.1"
-      version_scheme 2
-    end.new
-
-    shutup do
-      [f1, f2, f3, f4].each do |f|
-        f.brew { f.install }
-        Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
-      end
-    end
-
-    assert_predicate f1, :installed?
-    assert_predicate f2, :installed?
-    assert_predicate f3, :installed?
-    assert_predicate f4, :installed?
-
-    assert_equal [f2, f1].map { |f| Keg.new(f.prefix) },
-                 f3.eligible_kegs_for_cleanup.sort_by(&:version)
-  end
-
-  def test_eligible_kegs_for_cleanup_keg_pinned
-    f1 = Class.new(Testball) { version "0.1" }.new
-    f2 = Class.new(Testball) { version "0.2" }.new
-    f3 = Class.new(Testball) { version "0.3" }.new
-
-    shutup do
-      f1.brew { f1.install }
-      f1.pin
-      f2.brew { f2.install }
-      f3.brew { f3.install }
-    end
-
-    assert_equal (HOMEBREW_PINNED_KEGS/f1.name).resolved_path, f1.prefix
-
-    assert_predicate f1, :installed?
-    assert_predicate f2, :installed?
-    assert_predicate f3, :installed?
-
-    assert_equal [Keg.new(f2.prefix)], shutup { f3.eligible_kegs_for_cleanup }
-  end
-
-  def test_eligible_kegs_for_cleanup_head_installed
-    f = formula do
-      version "0.1"
-      head "foo"
-    end
-
-    stable_prefix = f.installed_prefix
-    stable_prefix.mkpath
-
-    [["000000_1", 1], ["111111", 2], ["111111_1", 2]].each do |pkg_version_suffix, stamp|
-      prefix = f.prefix("HEAD-#{pkg_version_suffix}")
-      prefix.mkpath
-      tab = Tab.empty
-      tab.tabfile = prefix.join("INSTALL_RECEIPT.json")
-      tab.source_modified_time = stamp
-      tab.write
-    end
-
-    eligible_kegs = f.installed_kegs - [Keg.new(f.prefix("HEAD-111111_1"))]
-    assert_equal eligible_kegs, f.eligible_kegs_for_cleanup
-  end
-
-  def test_pour_bottle
-    f_false = formula("foo") do
-      url "foo-1.0"
-      def pour_bottle?
-        false
-      end
-    end
-    refute f_false.pour_bottle?
-
-    f_true = formula("foo") do
-      url "foo-1.0"
-      def pour_bottle?
-        true
-      end
-    end
-    assert f_true.pour_bottle?
-  end
-
-  def test_pour_bottle_dsl
-    f_false = formula("foo") do
-      url "foo-1.0"
-      pour_bottle? do
-        reason "false reason"
-        satisfy { var == etc }
-      end
-    end
-    refute f_false.pour_bottle?
-
-    f_true = formula("foo") do
-      url "foo-1.0"
-      pour_bottle? do
-        reason "true reason"
-        satisfy { true }
-      end
-    end
-    assert f_true.pour_bottle?
-  end
-end
-
-class AliasChangeTests < Homebrew::TestCase
-  attr_reader :f, :new_formula, :tab, :alias_path
-
-  def make_formula(name, version)
-    f = formula(name, alias_path: alias_path) { url "foo-#{version}" }
-    f.build = tab
-    f
-  end
-
-  def setup
-    super
-
-    alias_name = "bar"
-    @alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
-
-    @tab = Tab.empty
-
-    @f = make_formula("formula_name", "1.0")
-    @new_formula = make_formula("new_formula_name", "1.1")
-
-    Formula.stubs(:installed).returns([f])
-  end
-
-  def test_alias_changes_when_not_installed_with_alias
-    tab.source["path"] = Formulary.core_path(f.name).to_s
-
-    assert_nil f.current_installed_alias_target
-    assert_equal f, f.latest_formula
-    refute_predicate f, :installed_alias_target_changed?
-    refute_predicate f, :supersedes_an_installed_formula?
-    refute_predicate f, :alias_changed?
-    assert_predicate f.old_installed_formulae, :empty?
-  end
-
-  def test_alias_changes_when_not_changed
-    tab.source["path"] = alias_path
-    stub_formula_loader(f, alias_path)
-
-    assert_equal f, f.current_installed_alias_target
-    assert_equal f, f.latest_formula
-    refute_predicate f, :installed_alias_target_changed?
-    refute_predicate f, :supersedes_an_installed_formula?
-    refute_predicate f, :alias_changed?
-    assert_predicate f.old_installed_formulae, :empty?
-  end
-
-  def test_alias_changes_when_new_alias_target
-    tab.source["path"] = alias_path
-    stub_formula_loader(new_formula, alias_path)
-
-    assert_equal new_formula, f.current_installed_alias_target
-    assert_equal new_formula, f.latest_formula
-    assert_predicate f, :installed_alias_target_changed?
-    refute_predicate f, :supersedes_an_installed_formula?
-    assert_predicate f, :alias_changed?
-    assert_predicate f.old_installed_formulae, :empty?
-  end
-
-  def test_alias_changes_when_old_formulae_installed
-    tab.source["path"] = alias_path
-    stub_formula_loader(new_formula, alias_path)
-
-    assert_equal new_formula, new_formula.current_installed_alias_target
-    assert_equal new_formula, new_formula.latest_formula
-    refute_predicate new_formula, :installed_alias_target_changed?
-    assert_predicate new_formula, :supersedes_an_installed_formula?
-    assert_predicate new_formula, :alias_changed?
-    assert_equal [f], new_formula.old_installed_formulae
-  end
-end
-
-class OutdatedVersionsTests < Homebrew::TestCase
-  attr_reader :outdated_prefix,
-              :same_prefix,
-              :greater_prefix,
-              :head_prefix,
-              :old_alias_target_prefix
-  attr_reader :f, :old_formula, :new_formula
-
-  def setup
-    super
-
-    @f = formula do
-      url "foo"
-      version "1.20"
-    end
-
-    @old_formula = formula("foo@1") { url "foo-1.0" }
-    @new_formula = formula("foo@2") { url "foo-2.0" }
-
-    @outdated_prefix = HOMEBREW_CELLAR/"#{f.name}/1.11"
-    @same_prefix = HOMEBREW_CELLAR/"#{f.name}/1.20"
-    @greater_prefix = HOMEBREW_CELLAR/"#{f.name}/1.21"
-    @head_prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD"
-    @old_alias_target_prefix = HOMEBREW_CELLAR/"#{old_formula.name}/1.0"
-  end
-
-  def alias_path
-    "#{@f.tap.alias_dir}/bar"
-  end
-
-  def setup_tab_for_prefix(prefix, options = {})
-    prefix.mkpath
-    tab = Tab.empty
-    tab.tabfile = prefix.join("INSTALL_RECEIPT.json")
-    tab.source["path"] = options[:path].to_s if options[:path]
-    tab.source["tap"] = options[:tap] if options[:tap]
-    tab.source["versions"] = options[:versions] if options[:versions]
-    tab.source_modified_time = options[:source_modified_time].to_i
-    tab.write unless options[:no_write]
-    tab
-  end
-
-  def reset_outdated_kegs
-    f.instance_variable_set(:@outdated_kegs, nil)
-  end
-
-  def test_greater_different_tap_installed
-    setup_tab_for_prefix(greater_prefix, tap: "user/repo")
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_greater_same_tap_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-    setup_tab_for_prefix(greater_prefix, tap: "homebrew/core")
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_different_tap_installed
-    setup_tab_for_prefix(outdated_prefix, tap: "user/repo")
-    refute_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_same_tap_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-    setup_tab_for_prefix(outdated_prefix, tap: "homebrew/core")
-    refute_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_follow_alias_and_alias_unchanged
-    f.follow_installed_alias = true
-    f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
-    stub_formula_loader(f, alias_path)
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_follow_alias_and_alias_changed_and_new_target_not_installed
-    f.follow_installed_alias = true
-    f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
-    stub_formula_loader(new_formula, alias_path)
-    refute_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_follow_alias_and_alias_changed_and_new_target_installed
-    f.follow_installed_alias = true
-    f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
-    stub_formula_loader(new_formula, alias_path)
-    setup_tab_for_prefix(new_formula.prefix) # install new_formula
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_no_follow_alias_and_alias_unchanged
-    f.follow_installed_alias = false
-    f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
-    stub_formula_loader(f, alias_path)
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_no_follow_alias_and_alias_changed
-    f.follow_installed_alias = false
-    f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
-    stub_formula_loader(formula("foo@2") { url "foo-2.0" }, alias_path)
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_old_alias_targets_installed
-    @f = formula(alias_path: alias_path) { url "foo-1.0" }
-    tab = setup_tab_for_prefix(old_alias_target_prefix, path: alias_path)
-    old_formula.build = tab
-    Formula.stubs(:installed).returns([old_formula])
-    refute_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_old_alias_targets_not_installed
-    @f = formula(alias_path: alias_path) { url "foo-1.0" }
-    tab = setup_tab_for_prefix(old_alias_target_prefix, path: old_formula.path)
-    old_formula.build = tab
-    Formula.stubs(:installed).returns([old_formula])
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_same_head_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-    setup_tab_for_prefix(head_prefix, tap: "homebrew/core")
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_different_head_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-    setup_tab_for_prefix(head_prefix, tap: "user/repo")
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_mixed_taps_greater_version_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-    setup_tab_for_prefix(outdated_prefix, tap: "homebrew/core")
-    setup_tab_for_prefix(greater_prefix, tap: "user/repo")
-
-    assert_predicate f.outdated_kegs, :empty?
-
-    setup_tab_for_prefix(greater_prefix, tap: "homebrew/core")
-    reset_outdated_kegs
-
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_mixed_taps_outdated_version_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-
-    extra_outdated_prefix = HOMEBREW_CELLAR/"#{f.name}/1.0"
-
-    setup_tab_for_prefix(outdated_prefix)
-    setup_tab_for_prefix(extra_outdated_prefix, tap: "homebrew/core")
-    reset_outdated_kegs
-
-    refute_predicate f.outdated_kegs, :empty?
-
-    setup_tab_for_prefix(outdated_prefix, tap: "user/repo")
-    reset_outdated_kegs
-
-    refute_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_same_version_tap_installed
-    f.instance_variable_set(:@tap, CoreTap.instance)
-    setup_tab_for_prefix(same_prefix, tap: "homebrew/core")
-
-    assert_predicate f.outdated_kegs, :empty?
-
-    setup_tab_for_prefix(same_prefix, tap: "user/repo")
-    reset_outdated_kegs
-
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_installed_head_less_than_stable
-    tab = setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0" })
-    refute_predicate f.outdated_kegs, :empty?
-
-    # Tab.for_keg(head_prefix) will be fetched from CACHE but we write it anyway
-    tab.source["versions"] = { "stable" => f.version.to_s }
-    tab.write
-    reset_outdated_kegs
-
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_fetch_head
-    outdated_stable_prefix = HOMEBREW_CELLAR.join("testball/1.0")
-    head_prefix_a = HOMEBREW_CELLAR.join("testball/HEAD")
-    head_prefix_b = HOMEBREW_CELLAR.join("testball/HEAD-aaaaaaa_1")
-    head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-18a7103")
-
-    setup_tab_for_prefix(outdated_stable_prefix)
-    tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" })
-    setup_tab_for_prefix(head_prefix_b)
-
-    testball_repo = HOMEBREW_PREFIX.join("testball_repo")
-    testball_repo.mkdir
-
-    @f = formula("testball") do
-      url "foo"
-      version "2.10"
-      head "file://#{testball_repo}", using: :git
-    end
-
-    testball_repo.cd do
-      FileUtils.touch "LICENSE"
-      shutup do
-        system "git", "init"
-        system "git", "add", "--all"
-        system "git", "commit", "-m", "Initial commit"
-      end
-    end
-
-    refute_predicate f.outdated_kegs(fetch_head: true), :empty?
-
-    tab_a.source["versions"] = { "stable" => f.version.to_s }
-    tab_a.write
-    reset_outdated_kegs
-    refute_predicate f.outdated_kegs(fetch_head: true), :empty?
-
-    head_prefix_a.rmtree
-    reset_outdated_kegs
-    refute_predicate f.outdated_kegs(fetch_head: true), :empty?
-
-    setup_tab_for_prefix(head_prefix_c, source_modified_time: 1)
-    reset_outdated_kegs
-    assert_predicate f.outdated_kegs(fetch_head: true), :empty?
-  ensure
-    testball_repo.rmtree if testball_repo.exist?
-  end
-
-  def test_outdated_kegs_version_scheme_changed
-    @f = formula("testball") do
-      url "foo"
-      version "20141010"
-      version_scheme 1
-    end
-
-    prefix = HOMEBREW_CELLAR.join("testball/0.1")
-    setup_tab_for_prefix(prefix, versions: { "stable" => "0.1" })
-
-    refute_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_kegs_mixed_version_schemes
-    @f = formula("testball") do
-      url "foo"
-      version "20141010"
-      version_scheme 3
-    end
-
-    prefix_a = HOMEBREW_CELLAR.join("testball/20141009")
-    setup_tab_for_prefix(prefix_a, versions: { "stable" => "20141009", "version_scheme" => 1 })
-
-    prefix_b = HOMEBREW_CELLAR.join("testball/2.14")
-    setup_tab_for_prefix(prefix_b, versions: { "stable" => "2.14", "version_scheme" => 2 })
-
-    refute_predicate f.outdated_kegs, :empty?
-    reset_outdated_kegs
-
-    prefix_c = HOMEBREW_CELLAR.join("testball/20141009")
-    setup_tab_for_prefix(prefix_c, versions: { "stable" => "20141009", "version_scheme" => 3 })
-
-    refute_predicate f.outdated_kegs, :empty?
-    reset_outdated_kegs
-
-    prefix_d = HOMEBREW_CELLAR.join("testball/20141011")
-    setup_tab_for_prefix(prefix_d, versions: { "stable" => "20141009", "version_scheme" => 3 })
-    assert_predicate f.outdated_kegs, :empty?
-  end
-
-  def test_outdated_kegs_head_with_version_scheme
-    @f = formula("testball") do
-      url "foo"
-      version "1.0"
-      version_scheme 2
-    end
-
-    head_prefix = HOMEBREW_CELLAR.join("testball/HEAD")
-
-    setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 1 })
-    refute_predicate f.outdated_kegs, :empty?
-
-    reset_outdated_kegs
-    head_prefix.rmtree
-
-    setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 2 })
-    assert_predicate f.outdated_kegs, :empty?
-  end
-end
diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb
index 8e9d23589..213ad511d 100644
--- a/Library/Homebrew/test/formulary_spec.rb
+++ b/Library/Homebrew/test/formulary_spec.rb
@@ -216,4 +216,12 @@ describe Formulary do
       end
     end
   end
+
+  describe "::core_path" do
+    it "returns the path to a Formula in the core tap" do
+      name = "foo-bar"
+      expect(subject.core_path(name))
+        .to eq(Pathname.new("#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/Formula/#{name}.rb"))
+    end
+  end
 end
-- 
cgit v1.2.3


From af793f44c99d2408c267bf73f6a14cec987c2094 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 18:15:49 +0100
Subject: Convert Keg test to spec.

---
 Library/Homebrew/test/keg_spec.rb | 486 ++++++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/keg_test.rb | 475 -------------------------------------
 2 files changed, 486 insertions(+), 475 deletions(-)
 create mode 100644 Library/Homebrew/test/keg_spec.rb
 delete mode 100644 Library/Homebrew/test/keg_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/keg_spec.rb b/Library/Homebrew/test/keg_spec.rb
new file mode 100644
index 000000000..f40002dd2
--- /dev/null
+++ b/Library/Homebrew/test/keg_spec.rb
@@ -0,0 +1,486 @@
+require "keg"
+require "stringio"
+
+describe Keg do
+  include FileUtils
+
+  def setup_test_keg(name, version)
+    path = HOMEBREW_CELLAR/name/version
+    (path/"bin").mkpath
+
+    %w[hiworld helloworld goodbye_cruel_world].each do |file|
+      touch path/"bin"/file
+    end
+
+    keg = described_class.new(path)
+    kegs << keg
+    keg
+  end
+
+  around(:each) do |example|
+    begin
+      @old_stdout = $stdout
+      $stdout = StringIO.new
+
+      example.run
+    ensure
+      $stdout = @old_stdout
+    end
+  end
+
+  let(:dst) { HOMEBREW_PREFIX/"bin"/"helloworld" }
+  let(:nonexistent) { Pathname.new("/some/nonexistent/path") }
+  let(:mode) { OpenStruct.new }
+  let!(:keg) { setup_test_keg("foo", "1.0") }
+  let(:kegs) { [] }
+
+  before(:each) do
+    (HOMEBREW_PREFIX/"bin").mkpath
+    (HOMEBREW_PREFIX/"lib").mkpath
+  end
+
+  after(:each) do
+    kegs.each(&:unlink)
+    rmtree HOMEBREW_PREFIX/"lib"
+  end
+
+  specify "::all" do
+    Formula.clear_racks_cache
+    expect(described_class.all).to eq([keg])
+  end
+
+  specify "#empty_installation?" do
+    %w[.DS_Store INSTALL_RECEIPT.json LICENSE.txt].each do |file|
+      touch keg/file
+    end
+
+    expect(keg).to exist
+    expect(keg).to be_a_directory
+    expect(keg).not_to be_an_empty_installation
+
+    (keg/"bin").rmtree
+    expect(keg).to be_an_empty_installation
+  end
+
+  specify "#oldname_opt_record" do
+    expect(keg.oldname_opt_record).to be nil
+    oldname_opt_record = HOMEBREW_PREFIX/"opt/oldfoo"
+    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/1.0")
+    expect(keg.oldname_opt_record).to eq(oldname_opt_record)
+  end
+
+  specify "#remove_oldname_opt_record" do
+    oldname_opt_record = HOMEBREW_PREFIX/"opt/oldfoo"
+    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/2.0")
+    keg.remove_oldname_opt_record
+    expect(oldname_opt_record).to be_a_symlink
+    oldname_opt_record.unlink
+    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/1.0")
+    keg.remove_oldname_opt_record
+    expect(oldname_opt_record).not_to be_a_symlink
+  end
+
+  describe "#link" do
+    it "links a Keg" do
+      expect(keg.link).to eq(3)
+      (HOMEBREW_PREFIX/"bin").children.each do |c|
+        expect(c.readlink).to be_relative
+      end
+    end
+
+    context "with dry run set to true" do
+      it "only prints what would be done" do
+        mode.dry_run = true
+
+        expect(keg.link(mode)).to eq(0)
+        expect(keg).not_to be_linked
+
+        ["hiworld", "helloworld", "goodbye_cruel_world"].each do |file|
+          expect($stdout.string).to match("#{HOMEBREW_PREFIX}/bin/#{file}")
+        end
+        expect($stdout.string.lines.count).to eq(3)
+      end
+    end
+
+    it "fails when already linked" do
+      keg.link
+
+      expect { keg.link }.to raise_error(Keg::AlreadyLinkedError)
+    end
+
+    it "fails when files exist" do
+      touch dst
+
+      expect { keg.link }.to raise_error(Keg::ConflictError)
+    end
+
+    it "ignores broken symlinks at target" do
+      src = keg/"bin"/"helloworld"
+      dst.make_symlink(nonexistent)
+      keg.link
+      expect(dst.readlink).to eq(src.relative_path_from(dst.dirname))
+    end
+
+    context "with overwrite set to true" do
+      it "overwrite existing files" do
+        touch dst
+        mode.overwrite = true
+        expect(keg.link(mode)).to eq(3)
+        expect(keg).to be_linked
+      end
+
+      it "overwrites broken symlinks" do
+        dst.make_symlink "nowhere"
+        mode.overwrite = true
+        expect(keg.link(mode)).to eq(3)
+        expect(keg).to be_linked
+      end
+
+      it "still supports dryrun" do
+        touch dst
+        mode.overwrite = true
+        mode.dry_run = true
+
+        expect(keg.link(mode)).to eq(0)
+        expect(keg).not_to be_linked
+
+        expect($stdout.string).to eq("#{dst}\n")
+      end
+    end
+
+    it "also creates an opt link" do
+      expect(keg).not_to be_optlinked
+      keg.link
+      expect(keg).to be_optlinked
+    end
+
+    specify "pkgconfig directory is created" do
+      link = HOMEBREW_PREFIX/"lib"/"pkgconfig"
+      (keg/"lib"/"pkgconfig").mkpath
+      keg.link
+      expect(link.lstat).to be_a_directory
+    end
+
+    specify "cmake directory is created" do
+      link = HOMEBREW_PREFIX/"lib"/"cmake"
+      (keg/"lib"/"cmake").mkpath
+      keg.link
+      expect(link.lstat).to be_a_directory
+    end
+
+    specify "symlinks are linked directly" do
+      link = HOMEBREW_PREFIX/"lib"/"pkgconfig"
+
+      (keg/"lib"/"example").mkpath
+      (keg/"lib"/"pkgconfig").make_symlink "example"
+      keg.link
+
+      expect(link.resolved_path).to be_a_symlink
+      expect(link.lstat).to be_a_symlink
+    end
+  end
+
+  describe "#unlink" do
+    it "unlinks a Keg" do
+      keg.link
+      expect(dst).to be_a_symlink
+      expect(keg.unlink).to eq(3)
+      expect(dst).not_to be_a_symlink
+    end
+
+    it "prunes empty top-level directories" do
+      mkpath HOMEBREW_PREFIX/"lib/foo/bar"
+      mkpath keg/"lib/foo/bar"
+      touch keg/"lib/foo/bar/file1"
+
+      keg.unlink
+
+      expect(HOMEBREW_PREFIX/"lib/foo").not_to be_a_directory
+    end
+
+    it "ignores .DS_Store when pruning empty directories" do
+      mkpath HOMEBREW_PREFIX/"lib/foo/bar"
+      touch HOMEBREW_PREFIX/"lib/foo/.DS_Store"
+      mkpath keg/"lib/foo/bar"
+      touch keg/"lib/foo/bar/file1"
+
+      keg.unlink
+
+      expect(HOMEBREW_PREFIX/"lib/foo").not_to be_a_directory
+      expect(HOMEBREW_PREFIX/"lib/foo/.DS_Store").not_to exist
+    end
+
+    it "doesn't remove opt link" do
+      keg.link
+      keg.unlink
+      expect(keg).to be_optlinked
+    end
+
+    it "preverves broken symlinks pointing outside the Keg" do
+      keg.link
+      dst.delete
+      dst.make_symlink(nonexistent)
+      keg.unlink
+      expect(dst).to be_a_symlink
+    end
+
+    it "preverves broken symlinks pointing into the Keg" do
+      keg.link
+      dst.resolved_path.delete
+      keg.unlink
+      expect(dst).to be_a_symlink
+    end
+
+    it "preverves symlinks pointing outside the Keg" do
+      keg.link
+      dst.delete
+      dst.make_symlink(Pathname.new("/bin/sh"))
+      keg.unlink
+      expect(dst).to be_a_symlink
+    end
+
+    it "preserves real files" do
+      keg.link
+      dst.delete
+      touch dst
+      keg.unlink
+      expect(dst).to be_a_file
+    end
+
+    it "ignores nonexistent file" do
+      keg.link
+      dst.delete
+      expect(keg.unlink).to eq(2)
+    end
+
+    it "doesn't remove links to symlinks" do
+      a = HOMEBREW_CELLAR/"a"/"1.0"
+      b = HOMEBREW_CELLAR/"b"/"1.0"
+
+      (a/"lib"/"example").mkpath
+      (a/"lib"/"example2").make_symlink "example"
+      (b/"lib"/"example2").mkpath
+
+      a = described_class.new(a)
+      b = described_class.new(b)
+      a.link
+
+      lib = HOMEBREW_PREFIX/"lib"
+      expect(lib.children.length).to eq(2)
+      expect { b.link }.to raise_error(Keg::ConflictError)
+      expect(lib.children.length).to eq(2)
+    end
+
+    it "removes broken symlinks that conflict with directories" do
+      a = HOMEBREW_CELLAR/"a"/"1.0"
+      (a/"lib"/"foo").mkpath
+
+      keg = described_class.new(a)
+
+      link = HOMEBREW_PREFIX/"lib"/"foo"
+      link.parent.mkpath
+      link.make_symlink(nonexistent)
+
+      keg.link
+    end
+  end
+
+  describe "#optlink" do
+    it "creates an opt link" do
+      oldname_opt_record = HOMEBREW_PREFIX/"opt/oldfoo"
+      oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/1.0")
+      keg_record = HOMEBREW_CELLAR/"foo"/"2.0"
+      (keg_record/"bin").mkpath
+      keg = described_class.new(keg_record)
+      keg.optlink
+      expect(keg_record).to eq(oldname_opt_record.resolved_path)
+      keg.uninstall
+      expect(oldname_opt_record).not_to be_a_symlink
+    end
+
+    it "doesn't fail if already opt-linked" do
+      keg.opt_record.make_relative_symlink Pathname.new(keg)
+      keg.optlink
+      expect(keg).to be_optlinked
+    end
+
+    it "replaces an existing directory" do
+      keg.opt_record.mkpath
+      keg.optlink
+      expect(keg).to be_optlinked
+    end
+
+    it "replaces an existing file" do
+      keg.opt_record.parent.mkpath
+      keg.opt_record.write("foo")
+      keg.optlink
+      expect(keg).to be_optlinked
+    end
+  end
+
+  specify "#link and #unlink" do
+    expect(keg).not_to be_linked
+    keg.link
+    expect(keg).to be_linked
+    keg.unlink
+    expect(keg).not_to be_linked
+  end
+
+  describe "::find_some_installed_dependents" do
+    def stub_formula_name(name)
+      f = formula(name) { url "foo-1.0" }
+      stub_formula_loader f
+      stub_formula_loader f, "homebrew/core/#{f}"
+      f
+    end
+
+    def setup_test_keg(name, version)
+      f = stub_formula_name(name)
+      keg = super
+      Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
+      keg
+    end
+
+    before(:each) do
+      keg.link
+    end
+
+    def alter_tab(keg = dependent)
+      tab = Tab.for_keg(keg)
+      yield tab
+      tab.write
+    end
+
+    # 1.1.6 is the earliest version of Homebrew that generates correct runtime
+    # dependency lists in Tabs.
+    def dependencies(deps, homebrew_version: "1.1.6")
+      alter_tab do |tab|
+        tab.homebrew_version = homebrew_version
+        tab.tabfile = dependent/Tab::FILENAME
+        tab.runtime_dependencies = deps
+      end
+    end
+
+    def unreliable_dependencies(deps)
+      # 1.1.5 is (hopefully!) the last version of Homebrew that generates
+      # incorrect runtime dependency lists in Tabs.
+      dependencies(deps, homebrew_version: "1.1.5")
+    end
+
+    let(:dependent) { setup_test_keg("bar", "1.0") }
+
+    # Test with a keg whose formula isn't known.
+    # This can happen if e.g. a formula is installed
+    # from a file path or URL.
+    specify "unknown Formula" do
+      allow(Formulary).to receive(:loader_for).and_call_original
+      alter_tab(keg) do |t|
+        t.source["tap"] = "some/tap"
+        t.source["path"] = nil
+      end
+
+      dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }]
+      expect(keg.installed_dependents).to eq([dependent])
+      expect(described_class.find_some_installed_dependents([keg])).to eq([[keg], ["bar 1.0"]])
+
+      dependencies nil
+      # It doesn't make sense for a keg with no formula to have any dependents,
+      # so that can't really be tested.
+      expect(described_class.find_some_installed_dependents([keg])).to be nil
+    end
+
+    specify "a dependency with no Tap in Tab" do
+      tap_dep = setup_test_keg("baz", "1.0")
+
+      alter_tab(keg) { |t| t.source["tap"] = nil }
+
+      dependencies nil
+      Formula["bar"].class.depends_on "foo"
+      Formula["bar"].class.depends_on "baz"
+
+      result = described_class.find_some_installed_dependents([keg, tap_dep])
+      expect(result).to eq([[keg, tap_dep], ["bar"]])
+    end
+
+    specify "no dependencies anywhere" do
+      dependencies nil
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg])).to be nil
+    end
+
+    specify "missing Formula dependency" do
+      dependencies nil
+      Formula["bar"].class.depends_on "foo"
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg])).to eq([[keg], ["bar"]])
+    end
+
+    specify "uninstalling dependent and dependency" do
+      dependencies nil
+      Formula["bar"].class.depends_on "foo"
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg, dependent])).to be nil
+    end
+
+    specify "renamed dependency" do
+      dependencies nil
+
+      stub_formula_loader Formula["foo"], "homebrew/core/foo-old"
+      renamed_path = HOMEBREW_CELLAR/"foo-old"
+      (HOMEBREW_CELLAR/"foo").rename(renamed_path)
+      renamed_keg = described_class.new(renamed_path/"1.0")
+
+      Formula["bar"].class.depends_on "foo"
+
+      result = described_class.find_some_installed_dependents([renamed_keg])
+      expect(result).to eq([[renamed_keg], ["bar"]])
+    end
+
+    specify "empty dependencies in Tab" do
+      dependencies []
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg])).to be nil
+    end
+
+    specify "same name but different version in Tab" do
+      dependencies [{ "full_name" => "foo", "version" => "1.1" }]
+      expect(keg.installed_dependents).to eq([dependent])
+      expect(described_class.find_some_installed_dependents([keg])).to eq([[keg], ["bar 1.0"]])
+    end
+
+    specify "different name and same version in Tab" do
+      stub_formula_name("baz")
+      dependencies [{ "full_name" => "baz", "version" => keg.version.to_s }]
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg])).to be nil
+    end
+
+    specify "same name and version in Tab" do
+      dependencies [{ "full_name" => "foo", "version" => "1.0" }]
+      expect(keg.installed_dependents).to eq([dependent])
+      expect(described_class.find_some_installed_dependents([keg])).to eq([[keg], ["bar 1.0"]])
+    end
+
+    specify "fallback for old versions" do
+      unreliable_dependencies [{ "full_name" => "baz", "version" => "1.0" }]
+      Formula["bar"].class.depends_on "foo"
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg])).to eq([[keg], ["bar"]])
+    end
+
+    specify "non-opt-linked" do
+      keg.remove_opt_record
+      dependencies [{ "full_name" => "foo", "version" => "1.0" }]
+      expect(keg.installed_dependents).to be_empty
+      expect(described_class.find_some_installed_dependents([keg])).to be nil
+    end
+
+    specify "keg-only" do
+      keg.unlink
+      Formula["foo"].class.keg_only "a good reason"
+      dependencies [{ "full_name" => "foo", "version" => "1.1" }] # different version
+      expect(keg.installed_dependents).to eq([dependent])
+      expect(described_class.find_some_installed_dependents([keg])).to eq([[keg], ["bar 1.0"]])
+    end
+  end
+end
diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb
deleted file mode 100644
index bd4232038..000000000
--- a/Library/Homebrew/test/keg_test.rb
+++ /dev/null
@@ -1,475 +0,0 @@
-require "testing_env"
-require "keg"
-require "stringio"
-
-class LinkTestCase < Homebrew::TestCase
-  include FileUtils
-
-  def setup_test_keg(name, version)
-    path = HOMEBREW_CELLAR.join(name, version)
-    path.join("bin").mkpath
-
-    %w[hiworld helloworld goodbye_cruel_world].each do |file|
-      touch path.join("bin", file)
-    end
-
-    keg = Keg.new(path)
-    @kegs ||= []
-    @kegs << keg
-    keg
-  end
-
-  def setup
-    super
-
-    @keg = setup_test_keg("foo", "1.0")
-    @dst = HOMEBREW_PREFIX.join("bin", "helloworld")
-    @nonexistent = Pathname.new("/some/nonexistent/path")
-
-    @mode = OpenStruct.new
-
-    @old_stdout = $stdout
-    $stdout = StringIO.new
-
-    mkpath HOMEBREW_PREFIX/"bin"
-    mkpath HOMEBREW_PREFIX/"lib"
-  end
-
-  def teardown
-    @kegs.each(&:unlink)
-    $stdout = @old_stdout
-    rmtree HOMEBREW_PREFIX/"lib"
-    super
-  end
-end
-
-class LinkTests < LinkTestCase
-  def test_all
-    Formula.clear_racks_cache
-    assert_equal [@keg], Keg.all
-  end
-
-  def test_empty_installation
-    %w[.DS_Store INSTALL_RECEIPT.json LICENSE.txt].each do |file|
-      touch @keg/file
-    end
-    assert_predicate @keg, :exist?
-    assert_predicate @keg, :directory?
-    refute_predicate @keg, :empty_installation?
-
-    (@keg/"bin").rmtree
-    assert_predicate @keg, :empty_installation?
-  end
-
-  def test_linking_keg
-    assert_equal 3, @keg.link
-    (HOMEBREW_PREFIX/"bin").children.each { |c| assert_predicate c.readlink, :relative? }
-  end
-
-  def test_unlinking_keg
-    @keg.link
-    assert_predicate @dst, :symlink?
-    assert_equal 3, @keg.unlink
-    refute_predicate @dst, :symlink?
-  end
-
-  def test_oldname_opt_record
-    assert_nil @keg.oldname_opt_record
-    oldname_opt_record = HOMEBREW_PREFIX/"opt/oldfoo"
-    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/1.0")
-    assert_equal oldname_opt_record, @keg.oldname_opt_record
-  end
-
-  def test_optlink_relink
-    oldname_opt_record = HOMEBREW_PREFIX/"opt/oldfoo"
-    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/1.0")
-    keg_record = HOMEBREW_CELLAR.join("foo", "2.0")
-    keg_record.join("bin").mkpath
-    keg = Keg.new(keg_record)
-    keg.optlink
-    assert_equal keg_record, oldname_opt_record.resolved_path
-    keg.uninstall
-    refute_predicate oldname_opt_record, :symlink?
-  end
-
-  def test_remove_oldname_opt_record
-    oldname_opt_record = HOMEBREW_PREFIX/"opt/oldfoo"
-    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/2.0")
-    @keg.remove_oldname_opt_record
-    assert_predicate oldname_opt_record, :symlink?
-    oldname_opt_record.unlink
-    oldname_opt_record.make_relative_symlink(HOMEBREW_CELLAR/"foo/1.0")
-    @keg.remove_oldname_opt_record
-    refute_predicate oldname_opt_record, :symlink?
-  end
-
-  def test_link_dry_run
-    @mode.dry_run = true
-
-    assert_equal 0, @keg.link(@mode)
-    refute_predicate @keg, :linked?
-
-    ["hiworld", "helloworld", "goodbye_cruel_world"].each do |file|
-      assert_match "#{HOMEBREW_PREFIX}/bin/#{file}", $stdout.string
-    end
-    assert_equal 3, $stdout.string.lines.count
-  end
-
-  def test_linking_fails_when_already_linked
-    @keg.link
-    assert_raises(Keg::AlreadyLinkedError) { @keg.link }
-  end
-
-  def test_linking_fails_when_files_exist
-    touch @dst
-    assert_raises(Keg::ConflictError) { @keg.link }
-  end
-
-  def test_link_ignores_broken_symlinks_at_target
-    src = @keg.join("bin", "helloworld")
-    @dst.make_symlink(@nonexistent)
-    @keg.link
-    assert_equal src.relative_path_from(@dst.dirname), @dst.readlink
-  end
-
-  def test_link_overwrite
-    touch @dst
-    @mode.overwrite = true
-    assert_equal 3, @keg.link(@mode)
-    assert_predicate @keg, :linked?
-  end
-
-  def test_link_overwrite_broken_symlinks
-    @dst.make_symlink "nowhere"
-    @mode.overwrite = true
-    assert_equal 3, @keg.link(@mode)
-    assert_predicate @keg, :linked?
-  end
-
-  def test_link_overwrite_dryrun
-    touch @dst
-    @mode.overwrite = true
-    @mode.dry_run = true
-
-    assert_equal 0, @keg.link(@mode)
-    refute_predicate @keg, :linked?
-
-    assert_equal "#{@dst}\n", $stdout.string
-  end
-
-  def test_unlink_prunes_empty_toplevel_directories
-    mkpath HOMEBREW_PREFIX/"lib/foo/bar"
-    mkpath @keg/"lib/foo/bar"
-    touch @keg/"lib/foo/bar/file1"
-
-    @keg.unlink
-
-    refute_predicate HOMEBREW_PREFIX/"lib/foo", :directory?
-  end
-
-  def test_unlink_ignores_ds_store_when_pruning_empty_dirs
-    mkpath HOMEBREW_PREFIX/"lib/foo/bar"
-    touch HOMEBREW_PREFIX/"lib/foo/.DS_Store"
-    mkpath @keg/"lib/foo/bar"
-    touch @keg/"lib/foo/bar/file1"
-
-    @keg.unlink
-
-    refute_predicate HOMEBREW_PREFIX/"lib/foo", :directory?
-    refute_predicate HOMEBREW_PREFIX/"lib/foo/.DS_Store", :exist?
-  end
-
-  def test_linking_creates_opt_link
-    refute_predicate @keg, :optlinked?
-    @keg.link
-    assert_predicate @keg, :optlinked?
-  end
-
-  def test_unlinking_does_not_remove_opt_link
-    @keg.link
-    @keg.unlink
-    assert_predicate @keg, :optlinked?
-  end
-
-  def test_existing_opt_link
-    @keg.opt_record.make_relative_symlink Pathname.new(@keg)
-    @keg.optlink
-    assert_predicate @keg, :optlinked?
-  end
-
-  def test_existing_opt_link_directory
-    @keg.opt_record.mkpath
-    @keg.optlink
-    assert_predicate @keg, :optlinked?
-  end
-
-  def test_existing_opt_link_file
-    @keg.opt_record.parent.mkpath
-    @keg.opt_record.write("foo")
-    @keg.optlink
-    assert_predicate @keg, :optlinked?
-  end
-
-  def test_linked_keg
-    refute_predicate @keg, :linked?
-    @keg.link
-    assert_predicate @keg, :linked?
-    @keg.unlink
-    refute_predicate @keg, :linked?
-  end
-
-  def test_unlink_preserves_broken_symlink_pointing_outside_the_keg
-    @keg.link
-    @dst.delete
-    @dst.make_symlink(@nonexistent)
-    @keg.unlink
-    assert_predicate @dst, :symlink?
-  end
-
-  def test_unlink_preserves_broken_symlink_pointing_into_the_keg
-    @keg.link
-    @dst.resolved_path.delete
-    @keg.unlink
-    assert_predicate @dst, :symlink?
-  end
-
-  def test_unlink_preserves_symlink_pointing_outside_of_keg
-    @keg.link
-    @dst.delete
-    @dst.make_symlink(Pathname.new("/bin/sh"))
-    @keg.unlink
-    assert_predicate @dst, :symlink?
-  end
-
-  def test_unlink_preserves_real_file
-    @keg.link
-    @dst.delete
-    touch @dst
-    @keg.unlink
-    assert_predicate @dst, :file?
-  end
-
-  def test_unlink_ignores_nonexistent_file
-    @keg.link
-    @dst.delete
-    assert_equal 2, @keg.unlink
-  end
-
-  def test_pkgconfig_is_mkpathed
-    link = HOMEBREW_PREFIX.join("lib", "pkgconfig")
-    @keg.join("lib", "pkgconfig").mkpath
-    @keg.link
-    assert_predicate link.lstat, :directory?
-  end
-
-  def test_cmake_is_mkpathed
-    link = HOMEBREW_PREFIX.join("lib", "cmake")
-    @keg.join("lib", "cmake").mkpath
-    @keg.link
-    assert_predicate link.lstat, :directory?
-  end
-
-  def test_symlinks_are_linked_directly
-    link = HOMEBREW_PREFIX.join("lib", "pkgconfig")
-
-    @keg.join("lib", "example").mkpath
-    @keg.join("lib", "pkgconfig").make_symlink "example"
-    @keg.link
-
-    assert_predicate link.resolved_path, :symlink?
-    assert_predicate link.lstat, :symlink?
-  end
-
-  def test_links_to_symlinks_are_not_removed
-    a = HOMEBREW_CELLAR.join("a", "1.0")
-    b = HOMEBREW_CELLAR.join("b", "1.0")
-
-    a.join("lib", "example").mkpath
-    a.join("lib", "example2").make_symlink "example"
-    b.join("lib", "example2").mkpath
-
-    a = Keg.new(a)
-    b = Keg.new(b)
-    a.link
-
-    lib = HOMEBREW_PREFIX.join("lib")
-    assert_equal 2, lib.children.length
-    assert_raises(Keg::ConflictError) { b.link }
-    assert_equal 2, lib.children.length
-  ensure
-    a.unlink
-  end
-
-  def test_removes_broken_symlinks_that_conflict_with_directories
-    a = HOMEBREW_CELLAR.join("a", "1.0")
-    a.join("lib", "foo").mkpath
-
-    keg = Keg.new(a)
-
-    link = HOMEBREW_PREFIX.join("lib", "foo")
-    link.parent.mkpath
-    link.make_symlink(@nonexistent)
-
-    keg.link
-  ensure
-    keg.unlink
-  end
-end
-
-class InstalledDependantsTests < LinkTestCase
-  def stub_formula_name(name)
-    f = formula(name) { url "foo-1.0" }
-    stub_formula_loader f
-    stub_formula_loader f, "homebrew/core/#{f}"
-    f
-  end
-
-  def setup_test_keg(name, version)
-    f = stub_formula_name(name)
-    keg = super
-    Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
-    keg
-  end
-
-  def setup
-    super
-    @dependent = setup_test_keg("bar", "1.0")
-    @keg.link
-  end
-
-  def alter_tab(keg = @dependent)
-    tab = Tab.for_keg(keg)
-    yield tab
-    tab.write
-  end
-
-  # 1.1.6 is the earliest version of Homebrew that generates correct runtime
-  # dependency lists in tabs.
-  def dependencies(deps, homebrew_version: "1.1.6")
-    alter_tab do |tab|
-      tab.homebrew_version = homebrew_version
-      tab.tabfile = @dependent.join("INSTALL_RECEIPT.json")
-      tab.runtime_dependencies = deps
-    end
-  end
-
-  def unreliable_dependencies(deps)
-    # 1.1.5 is (hopefully!) the last version of Homebrew that generates
-    # incorrect runtime dependency lists in tabs.
-    dependencies(deps, homebrew_version: "1.1.5")
-  end
-
-  # Test with a keg whose formula isn't known.
-  # This can happen if e.g. a formula is installed
-  # from a file path or URL.
-  def test_unknown_formula
-    Formulary.unstub(:loader_for)
-    alter_tab(@keg) do |t|
-      t.source["tap"] = "some/tap"
-      t.source["path"] = nil
-    end
-
-    dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }]
-    assert_equal [@dependent], @keg.installed_dependents
-    assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
-
-    dependencies nil
-    # It doesn't make sense for a keg with no formula to have any dependents,
-    # so that can't really be tested.
-    assert_nil Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_a_dependency_with_no_tap_in_tab
-    @tap_dep = setup_test_keg("baz", "1.0")
-
-    alter_tab(@keg) { |t| t.source["tap"] = nil }
-
-    dependencies nil
-    Formula["bar"].class.depends_on "foo"
-    Formula["bar"].class.depends_on "baz"
-
-    result = Keg.find_some_installed_dependents([@keg, @tap_dep])
-    assert_equal [[@keg, @tap_dep], ["bar"]], result
-  end
-
-  def test_no_dependencies_anywhere
-    dependencies nil
-    assert_empty @keg.installed_dependents
-    assert_nil Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_missing_formula_dependency
-    dependencies nil
-    Formula["bar"].class.depends_on "foo"
-    assert_empty @keg.installed_dependents
-    assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_uninstalling_dependent_and_dependency
-    dependencies nil
-    Formula["bar"].class.depends_on "foo"
-    assert_empty @keg.installed_dependents
-    assert_nil Keg.find_some_installed_dependents([@keg, @dependent])
-  end
-
-  def test_renamed_dependency
-    dependencies nil
-
-    stub_formula_loader Formula["foo"], "homebrew/core/foo-old"
-    renamed_path = HOMEBREW_CELLAR/"foo-old"
-    (HOMEBREW_CELLAR/"foo").rename(renamed_path)
-    renamed_keg = Keg.new(renamed_path.join("1.0"))
-
-    Formula["bar"].class.depends_on "foo"
-
-    result = Keg.find_some_installed_dependents([renamed_keg])
-    assert_equal [[renamed_keg], ["bar"]], result
-  end
-
-  def test_empty_dependencies_in_tab
-    dependencies []
-    assert_empty @keg.installed_dependents
-    assert_nil Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_same_name_different_version_in_tab
-    dependencies [{ "full_name" => "foo", "version" => "1.1" }]
-    assert_equal [@dependent], @keg.installed_dependents
-    assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_different_name_same_version_in_tab
-    stub_formula_name("baz")
-    dependencies [{ "full_name" => "baz", "version" => @keg.version.to_s }]
-    assert_empty @keg.installed_dependents
-    assert_nil Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_same_name_and_version_in_tab
-    dependencies [{ "full_name" => "foo", "version" => "1.0" }]
-    assert_equal [@dependent], @keg.installed_dependents
-    assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_fallback_for_old_versions
-    unreliable_dependencies [{ "full_name" => "baz", "version" => "1.0" }]
-    Formula["bar"].class.depends_on "foo"
-    assert_empty @keg.installed_dependents
-    assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_nonoptlinked
-    @keg.remove_opt_record
-    dependencies [{ "full_name" => "foo", "version" => "1.0" }]
-    assert_empty @keg.installed_dependents
-    assert_nil Keg.find_some_installed_dependents([@keg])
-  end
-
-  def test_keg_only
-    @keg.unlink
-    Formula["foo"].class.keg_only "a good reason"
-    dependencies [{ "full_name" => "foo", "version" => "1.1" }] # different version
-    assert_equal [@dependent], @keg.installed_dependents
-    assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
-  end
-end
-- 
cgit v1.2.3


From 37f7e84e04051af769f13dda3b0d400802446a7f Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 19:34:46 +0100
Subject: Convert Options test to spec.

---
 Library/Homebrew/test/options_spec.rb | 148 ++++++++++++++++++++++++++++++++++
 Library/Homebrew/test/options_test.rb | 148 ----------------------------------
 2 files changed, 148 insertions(+), 148 deletions(-)
 create mode 100644 Library/Homebrew/test/options_spec.rb
 delete mode 100644 Library/Homebrew/test/options_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/options_spec.rb b/Library/Homebrew/test/options_spec.rb
new file mode 100644
index 000000000..a05bb139e
--- /dev/null
+++ b/Library/Homebrew/test/options_spec.rb
@@ -0,0 +1,148 @@
+require "options"
+
+describe Option do
+  subject { described_class.new("foo") }
+
+  specify "#to_s" do
+    expect(subject.to_s).to eq("--foo")
+  end
+
+  specify "equality" do
+    foo = Option.new("foo")
+    bar = Option.new("bar")
+    expect(subject).to eq(foo)
+    expect(subject).not_to eq(bar)
+    expect(subject).to eql(foo)
+    expect(subject).not_to eql(bar)
+  end
+
+  specify "#description" do
+    expect(subject.description).to be_empty
+    expect(Option.new("foo", "foo").description).to eq("foo")
+  end
+
+  specify "#inspect" do
+    expect(subject.inspect).to eq("#")
+  end
+end
+
+describe DeprecatedOption do
+  subject { described_class.new("foo", "bar") }
+
+  specify "#old" do
+    expect(subject.old).to eq("foo")
+  end
+
+  specify "#old_flag" do
+    expect(subject.old_flag).to eq("--foo")
+  end
+
+  specify "#current" do
+    expect(subject.current).to eq("bar")
+  end
+
+  specify "#current_flag" do
+    expect(subject.current_flag).to eq("--bar")
+  end
+
+  specify "equality" do
+    foobar = DeprecatedOption.new("foo", "bar")
+    boofar = DeprecatedOption.new("boo", "far")
+    expect(foobar).to eq(subject)
+    expect(subject).to eq(foobar)
+    expect(boofar).not_to eq(subject)
+    expect(subject).not_to eq(boofar)
+  end
+end
+
+describe Options do
+  it "removes duplicate options" do
+    subject << Option.new("foo")
+    subject << Option.new("foo")
+    expect(subject).to include("--foo")
+    expect(subject.count).to eq(1)
+  end
+
+  it "preserves  existing member when adding a duplicate" do
+    a = Option.new("foo", "bar")
+    b = Option.new("foo", "qux")
+    subject << a << b
+    expect(subject.count).to eq(1)
+    expect(subject.first).to be(a)
+    expect(subject.first.description).to eq(a.description)
+  end
+
+  specify "#include?" do
+    subject << Option.new("foo")
+    expect(subject).to include("--foo")
+    expect(subject).to include("foo")
+    expect(subject).to include(Option.new("foo"))
+  end
+
+  describe "#+" do
+    it "returns options" do
+      expect(subject + Options.new).to be_an_instance_of(Options)
+    end
+  end
+
+  describe "#-" do
+    it "returns options" do
+      expect(subject - Options.new).to be_an_instance_of(Options)
+    end
+  end
+
+  specify "#&" do
+    foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
+    options = Options.new << foo << bar
+    subject << foo << baz
+    expect((subject & options).to_a).to eq([foo])
+  end
+
+  specify "#|" do
+    foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
+    options = Options.new << foo << bar
+    subject << foo << baz
+    expect((subject | options).sort).to eq([foo, bar, baz].sort)
+  end
+
+  specify "#*" do
+    subject << Option.new("aa") << Option.new("bb") << Option.new("cc")
+    expect((subject * "XX").split("XX").sort).to eq(%w[--aa --bb --cc])
+  end
+
+  describe "<<" do
+    it "returns itself" do
+      expect(subject << Option.new("foo")).to be subject
+    end
+  end
+
+  specify "#as_flags" do
+    subject << Option.new("foo")
+    expect(subject.as_flags).to eq(%w[--foo])
+  end
+
+  specify "#to_a" do
+    option = Option.new("foo")
+    subject << option
+    expect(subject.to_a).to eq([option])
+  end
+
+  specify "#to_ary" do
+    option = Option.new("foo")
+    subject << option
+    expect(subject.to_ary).to eq([option])
+  end
+
+  specify "::create_with_array" do
+    array = %w[--foo --bar]
+    option1 = Option.new("foo")
+    option2 = Option.new("bar")
+    expect(Options.create(array).sort).to eq([option1, option2].sort)
+  end
+
+  specify "#inspect" do
+    expect(subject.inspect).to eq("#")
+    subject << Option.new("foo")
+    expect(subject.inspect).to eq("#]>")
+  end
+end
diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb
deleted file mode 100644
index 0a6e198d3..000000000
--- a/Library/Homebrew/test/options_test.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-require "testing_env"
-require "options"
-
-class OptionTests < Homebrew::TestCase
-  def setup
-    super
-    @option = Option.new("foo")
-  end
-
-  def test_to_s
-    assert_equal "--foo", @option.to_s
-  end
-
-  def test_equality
-    foo = Option.new("foo")
-    bar = Option.new("bar")
-    assert_equal foo, @option
-    refute_equal bar, @option
-    assert_eql @option, foo
-    refute_eql @option, bar
-  end
-
-  def test_description
-    assert_empty @option.description
-    assert_equal "foo", Option.new("foo", "foo").description
-  end
-
-  def test_inspect
-    assert_equal "#", @option.inspect
-  end
-end
-
-class DeprecatedOptionTests < Homebrew::TestCase
-  def setup
-    super
-    @deprecated_option = DeprecatedOption.new("foo", "bar")
-  end
-
-  def test_old
-    assert_equal "foo", @deprecated_option.old
-    assert_equal "--foo", @deprecated_option.old_flag
-  end
-
-  def test_current
-    assert_equal "bar", @deprecated_option.current
-    assert_equal "--bar", @deprecated_option.current_flag
-  end
-
-  def test_equality
-    foobar = DeprecatedOption.new("foo", "bar")
-    boofar = DeprecatedOption.new("boo", "far")
-    assert_equal foobar, @deprecated_option
-    refute_equal boofar, @deprecated_option
-    assert_eql @deprecated_option, foobar
-    refute_eql @deprecated_option, boofar
-  end
-end
-
-class OptionsTests < Homebrew::TestCase
-  def setup
-    super
-    @options = Options.new
-  end
-
-  def test_no_duplicate_options
-    @options << Option.new("foo")
-    @options << Option.new("foo")
-    assert_includes @options, "--foo"
-    assert_equal 1, @options.count
-  end
-
-  def test_preserves_existing_member_when_pushing_duplicate
-    a = Option.new("foo", "bar")
-    b = Option.new("foo", "qux")
-    @options << a << b
-    assert_equal 1, @options.count
-    assert_same a, @options.first
-    assert_equal a.description, @options.first.description
-  end
-
-  def test_include
-    @options << Option.new("foo")
-    assert_includes @options, "--foo"
-    assert_includes @options, "foo"
-    assert_includes @options, Option.new("foo")
-  end
-
-  def test_union_returns_options
-    assert_instance_of Options, @options + Options.new
-  end
-
-  def test_difference_returns_options
-    assert_instance_of Options, @options - Options.new
-  end
-
-  def test_shovel_returns_self
-    assert_same @options, @options << Option.new("foo")
-  end
-
-  def test_as_flags
-    @options << Option.new("foo")
-    assert_equal %w[--foo], @options.as_flags
-  end
-
-  def test_to_a
-    option = Option.new("foo")
-    @options << option
-    assert_equal [option], @options.to_a
-  end
-
-  def test_to_ary
-    option = Option.new("foo")
-    @options << option
-    assert_equal [option], @options.to_ary
-  end
-
-  def test_intersection
-    foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
-    options = Options.new << foo << bar
-    @options << foo << baz
-    assert_equal [foo], (@options & options).to_a
-  end
-
-  def test_set_union
-    foo, bar, baz = %w[foo bar baz].map { |o| Option.new(o) }
-    options = Options.new << foo << bar
-    @options << foo << baz
-    assert_equal [foo, bar, baz].sort, (@options | options).sort
-  end
-
-  def test_times
-    @options << Option.new("aa") << Option.new("bb") << Option.new("cc")
-    assert_equal %w[--aa --bb --cc], (@options * "XX").split("XX").sort
-  end
-
-  def test_create_with_array
-    array = %w[--foo --bar]
-    option1 = Option.new("foo")
-    option2 = Option.new("bar")
-    assert_equal [option1, option2].sort, Options.create(array).sort
-  end
-
-  def test_inspect
-    assert_equal "#", @options.inspect
-    @options << Option.new("foo")
-    assert_equal "#]>", @options.inspect
-  end
-end
-- 
cgit v1.2.3


From ac2cafe13914881d6db72c57e007ccaa7a6a0e04 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 20:10:25 +0100
Subject: Convert Caveats test to spec.

---
 Library/Homebrew/test/caveats_spec.rb | 29 +++++++++++++++++++++++++++++
 Library/Homebrew/test/caveats_test.rb | 30 ------------------------------
 2 files changed, 29 insertions(+), 30 deletions(-)
 create mode 100644 Library/Homebrew/test/caveats_spec.rb
 delete mode 100644 Library/Homebrew/test/caveats_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/caveats_spec.rb b/Library/Homebrew/test/caveats_spec.rb
new file mode 100644
index 000000000..d8be9dc52
--- /dev/null
+++ b/Library/Homebrew/test/caveats_spec.rb
@@ -0,0 +1,29 @@
+require "formula"
+require "caveats"
+
+describe Caveats do
+  subject { described_class.new(f) }
+  let(:f) { formula { url "foo-1.0" } }
+
+  specify "#f" do
+    expect(subject.f).to eq(f)
+  end
+
+  describe "#empty?" do
+    it "returns true if the Formula has no caveats" do
+      expect(subject).to be_empty
+    end
+
+    it "returns false if the Formula has caveats" do
+      f = formula do
+        url "foo-1.0"
+
+        def caveats
+          "something"
+        end
+      end
+
+      expect(described_class.new(f)).not_to be_empty
+    end
+  end
+end
diff --git a/Library/Homebrew/test/caveats_test.rb b/Library/Homebrew/test/caveats_test.rb
deleted file mode 100644
index 3a582b907..000000000
--- a/Library/Homebrew/test/caveats_test.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require "testing_env"
-require "formula"
-require "caveats"
-
-class CaveatsTests < Homebrew::TestCase
-  def setup
-    super
-    @f = formula { url "foo-1.0" }
-    @c = Caveats.new @f
-  end
-
-  def test_f
-    assert_equal @f, @c.f
-  end
-
-  def test_empty?
-    assert @c.empty?
-
-    f = formula do
-      url "foo-1.0"
-
-      def caveats
-        "something"
-      end
-    end
-    c = Caveats.new f
-
-    refute c.empty?
-  end
-end
-- 
cgit v1.2.3


From 4501f69592c13b72b6d0c1dd8c0eeec0c40244ed Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 19:49:46 +0100
Subject: Convert `cmd/info` test to spec.

---
 Library/Homebrew/test/cmd/info_spec.rb | 20 ++++++++++++++++++++
 Library/Homebrew/test/info_test.rb     | 20 --------------------
 2 files changed, 20 insertions(+), 20 deletions(-)
 delete mode 100644 Library/Homebrew/test/info_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/info_spec.rb b/Library/Homebrew/test/cmd/info_spec.rb
index d33035972..8deef3d23 100644
--- a/Library/Homebrew/test/cmd/info_spec.rb
+++ b/Library/Homebrew/test/cmd/info_spec.rb
@@ -1,3 +1,5 @@
+require "cmd/info"
+
 describe "brew info", :integration_test do
   it "prints information about a given Formula" do
     setup_test_formula "testball"
@@ -8,3 +10,21 @@ describe "brew info", :integration_test do
       .and be_a_success
   end
 end
+
+describe Homebrew do
+  let(:remote) { "https://github.com/Homebrew/homebrew-core" }
+
+  specify "::github_remote_path" do
+    expect(subject.github_remote_path(remote, "Formula/git.rb"))
+      .to eq("https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb")
+
+    expect(subject.github_remote_path("#{remote}.git", "Formula/git.rb"))
+      .to eq("https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb")
+
+    expect(subject.github_remote_path("git@github.com:user/repo", "foo.rb"))
+      .to eq("https://github.com/user/repo/blob/master/foo.rb")
+
+    expect(subject.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
+      .to eq("https://mywebsite.com/foo/bar.rb")
+  end
+end
diff --git a/Library/Homebrew/test/info_test.rb b/Library/Homebrew/test/info_test.rb
deleted file mode 100644
index d8a0f7904..000000000
--- a/Library/Homebrew/test/info_test.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require "testing_env"
-require "cmd/info"
-require "formula"
-require "testing_env"
-
-class InfoCommandTests < Homebrew::TestCase
-  def test_github_remote_path
-    remote = "https://github.com/Homebrew/homebrew-core"
-    assert_equal "https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb",
-      Homebrew.github_remote_path(remote, "Formula/git.rb")
-    assert_equal "https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb",
-      Homebrew.github_remote_path("#{remote}.git", "Formula/git.rb")
-
-    assert_equal "https://github.com/user/repo/blob/master/foo.rb",
-      Homebrew.github_remote_path("git@github.com:user/repo", "foo.rb")
-
-    assert_equal "https://mywebsite.com/foo/bar.rb",
-      Homebrew.github_remote_path("https://mywebsite.com", "foo/bar.rb")
-  end
-end
-- 
cgit v1.2.3


From 2826aa4c7f9b6d8c9ebac30c084160e10365ef55 Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sat, 25 Feb 2017 20:28:38 +0100
Subject: Convert BuildOptions test to spec.

---
 Library/Homebrew/test/build_options_spec.rb | 52 +++++++++++++++++++++++++++++
 Library/Homebrew/test/build_options_test.rb | 50 ---------------------------
 Library/Homebrew/test/tab_spec.rb           | 10 +++---
 3 files changed, 57 insertions(+), 55 deletions(-)
 create mode 100644 Library/Homebrew/test/build_options_spec.rb
 delete mode 100644 Library/Homebrew/test/build_options_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/build_options_spec.rb b/Library/Homebrew/test/build_options_spec.rb
new file mode 100644
index 000000000..5acc12f30
--- /dev/null
+++ b/Library/Homebrew/test/build_options_spec.rb
@@ -0,0 +1,52 @@
+require "build_options"
+require "options"
+
+RSpec::Matchers.alias_matcher :be_built_with, :be_with
+RSpec::Matchers.alias_matcher :be_built_without, :be_without
+
+describe BuildOptions do
+  subject { described_class.new(args, opts) }
+  let(:bad_build) { described_class.new(bad_args, opts) }
+  let(:args) { Options.create(%w[--with-foo --with-bar --without-qux]) }
+  let(:opts) { Options.create(%w[--with-foo --with-bar --without-baz --without-qux]) }
+  let(:bad_args) { Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc]) }
+
+  specify "#include?" do
+    expect(subject).to include("with-foo")
+    expect(subject).not_to include("with-qux")
+    expect(subject).not_to include("--with-foo")
+  end
+
+  specify "#with?" do
+    expect(subject).to be_built_with("foo")
+    expect(subject).to be_built_with("bar")
+    expect(subject).to be_built_with("baz")
+  end
+
+  specify "#without?" do
+    expect(subject).to be_built_without("qux")
+    expect(subject).to be_built_without("xyz")
+  end
+
+  specify "#used_options" do
+    expect(subject.used_options).to include("--with-foo")
+    expect(subject.used_options).to include("--with-bar")
+  end
+
+  specify "#unused_options" do
+    expect(subject.unused_options).to include("--without-baz")
+  end
+
+  specify "#invalid_options" do
+    expect(subject.invalid_options).to be_empty
+    expect(bad_build.invalid_options).to include("--without-bas")
+    expect(bad_build.invalid_options).to include("--without-abc")
+    expect(bad_build.invalid_options).not_to include("--with-foo")
+    expect(bad_build.invalid_options).not_to include("--with-baz")
+  end
+
+  specify "#invalid_option_names" do
+    expect(subject.invalid_option_names).to be_empty
+    expect(bad_build.invalid_option_names).to eq(%w[--without-abc --without-bas])
+  end
+end
diff --git a/Library/Homebrew/test/build_options_test.rb b/Library/Homebrew/test/build_options_test.rb
deleted file mode 100644
index 05e7ccd94..000000000
--- a/Library/Homebrew/test/build_options_test.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require "testing_env"
-require "build_options"
-require "options"
-
-class BuildOptionsTests < Homebrew::TestCase
-  def setup
-    super
-    args = Options.create(%w[--with-foo --with-bar --without-qux])
-    opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux])
-    @build = BuildOptions.new(args, opts)
-    bad_args = Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc])
-    @bad_build = BuildOptions.new(bad_args, opts)
-  end
-
-  def test_include
-    assert_includes @build, "with-foo"
-    refute_includes @build, "with-qux"
-    refute_includes @build, "--with-foo"
-  end
-
-  def test_with_without
-    assert @build.with?("foo")
-    assert @build.with?("bar")
-    assert @build.with?("baz")
-    assert @build.without?("qux")
-    assert @build.without?("xyz")
-  end
-
-  def test_used_options
-    assert_includes @build.used_options, "--with-foo"
-    assert_includes @build.used_options, "--with-bar"
-  end
-
-  def test_unused_options
-    assert_includes @build.unused_options, "--without-baz"
-  end
-
-  def test_invalid_options
-    assert_empty @build.invalid_options
-    assert_includes @bad_build.invalid_options, "--without-bas"
-    assert_includes @bad_build.invalid_options, "--without-abc"
-    refute_includes @bad_build.invalid_options, "--with-foo"
-    refute_includes @bad_build.invalid_options, "--with-baz"
-  end
-
-  def test_invalid_option_names
-    assert_empty @build.invalid_option_names
-    assert_equal @bad_build.invalid_option_names, %w[--without-abc --without-bas]
-  end
-end
diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb
index 32a06a681..01dbeb67c 100644
--- a/Library/Homebrew/test/tab_spec.rb
+++ b/Library/Homebrew/test/tab_spec.rb
@@ -1,7 +1,7 @@
 require "tab"
 require "formula"
 
-RSpec::Matchers.alias_matcher :have_option_with, :be_with
+RSpec::Matchers.alias_matcher :be_built_with, :be_with
 
 describe Tab do
   matcher :be_poured_from_bottle do
@@ -80,10 +80,10 @@ describe Tab do
   end
 
   specify "#with?" do
-    expect(subject).to have_option_with("foo")
-    expect(subject).to have_option_with("qux")
-    expect(subject).not_to have_option_with("bar")
-    expect(subject).not_to have_option_with("baz")
+    expect(subject).to be_built_with("foo")
+    expect(subject).to be_built_with("qux")
+    expect(subject).not_to be_built_with("bar")
+    expect(subject).not_to be_built_with("baz")
   end
 
   specify "#universal?" do
-- 
cgit v1.2.3


From 7a361553f811e864dbf1980c64d8cd83957068e5 Mon Sep 17 00:00:00 2001
From: Uladzislau Shablinski
Date: Sun, 26 Feb 2017 01:24:53 +0300
Subject: system_config: check if devtools installed

Fixes #2192
---
 Library/Homebrew/system_config.rb | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb
index 043f60919..56826f62d 100644
--- a/Library/Homebrew/system_config.rb
+++ b/Library/Homebrew/system_config.rb
@@ -7,19 +7,35 @@ require "development_tools"
 class SystemConfig
   class << self
     def gcc_4_2
-      @gcc_4_2 ||= DevelopmentTools.gcc_4_2_build_version if DevelopmentTools.installed?
+      @gcc_4_2 ||= if DevelopmentTools.installed?
+        DevelopmentTools.gcc_4_2_build_version
+      else
+        Version::NULL
+      end
     end
 
     def gcc_4_0
-      @gcc_4_0 ||= DevelopmentTools.gcc_4_0_build_version if DevelopmentTools.installed?
+      @gcc_4_0 ||= if DevelopmentTools.installed?
+        DevelopmentTools.gcc_4_0_build_version
+      else
+        Version::NULL
+      end
     end
 
     def clang
-      @clang ||= DevelopmentTools.clang_version if DevelopmentTools.installed?
+      @clang ||= if DevelopmentTools.installed?
+        DevelopmentTools.clang_version
+      else
+        Version::NULL
+      end
     end
 
     def clang_build
-      @clang_build ||= DevelopmentTools.clang_build_version if DevelopmentTools.installed?
+      @clang_build ||= if DevelopmentTools.installed?
+        DevelopmentTools.clang_build_version
+      else
+        Version::NULL
+      end
     end
 
     def head
-- 
cgit v1.2.3


From 6cb56297378cb57ade790c392dacf4a3bf02f7da Mon Sep 17 00:00:00 2001
From: EricFromCanada
Date: Sat, 25 Feb 2017 17:27:08 -0500
Subject: Work around man page generator bug for pull.rb

To work around ronn's [issue with nested
lists](https://github.com/rtomayko/ronn/issues/35), treat each item as
a separate paragraph with alternate list markers.
---
 Library/Homebrew/dev-cmd/pull.rb | 53 +++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 22 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index c2342d39c..98a62e578 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -1,33 +1,42 @@
-#: `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`]  []
-#:
+#:  * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`]  []:
 #:    Gets a patch from a GitHub commit or pull request and applies it to Homebrew.
 #:    Optionally, installs the formulae changed by the patch.
 #:
 #:    Each  may be one of:
-#:      * The ID number of a PR (Pull Request) in the homebrew/core GitHub
+#:
+#:      ~ The ID number of a PR (pull request) in the homebrew/core GitHub
 #:        repository
-#:      * The URL of a PR on GitHub, using either the web page or API URL
+#:
+#:      ~ The URL of a PR on GitHub, using either the web page or API URL
 #:        formats. In this form, the PR may be on Homebrew/brew,
 #:        Homebrew/homebrew-core or any tap.
-#:      * The URL of a commit on GitHub
-#:      * A "http://bot.brew.sh/job/..." string specifying a testing job ID
 #:
-#:   If `--bottle` was passed, handle bottles, pulling the bottle-update
-#:   commit and publishing files on Bintray.
-#:   If `--bump` was passed, for one-formula PRs, automatically reword
-#:   commit message to our preferred format.
-#:   If `--clean` was passed, do not rewrite or otherwise modify the
-#:   commits found in the pulled PR.
-#:   If `--ignore-whitespace` was passed, silently ignore whitespace
-#:   discrepancies when applying diffs.
-#:   If `--resolve` was passed, when a patch fails to apply, leave in
-#:   progress and allow user to
-#:                  resolve, instead of aborting.
-#:   If `--branch-okay` was passed, do not warn if pulling to a branch
-#:   besides master (useful for testing).
-#:   If `--no-pbcopy` was passed, do not copy anything to the system
-#    clipboard.
-#:   If `--no-publish` was passed, do not publish bottles to Bintray.
+#:      ~ The URL of a commit on GitHub
+#:
+#:      ~ A "http://bot.brew.sh/job/..." string specifying a testing job ID
+#:
+#:    If `--bottle` is passed, handle bottles, pulling the bottle-update
+#:    commit and publishing files on Bintray.
+#:
+#:    If `--bump` is passed, for one-formula PRs, automatically reword
+#:    commit message to our preferred format.
+#:
+#:    If `--clean` is passed, do not rewrite or otherwise modify the
+#:    commits found in the pulled PR.
+#:
+#:    If `--ignore-whitespace` is passed, silently ignore whitespace
+#:    discrepancies when applying diffs.
+#:
+#:    If `--resolve` is passed, when a patch fails to apply, leave in
+#:    progress and allow user to resolve, instead of aborting.
+#:
+#:    If `--branch-okay` is passed, do not warn if pulling to a branch
+#:    besides master (useful for testing).
+#:
+#:    If `--no-pbcopy` is passed, do not copy anything to the system
+#:    clipboard.
+#:
+#:    If `--no-publish` is passed, do not publish bottles to Bintray.
 
 require "net/http"
 require "net/https"
-- 
cgit v1.2.3


From afc539f86e2be27744838d0db6f85bcfe20fa857 Mon Sep 17 00:00:00 2001
From: EricFromCanada
Date: Sat, 25 Feb 2017 17:37:57 -0500
Subject: Update brew's man page formatting and grammar

Also update command specifications to match descriptions.
---
 Library/Homebrew/cmd/cleanup.rb                 |  2 +-
 Library/Homebrew/cmd/desc.rb                    |  7 +++----
 Library/Homebrew/cmd/info.rb                    |  4 ++--
 Library/Homebrew/cmd/outdated.rb                |  2 +-
 Library/Homebrew/cmd/readall.rb                 |  2 +-
 Library/Homebrew/cmd/search.rb                  |  2 +-
 Library/Homebrew/cmd/tap-info.rb                |  2 +-
 Library/Homebrew/cmd/unlink.rb                  |  2 +-
 Library/Homebrew/cmd/unpack.rb                  |  2 +-
 Library/Homebrew/cmd/uses.rb                    |  4 ++--
 Library/Homebrew/dev-cmd/boneyard-formula-pr.rb |  2 +-
 Library/Homebrew/dev-cmd/bottle.rb              |  3 +--
 Library/Homebrew/dev-cmd/bump-formula-pr.rb     | 13 ++++++-------
 Library/Homebrew/dev-cmd/create.rb              |  3 +--
 Library/Homebrew/dev-cmd/formula.rb             |  2 +-
 Library/Homebrew/dev-cmd/linkage.rb             |  2 +-
 Library/Homebrew/dev-cmd/mirror.rb              |  2 +-
 Library/Homebrew/dev-cmd/release-notes.rb       |  6 +++---
 Library/Homebrew/dev-cmd/tests.rb               |  2 +-
 Library/Homebrew/dev-cmd/update-test.rb         |  8 ++++----
 Library/Homebrew/manpages/brew.1.md.erb         |  4 ++--
 21 files changed, 36 insertions(+), 40 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index 5b46e0872..126309579 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -7,7 +7,7 @@
 #:    If `--dry-run` or `-n` is passed, show what would be removed, but do not
 #:    actually remove anything.
 #:
-#:    If `-s` is passed, scrubs the cache, removing downloads for even the latest
+#:    If `-s` is passed, scrub the cache, removing downloads for even the latest
 #:    versions of formulae. Note downloads for any installed formulae will still not be
 #:    deleted. If you want to delete those too: `rm -rf $(brew --cache)`
 
diff --git a/Library/Homebrew/cmd/desc.rb b/Library/Homebrew/cmd/desc.rb
index 3ef02288b..53291602e 100644
--- a/Library/Homebrew/cmd/desc.rb
+++ b/Library/Homebrew/cmd/desc.rb
@@ -1,11 +1,10 @@
 #:  * `desc` :
 #:    Display 's name and one-line description.
 #:
-#:  * `desc` [`-s`|`-n`|`-d`] :
+#:  * `desc` [`-s`|`-n`|`-d`] (|`/``/`):
 #:    Search both name and description (`-s`), just the names (`-n`), or just  the
-#:    descriptions (`-d`) for ``. `` is by default interpreted
-#:    as a literal string; if flanked by slashes, it is instead interpreted as a
-#:    regular expression. Formula descriptions are cached; the cache is created on
+#:    descriptions (`-d`) for . If  is flanked by slashes, it is interpreted
+#:    as a regular expression. Formula descriptions are cached; the cache is created on
 #:    the first search, making that search slower than subsequent ones.
 
 require "descriptions"
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 1850ae003..b06d99466 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -4,7 +4,7 @@
 #:  * `info` `--github` :
 #:    Open a browser to the GitHub History page for formula .
 #:
-#:    To view formula history locally: `brew log -p `.
+#:    To view formula history locally: `brew log -p `
 #:
 #:  * `info` `--json=` (`--all`|`--installed`|):
 #:    Print a JSON representation of . Currently the only accepted value
@@ -13,7 +13,7 @@
 #:    Pass `--all` to get information on all formulae, or `--installed` to get
 #:    information on all installed formulae.
 #:
-#:    See the docs for examples of using the JSON:
+#:    See the docs for examples of using the JSON output:
 #:    
 
 require "blacklist"
diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb
index 9ed7a0f79..a18f4e399 100644
--- a/Library/Homebrew/cmd/outdated.rb
+++ b/Library/Homebrew/cmd/outdated.rb
@@ -1,4 +1,4 @@
-#:  * `outdated` [`--quiet`|`--verbose`|`--json=v1`] [`--fetch-HEAD`]:
+#:  * `outdated` [`--quiet`|`--verbose`|`--json=`] [`--fetch-HEAD`]:
 #:    Show formulae that have an updated version available.
 #:
 #:    By default, version information is displayed in interactive shells, and
diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb
index 7c1a085c9..3591e0c09 100644
--- a/Library/Homebrew/cmd/readall.rb
+++ b/Library/Homebrew/cmd/readall.rb
@@ -4,7 +4,7 @@
 #:
 #:    This can be useful for debugging issues across all formulae
 #:    when making significant changes to `formula.rb`,
-#:    or to determine if any current formulae have Ruby issues
+#:    or to determine if any current formulae have Ruby issues.
 
 require "readall"
 
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index d69164eb9..e834a00b5 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -2,7 +2,7 @@
 #:    Display all locally available formulae for brewing (including tapped ones).
 #:    No online search is performed if called without arguments.
 #:
-#:  * `search` [`--desc`] |`/``/`:
+#:  * `search` [`--desc`] (|`/``/`):
 #:    Perform a substring search of formula names for . If  is
 #:    surrounded with slashes, then it is interpreted as a regular expression.
 #:    The search for  is extended online to some popular taps.
diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb
index b46de30c1..225b70097 100644
--- a/Library/Homebrew/cmd/tap-info.rb
+++ b/Library/Homebrew/cmd/tap-info.rb
@@ -12,7 +12,7 @@
 #:
 #:    Pass `--installed` to get information on installed taps.
 #:
-#:    See the docs for examples of using the JSON:
+#:    See the docs for examples of using the JSON output:
 #:    
 
 require "tap"
diff --git a/Library/Homebrew/cmd/unlink.rb b/Library/Homebrew/cmd/unlink.rb
index a105f9c56..3f858b2c4 100644
--- a/Library/Homebrew/cmd/unlink.rb
+++ b/Library/Homebrew/cmd/unlink.rb
@@ -1,7 +1,7 @@
 #:  * `unlink` [`--dry-run`] :
 #:    Remove symlinks for  from the Homebrew prefix. This can be useful
 #:    for temporarily disabling a formula:
-#:    `brew unlink foo && commands && brew link foo`.
+#:    `brew unlink  &&  && brew link `
 #:
 #:    If `--dry-run` or `-n` is passed, Homebrew will list all files which would
 #:    be unlinked, but will not actually unlink or delete any files.
diff --git a/Library/Homebrew/cmd/unpack.rb b/Library/Homebrew/cmd/unpack.rb
index 4e6584e70..60d796d9f 100644
--- a/Library/Homebrew/cmd/unpack.rb
+++ b/Library/Homebrew/cmd/unpack.rb
@@ -1,7 +1,7 @@
 #:  * `unpack` [`--git`|`--patch`] [`--destdir=`] :
 #:    Unpack the source files for  into subdirectories of the current
 #:    working directory. If `--destdir=` is given, the subdirectories will
-#:    be created in the directory named by `` instead.
+#:    be created in the directory named by  instead.
 #:
 #:    If `--patch` is passed, patches for  will be applied to the
 #:    unpacked source.
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index 5f6611dfc..b1122c90a 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -12,8 +12,8 @@
 #:    `--include-build`. Similarly, pass `--include-optional` to include `:optional`
 #:    dependencies. To skip `:recommended` type dependencies, pass `--skip-recommended`.
 #:
-#:    By default, `uses` shows usages of `formula` by stable builds. To find
-#:    cases where `formula` is used by development or HEAD build, pass
+#:    By default, `uses` shows usages of  by stable builds. To find
+#:    cases where  is used by development or HEAD build, pass
 #:    `--devel` or `--HEAD`.
 
 require "formula"
diff --git a/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb b/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
index 3066d2ee6..7531ef9cf 100644
--- a/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/boneyard-formula-pr.rb
@@ -1,5 +1,5 @@
 #: @hide_from_man_page
-#:  * `boneyard-formula-pr` [`--dry-run`] [`--local`] [`--reason=`]  :
+#:  * `boneyard-formula-pr` [`--dry-run`] [`--local`] [`--reason=`]  :
 #:    Creates a pull request to boneyard a formula.
 #:
 #:    If `--dry-run` is passed, print what would be done rather than doing it.
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 7367e5c37..91bdcba93 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -1,6 +1,5 @@
-#:  * `bottle` [`--verbose`] [`--no-rebuild`] [`--keep-old`] [`--skip-relocation`] [`--root-url=`] [`--force-core-tap`]:
+#:  * `bottle` [`--verbose`] [`--no-rebuild`] [`--keep-old`] [`--skip-relocation`] [`--root-url=`] [`--force-core-tap`]:
 #:  * `bottle` `--merge` [`--no-commit`] [`--keep-old`] [`--write`]:
-#:
 #:    Generate a bottle (binary package) from a formula installed with
 #:    `--build-bottle`.
 
diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
index bfe9c7776..6c7b7d5b5 100644
--- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -1,8 +1,7 @@
-#:  * `bump-formula-pr` [`--devel`] [`--dry-run`] [`--audit`|`--strict`] [`--message=`] `--url=` `--sha256=` :
-#:  * `bump-formula-pr` [`--devel`] [`--dry-run`] [`--audit`|`--strict`] [`--message=`] `--tag=` `--revision=` :
-#:    Creates a pull request to update the formula with a new url or a new tag.
+#:  * `bump-formula-pr` [`--devel`] [`--dry-run` [`--write`]] [`--audit`|`--strict`] [`--mirror=`] [`--version=`] [`--message=`] (`--url=` `--sha256=`|`--tag=` `--revision=`) :
+#:    Creates a pull request to update the formula with a new URL or a new tag.
 #:
-#:    If a  is specified, the  checksum of the new download must
+#:    If a  is specified, the  checksum of the new download must
 #:    also be specified. A best effort to determine the  and 
 #:    name will be made if either or both values are not supplied by the user.
 #:
@@ -21,17 +20,17 @@
 #:
 #:    If `--strict` is passed, run `brew audit --strict` before opening the PR.
 #:
-#:    If `--mirror=` is passed, use the value as a mirror url.
+#:    If `--mirror=` is passed, use the value as a mirror URL.
 #:
 #:    If `--version=` is passed, use the value to override the value
-#:    parsed from the url or tag. Note that `--version=0` can be used to delete
+#:    parsed from the URL or tag. Note that `--version=0` can be used to delete
 #:    an existing `version` override from a formula if it has become redundant.
 #:
 #:    If `--message=` is passed, append  to the default PR
 #:    message.
 #:
 #:    Note that this command cannot be used to transition a formula from a
-#:    url-and-sha256 style specification into a tag-and-revision style
+#:    URL-and-sha256 style specification into a tag-and-revision style
 #:    specification, nor vice versa. It must use whichever style specification
 #:    the preexisting formula already uses.
 
diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb
index b4cda0fad..9c58dc71a 100644
--- a/Library/Homebrew/dev-cmd/create.rb
+++ b/Library/Homebrew/dev-cmd/create.rb
@@ -3,8 +3,7 @@
 #:    Homebrew will attempt to automatically derive the formula name
 #:    and version, but if it fails, you'll have to make your own template. The `wget`
 #:    formula serves as a simple example. For the complete API have a look at
-#:
-#:    
+#:    .
 #:
 #:    If `--autotools` is passed, create a basic template for an Autotools-style build.
 #:    If `--cmake` is passed, create a basic template for a CMake-style build.
diff --git a/Library/Homebrew/dev-cmd/formula.rb b/Library/Homebrew/dev-cmd/formula.rb
index 71687dfa7..67d11edce 100644
--- a/Library/Homebrew/dev-cmd/formula.rb
+++ b/Library/Homebrew/dev-cmd/formula.rb
@@ -1,5 +1,5 @@
 #:  * `formula` :
-#:    Display the path where  is
+#:    Display the path where  is located.
 
 require "formula"
 
diff --git a/Library/Homebrew/dev-cmd/linkage.rb b/Library/Homebrew/dev-cmd/linkage.rb
index 44e0f224e..e4da827f2 100644
--- a/Library/Homebrew/dev-cmd/linkage.rb
+++ b/Library/Homebrew/dev-cmd/linkage.rb
@@ -1,4 +1,4 @@
-#:  * `linkage` [`--test`] [`--reverse`]  :
+#:  * `linkage` [`--test`] [`--reverse`]  :
 #:    Checks the library links of an installed formula.
 #:
 #:    Only works on installed formulae. An error is raised if it is run on
diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb
index bd5868726..10811493c 100644
--- a/Library/Homebrew/dev-cmd/mirror.rb
+++ b/Library/Homebrew/dev-cmd/mirror.rb
@@ -1,5 +1,5 @@
 #: @hide_from_man_page
-#:  * `mirror` [`--test`]  [ ...]:
+#:  * `mirror` [`--test`] :
 #:    Reuploads the stable URL for a formula to Bintray to use it as a mirror.
 
 module Homebrew
diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb
index 919243764..eb398fcfb 100644
--- a/Library/Homebrew/dev-cmd/release-notes.rb
+++ b/Library/Homebrew/dev-cmd/release-notes.rb
@@ -1,7 +1,7 @@
-#:  * `release-notes` [] []:
+#:  * `release-notes` [`--markdown`] [] []:
 #:    Output the merged pull requests on Homebrew/brew between two Git refs.
-#:    If no `previous_tag` is provided it defaults to the newest tag.
-#:    If no `end_ref` is provided it defaults to `origin/master`.
+#:    If no  is provided it defaults to the newest tag.
+#:    If no  is provided it defaults to `origin/master`.
 #:
 #:    If `--markdown` is passed, output as a Markdown list.
 
diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index 6276d1c1b..0c8621a01 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -1,4 +1,4 @@
-#:  * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`] [`--seed` ] [`--trace`] [`--online`] [`--official-cmd-taps`]:
+#:  * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=``:`] [`--seed` ] [`--trace`] [`--online`] [`--official-cmd-taps`]:
 #:    Run Homebrew's unit and integration tests.
 
 require "fileutils"
diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb
index 3b8dc11f9..9704426dd 100644
--- a/Library/Homebrew/dev-cmd/update-test.rb
+++ b/Library/Homebrew/dev-cmd/update-test.rb
@@ -1,14 +1,14 @@
-#:  * `update-test` [`--commit=`] [`--before=`] [`--keep-tmp`]:
+#:  * `update-test` [`--commit=`] [`--before=`] [`--keep-tmp`]:
 #:    Runs a test of `brew update` with a new repository clone.
 #:
 #:    If no arguments are passed, use `origin/master` as the start commit.
 #:
-#:    If `--commit=` is passed, use `` as the start commit.
+#:    If `--commit=` is passed, use  as the start commit.
 #:
-#:    If `--before=` is passed, use the commit at `` as the
+#:    If `--before=` is passed, use the commit at  as the
 #:    start commit.
 #:
-#:    If `--to-tag` is passed, set HOMEBREW_UPDATE_TO_TAG to test updating
+#:    If `--to-tag` is passed, set `HOMEBREW_UPDATE_TO_TAG` to test updating
 #:    between tags.
 #:
 #:    If `--keep-tmp` is passed, retain the temporary directory containing
diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb
index a7f099e9d..05fc1cb23 100644
--- a/Library/Homebrew/manpages/brew.1.md.erb
+++ b/Library/Homebrew/manpages/brew.1.md.erb
@@ -40,7 +40,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
   * `list`:
     List all installed formulae.
 
-  * `search` |`/``/`:
+  * `search` (|`/``/`):
     Perform a substring search of formula names for . If  is
     surrounded with slashes, then it is interpreted as a regular expression.
     The search for  is extended online to some popular taps.
@@ -214,7 +214,7 @@ can take several different forms:
     to insecure HTTP.
 
     While ensuring your downloads are fully secure, this is likely
-    to cause from-source Sourceforge, some GNU & GNOME based
+    to cause from-source SourceForge, some GNU & GNOME based
     formulae to fail to download.
 
   * `HOMEBREW_NO_GITHUB_API`:
-- 
cgit v1.2.3


From 922a52486bba6afbb01d259f1890c38cde609406 Mon Sep 17 00:00:00 2001
From: EricFromCanada
Date: Sat, 25 Feb 2017 17:45:43 -0500
Subject: Update brew cask's man page formatting and grammar

Includes replacing some non-ASCII characters, which weren't being
processed properly.
---
 Library/Homebrew/manpages/brew-cask.1.md | 49 ++++++++++++++++----------------
 1 file changed, 25 insertions(+), 24 deletions(-)

(limited to 'Library')

diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md
index a9da5bca6..e882f09d1 100644
--- a/Library/Homebrew/manpages/brew-cask.1.md
+++ b/Library/Homebrew/manpages/brew-cask.1.md
@@ -86,19 +86,19 @@ names, and other aspects of this manual are still subject to change.
     If  is given, summarize the staged files associated with the
     given Cask.
 
-  * `reinstall`  [  ...]
+  * `reinstall`  [  ... ]:
     Reinstall the given Cask.
 
   * `search` or `-S` [ | //]:
-    Without argument, display all Casks available for install, otherwise
+    Without an argument, display all Casks available for install; otherwise
     perform a substring search of known Cask tokens for  or, if the
     text is delimited by slashes (//), it is interpreted as a
     Ruby regular expression.
 
   * `style` [--fix] [  ... ]:
-   Check the given Casks for correct style using [RuboCop Cask](https://github.com/caskroom/rubocop-cask).
-   If no tokens are given on the command line, all Casks are checked.
-   With `--fix`, auto-correct any style errors if possible.
+    Check the given Casks for correct style using [RuboCop Cask](https://github.com/caskroom/rubocop-cask).
+    If no tokens are given on the command line, all Casks are checked.
+    With `--fix`, auto-correct any style errors if possible.
 
   * `uninstall` or `rm` or `remove` [--force]  [  ... ]:
     Uninstall the given Cask. With `--force`, uninstall even if the Cask
@@ -111,7 +111,7 @@ names, and other aspects of this manual are still subject to change.
     the Cask does not appear to be currently installed.
 
     Removes all staged versions of the Cask distribution found under
-    `/`.
+    `/`.
 
     If the Cask definition contains a `zap` stanza, performs additional
     `zap` actions as defined there, such as removing local preference
@@ -123,18 +123,18 @@ names, and other aspects of this manual are still subject to change.
 ## INTERNAL COMMANDS
 
   * `_appcast_checkpoint` [--calculate] [  ... |  ... ]:
-    Given a `token`, returns the current appcast checkpoint, or calculates
-    the appcast checkpoint if the `--calculate` flag is specified.  
-    Given a `URL`, calculates the appcast checkpoint for it.
+    Given a , returns the current appcast checkpoint, or calculates
+    the appcast checkpoint if the `--calculate` flag is specified.
 
-  * `_stanza`  [ --table | --yaml | --inspect | --quiet ] [  ... ]:
-    Given a `stanza_name` and a `cask_token`, returns the current stanza
-    for a given Cask. If no `cask_token` is given, then data for all
-    Casks is returned.
+    Given a , calculates the appcast checkpoint for it.
+
+  * `_stanza`  [ --table | --yaml | --inspect | --quiet ] [  ... ]:
+    Given a  and a , returns the current stanza for a
+    given Cask. If no  is given, then data for all Casks is returned.
 
 ## OPTIONS
 
-To make these options persistent, see the ENVIRONMENT section, below.
+To make these options persistent, see the [ENVIRONMENT][] section, below.
 
 Some of these (such as `--prefpanedir`) may be subject to removal
 in a future version.
@@ -150,7 +150,7 @@ in a future version.
     Abort Cask installation if the Cask does not have a checksum defined.
 
   * `--caskroom=`:
-    Location of the Caskroom, where all binaries are stored. The default value is: `$(brew --prefix)/Caskroom`.
+    Set location of the Caskroom, where all binaries are stored. The default value is `$(brew --prefix)/Caskroom`.
 
   * `--verbose`:
     Give additional feedback during installation.
@@ -218,17 +218,17 @@ the Homebrew command:
 Most Homebrew-Cask commands can accept a Cask token as an argument. As
 described above, the argument can take the form of:
 
-  * A token as returned by `brew cask search`, _eg_ `google-chrome`
+  * A token as returned by `brew cask search`, e.g. `google-chrome`
 
 Homebrew-Cask also accepts three other forms in place of plain tokens:
 
-  * A fully-qualified token which includes the Tap name, _eg_
+  * A fully-qualified token which includes the Tap name, e.g.
     `caskroom/fonts/font-symbola`
 
-  * A fully-qualified pathname to a Cask file, _eg_
+  * A fully-qualified pathname to a Cask file, e.g.
     `/usr/local/Library/Taps/caskroom/homebrew-cask/Casks/google-chrome.rb`
 
-  * A `curl`-retrievable URI to a Cask file, _eg_
+  * A `curl`-retrievable URI to a Cask file, e.g.
     `https://raw.githubusercontent.com/caskroom/homebrew-cask/f25b6babcd398abf48e33af3d887b2d00de1d661/Casks/google-chrome.rb`
 
 ## ENVIRONMENT
@@ -239,17 +239,18 @@ information.
 
 Environment variables specific to Homebrew-Cask:
 
-  * HOMEBREW\_CASK\_OPTS:
+  * `HOMEBREW_CASK_OPTS`:
     This variable may contain any arguments normally used as options on
     the command-line. This is particularly useful to make options persistent.
     For example, you might add to your .bash_profile or .zshenv something like:
-    `export HOMEBREW_CASK_OPTS='--appdir=/Applications --caskroom=/etc/Caskroom'`.
+
+               export HOMEBREW_CASK_OPTS='--appdir=/Applications --caskroom=/etc/Caskroom'
 
 ## SEE ALSO
 
-The Homebrew-Cask home page: .
+The Homebrew-Cask home page: 
 
-The Homebrew-Cask GitHub page: .
+The Homebrew-Cask GitHub page: 
 
 `brew`(1), `curl`(1)
 
@@ -261,7 +262,7 @@ Man page format based on `brew.1.md` from Homebrew.
 
 ## BUGS
 
-We still have bugs — and we are busy fixing them!  If you have a problem, don’t
+We still have bugs - and we are busy fixing them!  If you have a problem, don't
 be shy about reporting it on our [GitHub issues page](https://github.com/caskroom/homebrew-cask/issues?state=open).
 
 When reporting bugs, remember that Homebrew-Cask is an independent project from
-- 
cgit v1.2.3


From 177aefdf555488653572f1f98bf4d6d8c7a03671 Mon Sep 17 00:00:00 2001
From: Misty De Meo
Date: Sun, 26 Feb 2017 14:53:00 +1100
Subject: xcodebuild audit: match xcodebuild with no args

Closes #2199.

Signed-off-by: Misty De Meo 
---
 Library/Homebrew/dev-cmd/audit.rb   |  2 +-
 Library/Homebrew/test/audit_test.rb | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

(limited to 'Library')

diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 134965355..35d590b69 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -924,7 +924,7 @@ class FormulaAuditor
       end
     end
 
-    if text =~ /xcodebuild[ (]["'*]/ && !text.include?("SYMROOT=")
+    if text =~ /xcodebuild[ (]*["'*]*/ && !text.include?("SYMROOT=")
       problem 'xcodebuild should be passed an explicit "SYMROOT"'
     end
 
diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb
index 1d93c31e0..f4b7cae4a 100644
--- a/Library/Homebrew/test/audit_test.rb
+++ b/Library/Homebrew/test/audit_test.rb
@@ -465,4 +465,38 @@ class FormulaAuditorTests < Homebrew::TestCase
       end
     end
   end
+
+  def test_audit_xcodebuild_suggests_symroot
+    fa = formula_auditor "foo", <<-EOS.undent
+      class Foo < Formula
+        url "http://example.com/foo-1.0.tgz"
+        homepage "http://example.com"
+
+        def install
+          xcodebuild "-project", "meow.xcodeproject"
+        end
+      end
+    EOS
+
+    fa.audit_text
+
+    assert_match 'xcodebuild should be passed an explicit "SYMROOT"', fa.problems.first
+  end
+
+  def test_audit_bare_xcodebuild_suggests_symroot_also
+    fa = formula_auditor "foo", <<-EOS.undent
+      class Foo < Formula
+        url "http://example.com/foo-1.0.tgz"
+        homepage "http://example.com"
+
+        def install
+          xcodebuild
+        end
+      end
+    EOS
+
+    fa.audit_text
+
+    assert_match 'xcodebuild should be passed an explicit "SYMROOT"', fa.problems.first
+  end
 end
-- 
cgit v1.2.3


From cc9d76cf227b4762431c710998727fb4f6f01dad Mon Sep 17 00:00:00 2001
From: Markus Reiter
Date: Sun, 26 Feb 2017 13:22:16 +0100
Subject: Convert `cmd/update-report` test to spec.

---
 Library/Homebrew/test/cmd/update-report_spec.rb | 127 ++++++++++++++++++++++
 Library/Homebrew/test/update_report_test.rb     | 135 ------------------------
 2 files changed, 127 insertions(+), 135 deletions(-)
 create mode 100644 Library/Homebrew/test/cmd/update-report_spec.rb
 delete mode 100644 Library/Homebrew/test/update_report_test.rb

(limited to 'Library')

diff --git a/Library/Homebrew/test/cmd/update-report_spec.rb b/Library/Homebrew/test/cmd/update-report_spec.rb
new file mode 100644
index 000000000..3665e3c78
--- /dev/null
+++ b/Library/Homebrew/test/cmd/update-report_spec.rb
@@ -0,0 +1,127 @@
+require "cmd/update-report"
+require "formula_versions"
+require "yaml"
+
+describe Reporter do
+  def perform_update(fixture_name = "")
+    allow(Formulary).to receive(:factory).and_return(double(pkg_version: "1.0"))
+    allow(FormulaVersions).to receive(:new).and_return(double(formula_at_revision: "2.0"))
+
+    diff = YAML.load_file("#{TEST_FIXTURE_DIR}/updater_fixture.yaml")[fixture_name]
+    allow(subject).to receive(:diff).and_return(diff || "")
+
+    hub.add(subject) if subject.updated?
+  end
+
+  let(:reporter_class) do
+    Class.new(described_class) do
+      def initialize(tap)
+        @tap = tap
+
+        ENV["HOMEBREW_UPDATE_BEFORE#{repo_var}"] = "12345678"
+        ENV["HOMEBREW_UPDATE_AFTER#{repo_var}"] = "abcdef00"
+
+        super(tap)
+      end
+    end
+  end
+  subject { reporter_class.new(tap) }
+  let(:tap) { CoreTap.new }
+  let(:hub) { ReporterHub.new }
+
+  specify "without revision variable" do
+    ENV.delete_if { |k, _v| k.start_with? "HOMEBREW_UPDATE" }
+
+    expect {
+      described_class.new(tap)
+    }.to raise_error(Reporter::ReporterRevisionUnsetError)
+  end
+
+  specify "without any changes" do
+    perform_update
+    expect(hub).to be_empty
+  end
+
+  specify "without Formula changes" do
+    perform_update("update_git_diff_output_without_formulae_changes")
+
+    expect(hub.select_formula(:M)).to be_empty
+    expect(hub.select_formula(:A)).to be_empty
+    expect(hub.select_formula(:D)).to be_empty
+  end
+
+  specify "with Formula changes" do
+    perform_update("update_git_diff_output_with_formulae_changes")
+
+    expect(hub.select_formula(:M)).to eq(%w[xar yajl])
+    expect(hub.select_formula(:A)).to eq(%w[antiword bash-completion ddrescue dict lua])
+  end
+
+  specify "with removed Formulae" do
+    perform_update("update_git_diff_output_with_removed_formulae")
+
+    expect(hub.select_formula(:D)).to eq(%w[libgsasl])
+  end
+
+  specify "with changed file type" do
+    perform_update("update_git_diff_output_with_changed_filetype")
+
+    expect(hub.select_formula(:M)).to eq(%w[elixir])
+    expect(hub.select_formula(:A)).to eq(%w[libbson])
+    expect(hub.select_formula(:D)).to eq(%w[libgsasl])
+  end
+
+  specify "with renamed Formula" do
+    allow(tap).to receive(:formula_renames).and_return("cv" => "progress")
+    perform_update("update_git_diff_output_with_formula_rename")
+
+    expect(hub.select_formula(:A)).to be_empty
+    expect(hub.select_formula(:D)).to be_empty
+    expect(hub.select_formula(:R)).to eq([["cv", "progress"]])
+  end
+
+  context "when updating a Tap other than the core Tap" do
+    let(:tap) { Tap.new("foo", "bar") }
+
+    before(:each) do
+      (tap.path/"Formula").mkpath
+    end
+
+    after(:each) do
+      tap.path.parent.rmtree
+    end
+
+    specify "with restructured Tap" do
+      perform_update("update_git_diff_output_with_restructured_tap")
+
+      expect(hub.select_formula(:A)).to be_empty
+      expect(hub.select_formula(:D)).to be_empty
+      expect(hub.select_formula(:R)).to be_empty
+    end
+
+    specify "with renamed Formula and restructured Tap" do
+      allow(tap).to receive(:formula_renames).and_return("xchat" => "xchat2")
+      perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
+
+      expect(hub.select_formula(:A)).to be_empty
+      expect(hub.select_formula(:D)).to be_empty
+      expect(hub.select_formula(:R)).to eq([%w[foo/bar/xchat foo/bar/xchat2]])
+    end
+
+    specify "with simulated 'homebrew/php' restructuring" do
+      perform_update("update_git_diff_simulate_homebrew_php_restructuring")
+
+      expect(hub.select_formula(:A)).to be_empty
+      expect(hub.select_formula(:D)).to be_empty
+      expect(hub.select_formula(:R)).to be_empty
+    end
+
+    specify "with Formula changes" do
+      perform_update("update_git_diff_output_with_tap_formulae_changes")
+
+      expect(hub.select_formula(:A)).to eq(%w[foo/bar/lua])
+      expect(hub.select_formula(:M)).to eq(%w[foo/bar/git])
+      expect(hub.select_formula(:D)).to be_empty
+    end
+  end
+end
diff --git a/Library/Homebrew/test/update_report_test.rb b/Library/Homebrew/test/update_report_test.rb
deleted file mode 100644
index 32c3e36d0..000000000
--- a/Library/Homebrew/test/update_report_test.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-require "testing_env"
-require "cmd/update-report"
-require "formula_versions"
-require "yaml"
-
-class ReportTests < Homebrew::TestCase
-  class ReporterMock < ::Reporter
-    attr_accessor :diff
-
-    def initialize(tap)
-      @tap = tap
-      ENV["HOMEBREW_UPDATE_BEFORE#{repo_var}"] = "12345678"
-      ENV["HOMEBREW_UPDATE_AFTER#{repo_var}"] = "abcdef12"
-      super(tap)
-    end
-  end
-
-  def fixture(name)
-    self.class.fixture_data[name] || ""
-  end
-
-  def self.fixture_data
-    @fixture_data ||= YAML.load_file("#{TEST_FIXTURE_DIR}/updater_fixture.yaml")
-  end
-
-  def setup
-    super
-    @tap = CoreTap.new
-    @reporter = ReporterMock.new(@tap)
-    @hub = ReporterHub.new
-  end
-
-  def perform_update(fixture_name = "")
-    Formulary.stubs(:factory).returns(stub(pkg_version: "1.0"))
-    FormulaVersions.stubs(:new).returns(stub(formula_at_revision: "2.0"))
-    @reporter.diff = fixture(fixture_name)
-    @hub.add(@reporter) if @reporter.updated?
-  end
-
-  def test_update_report_without_revision_var
-    ENV.delete_if { |k, _v| k.start_with? "HOMEBREW_UPDATE" }
-    assert_raises(Reporter::ReporterRevisionUnsetError) { Reporter.new(@tap) }
-  end
-
-  def test_update_homebrew_without_any_changes
-    perform_update
-    assert_empty @hub
-  end
-
-  def test_update_homebrew_without_formulae_changes
-    perform_update("update_git_diff_output_without_formulae_changes")
-    assert_empty @hub.select_formula(:M)
-    assert_empty @hub.select_formula(:A)
-    assert_empty @hub.select_formula(:D)
-  end
-
-  def test_update_homebrew_with_formulae_changes
-    perform_update("update_git_diff_output_with_formulae_changes")
-    assert_equal %w[xar yajl], @hub.select_formula(:M)
-    assert_equal %w[antiword bash-completion ddrescue dict lua], @hub.select_formula(:A)
-  end
-
-  def test_update_homebrew_with_removed_formulae
-    perform_update("update_git_diff_output_with_removed_formulae")
-    assert_equal %w[libgsasl], @hub.select_formula(:D)
-  end
-
-  def test_update_homebrew_with_changed_filetype
-    perform_update("update_git_diff_output_with_changed_filetype")
-    assert_equal %w[elixir], @hub.select_formula(:M)
-    assert_equal %w[libbson], @hub.select_formula(:A)
-    assert_equal %w[libgsasl], @hub.select_formula(:D)
-  end
-
-  def test_update_homebrew_with_formula_rename
-    @tap.stubs(:formula_renames).returns("cv" => "progress")
-    perform_update("update_git_diff_output_with_formula_rename")
-    assert_empty @hub.select_formula(:A)
-    assert_empty @hub.select_formula(:D)
-    assert_equal [["cv", "progress"]], @hub.select_formula(:R)
-  end
-
-  def test_update_homebrew_with_restructured_tap
-    tap = Tap.new("foo", "bar")
-    @reporter = ReporterMock.new(tap)
-    tap.path.join("Formula").mkpath
-
-    perform_update("update_git_diff_output_with_restructured_tap")
-    assert_empty @hub.select_formula(:A)
-    assert_empty @hub.select_formula(:D)
-    assert_empty @hub.select_formula(:R)
-  ensure
-    tap.path.parent.rmtree
-  end
-
-  def test_update_homebrew_with_formula_rename_and_restructuring
-    tap = Tap.new("foo", "bar")
-    @reporter = ReporterMock.new(tap)
-    tap.path.join("Formula").mkpath
-    tap.stubs(:formula_renames).returns("xchat" => "xchat2")
-
-    perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
-    assert_empty @hub.select_formula(:A)
-    assert_empty @hub.select_formula(:D)
-    assert_equal [%w[foo/bar/xchat foo/bar/xchat2]], @hub.select_formula(:R)
-  ensure
-    tap.path.parent.rmtree
-  end
-
-  def test_update_homebrew_simulate_homebrew_php_restructuring
-    tap = Tap.new("foo", "bar")
-    @reporter = ReporterMock.new(tap)
-    tap.path.join("Formula").mkpath
-
-    perform_update("update_git_diff_simulate_homebrew_php_restructuring")
-    assert_empty @hub.select_formula(:A)
-    assert_empty @hub.select_formula(:D)
-    assert_empty @hub.select_formula(:R)
-  ensure
-    tap.path.parent.rmtree
-  end
-
-  def test_update_homebrew_with_tap_formulae_changes
-    tap = Tap.new("foo", "bar")
-    @reporter = ReporterMock.new(tap)
-    tap.path.join("Formula").mkpath
-
-    perform_update("update_git_diff_output_with_tap_formulae_changes")
-    assert_equal %w[foo/bar/lua], @hub.select_formula(:A)
-    assert_equal %w[foo/bar/git], @hub.select_formula(:M)
-    assert_empty @hub.select_formula(:D)
-  ensure
-    tap.path.parent.rmtree
-  end
-end
-- 
cgit v1.2.3