aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/extend/pathname.rb2
-rw-r--r--Library/Homebrew/test/ENV_test.rb27
-rw-r--r--Library/Homebrew/test/cache_formula_test.rb8
-rw-r--r--Library/Homebrew/test/cache_test.rb8
-rw-r--r--Library/Homebrew/test/cat_test.rb8
-rw-r--r--Library/Homebrew/test/cleanup_test.rb7
-rw-r--r--Library/Homebrew/test/cmd/--cache_spec.rb15
-rw-r--r--Library/Homebrew/test/cmd/--env_spec.rb44
-rw-r--r--Library/Homebrew/test/cmd/cat_spec.rb11
-rw-r--r--Library/Homebrew/test/cmd/cleanup_spec.rb12
-rw-r--r--Library/Homebrew/test/cmd/command_spec.rb13
-rw-r--r--Library/Homebrew/test/cmd/config_spec.rb8
-rw-r--r--Library/Homebrew/test/cmd/desc_spec.rb40
-rw-r--r--Library/Homebrew/test/cmd/link_spec.rb56
-rw-r--r--Library/Homebrew/test/cmd/log_spec.rb41
-rw-r--r--Library/Homebrew/test/cmd/migrate_spec.rb46
-rw-r--r--Library/Homebrew/test/cmd/options_spec.rb12
-rw-r--r--Library/Homebrew/test/cmd/reinstall_spec.rb47
-rw-r--r--Library/Homebrew/test/cmd/search_spec.rb57
-rw-r--r--Library/Homebrew/test/cmd/sh_spec.rb8
-rw-r--r--Library/Homebrew/test/command_test.rb11
-rw-r--r--Library/Homebrew/test/config_test.rb8
-rw-r--r--Library/Homebrew/test/create_test.rb12
-rw-r--r--Library/Homebrew/test/desc_test.rb17
-rw-r--r--Library/Homebrew/test/dev-cmd/create_spec.rb13
-rw-r--r--Library/Homebrew/test/dev-cmd/formula_spec.rb10
-rw-r--r--Library/Homebrew/test/formula_cmd_test.rb8
-rw-r--r--Library/Homebrew/test/link_test.rb23
-rw-r--r--Library/Homebrew/test/log_formula_test.rb27
-rw-r--r--Library/Homebrew/test/log_test.rb13
-rw-r--r--Library/Homebrew/test/migrate_test.rb18
-rw-r--r--Library/Homebrew/test/options_test.rb12
-rw-r--r--Library/Homebrew/test/reinstall_pinned_test.rb15
-rw-r--r--Library/Homebrew/test/reinstall_test.rb24
-rw-r--r--Library/Homebrew/test/search_test.rb30
-rw-r--r--Library/Homebrew/test/sh_test.rb8
-rw-r--r--Library/Homebrew/test/spec_helper.rb4
-rw-r--r--Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb74
38 files changed, 512 insertions, 285 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index cfb028704..9f6861a9a 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -335,7 +335,7 @@ class Pathname
alias to_str to_s unless method_defined?(:to_str)
def cd
- Dir.chdir(self) { yield }
+ Dir.chdir(self) { yield self }
end
def subdirs
diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb
index cbfd01e25..66b59d8a4 100644
--- a/Library/Homebrew/test/ENV_test.rb
+++ b/Library/Homebrew/test/ENV_test.rb
@@ -2,33 +2,6 @@ require "testing_env"
require "extend/ENV"
require "testing_env"
-class IntegrationCommandTestEnv < IntegrationCommandTestCase
- def test_env
- assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/,
- cmd("--env"))
- end
-
- def test_env_fish
- assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/,
- cmd("--env", "--shell=fish"))
- end
-
- def test_env_csh
- assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/,
- cmd("--env", "--shell=tcsh"))
- end
-
- def test_env_bash
- assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/,
- cmd("--env", "--shell=bash"))
- end
-
- def test_env_plain
- assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/,
- cmd("--env", "--plain"))
- end
-end
-
module SharedEnvTests
def setup
super
diff --git a/Library/Homebrew/test/cache_formula_test.rb b/Library/Homebrew/test/cache_formula_test.rb
deleted file mode 100644
index 6dcb6a745..000000000
--- a/Library/Homebrew/test/cache_formula_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCacheFormula < IntegrationCommandTestCase
- def test_cache_formula
- assert_match %r{#{HOMEBREW_CACHE}/testball-},
- cmd("--cache", testball)
- end
-end
diff --git a/Library/Homebrew/test/cache_test.rb b/Library/Homebrew/test/cache_test.rb
deleted file mode 100644
index 3a9e6b011..000000000
--- a/Library/Homebrew/test/cache_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCache < IntegrationCommandTestCase
- def test_cache
- assert_equal HOMEBREW_CACHE.to_s,
- cmd("--cache")
- end
-end
diff --git a/Library/Homebrew/test/cat_test.rb b/Library/Homebrew/test/cat_test.rb
deleted file mode 100644
index bb37b5fde..000000000
--- a/Library/Homebrew/test/cat_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCat < IntegrationCommandTestCase
- def test_cat
- formula_file = setup_test_formula "testball"
- assert_equal formula_file.read.chomp, cmd("cat", "testball")
- end
-end
diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb
index e6fc31dfe..bc7a6713c 100644
--- a/Library/Homebrew/test/cleanup_test.rb
+++ b/Library/Homebrew/test/cleanup_test.rb
@@ -5,13 +5,6 @@ require "fileutils"
require "pathname"
require "testing_env"
-class IntegrationCommandTestCleanup < IntegrationCommandTestCase
- def test_cleanup
- (HOMEBREW_CACHE/"test").write "test"
- assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all")
- end
-end
-
class CleanupTests < Homebrew::TestCase
def setup
super
diff --git a/Library/Homebrew/test/cmd/--cache_spec.rb b/Library/Homebrew/test/cmd/--cache_spec.rb
new file mode 100644
index 000000000..fb3c9cee6
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--cache_spec.rb
@@ -0,0 +1,15 @@
+describe "brew --cache", :integration_test do
+ it "print the location of Homebrew's cache when no argument is given" do
+ expect { brew "--cache" }
+ .to output("#{HOMEBREW_CACHE}\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "prints all cache files for a given Formula" do
+ expect { brew "--cache", testball }
+ .to output(%r{#{HOMEBREW_CACHE}/testball-}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/cmd/--env_spec.rb b/Library/Homebrew/test/cmd/--env_spec.rb
new file mode 100644
index 000000000..7dd84132a
--- /dev/null
+++ b/Library/Homebrew/test/cmd/--env_spec.rb
@@ -0,0 +1,44 @@
+describe "brew --env", :integration_test do
+ it "prints the Homebrew build environment variables" do
+ expect { brew "--env" }
+ .to output(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ describe "--shell=bash" do
+ it "prints the Homebrew build environment variables in Bash syntax" do
+ expect { brew "--env", "--shell=bash" }
+ .to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ describe "--shell=fish" do
+ it "prints the Homebrew build environment variables in Fish syntax" do
+ expect { brew "--env", "--shell=fish" }
+ .to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ describe "--shell=tcsh" do
+ it "prints the Homebrew build environment variables in Tcsh syntax" do
+ expect { brew "--env", "--shell=tcsh" }
+ .to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ describe "--plain" do
+ it "prints the Homebrew build environment variables without quotes" do
+ expect { brew "--env", "--plain" }
+ .to output(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+end
diff --git a/Library/Homebrew/test/cmd/cat_spec.rb b/Library/Homebrew/test/cmd/cat_spec.rb
new file mode 100644
index 000000000..8c230abee
--- /dev/null
+++ b/Library/Homebrew/test/cmd/cat_spec.rb
@@ -0,0 +1,11 @@
+describe "brew cat", :integration_test do
+ it "prints the content of a given Formula" do
+ formula_file = setup_test_formula "testball"
+ content = formula_file.read
+
+ expect { brew "cat", "testball" }
+ .to output(content).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/cmd/cleanup_spec.rb b/Library/Homebrew/test/cmd/cleanup_spec.rb
new file mode 100644
index 000000000..9e2cf493f
--- /dev/null
+++ b/Library/Homebrew/test/cmd/cleanup_spec.rb
@@ -0,0 +1,12 @@
+describe "brew cleanup", :integration_test do
+ describe "--prune=all" do
+ it "removes all files in Homebrew's cache" do
+ (HOMEBREW_CACHE/"test").write "test"
+
+ expect { brew "cleanup", "--prune=all" }
+ .to output(%r{#{Regexp.escape(HOMEBREW_CACHE)}/test}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+end
diff --git a/Library/Homebrew/test/cmd/command_spec.rb b/Library/Homebrew/test/cmd/command_spec.rb
new file mode 100644
index 000000000..5d6a67b70
--- /dev/null
+++ b/Library/Homebrew/test/cmd/command_spec.rb
@@ -0,0 +1,13 @@
+describe "brew command", :integration_test do
+ it "returns the file for a given command" do
+ expect { brew "command", "info" }
+ .to output(%r{#{Regexp.escape(HOMEBREW_LIBRARY_PATH)}/cmd/info.rb}).to_stdout
+ .and be_a_success
+ end
+
+ it "fails when the given command is unknown" do
+ expect { brew "command", "does-not-exist" }
+ .to output(/Unknown command/).to_stderr
+ .and be_a_failure
+ end
+end
diff --git a/Library/Homebrew/test/cmd/config_spec.rb b/Library/Homebrew/test/cmd/config_spec.rb
new file mode 100644
index 000000000..7687fcdc7
--- /dev/null
+++ b/Library/Homebrew/test/cmd/config_spec.rb
@@ -0,0 +1,8 @@
+describe "brew config", :integration_test do
+ it "prints information about the current Homebrew configuration" do
+ expect { brew "config" }
+ .to output(/HOMEBREW_VERSION: #{HOMEBREW_VERSION}/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/cmd/desc_spec.rb b/Library/Homebrew/test/cmd/desc_spec.rb
new file mode 100644
index 000000000..b09819d81
--- /dev/null
+++ b/Library/Homebrew/test/cmd/desc_spec.rb
@@ -0,0 +1,40 @@
+describe "brew desc", :integration_test do
+ let(:desc_cache) { HOMEBREW_CACHE/"desc_cache.json" }
+
+ it "shows a given Formula's description" do
+ setup_test_formula "testball"
+
+ expect { brew "desc", "testball" }
+ .to output("testball: Some test\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "fails when both --search and --name are specified" do
+ expect { brew "desc", "--search", "--name" }
+ .to output(/Pick one, and only one/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ describe "--search" do
+ it "fails when no search term is given" do
+ expect { brew "desc", "--search" }
+ .to output(/You must provide a search term/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+ end
+
+ describe "--description" do
+ it "creates a description cache" do
+ expect(desc_cache).not_to exist
+
+ shutup do
+ expect { brew "desc", "--description", "testball" }.to be_a_success
+ end
+
+ expect(desc_cache).to exist
+ end
+ end
+end
diff --git a/Library/Homebrew/test/cmd/link_spec.rb b/Library/Homebrew/test/cmd/link_spec.rb
new file mode 100644
index 000000000..7b85c96dc
--- /dev/null
+++ b/Library/Homebrew/test/cmd/link_spec.rb
@@ -0,0 +1,56 @@
+describe "brew link", :integration_test do
+ it "fails when no argument is given" do
+ expect { brew "link" }
+ .to output(/This command requires a keg argument/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "does not fail if the given Formula is already linked" do
+ setup_test_formula "testball1"
+
+ shutup do
+ expect { brew "install", "testball1" }.to be_a_success
+ expect { brew "link", "testball1" }.to be_a_success
+ end
+ end
+
+ it "links a given Formula" do
+ setup_test_formula "testball1"
+
+ shutup do
+ expect { brew "install", "testball1" }.to be_a_success
+ expect { brew "unlink", "testball1" }.to be_a_success
+ end
+
+ expect { brew "link", "--dry-run", "testball1" }
+ .to output(/Would link/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "link", "--dry-run", "--overwrite", "testball1" }
+ .to output(/Would remove/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "link", "testball1" }
+ .to output(/Linking/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "refuses to link keg-only Formulae" do
+ setup_test_formula "testball1", <<-EOS.undent
+ keg_only "just because"
+ EOS
+
+ shutup do
+ expect { brew "install", "testball1" }.to be_a_success
+ end
+
+ expect { brew "link", "testball1" }
+ .to output(/testball1 is keg-only/).to_stderr
+ .and output(/Note that doing so can interfere with building software\./).to_stdout
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/cmd/log_spec.rb b/Library/Homebrew/test/cmd/log_spec.rb
new file mode 100644
index 000000000..bdbca8912
--- /dev/null
+++ b/Library/Homebrew/test/cmd/log_spec.rb
@@ -0,0 +1,41 @@
+describe "brew log", :integration_test do
+ it "shows the Git log for the Homebrew repository when no argument is given" do
+ HOMEBREW_REPOSITORY.cd do
+ shutup do
+ system "git", "init"
+ system "git", "commit", "--allow-empty", "-m", "This is a test commit"
+ end
+ end
+
+ expect { brew "log" }
+ .to output(/This is a test commit/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "shows the Git log for a given Formula" do
+ setup_test_formula "testball"
+
+ core_tap = CoreTap.new
+ core_tap.path.cd do
+ shutup do
+ system "git", "init"
+ system "git", "add", "--all"
+ system "git", "commit", "-m", "This is a test commit for Testball"
+ end
+ end
+
+ core_tap_url = "file://#{core_tap.path}"
+ shallow_tap = Tap.fetch("homebrew", "shallow")
+ shutup do
+ system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
+ end
+
+ expect { brew "log", "#{shallow_tap}/testball" }
+ .to output(/This is a test commit for Testball/).to_stdout
+ .and output(/Warning: The git repository is a shallow clone/).to_stderr
+ .and be_a_success
+
+ expect(shallow_tap.path/".git/shallow").to exist, "A shallow clone should have been created."
+ end
+end
diff --git a/Library/Homebrew/test/cmd/migrate_spec.rb b/Library/Homebrew/test/cmd/migrate_spec.rb
new file mode 100644
index 000000000..18c94fa01
--- /dev/null
+++ b/Library/Homebrew/test/cmd/migrate_spec.rb
@@ -0,0 +1,46 @@
+describe "brew migrate", :integration_test do
+ before(:each) do
+ setup_test_formula "testball1"
+ setup_test_formula "testball2"
+ end
+
+ it "fails when no argument is given" do
+ expect { brew "migrate" }
+ .to output(/Invalid usage/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "fails when a given Formula doesn't exist" do
+ expect { brew "migrate", "testball" }
+ .to output(/No available formula with the name "testball"/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "fails if a given Formula doesn't replace another one" do
+ expect { brew "migrate", "testball1" }
+ .to output(/testball1 doesn't replace any formula/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "migrates a renamed Formula" do
+ install_and_rename_coretap_formula "testball1", "testball2"
+
+ expect { brew "migrate", "testball1" }
+ .to output(/Migrating testball1 to testball2/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "fails if a given Formula is not installed" do
+ install_and_rename_coretap_formula "testball1", "testball2"
+ (HOMEBREW_CELLAR/"testball1").rmtree
+
+ expect { brew "migrate", "testball1" }
+ .to output(/Error: No such keg/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+end
diff --git a/Library/Homebrew/test/cmd/options_spec.rb b/Library/Homebrew/test/cmd/options_spec.rb
new file mode 100644
index 000000000..33fe8b107
--- /dev/null
+++ b/Library/Homebrew/test/cmd/options_spec.rb
@@ -0,0 +1,12 @@
+describe "brew options", :integration_test do
+ it "prints a given Formula's options" do
+ setup_test_formula "testball", <<-EOS.undent
+ depends_on "bar" => :recommended
+ EOS
+
+ expect { brew "options", "testball" }
+ .to output("--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support\n\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/cmd/reinstall_spec.rb b/Library/Homebrew/test/cmd/reinstall_spec.rb
new file mode 100644
index 000000000..74d36bbb8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/reinstall_spec.rb
@@ -0,0 +1,47 @@
+require "extend/ENV"
+
+describe "brew reinstall", :integration_test do
+ let(:bin) { (HOMEBREW_PREFIX/"bin").realpath }
+ let(:path) { "#{bin}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
+
+ before(:each) do
+ setup_test_formula "testball"
+
+ shutup do
+ expect { brew "install", "testball", "--with-foo" }.to be_a_success
+ end
+ end
+
+ it "reinstalls a Formula" do
+ foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo"
+ expect(foo_dir).to exist
+ foo_dir.rmtree
+
+ expect { brew "reinstall", "testball", "PATH" => path }
+ .to output(/Reinstalling testball --with-foo/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect(foo_dir).to exist
+ end
+
+ it "reinstalls a Formula even when one of the options is invalid" do
+ expect { brew "reinstall", "testball", "--with-fo", "PATH" => path }
+ .to output(/Reinstalling testball --with-foo/).to_stdout
+ .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr
+ .and be_a_success
+ end
+
+ it "refuses to reinstall a pinned Formula, but doesn't fail" do
+ (HOMEBREW_CELLAR/"testball/0.1").mkpath
+ HOMEBREW_PINNED_KEGS.mkpath
+ FileUtils.ln_s HOMEBREW_CELLAR/"testball/0.1", HOMEBREW_PINNED_KEGS/"testball"
+
+ expect { brew "reinstall", "testball" }
+ .to output(/testball is pinned. You must unpin it to reinstall./).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_success
+
+ HOMEBREW_PINNED_KEGS.rmtree
+ end
+end
diff --git a/Library/Homebrew/test/cmd/search_spec.rb b/Library/Homebrew/test/cmd/search_spec.rb
new file mode 100644
index 000000000..06b7073d8
--- /dev/null
+++ b/Library/Homebrew/test/cmd/search_spec.rb
@@ -0,0 +1,57 @@
+describe "brew search", :integration_test do
+ before(:each) do
+ setup_test_formula "testball"
+ end
+
+ it "lists all available Formulae when no argument is given" do
+ expect { brew "search" }
+ .to output(/testball/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "supports searching by name" do
+ expect { brew "search", "testball" }
+ .to output(/testball/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "supports searching a fully-qualified name " do
+ expect { brew "search", "homebrew/homebrew-core/testball" }
+ .to output(/testball/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ describe "--desc" do
+ let(:desc_cache) { HOMEBREW_CACHE/"desc_cache.json" }
+
+ it "supports searching in descriptions and creates a description cache" do
+ expect(desc_cache).not_to exist
+
+ expect { brew "search", "--desc", "Some test" }
+ .to output(/testball/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect(desc_cache).to exist
+ end
+ end
+
+ {
+ "macports" => "https://www.macports.org/ports.php?by=name&substr=testball",
+ "fink" => "http://pdb.finkproject.org/pdb/browse.php?summary=testball",
+ "debian" => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all&section=all",
+ "opensuse" => "https://software.opensuse.org/search?q=testball",
+ "fedora" => "https://admin.fedoraproject.org/pkgdb/packages/%2Atestball%2A/",
+ "ubuntu" => "http://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all&section=all",
+ }.each do |flag, url|
+ specify "--#{flag}" do
+ expect { brew "search", "--#{flag}", "testball", "HOMEBREW_BROWSER" => "echo" }
+ .to output("#{url}\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+end
diff --git a/Library/Homebrew/test/cmd/sh_spec.rb b/Library/Homebrew/test/cmd/sh_spec.rb
new file mode 100644
index 000000000..5260ddb75
--- /dev/null
+++ b/Library/Homebrew/test/cmd/sh_spec.rb
@@ -0,0 +1,8 @@
+describe "brew sh", :integration_test do
+ it "runs a shell with the Homebrew environment" do
+ expect { brew "sh", "SHELL" => which("true") }
+ .to output(/Your shell has been configured/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/command_test.rb b/Library/Homebrew/test/command_test.rb
deleted file mode 100644
index d5c7aaa88..000000000
--- a/Library/Homebrew/test/command_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCommand < IntegrationCommandTestCase
- def test_command
- assert_equal "#{HOMEBREW_LIBRARY_PATH}/cmd/info.rb",
- cmd("command", "info")
-
- assert_match "Unknown command",
- cmd_fail("command", "I-don't-exist")
- end
-end
diff --git a/Library/Homebrew/test/config_test.rb b/Library/Homebrew/test/config_test.rb
deleted file mode 100644
index 81da4660a..000000000
--- a/Library/Homebrew/test/config_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestConfig < IntegrationCommandTestCase
- def test_config
- assert_match "HOMEBREW_VERSION: #{HOMEBREW_VERSION}",
- cmd("config")
- end
-end
diff --git a/Library/Homebrew/test/create_test.rb b/Library/Homebrew/test/create_test.rb
deleted file mode 100644
index aeee428aa..000000000
--- a/Library/Homebrew/test/create_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestCreate < IntegrationCommandTestCase
- def test_create
- url = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
- cmd("create", url, "HOMEBREW_EDITOR" => "/bin/cat")
-
- formula_file = CoreTap.new.formula_dir/"testball.rb"
- assert formula_file.exist?, "The formula source should have been created"
- assert_match %Q(sha256 "#{TESTBALL_SHA256}"), formula_file.read
- end
-end
diff --git a/Library/Homebrew/test/desc_test.rb b/Library/Homebrew/test/desc_test.rb
deleted file mode 100644
index 2ba498135..000000000
--- a/Library/Homebrew/test/desc_test.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestDesc < IntegrationCommandTestCase
- def test_desc
- setup_test_formula "testball"
-
- assert_equal "testball: Some test", cmd("desc", "testball")
- assert_match "Pick one, and only one", cmd_fail("desc", "--search", "--name")
- assert_match "You must provide a search term", cmd_fail("desc", "--search")
-
- desc_cache = HOMEBREW_CACHE/"desc_cache.json"
- refute_predicate desc_cache, :exist?, "Cached file should not exist"
-
- cmd("desc", "--description", "testball")
- assert_predicate desc_cache, :exist?, "Cached file should not exist"
- end
-end
diff --git a/Library/Homebrew/test/dev-cmd/create_spec.rb b/Library/Homebrew/test/dev-cmd/create_spec.rb
new file mode 100644
index 000000000..b7f96ec7f
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/create_spec.rb
@@ -0,0 +1,13 @@
+describe "brew create", :integration_test do
+ let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
+ let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" }
+
+ it "creates a new Formula file for a given URL" do
+ shutup do
+ brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
+ end
+
+ expect(formula_file).to exist
+ expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}"))
+ end
+end
diff --git a/Library/Homebrew/test/dev-cmd/formula_spec.rb b/Library/Homebrew/test/dev-cmd/formula_spec.rb
new file mode 100644
index 000000000..cc5b3e9e8
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/formula_spec.rb
@@ -0,0 +1,10 @@
+describe "brew formula", :integration_test do
+ it "prints a given Formula's path" do
+ formula_file = setup_test_formula "testball"
+
+ expect { brew "formula", "testball" }
+ .to output("#{formula_file}\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/formula_cmd_test.rb b/Library/Homebrew/test/formula_cmd_test.rb
deleted file mode 100644
index abbe42d98..000000000
--- a/Library/Homebrew/test/formula_cmd_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestFormula < IntegrationCommandTestCase
- def test_formula
- formula_file = setup_test_formula "testball"
- assert_equal formula_file.to_s, cmd("formula", "testball")
- end
-end
diff --git a/Library/Homebrew/test/link_test.rb b/Library/Homebrew/test/link_test.rb
deleted file mode 100644
index 062caa0c0..000000000
--- a/Library/Homebrew/test/link_test.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLink < IntegrationCommandTestCase
- def test_link
- assert_match "This command requires a keg argument", cmd_fail("link")
-
- setup_test_formula "testball1"
- cmd("install", "testball1")
- cmd("link", "testball1")
-
- cmd("unlink", "testball1")
- assert_match "Would link", cmd("link", "--dry-run", "testball1")
- assert_match "Would remove",
- cmd("link", "--dry-run", "--overwrite", "testball1")
- assert_match "Linking", cmd("link", "testball1")
-
- setup_test_formula "testball2", <<-EOS.undent
- keg_only "just because"
- EOS
- cmd("install", "testball2")
- assert_match "testball2 is keg-only", cmd("link", "testball2")
- end
-end
diff --git a/Library/Homebrew/test/log_formula_test.rb b/Library/Homebrew/test/log_formula_test.rb
deleted file mode 100644
index bb6a1f661..000000000
--- a/Library/Homebrew/test/log_formula_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLogFormula < IntegrationCommandTestCase
- def test_log_formula
- core_tap = CoreTap.new
- setup_test_formula "testball"
-
- core_tap.path.cd do
- shutup do
- system "git", "init"
- system "git", "add", "--all"
- system "git", "commit", "-m", "This is a test commit for Testball"
- end
- end
-
- core_tap_url = "file://#{core_tap.path}"
- shallow_tap = Tap.fetch("homebrew", "shallow")
- shutup do
- system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
- end
-
- assert_match "This is a test commit for Testball",
- cmd("log", "#{shallow_tap}/testball")
- assert_predicate shallow_tap.path/".git/shallow", :exist?,
- "A shallow clone should have been created."
- end
-end
diff --git a/Library/Homebrew/test/log_test.rb b/Library/Homebrew/test/log_test.rb
deleted file mode 100644
index b2e150ccd..000000000
--- a/Library/Homebrew/test/log_test.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestLog < IntegrationCommandTestCase
- def test_log
- FileUtils.cd HOMEBREW_REPOSITORY do
- shutup do
- system "git", "init"
- system "git", "commit", "--allow-empty", "-m", "This is a test commit"
- end
- end
- assert_match "This is a test commit", cmd("log")
- end
-end
diff --git a/Library/Homebrew/test/migrate_test.rb b/Library/Homebrew/test/migrate_test.rb
deleted file mode 100644
index 17929d038..000000000
--- a/Library/Homebrew/test/migrate_test.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestMigrate < IntegrationCommandTestCase
- def test_migrate
- setup_test_formula "testball1"
- setup_test_formula "testball2"
- assert_match "Invalid usage", cmd_fail("migrate")
- assert_match "No available formula with the name \"testball\"",
- cmd_fail("migrate", "testball")
- assert_match "testball1 doesn't replace any formula",
- cmd_fail("migrate", "testball1")
-
- install_and_rename_coretap_formula "testball1", "testball2"
- assert_match "Migrating testball1 to testball2", cmd("migrate", "testball1")
- (HOMEBREW_CELLAR/"testball1").unlink
- assert_match "Error: No such keg", cmd_fail("migrate", "testball1")
- end
-end
diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb
index 09ea14180..0a6e198d3 100644
--- a/Library/Homebrew/test/options_test.rb
+++ b/Library/Homebrew/test/options_test.rb
@@ -1,17 +1,5 @@
require "testing_env"
require "options"
-require "testing_env"
-
-class IntegrationCommandTestOptions < IntegrationCommandTestCase
- def test_options
- setup_test_formula "testball", <<-EOS.undent
- depends_on "bar" => :recommended
- EOS
-
- assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support",
- cmd("options", "testball").chomp
- end
-end
class OptionTests < Homebrew::TestCase
def setup
diff --git a/Library/Homebrew/test/reinstall_pinned_test.rb b/Library/Homebrew/test/reinstall_pinned_test.rb
deleted file mode 100644
index 80f5518ea..000000000
--- a/Library/Homebrew/test/reinstall_pinned_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReinstallPinned < IntegrationCommandTestCase
- def test_reinstall_pinned
- setup_test_formula "testball"
-
- HOMEBREW_CELLAR.join("testball/0.1").mkpath
- HOMEBREW_PINNED_KEGS.mkpath
- FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_PINNED_KEGS/"testball"
-
- assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball")
-
- HOMEBREW_PINNED_KEGS.rmtree
- end
-end
diff --git a/Library/Homebrew/test/reinstall_test.rb b/Library/Homebrew/test/reinstall_test.rb
deleted file mode 100644
index 2906983c3..000000000
--- a/Library/Homebrew/test/reinstall_test.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestReinstall < IntegrationCommandTestCase
- def test_reinstall
- setup_test_formula "testball"
-
- cmd("install", "testball", "--with-foo")
- foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo"
- assert foo_dir.exist?
- foo_dir.rmtree
- assert_match "Reinstalling testball --with-foo",
- cmd("reinstall", "testball")
- assert foo_dir.exist?
- end
-
- def test_reinstall_with_invalid_option
- setup_test_formula "testball"
-
- cmd("install", "testball", "--with-foo")
-
- assert_match "testball: this formula has no --with-fo option so it will be ignored!",
- cmd("reinstall", "testball", "--with-fo")
- end
-end
diff --git a/Library/Homebrew/test/search_test.rb b/Library/Homebrew/test/search_test.rb
deleted file mode 100644
index 70b6f01fb..000000000
--- a/Library/Homebrew/test/search_test.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestSearch < IntegrationCommandTestCase
- def test_search
- setup_test_formula "testball"
- desc_cache = HOMEBREW_CACHE/"desc_cache.json"
- refute_predicate desc_cache, :exist?, "Cached file should not exist"
-
- assert_match "testball", cmd("search")
- assert_match "testball", cmd("search", "testball")
- assert_match "testball", cmd("search", "homebrew/homebrew-core/testball")
- assert_match "testball", cmd("search", "--desc", "Some test")
-
- flags = {
- "macports" => "https://www.macports.org/ports.php?by=name&substr=testball",
- "fink" => "http://pdb.finkproject.org/pdb/browse.php?summary=testball",
- "debian" => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all&section=all",
- "opensuse" => "https://software.opensuse.org/search?q=testball",
- "fedora" => "https://admin.fedoraproject.org/pkgdb/packages/%2Atestball%2A/",
- "ubuntu" => "http://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all&section=all",
- }
-
- flags.each do |flag, url|
- assert_equal url, cmd("search", "--#{flag}",
- "testball", "HOMEBREW_BROWSER" => "echo")
- end
-
- assert_predicate desc_cache, :exist?, "Cached file should exist"
- end
-end
diff --git a/Library/Homebrew/test/sh_test.rb b/Library/Homebrew/test/sh_test.rb
deleted file mode 100644
index 48fcdc54a..000000000
--- a/Library/Homebrew/test/sh_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestSh < IntegrationCommandTestCase
- def test_sh
- assert_match "Your shell has been configured",
- cmd("sh", "SHELL" => which("true"))
- end
-end
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index e4349c8a0..3724e4256 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -37,6 +37,10 @@ RSpec.configure do |config|
skip "Not on macOS." unless OS.mac?
end
+ if example.metadata[:needs_official_cmd_taps]
+ skip "Needs official command Taps." unless ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
+ end
+
if example.metadata[:needs_python]
skip "Python not installed." unless which("python")
end
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
index dd2271a3a..fc7b49fa4 100644
--- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -87,6 +87,80 @@ RSpec.shared_context "integration test" do
status
end
end
+
+ def setup_test_formula(name, content = nil)
+ case name
+ when /^testball/
+ content = <<-EOS.undent
+ desc "Some test"
+ homepage "https://example.com/#{name}"
+ url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
+ sha256 "#{TESTBALL_SHA256}"
+
+ option "with-foo", "Build with foo"
+
+ def install
+ (prefix/"foo"/"test").write("test") if build.with? "foo"
+ prefix.install Dir["*"]
+ (buildpath/"test.c").write \
+ "#include <stdio.h>\\nint main(){return printf(\\"test\\");}"
+ bin.mkpath
+ system ENV.cc, "test.c", "-o", bin/"test"
+ end
+
+ #{content}
+
+ # something here
+ EOS
+ when "foo"
+ content = <<-EOS.undent
+ url "https://example.com/#{name}-1.0"
+ EOS
+ when "bar"
+ content = <<-EOS.undent
+ url "https://example.com/#{name}-1.0"
+ depends_on "foo"
+ EOS
+ end
+
+ Formulary.core_path(name).tap do |formula_path|
+ formula_path.write <<-EOS.undent
+ class #{Formulary.class_s(name)} < Formula
+ #{content}
+ end
+ EOS
+ end
+ end
+
+ def setup_remote_tap(name)
+ Tap.fetch(name).tap do |tap|
+ tap.install(full_clone: false, quiet: true) unless tap.installed?
+ end
+ end
+
+ def install_and_rename_coretap_formula(old_name, new_name)
+ shutup do
+ CoreTap.instance.path.cd do |tap_path|
+ system "git", "init"
+ system "git", "add", "--all"
+ system "git", "commit", "-m",
+ "#{old_name.capitalize} has not yet been renamed"
+
+ brew "install", old_name
+
+ (tap_path/"Formula/#{old_name}.rb").unlink
+ (tap_path/"formula_renames.json").write JSON.generate(old_name => new_name)
+
+ system "git", "add", "--all"
+ system "git", "commit", "-m",
+ "#{old_name.capitalize} has been renamed to #{new_name.capitalize}"
+ end
+ end
+ end
+
+ def testball
+ "#{TEST_FIXTURE_DIR}/testball.rb"
+ end
end
RSpec.configure do |config|