aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/dev-cmd
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test/dev-cmd')
-rw-r--r--Library/Homebrew/test/dev-cmd/bottle_spec.rb30
-rw-r--r--Library/Homebrew/test/dev-cmd/create_spec.rb13
-rw-r--r--Library/Homebrew/test/dev-cmd/edit_spec.rb16
-rw-r--r--Library/Homebrew/test/dev-cmd/formula_spec.rb10
-rw-r--r--Library/Homebrew/test/dev-cmd/pull_spec.rb60
-rw-r--r--Library/Homebrew/test/dev-cmd/tap_spec.rb75
-rw-r--r--Library/Homebrew/test/dev-cmd/test_spec.rb56
7 files changed, 260 insertions, 0 deletions
diff --git a/Library/Homebrew/test/dev-cmd/bottle_spec.rb b/Library/Homebrew/test/dev-cmd/bottle_spec.rb
new file mode 100644
index 000000000..468ef2e90
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/bottle_spec.rb
@@ -0,0 +1,30 @@
+describe "brew bottle", :integration_test do
+ it "builds a bottle for the given Formula" do
+ begin
+ shutup do
+ expect { brew "install", "--build-bottle", testball }
+ .to be_a_success
+ end
+
+ expect { brew "bottle", "--no-rebuild", testball }
+ .to output(/Formula not from core or any taps/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+
+ setup_test_formula "testball"
+
+ # `brew bottle` should not fail with dead symlink
+ # https://github.com/Homebrew/legacy-homebrew/issues/49007
+ (HOMEBREW_CELLAR/"testball/0.1").cd do
+ FileUtils.ln_s "not-exist", "symlink"
+ end
+
+ expect { brew "bottle", "--no-rebuild", "testball" }
+ .to output(/testball-0\.1.*\.bottle\.tar\.gz/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ ensure
+ FileUtils.rm_f Dir.glob("testball-0.1*.bottle.tar.gz")
+ end
+ end
+end
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/edit_spec.rb b/Library/Homebrew/test/dev-cmd/edit_spec.rb
new file mode 100644
index 000000000..5cedb0524
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/edit_spec.rb
@@ -0,0 +1,16 @@
+describe "brew edit", :integration_test do
+ it "opens a given Formula in an editor" do
+ HOMEBREW_REPOSITORY.cd do
+ shutup do
+ system "git", "init"
+ end
+ end
+
+ setup_test_formula "testball"
+
+ expect { brew "edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat" }
+ .to output(/# something here/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/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/dev-cmd/pull_spec.rb b/Library/Homebrew/test/dev-cmd/pull_spec.rb
new file mode 100644
index 000000000..3c0108df2
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/pull_spec.rb
@@ -0,0 +1,60 @@
+describe "brew pull", :integration_test do
+ it "fails when no argument is given" do
+ expect { brew "pull" }
+ .to output(/This command requires at least one argument/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "fetches a patch from a GitHub commit or pull request and applies it" do
+ skip "Requires network connection." if ENV["HOMEBREW_NO_GITHUB_API"]
+
+ CoreTap.instance.path.cd do
+ shutup do
+ system "git", "init"
+ system "git", "checkout", "-b", "new-branch"
+ end
+ end
+
+ expect { brew "pull", "https://bot.brew.sh/job/Homebrew\%20Testing/1028/" }
+ .to output(/Testing URLs require `\-\-bottle`!/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+
+ expect { brew "pull", "1" }
+ .to output(/Fetching patch/).to_stdout
+ .and output(/Current branch is new\-branch/).to_stderr
+ .and be_a_failure
+
+ expect { brew "pull", "--bump", "8" }
+ .to output(/Fetching patch/).to_stdout
+ .and output(/No changed formulae found to bump/).to_stderr
+ .and be_a_failure
+
+ expect { brew "pull", "--bump", "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122" }
+ .to output(/Fetching patch/).to_stdout
+ .and output(/Can only bump one changed formula/).to_stderr
+ .and be_a_failure
+
+ expect { brew "pull", "https://github.com/Homebrew/homebrew-core/pull/1" }
+ .to output(/Fetching patch/).to_stdout
+ .and output(/Patch failed to apply/).to_stderr
+ .and be_a_failure
+ end
+
+ describe "--rebase" do
+ it "fails" do
+ expect { brew "pull", "--rebase" }
+ .to output(/You meant `git pull --rebase`./).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+ end
+
+ it "fails when given 0" do
+ expect { brew "pull", "0" }
+ .to output(/Not a GitHub pull request or commit/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+end
diff --git a/Library/Homebrew/test/dev-cmd/tap_spec.rb b/Library/Homebrew/test/dev-cmd/tap_spec.rb
new file mode 100644
index 000000000..a24c67aae
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/tap_spec.rb
@@ -0,0 +1,75 @@
+describe "brew tap", :integration_test do
+ it "taps a given Tap" do
+ path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
+ path.mkpath
+ path.cd do
+ shutup do
+ system "git", "init"
+ system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
+ FileUtils.touch "readme"
+ system "git", "add", "--all"
+ system "git", "commit", "-m", "init"
+ end
+ end
+
+ expect { brew "tap" }
+ .to output(%r{homebrew/foo}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap", "--list-official" }
+ .to output(%r{homebrew/science}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap-info" }
+ .to output(/2 taps/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap-info", "homebrew/foo" }
+ .to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap-info", "--json=v1", "--installed" }
+ .to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap-pin", "homebrew/foo" }
+ .to output(%r{Pinned homebrew/foo}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap", "--list-pinned" }
+ .to output(%r{homebrew/foo}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap-unpin", "homebrew/foo" }
+ .to output(%r{Unpinned homebrew/foo}).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap", "homebrew/bar", path/".git" }
+ .to output(/Tapped/).to_stdout
+ .and output(/Cloning/).to_stderr
+ .and be_a_success
+
+ expect { brew "untap", "homebrew/bar" }
+ .to output(/Untapped/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "tap", "homebrew/bar", path/".git", "-q", "--full" }
+ .to be_a_success
+ .and not_to_output.to_stdout
+ .and not_to_output.to_stderr
+
+ expect { brew "untap", "homebrew/bar" }
+ .to output(/Untapped/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end
diff --git a/Library/Homebrew/test/dev-cmd/test_spec.rb b/Library/Homebrew/test/dev-cmd/test_spec.rb
new file mode 100644
index 000000000..b73d042e4
--- /dev/null
+++ b/Library/Homebrew/test/dev-cmd/test_spec.rb
@@ -0,0 +1,56 @@
+describe "brew test", :integration_test do
+ it "fails when no argument is given" do
+ expect { brew "test" }
+ .to output(/This command requires a formula argument/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "fails when a Formula is not installed" do
+ expect { brew "test", testball }
+ .to output(/Testing requires the latest version of testball/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "fails when a Formula has no test" do
+ shutup do
+ expect { brew "install", testball }.to be_a_success
+ end
+
+ expect { brew "test", testball }
+ .to output(/testball defines no test/).to_stderr
+ .and not_to_output.to_stdout
+ .and be_a_failure
+ end
+
+ it "tests a given Formula" do
+ setup_test_formula "testball", <<-EOS.undent
+ head "https://github.com/example/testball2.git"
+
+ devel do
+ url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
+ sha256 "#{TESTBALL_SHA256}"
+ end
+
+ keg_only "just because"
+
+ test do
+ end
+ EOS
+
+ shutup do
+ expect { brew "install", "testball" }.to be_a_success
+ end
+
+ expect { brew "test", "--HEAD", "testball" }
+ .to output(/Testing testball/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "test", "--devel", "testball" }
+ .to output(/Testing testball/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+end