aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/.rubocop_todo.yml2
-rw-r--r--Library/Homebrew/brew.sh3
-rw-r--r--Library/Homebrew/build.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/audit.rb19
-rw-r--r--Library/Homebrew/cask/lib/hbc/cache.rb21
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb1
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb61
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_help.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb14
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/appcast.rb16
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/audit_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/cli_spec.rb16
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb2
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/suite_test.rb2
-rw-r--r--Library/Homebrew/cask/test/cask/dsl_test.rb6
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb2
-rw-r--r--Library/Homebrew/caveats.rb25
-rw-r--r--Library/Homebrew/cmd/install.rb11
-rw-r--r--Library/Homebrew/cmd/upgrade.rb24
-rw-r--r--Library/Homebrew/cmd/uses.rb28
-rw-r--r--Library/Homebrew/dependency.rb2
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb52
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb3
-rw-r--r--Library/Homebrew/dev-cmd/create.rb6
-rw-r--r--Library/Homebrew/dev-cmd/tests.rb1
-rw-r--r--Library/Homebrew/download_strategy.rb104
-rw-r--r--Library/Homebrew/emoji.rb12
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb2
-rw-r--r--Library/Homebrew/extend/fileutils.rb2
-rw-r--r--Library/Homebrew/formula.rb14
-rw-r--r--Library/Homebrew/formula_installer.rb26
-rw-r--r--Library/Homebrew/formula_support.rb47
-rw-r--r--Library/Homebrew/keg.rb56
-rw-r--r--Library/Homebrew/manpages/brew-cask.1.md7
-rw-r--r--Library/Homebrew/manpages/brew.1.md.erb2
-rw-r--r--Library/Homebrew/official_taps.rb3
-rw-r--r--Library/Homebrew/os/mac/xcode.rb2
-rw-r--r--Library/Homebrew/requirement.rb36
-rw-r--r--Library/Homebrew/tab.rb6
-rw-r--r--Library/Homebrew/test/ARGV_test.rb3
-rw-r--r--Library/Homebrew/test/ENV_test.rb1
-rw-r--r--Library/Homebrew/test/audit_test.rb19
-rw-r--r--Library/Homebrew/test/bottle_collector_test.rb1
-rw-r--r--Library/Homebrew/test/bottle_hooks_test.rb2
-rw-r--r--Library/Homebrew/test/build_environment_test.rb1
-rw-r--r--Library/Homebrew/test/build_options_test.rb1
-rw-r--r--Library/Homebrew/test/caveats_test.rb1
-rw-r--r--Library/Homebrew/test/checksum_verification_test.rb4
-rw-r--r--Library/Homebrew/test/cleaner_test.rb5
-rw-r--r--Library/Homebrew/test/cleanup_test.rb7
-rw-r--r--Library/Homebrew/test/commands_test.rb6
-rw-r--r--Library/Homebrew/test/compiler_selector_test.rb1
-rw-r--r--Library/Homebrew/test/dependencies_test.rb2
-rw-r--r--Library/Homebrew/test/dependency_collector_test.rb2
-rw-r--r--Library/Homebrew/test/dependency_expansion_test.rb1
-rw-r--r--Library/Homebrew/test/dependency_test.rb6
-rw-r--r--Library/Homebrew/test/descriptions_test.rb3
-rw-r--r--Library/Homebrew/test/diagnostic_test.rb8
-rw-r--r--Library/Homebrew/test/download_strategies_test.rb143
-rw-r--r--Library/Homebrew/test/emoji_test.rb11
-rw-r--r--Library/Homebrew/test/formula_installer_test.rb15
-rw-r--r--Library/Homebrew/test/formula_lock_test.rb3
-rw-r--r--Library/Homebrew/test/formula_pin_test.rb5
-rw-r--r--Library/Homebrew/test/formula_test.rb105
-rw-r--r--Library/Homebrew/test/formulary_test.rb25
-rw-r--r--Library/Homebrew/test/gpg2_requirement_test.rb7
-rw-r--r--Library/Homebrew/test/gpg_test.rb10
-rw-r--r--Library/Homebrew/test/install_test.rb17
-rw-r--r--Library/Homebrew/test/keg_test.rb17
-rw-r--r--Library/Homebrew/test/language_python_test.rb5
-rw-r--r--Library/Homebrew/test/migrator_test.rb23
-rw-r--r--Library/Homebrew/test/options_test.rb3
-rw-r--r--Library/Homebrew/test/os/mac/bottle_collector_test.rb1
-rw-r--r--Library/Homebrew/test/os/mac/dependency_collector_test.rb2
-rw-r--r--Library/Homebrew/test/os/mac/diagnostic_test.rb8
-rw-r--r--Library/Homebrew/test/os/mac/keg_test.rb8
-rw-r--r--Library/Homebrew/test/os/mac/mach_test.rb3
-rw-r--r--Library/Homebrew/test/os/mac/version_test.rb1
-rw-r--r--Library/Homebrew/test/patch_test.rb1
-rw-r--r--Library/Homebrew/test/patching_test.rb5
-rw-r--r--Library/Homebrew/test/pathname_test.rb6
-rw-r--r--Library/Homebrew/test/resource_test.rb1
-rw-r--r--Library/Homebrew/test/sandbox_test.rb15
-rw-r--r--Library/Homebrew/test/shell_test.rb3
-rw-r--r--Library/Homebrew/test/software_spec_test.rb3
-rw-r--r--Library/Homebrew/test/stdlib_test.rb1
-rw-r--r--Library/Homebrew/test/support/helper/env.rb15
-rw-r--r--Library/Homebrew/test/support/helper/integration_command_test_case.rb42
-rw-r--r--Library/Homebrew/test/support/helper/lifecycle_enforcer.rb22
-rw-r--r--Library/Homebrew/test/support/helper/test_case.rb47
-rw-r--r--Library/Homebrew/test/tab_test.rb7
-rw-r--r--Library/Homebrew/test/tap_test.rb30
-rw-r--r--Library/Homebrew/test/uninstall_test.rb9
-rw-r--r--Library/Homebrew/test/update_report_test.rb1
-rw-r--r--Library/Homebrew/test/utils_test.rb27
-rw-r--r--Library/Homebrew/test/versions_test.rb2
-rw-r--r--Library/Homebrew/utils.rb4
-rw-r--r--docs/Formula-Cookbook.md2
-rw-r--r--docs/Versions.md2
-rw-r--r--docs/brew.1.html7
-rw-r--r--manpages/brew-cask.19
-rw-r--r--manpages/brew.15
105 files changed, 830 insertions, 570 deletions
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.
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/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
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/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{<pubDate>[^<]*</pubDate>}, "")
- # 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/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
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..790e917b2
--- /dev/null
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb
@@ -0,0 +1,61 @@
+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?
+
+ 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)
+ 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
+ if calculate
+ result = cask.appcast.calculate_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}"
+ else
+ puts cask_tokens.count > 1 ? "#{checkpoint} #{cask}": checkpoint
+ count += 1
+ end
+ end
+ end
+
+ count == cask_tokens.count
+ end
+
+ def self.help
+ "prints or calculates a given Cask's or URL's appcast checkpoint"
+ end
+
+ def self.needs_init?
+ true
+ end
+ end
+ end
+end
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 e5c04ee51..105e946d7 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 = cask_tokens_from(args)
stanza = cask_tokens.shift.to_sym
cask_tokens = Hbc.all_tokens if cask_tokens.empty?
@@ -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
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
index 2f1245d3d..e27870622 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,20 @@ 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{<pubDate>[^<]*</pubDate>}m, "")
+ 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/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
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
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/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/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
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)
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
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 6f578caf6..5a3aeb7b3 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -44,9 +44,6 @@
#: If `--keep-tmp` is passed, the temporary files created during installation
#: are not deleted.
#:
-#: To install a newer version of HEAD use
-#: `brew rm <foo> && brew install --HEAD <foo>`.
-#:
#: * `install` `--interactive` [`--git`] <formula>:
#: Download and patch <formula>, then open a shell. This allows the user to
#: run `./configure --help` and otherwise determine how to turn the software
@@ -187,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
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 " "}"
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index fb11a31a7..5f6611dfc 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -57,16 +57,36 @@ module Homebrew
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
+ end
+ end
+
+ 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 = f.recursive_requirements do |dependent, req|
+
+ 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) }
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/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 744aa6fbe..5b0102130 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.conflicts.any? && 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)
@@ -481,6 +489,10 @@ class FormulaAuditor
next unless @strict
+ 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
+
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
@@ -493,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
@@ -678,11 +690,47 @@ class FormulaAuditor
end
end
+ unstable_whitelist = %w[
+ aalib 1.4rc5
+ automysqlbackup 3.0-rc6
+ aview 1.3.0rc1
+ distcc 3.2rc1
+ elm-format 0.5.2-alpha
+ ftgl 2.1.3-rc5
+ hidapi 0.8.0-rc1
+ libcaca 0.99b19
+ premake 4.4-beta5
+ pwnat 0.3-beta
+ pxz 4.999.9
+ recode 3.7-beta2
+ speexdsp 1.2rc3
+ sqoop 1.4.6
+ tcptraceroute 1.5beta7
+ testssl 2.8rc3
+ tiny-fugue 5.0b8
+ vbindiff 3.0_beta4
+ ].each_slice(2).to_a.map do |formula, version|
+ [formula, version.sub(/\d+$/, "")]
+ end
+
+ gnome_devel_whitelist = %w[
+ gtk-doc 1.25
+ libart 2.3.21
+ pygtkglext 1.1.0
+ ].each_slice(2).to_a.map do |formula, version|
+ [formula, version.split(".")[0..1].join(".")]
+ end
+
stable = formula.stable
case stable && stable.url
when /[\d\._-](alpha|beta|rc\d)/
- problem "Stable version URLs should not contain #{$1}"
+ matched = $1
+ version_prefix = stable.version.to_s.sub(/\d+$/, "")
+ return if unstable_whitelist.include?([formula.name, version_prefix])
+ problem "Stable version URLs should not contain #{matched}"
when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i
+ version_prefix = stable.version.to_s.split(".")[0..1].join(".")
+ return if gnome_devel_whitelist.include?([formula.name, version_prefix])
version = Version.parse(stable.url)
if version >= Version.create("1.0")
minor_version = version.to_s.split(".", 3)[1].to_i
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 9618cf412..7367e5c37 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
(
@@ -442,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"
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)
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/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 9f9b2abab..bd036067d 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -532,6 +532,110 @@ class S3DownloadStrategy < CurlDownloadStrategy
end
end
+# GitHubPrivateRepositoryDownloadStrategy downloads contents from GitHub
+# Private Repository. To use it, add
+# ":using => GitHubPrivateRepositoryDownloadStrategy" to the URL section of
+# your formula. This download strategy uses GitHub access tokens (in the
+# environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. This
+# strategy is suitable for corporate use just like S3DownloadStrategy, because
+# it lets you use a private GttHub repository for internal distribution. It
+# works with public one, but in that case simply use CurlDownloadStrategy.
+class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy
+ require "utils/formatter"
+ require "utils/github"
+
+ def initialize(name, resource)
+ super
+ parse_url_pattern
+ set_github_token
+ end
+
+ def parse_url_pattern
+ url_pattern = %r{https://github.com/([^/]+)/([^/]+)/(\S+)}
+ unless @url =~ url_pattern
+ raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Repository."
+ end
+
+ _, @owner, @repo, @filepath = *@url.match(url_pattern)
+ end
+
+ def download_url
+ "https://#{@github_token}@github.com/#{@owner}/#{@repo}/#{@filepath}"
+ end
+
+ def _fetch
+ curl download_url, "-C", downloaded_size, "-o", temporary_path
+ end
+
+ private
+
+ def set_github_token
+ @github_token = ENV["HOMEBREW_GITHUB_API_TOKEN"]
+ unless @github_token
+ raise CurlDownloadStrategyError, "Environmental variable HOMEBREW_GITHUB_API_TOKEN is required."
+ end
+ validate_github_repository_access!
+ end
+
+ def validate_github_repository_access!
+ # Test access to the repository
+ GitHub.repository(@owner, @repo)
+ rescue GitHub::HTTPNotFoundError
+ # We only handle HTTPNotFoundError here,
+ # becase AuthenticationFailedError is handled within util/github.
+ message = <<-EOS.undent
+ HOMEBREW_GITHUB_API_TOKEN can not access the repository: #{@owner}/#{@repo}
+ This token may not have permission to access the repository or the url of formula may be incorrect.
+ EOS
+ raise CurlDownloadStrategyError, message
+ end
+end
+
+# GitHubPrivateRepositoryReleaseDownloadStrategy downloads tarballs from GitHub
+# Release assets. To use it, add
+# ":using => GitHubPrivateRepositoryReleaseDownloadStrategy" to the URL section
+# of your formula. This download strategy uses GitHub access tokens (in the
+# environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request.
+class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDownloadStrategy
+ def parse_url_pattern
+ url_pattern = %r{https://github.com/([^/]+)/([^/]+)/releases/download/([^/]+)/(\S+)}
+ unless @url =~ url_pattern
+ raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release."
+ end
+
+ _, @owner, @repo, @tag, @filename = *@url.match(url_pattern)
+ end
+
+ def download_url
+ "https://#{@github_token}@api.github.com/repos/#{@owner}/#{@repo}/releases/assets/#{asset_id}"
+ end
+
+ def _fetch
+ # HTTP request header `Accept: application/octet-stream` is required.
+ # Without this, the GitHub API will respond with metadata, not binary.
+ curl download_url, "-C", downloaded_size, "-o", temporary_path, "-H", "Accept: application/octet-stream"
+ end
+
+ private
+
+ def asset_id
+ @asset_id ||= resolve_asset_id
+ end
+
+ def resolve_asset_id
+ release_metadata = fetch_release_metadata
+ assets = release_metadata["assets"].select { |a| a["name"] == @filename }
+ raise CurlDownloadStrategyError, "Asset file not found." if assets.empty?
+
+ assets.first["id"]
+ end
+
+ def fetch_release_metadata
+ release_url = "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}"
+ GitHub.open(release_url)
+ end
+end
+
class SubversionDownloadStrategy < VCSDownloadStrategy
def initialize(name, resource)
super
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/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
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]
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 91a3e8150..6df1eb4de 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.
@@ -1519,10 +1524,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
@@ -1619,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
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 24c068460..e8f0e4bf8 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -32,6 +32,7 @@ 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
@@ -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?
@@ -370,8 +385,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 +405,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)
@@ -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
@@ -808,6 +825,9 @@ class FormulaInstaller
tab.poured_from_bottle = true
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
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
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 14eb0e3f3..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,19 +190,11 @@ class Keg
@opt_record = HOMEBREW_PREFIX/"opt/#{name}"
end
- def to_s
- path.to_s
- end
-
def rack
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}>"
@@ -207,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?
@@ -243,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? &&
@@ -400,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|
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] [ <token> ... | <URL> ... ]:
+ 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.
diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb
index 2266f3e7a..a7f099e9d 100644
--- a/Library/Homebrew/manpages/brew.1.md.erb
+++ b/Library/Homebrew/manpages/brew.1.md.erb
@@ -31,7 +31,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
* `install` <formula>:
Install <formula>.
- * `remove` <formula>:
+ * `uninstall` <formula>:
Uninstall <formula>.
* `update`:
diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb
index c1ef431b6..f64370a4b 100644
--- a/Library/Homebrew/official_taps.rb
+++ b/Library/Homebrew/official_taps.rb
@@ -1,14 +1,11 @@
OFFICIAL_TAPS = %w[
apache
- completions
dupes
emacs
fuse
games
- gui
nginx
php
- python
science
tex
x11
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
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
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,
diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb
index 6805e0c62..e93d09c39 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
@@ -21,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/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..60cf27610 100644
--- a/Library/Homebrew/test/audit_test.rb
+++ b/Library/Homebrew/test/audit_test.rb
@@ -6,13 +6,10 @@ require "dev-cmd/audit"
class FormulaTextTests < Homebrew::TestCase
def setup
+ super
@dir = mktmpdir
end
- def teardown
- FileUtils.rm_rf @dir
- end
-
def formula_text(name, body = nil, options = {})
path = Pathname.new "#{@dir}/#{name}.rb"
path.open("w") do |f|
@@ -58,13 +55,10 @@ end
class FormulaAuditorTests < Homebrew::TestCase
def setup
+ super
@dir = mktmpdir
end
- def teardown
- FileUtils.rm_rf @dir
- end
-
def formula_auditor(name, text, options = {})
path = Pathname.new "#{@dir}/#{name}.rb"
path.open("w") do |f|
@@ -249,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
@@ -266,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"
@@ -281,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"
@@ -367,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/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..4c674edd2 100644
--- a/Library/Homebrew/test/checksum_verification_test.rb
+++ b/Library/Homebrew/test/checksum_verification_test.rb
@@ -17,10 +17,6 @@ class ChecksumVerificationTests < Homebrew::TestCase
end
end
- def teardown
- @_f.clear_cache
- 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 ac108421c..05a91b90b 100644
--- a/Library/Homebrew/test/cleaner_test.rb
+++ b/Library/Homebrew/test/cleaner_test.rb
@@ -6,14 +6,11 @@ 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?
- end
-
def test_clean_file
@f.bin.mkpath
@f.lib.mkpath
diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb
index bb8e1cdc6..8a292933a 100644
--- a/Library/Homebrew/test/cleanup_test.rb
+++ b/Library/Homebrew/test/cleanup_test.rb
@@ -14,14 +14,14 @@ end
class CleanupTests < Homebrew::TestCase
def setup
+ super
@ds_store = Pathname.new "#{HOMEBREW_PREFIX}/Library/.DS_Store"
FileUtils.touch @ds_store
end
def teardown
FileUtils.rm_f @ds_store
- ARGV.delete "--dry-run"
- ARGV.delete "--prune=all"
+ super
end
def test_cleanup
@@ -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/commands_test.rb b/Library/Homebrew/test/commands_test.rb
index d44d2da0e..5f5dc9586 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
@@ -45,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}"
@@ -65,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/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 65255995e..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
@@ -118,6 +119,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
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..7a1fb25f7 100644
--- a/Library/Homebrew/test/diagnostic_test.rb
+++ b/Library/Homebrew/test/diagnostic_test.rb
@@ -5,14 +5,10 @@ require "diagnostic"
class DiagnosticChecksTest < Homebrew::TestCase
def setup
- @env = ENV.to_hash
+ super
@checks = Homebrew::Diagnostic::Checks.new
end
- def teardown
- ENV.replace(@env)
- end
-
def test_inject_file_list
assert_equal "foo:\n",
@checks.inject_file_list([], "foo:\n")
@@ -103,8 +99,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/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb
index 87218fb12..40236b420 100644
--- a/Library/Homebrew/test/download_strategies_test.rb
+++ b/Library/Homebrew/test/download_strategies_test.rb
@@ -2,11 +2,12 @@ require "testing_env"
require "download_strategy"
class ResourceDouble
- attr_reader :url, :specs, :version
+ attr_reader :url, :specs, :version, :mirrors
def initialize(url = "http://example.com/foo.tar.gz", specs = {})
@url = url
@specs = specs
+ @mirrors = []
end
end
@@ -14,6 +15,7 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase
include FileUtils
def setup
+ super
@name = "foo"
@resource = ResourceDouble.new
@strategy = AbstractDownloadStrategy.new(@name, @resource)
@@ -60,10 +62,86 @@ class VCSDownloadStrategyTests < Homebrew::TestCase
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)
@@ -71,10 +149,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
mkpath @cached_location
end
- def teardown
- rmtree @cached_location
- end
-
def git_commit_all
shutup do
system "git", "add", "--all"
@@ -83,28 +157,14 @@ 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
- 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
@@ -118,18 +178,16 @@ 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
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 "c50c79b", @strategy.last_commit
+ assert_equal "f68266e", @strategy.last_commit
end
def test_fetch_last_commit
@@ -140,21 +198,19 @@ 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!
- assert_equal "c50c79b", @strategy.fetch_last_commit
+ assert_equal "f68266e", @strategy.fetch_last_commit
ensure
remote_repo.rmtree if remote_repo.directory?
end
@@ -162,6 +218,7 @@ end
class DownloadStrategyDetectorTests < Homebrew::TestCase
def setup
+ super
@d = DownloadStrategyDetector.new
end
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/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb
index 652548bd7..c99b2de74 100644
--- a/Library/Homebrew/test/formula_installer_test.rb
+++ b/Library/Homebrew/test/formula_installer_test.rb
@@ -84,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
@@ -128,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_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb
index 80ee9dd25..13244555d 100644
--- a/Library/Homebrew/test/formula_lock_test.rb
+++ b/Library/Homebrew/test/formula_lock_test.rb
@@ -3,13 +3,14 @@ require "formula_lock"
class FormulaLockTests < Homebrew::TestCase
def setup
+ super
@lock = FormulaLock.new("foo")
@lock.lock
end
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..7e3c7efa0 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
@@ -47,8 +48,4 @@ class FormulaPinTests < Homebrew::TestCase
refute_predicate @pin, :pinned?
refute_predicate HOMEBREW_PINNED_KEGS, :directory?
end
-
- def teardown
- @f.rack.rmtree
- end
end
diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb
index 81022d220..ecdd1847b 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
@@ -543,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
@@ -552,12 +533,6 @@ 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
@@ -569,9 +544,6 @@ class FormulaTests < Homebrew::TestCase
f.update_head_version
assert_equal Version.create("HEAD-5658946"), f.head.version
- ensure
- ENV.replace(initial_env)
- cached_location.rmtree
end
def test_legacy_options
@@ -689,6 +661,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"
@@ -733,9 +743,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
@@ -757,10 +764,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
@@ -783,8 +786,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
@@ -836,6 +837,8 @@ class AliasChangeTests < Homebrew::TestCase
end
def setup
+ super
+
alias_name = "bar"
@alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
@@ -904,6 +907,8 @@ class OutdatedVersionsTests < Homebrew::TestCase
attr_reader :f, :old_formula, :new_formula
def setup
+ super
+
@f = formula do
url "foo"
version "1.20"
@@ -919,11 +924,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)
- end
-
def alias_path
"#{@f.tap.alias_dir}/bar"
end
@@ -1088,13 +1088,12 @@ 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" })
setup_tab_for_prefix(head_prefix_b)
- initial_env = ENV.to_hash
testball_repo = HOMEBREW_PREFIX.join("testball_repo")
testball_repo.mkdir
@@ -1104,12 +1103,6 @@ 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
@@ -1134,13 +1127,7 @@ 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?
- 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
@@ -1154,8 +1141,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
@@ -1183,8 +1168,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
@@ -1204,7 +1187,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 3d88c8407..ea7ecf8d0 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")
@@ -39,10 +40,6 @@ class FormularyFactoryTest < Homebrew::TestCase
EOS
end
- def teardown
- @path.unlink
- end
-
def test_factory
assert_kind_of Formula, Formulary.factory(@name)
end
@@ -61,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
@@ -90,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
@@ -107,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
@@ -121,13 +111,12 @@ 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
class FormularyTapFactoryTest < Homebrew::TestCase
def setup
+ super
@name = "foo"
@tap = Tap.new "homebrew", "foo"
@path = @tap.path/"#{@name}.rb"
@@ -139,10 +128,6 @@ class FormularyTapFactoryTest < Homebrew::TestCase
@path.write @code
end
- def teardown
- @tap.path.rmtree
- end
-
def test_factory_tap_formula
assert_kind_of Formula, Formulary.factory(@name)
end
@@ -173,6 +158,7 @@ end
class FormularyTapPriorityTest < Homebrew::TestCase
def setup
+ super
@name = "foo"
@core_path = CoreTap.new.formula_dir/"#{@name}.rb"
@tap = Tap.new "homebrew", "foo"
@@ -186,11 +172,6 @@ class FormularyTapPriorityTest < Homebrew::TestCase
@tap_path.write code
end
- def teardown
- @core_path.unlink
- @tap.path.rmtree
- 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/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb
index fa7fc9ea4..3297c2851 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,11 +15,11 @@ class GPG2RequirementTests < Homebrew::TestCase
def teardown
FileUtils.rm_rf @dir
+ super
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 0374bdab4..ea4372549 100644
--- a/Library/Homebrew/test/gpg_test.rb
+++ b/Library/Homebrew/test/gpg_test.rb
@@ -3,18 +3,16 @@ 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
- 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
- ensure
- @dir.rmtree
end
end
diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb
index e047c0030..da6c1863f 100644
--- a/Library/Homebrew/test/install_test.rb
+++ b/Library/Homebrew/test/install_test.rb
@@ -73,13 +73,6 @@ 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
@@ -105,15 +98,11 @@ 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")
-
- 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 40b47b5e9..bd4232038 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")
@@ -34,15 +36,10 @@ 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
@@ -301,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
@@ -318,7 +313,6 @@ class LinkTests < LinkTestCase
keg.link
ensure
keg.unlink
- keg.uninstall
end
end
@@ -430,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/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb
index d1e3867f7..aa0a7d51d 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"
@@ -14,10 +15,6 @@ class LanguagePythonTests < Homebrew::TestCase
@venv = Language::Python::Virtualenv::Virtualenv.new(@formula, @dir, "python")
end
- def teardown
- FileUtils.rm_rf @dir
- end
-
def test_virtualenv_creation
@formula.expects(:resource).with("homebrew-virtualenv").returns(
mock("resource", stage: true)
diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb
index 8a2b6ad63..012ea12bb 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")
@@ -31,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
@@ -40,6 +39,8 @@ class MigratorTests < Homebrew::TestCase
include FileUtils
def setup
+ super
+
@new_f = Testball.new("newname")
@new_f.oldname = "oldname"
@@ -69,30 +70,16 @@ 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
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..704235b01 100644
--- a/Library/Homebrew/test/os/mac/diagnostic_test.rb
+++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb
@@ -5,14 +5,10 @@ require "diagnostic"
class OSMacDiagnosticChecksTest < Homebrew::TestCase
def setup
- @env = ENV.to_hash
+ super
@checks = Homebrew::Diagnostic::Checks.new
end
- def teardown
- ENV.replace(@env)
- end
-
def test_check_for_other_package_managers
MacOS.stubs(:macports_or_fink).returns ["fink"]
assert_match "You have MacPorts or Fink installed:",
@@ -20,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/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb
index e79cbc921..d1103415d 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
@@ -28,12 +30,12 @@ class OSMacLinkTests < Homebrew::TestCase
def teardown
@keg.unlink
- @keg.uninstall
$stdout = @old_stdout
- rmtree HOMEBREW_PREFIX/"bin"
rmtree HOMEBREW_PREFIX/"lib"
+
+ super
end
def test_mach_o_files_skips_hardlinks
@@ -48,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
@@ -64,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/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..3dacc0818 100644
--- a/Library/Homebrew/test/patching_test.rb
+++ b/Library/Homebrew/test/patching_test.rb
@@ -20,11 +20,6 @@ class PatchingTests < Homebrew::TestCase
end
end
- def teardown
- @_f.clear_cache
- @_f.patchlist.each { |p| p.clear_cache if p.external? }
- end
-
def assert_patched(formula)
shutup do
formula.brew do
diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb
index 2f6360719..b48a26fbd 100644
--- a/Library/Homebrew/test/pathname_test.rb
+++ b/Library/Homebrew/test/pathname_test.rb
@@ -7,16 +7,12 @@ module PathnameTestExtension
include FileUtils
def setup
+ super
@src = Pathname.new(mktmpdir)
@dst = Pathname.new(mktmpdir)
@file = @src/"foo"
@dir = @src/"bar"
end
-
- def teardown
- rmtree(@src)
- rmtree(@dst)
- end
end
class PathnameTests < Homebrew::TestCase
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..a633defce 100644
--- a/Library/Homebrew/test/sandbox_test.rb
+++ b/Library/Homebrew/test/sandbox_test.rb
@@ -3,26 +3,23 @@ require "sandbox"
class SandboxTest < Homebrew::TestCase
def setup
+ super
skip "sandbox not implemented" unless Sandbox.available?
@sandbox = Sandbox.new
@dir = Pathname.new(mktmpdir)
@file = @dir/"foo"
end
- def teardown
- @dir.rmtree
- end
-
def test_formula?
f = formula { url "foo-1.0" }
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),
@@ -30,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
@@ -50,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
@@ -64,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
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/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/env.rb b/Library/Homebrew/test/support/helper/env.rb
deleted file mode 100644
index 904a1d4c7..000000000
--- a/Library/Homebrew/test/support/helper/env.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Test
- module Helper
- module Env
- def with_environment(partial_env)
- old = ENV.to_hash
- ENV.update partial_env
- begin
- yield
- ensure
- ENV.replace old
- end
- end
- end
- 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 b79fdd6e0..a36b56691 100644
--- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb
+++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb
@@ -6,40 +6,12 @@ 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"
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
- end
-
def needs_test_cmd_taps
return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
@@ -106,16 +78,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
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..ab97ef758 100644
--- a/Library/Homebrew/test/support/helper/test_case.rb
+++ b/Library/Homebrew/test/support/helper/test_case.rb
@@ -1,17 +1,60 @@
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
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
+ def setup
+ super
+
+ @__argv = ARGV.dup
+ @__env = ENV.to_hash # dup doesn't work on ENV
+ end
+
+ def teardown
+ ARGV.replace(@__argv)
+ ENV.replace(@__env)
+
+ 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
+
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
diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb
index f9824ba2a..f6f55348d 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,16 +262,13 @@ 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 teardown
- @f.rack.rmtree
- 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 7114cdf22..578326cea 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")
@@ -65,13 +66,6 @@ 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"
@@ -80,12 +74,6 @@ class TapTest < Homebrew::TestCase
system "git", "commit", "-m", "init"
end
end
- ensure
- ENV.replace(env)
- end
-
- def teardown
- @path.rmtree
end
def test_fetch
@@ -171,8 +159,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
@@ -189,10 +175,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(/\A\d+ .+ ago\Z/, @tap.git_last_commit)
+ assert_equal "2017-01-22", @tap.git_last_commit_date
end
def test_private_remote
@@ -256,8 +242,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
@@ -285,6 +269,7 @@ class CoreTapTest < Homebrew::TestCase
include FileUtils
def setup
+ super
@repo = CoreTap.new
end
@@ -322,8 +307,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/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb
index 597e77e40..2f8bf4fff 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"
@@ -28,10 +30,7 @@ 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
def handle_unsatisfied_dependents
@@ -59,8 +58,6 @@ class UninstallTests < Homebrew::TestCase
assert_empty handle_unsatisfied_dependents
refute_predicate Homebrew, :failed?
end
- ensure
- ARGV.delete("--ignore-dependencies")
end
end
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..1f2fb7b55 100644
--- a/Library/Homebrew/test/utils_test.rb
+++ b/Library/Homebrew/test/utils_test.rb
@@ -5,13 +5,12 @@ require "utils/shell"
class UtilTests < Homebrew::TestCase
def setup
+ super
@dir = Pathname.new(mktmpdir)
- @env = ENV.to_hash
end
- def teardown
- @dir.rmtree
- ENV.replace @env
+ def esc(code)
+ /(\e\[\d+m)*\e\[#{code}m/
end
def test_ofail
@@ -27,11 +26,29 @@ class UtilTests < Homebrew::TestCase
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
@@ -212,7 +229,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/"],
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
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
diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md
index a77772939..ac9d8cc79 100644
--- a/docs/Formula-Cookbook.md
+++ b/docs/Formula-Cookbook.md
@@ -1,6 +1,6 @@
# Formula Cookbook
-A formula is a package definition written in Ruby. It can be created with `brew create $URL`, installed with `brew install $FORMULA`, and debugged with `brew install --debug --verbose $FORMULA`. Formulae use the [Formula API](http://www.rubydoc.info/github/Homebrew/brew/master/Formula) which provides various Homebrew-specific helpers.
+A formula is a package definition written in Ruby. It can be created with `brew create $URL` where `$URL` is a zip or tarball, installed with `brew install $FORMULA`, and debugged with `brew install --debug --verbose $FORMULA`. Formulae use the [Formula API](http://www.rubydoc.info/github/Homebrew/brew/master/Formula) which provides various Homebrew-specific helpers.
## Homebrew Terminology
diff --git a/docs/Versions.md b/docs/Versions.md
index 9e679db7d..bd3ef8a5f 100644
--- a/docs/Versions.md
+++ b/docs/Versions.md
@@ -11,6 +11,6 @@ Versioned formulae we include must meet the following standards:
* Versioned formulae should differ in major/minor (not patch) versions from the current stable release. This is because patch versions indicate bug or security updates and we want to ensure you apply security updates.
* Formulae that depend on versioned formulae must not depend on the same formulae at two different versions twice in their recursive dependencies. For example, if you depend on `openssl@1.0` and `foo`, and `foo` depends on `openssl` then you must instead use `openssl`.
-* Versioned formulae should strive to be linked at the same time as their non-versioned counterpart (without patching). If this is not possible, favour either `conflicts_with` or `keg_only` depending on whether users expect to have multiple versions installed at once or not.
+* Versioned formulae should only be linkable at the same time as their non-versioned counterpart if the upstream project provides support for e.g. suffixed binaries. If this is not possible, use `keg_only :versioned_formula` to allow users to have multiple versions installed at once.
You should create your own [tap](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) for formulae you or your organisation wishes to control the versioning of or those that do not meet the above standards.
diff --git a/docs/brew.1.html b/docs/brew.1.html
index ba65157cb..2e036eb55 100644
--- a/docs/brew.1.html
+++ b/docs/brew.1.html
@@ -22,7 +22,7 @@ didn't include with macOS.</p>
<dl>
<dt><code>install</code> <var>formula</var></dt><dd><p>Install <var>formula</var>.</p></dd>
-<dt><code>remove</code> <var>formula</var></dt><dd><p>Uninstall <var>formula</var>.</p></dd>
+<dt><code>uninstall</code> <var>formula</var></dt><dd><p>Uninstall <var>formula</var>.</p></dd>
<dt class="flush"><code>update</code></dt><dd><p>Fetch the newest version of Homebrew from GitHub using <code>git</code>(1).</p></dd>
<dt class="flush"><code>list</code></dt><dd><p>List all installed formulae.</p></dd>
<dt><code>search</code> <var>text</var>|<code>/</code><var>text</var><code>/</code></dt><dd><p>Perform a substring search of formula names for <var>text</var>. If <var>text</var> is
@@ -196,10 +196,7 @@ for installation.</p>
aka master, trunk, unstable.</p>
<p>If <code>--keep-tmp</code> is passed, the temporary files created during installation
-are not deleted.</p>
-
-<p>To install a newer version of HEAD use
-<code>brew rm &lt;foo> &amp;&amp; brew install --HEAD &lt;foo></code>.</p></dd>
+are not deleted.</p></dd>
<dt><code>install</code> <code>--interactive</code> [<code>--git</code>] <var>formula</var></dt><dd><p>Download and patch <var>formula</var>, then open a shell. This allows the user to
run <code>./configure --help</code> and otherwise determine how to turn the software
package into a Homebrew formula.</p>
diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1
index 63aad2c56..9b217fed5 100644
--- a/manpages/brew-cask.1
+++ b/manpages/brew-cask.1
@@ -105,6 +105,15 @@ If the Cask definition contains a \fBzap\fR stanza, performs additional \fBzap\f
.
.IP "" 0
.
+.SH "INTERNAL COMMANDS"
+.
+.TP
+\fB_appcast_checkpoint\fR [\-\-calculate] [ \fItoken\fR \.\.\. | \fIURL\fR \.\.\. ]
+Given a \fBtoken\fR, returns the current appcast checkpoint, or calculates the appcast checkpoint if the \fB\-\-calculate\fR flag is specified\.
+.
+.br
+Given a \fBURL\fR, calculates the appcast checkpoint for it\.
+.
.SH "OPTIONS"
To make these options persistent, see the ENVIRONMENT section, below\.
.
diff --git a/manpages/brew.1 b/manpages/brew.1
index aa1d1c1d0..f122337fb 100644
--- a/manpages/brew.1
+++ b/manpages/brew.1
@@ -26,7 +26,7 @@ With \fB\-\-verbose\fR or \fB\-v\fR, many commands print extra debugging informa
Install \fIformula\fR\.
.
.TP
-\fBremove\fR \fIformula\fR
+\fBuninstall\fR \fIformula\fR
Uninstall \fIformula\fR\.
.
.TP
@@ -258,9 +258,6 @@ If \fB\-\-HEAD\fR is passed, and \fIformula\fR defines it, install the HEAD vers
.IP
If \fB\-\-keep\-tmp\fR is passed, the temporary files created during installation are not deleted\.
.
-.IP
-To install a newer version of HEAD use \fBbrew rm <foo> && brew install \-\-HEAD <foo>\fR\.
-.
.TP
\fBinstall\fR \fB\-\-interactive\fR [\fB\-\-git\fR] \fIformula\fR
Download and patch \fIformula\fR, then open a shell\. This allows the user to run \fB\./configure \-\-help\fR and otherwise determine how to turn the software package into a Homebrew formula\.