style: remove RSpec/MultipleDescribes violations in commands
This commit is contained in:
parent
d5d7b6c3db
commit
4a82d807e1
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.__cache_args" do
|
||||
describe "brew --cache" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew --cache", :integration_test do
|
||||
it "prints all cache files for a given Formula" do
|
||||
it "prints all cache files for a given Formula", :integration_test do
|
||||
expect { brew "--cache", testball }
|
||||
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--testball-}o).to_stdout
|
||||
.and output(/Treating #{Regexp.escape(testball)} as a formula/).to_stderr
|
||||
@ -19,7 +17,7 @@ describe "brew --cache", :integration_test do
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "prints the cache files for a given Cask" do
|
||||
it "prints the cache files for a given Cask", :integration_test do
|
||||
expect { brew "--cache", cask_path("local-caffeine") }
|
||||
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--caffeine\.zip}o).to_stdout
|
||||
.and output(/Treating #{Regexp.escape(cask_path("local-caffeine"))} as a cask/).to_stderr
|
||||
@ -30,7 +28,7 @@ describe "brew --cache", :integration_test do
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "prints the cache files for a given Formula and Cask" do
|
||||
it "prints the cache files for a given Formula and Cask", :integration_test do
|
||||
expect { brew "--cache", testball, cask_path("local-caffeine") }
|
||||
.to output(
|
||||
%r{
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.__cellar_args" do
|
||||
describe "brew --cellar" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew --cellar", :integration_test do
|
||||
it "returns the Cellar subdirectory for a given Formula" do
|
||||
it "returns the Cellar subdirectory for a given Formula", :integration_test do
|
||||
expect { brew "--cellar", testball }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.__env_args" do
|
||||
describe "brew --env" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew --env", :integration_test do
|
||||
describe "--shell=bash" do
|
||||
describe "--shell=bash", :integration_test 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_stdout
|
||||
|
||||
@ -3,26 +3,24 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.__prefix_args" do
|
||||
describe "brew --prefix" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew --prefix", :integration_test do
|
||||
it "prints a given Formula's prefix" do
|
||||
it "prints a given Formula's prefix", :integration_test do
|
||||
expect { brew "--prefix", testball }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "errors if the given Formula doesn't exist" do
|
||||
it "errors if the given Formula doesn't exist", :integration_test do
|
||||
expect { brew "--prefix", "--installed", "nonexistent" }
|
||||
.to output(/No available formula/).to_stderr
|
||||
.and not_to_output.to_stdout
|
||||
.and be_a_failure
|
||||
end
|
||||
|
||||
it "prints a warning with `--installed` if the given Formula is not installed" do
|
||||
it "prints a warning with `--installed` if the given Formula is not installed", :integration_test do
|
||||
expect { brew "--prefix", "--installed", testball }
|
||||
.to not_to_output.to_stdout
|
||||
.and output(/testball/).to_stderr
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.__repository_args" do
|
||||
describe "brew --repository" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew --repository", :integration_test do
|
||||
it "prints the path of a given Tap" do
|
||||
it "prints the path of a given Tap", :integration_test do
|
||||
expect { brew "--repository", "foo/bar" }
|
||||
.to output("#{HOMEBREW_LIBRARY}/Taps/foo/homebrew-bar\n").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.__version_args" do
|
||||
describe "brew --version" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew --version", :integration_test do
|
||||
it "prints the Homebrew version" do
|
||||
it "prints the Homebrew version", :integration_test do
|
||||
expect { brew "--version" }
|
||||
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.analytics_args" do
|
||||
describe "brew analytics" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew analytics", :integration_test do
|
||||
it "when HOMEBREW_NO_ANALYTICS is unset is disabled after running `brew analytics off`" do
|
||||
it "when HOMEBREW_NO_ANALYTICS is unset is disabled after running `brew analytics off`", :integration_test do
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "init"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.autoremove_args" do
|
||||
describe "brew autoremove" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,11 +3,7 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.cleanup_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew cleanup", :integration_test do
|
||||
describe "brew cleanup" do
|
||||
before do
|
||||
FileUtils.mkdir_p HOMEBREW_LIBRARY/"Homebrew/vendor/"
|
||||
FileUtils.touch HOMEBREW_LIBRARY/"Homebrew/vendor/portable-ruby-version"
|
||||
@ -17,7 +13,9 @@ describe "brew cleanup", :integration_test do
|
||||
FileUtils.rm_rf HOMEBREW_LIBRARY/"Homebrew"
|
||||
end
|
||||
|
||||
describe "--prune=all" do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
describe "--prune=all", :integration_test do
|
||||
it "removes all files in Homebrew's cache" do
|
||||
(HOMEBREW_CACHE/"test").write "test"
|
||||
|
||||
|
||||
@ -6,12 +6,10 @@ require "fileutils"
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.commands_args" do
|
||||
describe "brew commands" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew commands", :integration_test do
|
||||
it "prints a list of all available commands" do
|
||||
it "prints a list of all available commands", :integration_test do
|
||||
expect { brew "commands" }
|
||||
.to output(/Built-in commands/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
|
||||
@ -4,9 +4,7 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "brew completions" do
|
||||
describe "Homebrew.completions_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "runs the status subcommand correctly", :integration_test do
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.config_args" do
|
||||
describe "brew config" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew config", :integration_test do
|
||||
it "prints information about the current Homebrew configuration" do
|
||||
it "prints information about the current Homebrew configuration", :integration_test do
|
||||
expect { brew "config" }
|
||||
.to output(/HOMEBREW_VERSION: #{Regexp.escape HOMEBREW_VERSION}/o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.deps_args" do
|
||||
describe "brew deps" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew deps", :integration_test do
|
||||
it "outputs all of a Formula's dependencies and their dependencies on separate lines" do
|
||||
it "outputs all of a Formula's dependencies and their dependencies on separate lines", :integration_test do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
setup_test_formula "baz", <<~RUBY
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.desc_args" do
|
||||
describe "brew desc" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew desc", :integration_test do
|
||||
it "shows a given Formula's description" do
|
||||
it "shows a given Formula's description", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "desc", "testball" }
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.doctor_args" do
|
||||
describe "brew doctor" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew doctor", :integration_test do
|
||||
specify "check_integration_test" do
|
||||
specify "check_integration_test", :integration_test do
|
||||
expect { brew "doctor", "check_integration_test" }
|
||||
.to output(/This is an integration test/).to_stderr
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.fetch_args" do
|
||||
describe "brew fetch" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew fetch", :integration_test do
|
||||
it "downloads the Formula's URL" do
|
||||
it "downloads the Formula's URL", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "fetch", "testball" }.to be_a_success
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.gist_logs_args" do
|
||||
describe "brew gist-logs" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -4,11 +4,7 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
require "support/lib/config"
|
||||
|
||||
describe "Homebrew.home_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew home", :integration_test do
|
||||
describe "brew home" do
|
||||
let(:testballhome_homepage) {
|
||||
Formula["testballhome"].homepage
|
||||
}
|
||||
@ -21,14 +17,16 @@ describe "brew home", :integration_test do
|
||||
Cask::CaskLoader.load(local_caffeine_path).homepage
|
||||
}
|
||||
|
||||
it "opens the project page when no formula or cask is specified" do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "opens the project page when no formula or cask is specified", :integration_test do
|
||||
expect { brew "home", "HOMEBREW_BROWSER" => "echo" }
|
||||
.to output("https://brew.sh\n").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "opens the homepage for a given Formula" do
|
||||
it "opens the homepage for a given Formula", :integration_test do
|
||||
setup_test_formula "testballhome"
|
||||
|
||||
expect { brew "home", "testballhome", "HOMEBREW_BROWSER" => "echo" }
|
||||
@ -37,7 +35,7 @@ describe "brew home", :integration_test do
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "opens the homepage for a given Cask" do
|
||||
it "opens the homepage for a given Cask", :integration_test do
|
||||
expect { brew "home", local_caffeine_path, "HOMEBREW_BROWSER" => "echo" }
|
||||
.to output(/#{local_caffeine_homepage}/).to_stdout
|
||||
.and output(/Treating #{Regexp.escape(local_caffeine_path)} as a cask/).to_stderr
|
||||
@ -48,7 +46,7 @@ describe "brew home", :integration_test do
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "opens the homepages for a given formula and Cask" do
|
||||
it "opens the homepages for a given formula and Cask", :integration_test do
|
||||
setup_test_formula "testballhome"
|
||||
|
||||
expect { brew "home", "testballhome", local_caffeine_path, "HOMEBREW_BROWSER" => "echo" }
|
||||
|
||||
@ -5,12 +5,10 @@ require "cmd/info"
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.info_args" do
|
||||
describe "brew info" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew info", :integration_test do
|
||||
it "prints as json with the --json=v1 flag" do
|
||||
it "prints as json with the --json=v1 flag", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "info", "testball", "--json=v1" }
|
||||
@ -19,7 +17,7 @@ describe "brew info", :integration_test do
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "prints as json with the --json=v2 flag" do
|
||||
it "prints as json with the --json=v2 flag", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "info", "testball", "--json=v2" }
|
||||
@ -27,22 +25,24 @@ describe "brew info", :integration_test do
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
|
||||
describe Homebrew do
|
||||
let(:remote) { "https://github.com/Homebrew/homebrew-core" }
|
||||
describe Homebrew do
|
||||
describe "::github_remote_path" do
|
||||
let(:remote) { "https://github.com/Homebrew/homebrew-core" }
|
||||
|
||||
specify "::github_remote_path" do
|
||||
expect(described_class.github_remote_path(remote, "Formula/git.rb"))
|
||||
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
||||
specify "returns correct URLs" do
|
||||
expect(described_class.github_remote_path(remote, "Formula/git.rb"))
|
||||
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
||||
|
||||
expect(described_class.github_remote_path("#{remote}.git", "Formula/git.rb"))
|
||||
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
||||
expect(described_class.github_remote_path("#{remote}.git", "Formula/git.rb"))
|
||||
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
||||
|
||||
expect(described_class.github_remote_path("git@github.com:user/repo", "foo.rb"))
|
||||
.to eq("https://github.com/user/repo/blob/HEAD/foo.rb")
|
||||
expect(described_class.github_remote_path("git@github.com:user/repo", "foo.rb"))
|
||||
.to eq("https://github.com/user/repo/blob/HEAD/foo.rb")
|
||||
|
||||
expect(described_class.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
|
||||
.to eq("https://mywebsite.com/foo/bar.rb")
|
||||
expect(described_class.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
|
||||
.to eq("https://mywebsite.com/foo/bar.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.install_args" do
|
||||
describe "brew install" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew install", :integration_test do
|
||||
it "installs formulae" do
|
||||
it "installs formulae", :integration_test do
|
||||
setup_test_formula "testball1"
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
@ -18,7 +16,7 @@ describe "brew install", :integration_test do
|
||||
expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").not_to be_a_file
|
||||
end
|
||||
|
||||
it "installs formulae with options" do
|
||||
it "installs formulae with options", :integration_test do
|
||||
setup_test_formula "testball1"
|
||||
|
||||
expect { brew "install", "testball1", "--with-foo" }
|
||||
@ -28,7 +26,7 @@ describe "brew install", :integration_test do
|
||||
expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").to be_a_file
|
||||
end
|
||||
|
||||
it "can install keg-only Formulae" do
|
||||
it "can install keg-only Formulae", :integration_test do
|
||||
setup_test_formula "testball1", <<~RUBY
|
||||
version "1.0"
|
||||
|
||||
@ -42,7 +40,7 @@ describe "brew install", :integration_test do
|
||||
expect(HOMEBREW_CELLAR/"testball1/1.0/foo/test").not_to be_a_file
|
||||
end
|
||||
|
||||
it "can install HEAD Formulae" do
|
||||
it "can install HEAD Formulae", :integration_test do
|
||||
repo_path = HOMEBREW_CACHE.join("repo")
|
||||
repo_path.join("bin").mkpath
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.leaves_args" do
|
||||
describe "brew leaves" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew leaves", :integration_test do
|
||||
context "when there are no installed Formulae" do
|
||||
context "when there are no installed Formulae", :integration_test do
|
||||
it "prints nothing" do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
@ -20,7 +18,7 @@ describe "brew leaves", :integration_test do
|
||||
end
|
||||
end
|
||||
|
||||
context "when there are only installed Formulae without dependencies" do
|
||||
context "when there are only installed Formulae without dependencies", :integration_test do
|
||||
it "prints all installed Formulae" do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
@ -33,7 +31,7 @@ describe "brew leaves", :integration_test do
|
||||
end
|
||||
end
|
||||
|
||||
context "when there are installed Formulae" do
|
||||
context "when there are installed Formulae", :integration_test do
|
||||
it "prints all installed Formulae that are not dependencies of another installed Formula" do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.link_args" do
|
||||
describe "brew link" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew link", :integration_test do
|
||||
it "links a given Formula" do
|
||||
it "links a given Formula", :integration_test do
|
||||
install_test_formula "testball"
|
||||
Formula["testball"].any_installed_keg.unlink
|
||||
|
||||
|
||||
@ -3,14 +3,12 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.list_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew list", :integration_test do
|
||||
describe "brew list" do
|
||||
let(:formulae) { %w[bar foo qux] }
|
||||
|
||||
it "prints all installed Formulae" do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "prints all installed Formulae", :integration_test do
|
||||
formulae.each do |f|
|
||||
(HOMEBREW_CELLAR/f/"1.0/somedir").mkpath
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.log_args" do
|
||||
describe "brew log" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew log", :integration_test do
|
||||
it "shows the Git log for a given Formula" do
|
||||
it "shows the Git log for a given Formula", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
core_tap = CoreTap.new
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.migrate_args" do
|
||||
describe "brew migrate" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew migrate", :integration_test do
|
||||
it "migrates a renamed Formula" do
|
||||
it "migrates a renamed Formula", :integration_test do
|
||||
setup_test_formula "testball1"
|
||||
setup_test_formula "testball2"
|
||||
install_and_rename_coretap_formula "testball1", "testball2"
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.missing_args" do
|
||||
describe "brew missing" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew missing", :integration_test do
|
||||
it "prints missing dependencies" do
|
||||
it "prints missing dependencies", :integration_test do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.options_args" do
|
||||
describe "brew options" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew options", :integration_test do
|
||||
it "prints a given Formula's options" do
|
||||
it "prints a given Formula's options", :integration_test do
|
||||
setup_test_formula "testball", <<~RUBY
|
||||
depends_on "bar" => :recommended
|
||||
RUBY
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.outdated_args" do
|
||||
describe "brew outdated" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew outdated", :integration_test do
|
||||
it "outputs JSON" do
|
||||
it "outputs JSON", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.pin_args" do
|
||||
describe "brew pin" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew pin", :integration_test do
|
||||
it "pins a Formula's version" do
|
||||
it "pins a Formula's version", :integration_test do
|
||||
install_test_formula "testball"
|
||||
|
||||
expect { brew "pin", "testball" }.to be_a_success
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.postinstall_args" do
|
||||
describe "brew postinstall" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.readall_args" do
|
||||
describe "brew readall" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew readall", :integration_test do
|
||||
it "imports all Formulae for a given Tap" do
|
||||
it "imports all Formulae for a given Tap", :integration_test do
|
||||
formula_file = setup_test_formula "testball"
|
||||
|
||||
alias_file = CoreTap.new.alias_dir/"foobar"
|
||||
|
||||
@ -4,12 +4,10 @@
|
||||
require "extend/ENV"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.reinstall_args" do
|
||||
describe "brew reinstall" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew reinstall", :integration_test do
|
||||
it "reinstalls a Formula" do
|
||||
it "reinstalls a Formula", :integration_test do
|
||||
install_test_formula "testball"
|
||||
foo_dir = HOMEBREW_CELLAR/"testball/0.1/bin"
|
||||
expect(foo_dir).to exist
|
||||
|
||||
@ -4,12 +4,10 @@
|
||||
require "cmd/search"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.search_args" do
|
||||
describe "brew search" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew search", :integration_test do
|
||||
it "falls back to a GitHub tap search when no formula is found", :needs_macos, :needs_network do
|
||||
it "falls back to a GitHub tap search when no formula is found", :integration_test, :needs_macos, :needs_network do
|
||||
setup_test_formula "testball"
|
||||
setup_remote_tap "homebrew/cask"
|
||||
|
||||
@ -19,7 +17,7 @@ describe "brew search", :integration_test do
|
||||
end
|
||||
|
||||
# doesn't actually need Linux but only want one integration test per-OS.
|
||||
it "finds formula in search", :need_linux do
|
||||
it "finds formula in search", :integration_test, :need_linux do
|
||||
setup_test_formula "testball"
|
||||
|
||||
expect { brew "search", "testball" }
|
||||
|
||||
@ -2,14 +2,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
shared_examples "parseable arguments" do
|
||||
subject(:method_name) do |example|
|
||||
example.metadata[:example_group][:parent_example_group][:description]
|
||||
.delete_prefix("Homebrew.")
|
||||
end
|
||||
subject(:method_name) { "#{command_name.tr("-", "_")}_args" }
|
||||
|
||||
let(:command_name) do
|
||||
method_name.delete_suffix("_args")
|
||||
.tr("_", "-")
|
||||
let(:command_name) do |example|
|
||||
example.metadata[:example_group][:parent_example_group][:description].delete_prefix("brew ")
|
||||
end
|
||||
|
||||
it "can parse arguments" do
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.tap_info_args" do
|
||||
describe "brew tap-info" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew tap-info", :integration_test do
|
||||
it "gets information for a given Tap" do
|
||||
it "gets information for a given Tap", :integration_test do
|
||||
setup_test_tap
|
||||
|
||||
expect { brew "tap-info", "--json=v1", "--installed" }
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.tap_args" do
|
||||
describe "brew tap" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew tap", :integration_test do
|
||||
it "taps a given Tap" do
|
||||
it "taps a given Tap", :integration_test do
|
||||
path = setup_test_tap
|
||||
|
||||
expect { brew "tap", "--force-auto-update", "--full", "homebrew/bar", path/".git" }
|
||||
|
||||
@ -5,12 +5,10 @@ require "cmd/uninstall"
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.uninstall_args" do
|
||||
describe "brew uninstall" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew uninstall", :integration_test do
|
||||
it "uninstalls a given Formula" do
|
||||
it "uninstalls a given Formula", :integration_test do
|
||||
install_test_formula "testball"
|
||||
|
||||
expect { brew "uninstall", "--force", "testball" }
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.unlink_args" do
|
||||
describe "brew unlink" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew unlink", :integration_test do
|
||||
it "unlinks a Formula" do
|
||||
it "unlinks a Formula", :integration_test do
|
||||
install_test_formula "testball"
|
||||
|
||||
expect { brew "unlink", "testball" }
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.unpin_args" do
|
||||
describe "brew unpin" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew unpin", :integration_test do
|
||||
it "unpins a Formula's version" do
|
||||
it "unpins a Formula's version", :integration_test do
|
||||
install_test_formula "testball"
|
||||
Formula["testball"].pin
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.untap_args" do
|
||||
describe "brew untap" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew untap", :integration_test do
|
||||
it "untaps a given Tap" do
|
||||
it "untaps a given Tap", :integration_test do
|
||||
setup_test_tap
|
||||
|
||||
expect { brew "untap", "homebrew/foo" }
|
||||
|
||||
@ -6,130 +6,130 @@ require "formula_versions"
|
||||
require "yaml"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.update_report_args" do
|
||||
describe "brew update-report" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe Reporter do
|
||||
let(:tap) { CoreTap.new }
|
||||
let(:reporter_class) do
|
||||
Class.new(described_class) do
|
||||
def initialize(tap)
|
||||
@tap = tap
|
||||
describe Reporter do
|
||||
let(:tap) { CoreTap.new }
|
||||
let(:reporter_class) do
|
||||
Class.new(described_class) do
|
||||
def initialize(tap)
|
||||
@tap = tap
|
||||
|
||||
ENV["HOMEBREW_UPDATE_BEFORE#{tap.repo_var}"] = "12345678"
|
||||
ENV["HOMEBREW_UPDATE_AFTER#{tap.repo_var}"] = "abcdef00"
|
||||
ENV["HOMEBREW_UPDATE_BEFORE#{tap.repo_var}"] = "12345678"
|
||||
ENV["HOMEBREW_UPDATE_AFTER#{tap.repo_var}"] = "abcdef00"
|
||||
|
||||
super(tap)
|
||||
super(tap)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
let(:reporter) { reporter_class.new(tap) }
|
||||
let(:hub) { ReporterHub.new }
|
||||
let(:reporter) { reporter_class.new(tap) }
|
||||
let(:hub) { ReporterHub.new }
|
||||
|
||||
def perform_update(fixture_name = "")
|
||||
allow(Formulary).to receive(:factory).and_return(double(pkg_version: "1.0"))
|
||||
allow(FormulaVersions).to receive(:new).and_return(double(formula_at_revision: "2.0"))
|
||||
def perform_update(fixture_name = "")
|
||||
allow(Formulary).to receive(:factory).and_return(double(pkg_version: "1.0"))
|
||||
allow(FormulaVersions).to receive(:new).and_return(double(formula_at_revision: "2.0"))
|
||||
|
||||
diff = YAML.load_file("#{TEST_FIXTURE_DIR}/updater_fixture.yaml")[fixture_name]
|
||||
allow(reporter).to receive(:diff).and_return(diff || "")
|
||||
diff = YAML.load_file("#{TEST_FIXTURE_DIR}/updater_fixture.yaml")[fixture_name]
|
||||
allow(reporter).to receive(:diff).and_return(diff || "")
|
||||
|
||||
hub.add(reporter) if reporter.updated?
|
||||
end
|
||||
|
||||
specify "without revision variable" do
|
||||
ENV.delete_if { |k, _v| k.start_with? "HOMEBREW_UPDATE" }
|
||||
|
||||
expect {
|
||||
described_class.new(tap)
|
||||
}.to raise_error(Reporter::ReporterRevisionUnsetError)
|
||||
end
|
||||
|
||||
specify "without any changes" do
|
||||
perform_update
|
||||
expect(hub).to be_empty
|
||||
end
|
||||
|
||||
specify "without Formula changes" do
|
||||
perform_update("update_git_diff_output_without_formulae_changes")
|
||||
|
||||
expect(hub.select_formula(:M)).to be_empty
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
end
|
||||
|
||||
specify "with Formula changes" do
|
||||
perform_update("update_git_diff_output_with_formulae_changes")
|
||||
|
||||
expect(hub.select_formula(:M)).to eq(%w[xar yajl])
|
||||
expect(hub.select_formula(:A)).to eq(%w[antiword bash-completion ddrescue dict lua])
|
||||
end
|
||||
|
||||
specify "with removed Formulae" do
|
||||
perform_update("update_git_diff_output_with_removed_formulae")
|
||||
|
||||
expect(hub.select_formula(:D)).to eq(%w[libgsasl])
|
||||
end
|
||||
|
||||
specify "with changed file type" do
|
||||
perform_update("update_git_diff_output_with_changed_filetype")
|
||||
|
||||
expect(hub.select_formula(:M)).to eq(%w[elixir])
|
||||
expect(hub.select_formula(:A)).to eq(%w[libbson])
|
||||
expect(hub.select_formula(:D)).to eq(%w[libgsasl])
|
||||
end
|
||||
|
||||
specify "with renamed Formula" do
|
||||
allow(tap).to receive(:formula_renames).and_return("cv" => "progress")
|
||||
perform_update("update_git_diff_output_with_formula_rename")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to eq([["cv", "progress"]])
|
||||
end
|
||||
|
||||
context "when updating a Tap other than the core Tap" do
|
||||
let(:tap) { Tap.new("foo", "bar") }
|
||||
|
||||
before do
|
||||
(tap.path/"Formula").mkpath
|
||||
hub.add(reporter) if reporter.updated?
|
||||
end
|
||||
|
||||
after do
|
||||
tap.path.parent.rmtree
|
||||
specify "without revision variable" do
|
||||
ENV.delete_if { |k, _v| k.start_with? "HOMEBREW_UPDATE" }
|
||||
|
||||
expect {
|
||||
described_class.new(tap)
|
||||
}.to raise_error(Reporter::ReporterRevisionUnsetError)
|
||||
end
|
||||
|
||||
specify "with restructured Tap" do
|
||||
perform_update("update_git_diff_output_with_restructured_tap")
|
||||
specify "without any changes" do
|
||||
perform_update
|
||||
expect(hub).to be_empty
|
||||
end
|
||||
|
||||
specify "without Formula changes" do
|
||||
perform_update("update_git_diff_output_without_formulae_changes")
|
||||
|
||||
expect(hub.select_formula(:M)).to be_empty
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to be_empty
|
||||
end
|
||||
|
||||
specify "with renamed Formula and restructured Tap" do
|
||||
allow(tap).to receive(:formula_renames).and_return("xchat" => "xchat2")
|
||||
perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to eq([%w[foo/bar/xchat foo/bar/xchat2]])
|
||||
end
|
||||
|
||||
specify "with simulated 'homebrew/php' restructuring" do
|
||||
perform_update("update_git_diff_simulate_homebrew_php_restructuring")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to be_empty
|
||||
end
|
||||
|
||||
specify "with Formula changes" do
|
||||
perform_update("update_git_diff_output_with_tap_formulae_changes")
|
||||
perform_update("update_git_diff_output_with_formulae_changes")
|
||||
|
||||
expect(hub.select_formula(:A)).to eq(%w[foo/bar/lua])
|
||||
expect(hub.select_formula(:M)).to eq(%w[foo/bar/git])
|
||||
expect(hub.select_formula(:M)).to eq(%w[xar yajl])
|
||||
expect(hub.select_formula(:A)).to eq(%w[antiword bash-completion ddrescue dict lua])
|
||||
end
|
||||
|
||||
specify "with removed Formulae" do
|
||||
perform_update("update_git_diff_output_with_removed_formulae")
|
||||
|
||||
expect(hub.select_formula(:D)).to eq(%w[libgsasl])
|
||||
end
|
||||
|
||||
specify "with changed file type" do
|
||||
perform_update("update_git_diff_output_with_changed_filetype")
|
||||
|
||||
expect(hub.select_formula(:M)).to eq(%w[elixir])
|
||||
expect(hub.select_formula(:A)).to eq(%w[libbson])
|
||||
expect(hub.select_formula(:D)).to eq(%w[libgsasl])
|
||||
end
|
||||
|
||||
specify "with renamed Formula" do
|
||||
allow(tap).to receive(:formula_renames).and_return("cv" => "progress")
|
||||
perform_update("update_git_diff_output_with_formula_rename")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to eq([["cv", "progress"]])
|
||||
end
|
||||
|
||||
context "when updating a Tap other than the core Tap" do
|
||||
let(:tap) { Tap.new("foo", "bar") }
|
||||
|
||||
before do
|
||||
(tap.path/"Formula").mkpath
|
||||
end
|
||||
|
||||
after do
|
||||
tap.path.parent.rmtree
|
||||
end
|
||||
|
||||
specify "with restructured Tap" do
|
||||
perform_update("update_git_diff_output_with_restructured_tap")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to be_empty
|
||||
end
|
||||
|
||||
specify "with renamed Formula and restructured Tap" do
|
||||
allow(tap).to receive(:formula_renames).and_return("xchat" => "xchat2")
|
||||
perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to eq([%w[foo/bar/xchat foo/bar/xchat2]])
|
||||
end
|
||||
|
||||
specify "with simulated 'homebrew/php' restructuring" do
|
||||
perform_update("update_git_diff_simulate_homebrew_php_restructuring")
|
||||
|
||||
expect(hub.select_formula(:A)).to be_empty
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
expect(hub.select_formula(:R)).to be_empty
|
||||
end
|
||||
|
||||
specify "with Formula changes" do
|
||||
perform_update("update_git_diff_output_with_tap_formulae_changes")
|
||||
|
||||
expect(hub.select_formula(:A)).to eq(%w[foo/bar/lua])
|
||||
expect(hub.select_formula(:M)).to eq(%w[foo/bar/git])
|
||||
expect(hub.select_formula(:D)).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.upgrade_args" do
|
||||
describe "brew upgrade" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew upgrade", :integration_test do
|
||||
it "upgrades a Formula and cleans up old versions" do
|
||||
it "upgrades a Formula and cleans up old versions", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.uses_args" do
|
||||
describe "brew uses" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew uses", :integration_test do
|
||||
it "prints the Formulae a given Formula is used by" do
|
||||
it "prints the Formulae a given Formula is used by", :integration_test do
|
||||
setup_test_formula "foo"
|
||||
setup_test_formula "bar"
|
||||
setup_test_formula "baz", <<~RUBY
|
||||
|
||||
@ -6,7 +6,7 @@ require "formulary"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
require "utils/spdx"
|
||||
|
||||
describe "Homebrew.audit_args" do
|
||||
describe "brew audit" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
|
||||
@ -4,12 +4,10 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
require "dev-cmd/bottle"
|
||||
|
||||
describe "Homebrew.bottle_args" do
|
||||
describe "brew bottle" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew bottle", :integration_test do
|
||||
it "builds a bottle for the given Formula" do
|
||||
it "builds a bottle for the given Formula", :integration_test do
|
||||
# create stub patchelf
|
||||
if OS.linux?
|
||||
setup_test_formula "patchelf"
|
||||
@ -40,6 +38,438 @@ describe "brew bottle", :integration_test do
|
||||
FileUtils.rm_f Dir.glob("testball--0.1*.bottle.tar.gz")
|
||||
end
|
||||
end
|
||||
|
||||
describe "--merge", :integration_test do
|
||||
let(:core_tap) { CoreTap.new }
|
||||
let(:tarball) do
|
||||
if OS.linux?
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz"
|
||||
else
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz"
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
Pathname("#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json").write stub_hash(
|
||||
name: "testball",
|
||||
version: "1.0",
|
||||
path: "#{core_tap.path}/Formula/testball.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "hello-1.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.big_sur.bottle.tar.gz",
|
||||
sha256: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
|
||||
Pathname("#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json").write stub_hash(
|
||||
name: "testball",
|
||||
version: "1.0",
|
||||
path: "#{core_tap.path}/Formula/testball.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "catalina",
|
||||
filename: "testball-1.0.catalina.bottle.tar.gz",
|
||||
local_filename: "testball--1.0.catalina.bottle.tar.gz",
|
||||
sha256: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
)
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
|
||||
it "adds the bottle block to a formula that has none" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
|
||||
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(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
||||
it "replaces the bottle block in a formula that already has a bottle block" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball", bottle_block: <<~EOS
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
cellar :any_skip_relocation
|
||||
sha256 big_sur: "6b276491297d4052538bd2fd22d5129389f27d90a98f831987236a5b90511b98"
|
||||
sha256 catalina: "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72"
|
||||
end
|
||||
EOS
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
option "with-foo", "Build with foo"
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
|
||||
def install
|
||||
(prefix/"foo"/"test").write("test") if build.with? "foo"
|
||||
prefix.install Dir["*"]
|
||||
(buildpath/"test.c").write \
|
||||
"#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
||||
it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula("testball")
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"--keep-old",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output("Error: `--keep-old` was passed but there was no existing bottle block!\n").to_stderr
|
||||
end
|
||||
|
||||
it "updates the bottle block in a formula that already has a bottle block when using --keep-old" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball", bottle_block: <<~EOS
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
cellar :any
|
||||
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
|
||||
end
|
||||
EOS
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"--keep-old",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
sha256 cellar: :any, high_sierra: "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
option "with-foo", "Build with foo"
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
sha256 cellar: :any, high_sierra: "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059"
|
||||
end
|
||||
|
||||
def install
|
||||
(prefix/"foo"/"test").write("test") if build.with? "foo"
|
||||
prefix.install Dir["*"]
|
||||
(buildpath/"test.c").write \
|
||||
"#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
describe Homebrew do
|
||||
subject(:homebrew) { described_class }
|
||||
|
||||
let(:hello_hash_big_sur) {
|
||||
JSON.parse stub_hash(
|
||||
name: "hello",
|
||||
version: "1.0",
|
||||
path: "/home/hello.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "hello-1.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.big_sur.bottle.tar.gz",
|
||||
sha256: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
}
|
||||
let(:hello_hash_catalina) {
|
||||
JSON.parse stub_hash(
|
||||
name: "hello",
|
||||
version: "1.0",
|
||||
path: "/home/hello.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "catalina",
|
||||
filename: "hello-1.0.catalina.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.catalina.bottle.tar.gz",
|
||||
sha256: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
)
|
||||
}
|
||||
let(:unzip_hash_big_sur) {
|
||||
JSON.parse stub_hash(
|
||||
name: "unzip",
|
||||
version: "2.0",
|
||||
path: "/home/unzip.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "unzip-2.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "unzip--2.0.big_sur.bottle.tar.gz",
|
||||
sha256: "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
||||
)
|
||||
}
|
||||
let(:unzip_hash_catalina) {
|
||||
JSON.parse stub_hash(
|
||||
name: "unzip",
|
||||
version: "2.0",
|
||||
path: "/home/unzip.rb",
|
||||
cellar: "any",
|
||||
os: "catalina",
|
||||
filename: "unzip-2.0.catalina.bottle.tar.gz",
|
||||
local_filename: "unzip--2.0.catalina.bottle.tar.gz",
|
||||
sha256: "d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||
)
|
||||
}
|
||||
|
||||
specify "::parse_json_files" do
|
||||
Tempfile.open("hello--1.0.big_sur.bottle.json") do |f|
|
||||
f.write stub_hash(
|
||||
name: "hello",
|
||||
version: "1.0",
|
||||
path: "/home/hello.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "hello-1.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.big_sur.bottle.tar.gz",
|
||||
sha256: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
f.close
|
||||
expect(
|
||||
homebrew.parse_json_files([f.path]).first["hello"]["bottle"]["tags"]["big_sur"]["filename"],
|
||||
).to eq("hello-1.0.big_sur.bottle.tar.gz")
|
||||
end
|
||||
end
|
||||
|
||||
specify "::merge_json_files" do
|
||||
bottles_hash = homebrew.merge_json_files(
|
||||
[hello_hash_big_sur, hello_hash_catalina, unzip_hash_big_sur, unzip_hash_catalina],
|
||||
)
|
||||
|
||||
hello_hash = bottles_hash["hello"]
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("hello-1.0.big_sur.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("hello--1.0.big_sur.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
||||
"a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any_skip_relocation")
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("hello-1.0.catalina.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("hello--1.0.catalina.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
||||
"5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
)
|
||||
unzip_hash = bottles_hash["unzip"]
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("unzip-2.0.big_sur.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("unzip--2.0.big_sur.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
||||
"16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
||||
)
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any")
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("unzip-2.0.catalina.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("unzip--2.0.catalina.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
||||
"d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||
)
|
||||
end
|
||||
|
||||
describe "#merge_bottle_spec" do
|
||||
it "allows new bottle hash to be empty" do
|
||||
valid_keys = [:root_url, :prefix, :cellar, :rebuild, :sha256]
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.sha256("f59bc65c91e4e698f6f050e1efea0040f57372d4dcf0996cbb8f97ced320403b" => :big_sur)
|
||||
expect { homebrew.merge_bottle_spec(valid_keys, old_spec, {}) }.not_to raise_error
|
||||
end
|
||||
|
||||
it "checks for conflicting root URL" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.root_url("https://failbrew.bintray.com/bottles")
|
||||
new_hash = { "root_url" => "https://testbrew.bintray.com/bottles" }
|
||||
expect(homebrew.merge_bottle_spec([:root_url], old_spec, new_hash)).to eq [
|
||||
['root_url: old: "https://failbrew.bintray.com/bottles", new: "https://testbrew.bintray.com/bottles"'],
|
||||
[],
|
||||
]
|
||||
end
|
||||
|
||||
it "checks for conflicting prefix" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.prefix("/opt/failbrew")
|
||||
new_hash = { "prefix" => "/opt/testbrew" }
|
||||
expect(homebrew.merge_bottle_spec([:prefix], old_spec, new_hash)).to eq [
|
||||
['prefix: old: "/opt/failbrew", new: "/opt/testbrew"'],
|
||||
[],
|
||||
]
|
||||
end
|
||||
|
||||
it "checks for conflicting rebuild number" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.rebuild(1)
|
||||
new_hash = { "rebuild" => 2 }
|
||||
expect(homebrew.merge_bottle_spec([:rebuild], old_spec, new_hash)).to eq [
|
||||
['rebuild: old: "1", new: "2"'],
|
||||
[],
|
||||
]
|
||||
end
|
||||
|
||||
it "checks for conflicting checksums" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")
|
||||
old_spec.sha256(mojave: "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f")
|
||||
new_hash = { "tags" => { "catalina" => "ec6d7f08412468f28dee2be17ad8cd8b883b16b34329efcecce019b8c9736428" } }
|
||||
expected_checksum_hash = { mojave: "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f" }
|
||||
expected_checksum_hash[:cellar] = Homebrew::DEFAULT_CELLAR
|
||||
expect(homebrew.merge_bottle_spec([:sha256], old_spec, new_hash)).to eq [
|
||||
["sha256 => catalina"],
|
||||
[expected_checksum_hash],
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
describe "::generate_sha256_line" do
|
||||
it "generates a string without cellar" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", nil)).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "generates a string with cellar symbol" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", :any)).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 cellar: :any, catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "generates a string with default cellar path" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", Homebrew::DEFAULT_LINUX_CELLAR)).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "generates a string with non-default cellar path" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", "/home/test")).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 cellar: "/home/test", catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def stub_hash(parameters)
|
||||
@ -71,435 +501,3 @@ def stub_hash(parameters)
|
||||
}
|
||||
EOS
|
||||
end
|
||||
|
||||
describe Homebrew do
|
||||
subject(:homebrew) { described_class }
|
||||
|
||||
let(:hello_hash_big_sur) {
|
||||
JSON.parse stub_hash(
|
||||
name: "hello",
|
||||
version: "1.0",
|
||||
path: "/home/hello.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "hello-1.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.big_sur.bottle.tar.gz",
|
||||
sha256: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
}
|
||||
let(:hello_hash_catalina) {
|
||||
JSON.parse stub_hash(
|
||||
name: "hello",
|
||||
version: "1.0",
|
||||
path: "/home/hello.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "catalina",
|
||||
filename: "hello-1.0.catalina.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.catalina.bottle.tar.gz",
|
||||
sha256: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
)
|
||||
}
|
||||
let(:unzip_hash_big_sur) {
|
||||
JSON.parse stub_hash(
|
||||
name: "unzip",
|
||||
version: "2.0",
|
||||
path: "/home/unzip.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "unzip-2.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "unzip--2.0.big_sur.bottle.tar.gz",
|
||||
sha256: "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
||||
)
|
||||
}
|
||||
let(:unzip_hash_catalina) {
|
||||
JSON.parse stub_hash(
|
||||
name: "unzip",
|
||||
version: "2.0",
|
||||
path: "/home/unzip.rb",
|
||||
cellar: "any",
|
||||
os: "catalina",
|
||||
filename: "unzip-2.0.catalina.bottle.tar.gz",
|
||||
local_filename: "unzip--2.0.catalina.bottle.tar.gz",
|
||||
sha256: "d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||
)
|
||||
}
|
||||
|
||||
specify "::parse_json_files" do
|
||||
Tempfile.open("hello--1.0.big_sur.bottle.json") do |f|
|
||||
f.write stub_hash(
|
||||
name: "hello",
|
||||
version: "1.0",
|
||||
path: "/home/hello.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "hello-1.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.big_sur.bottle.tar.gz",
|
||||
sha256: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
f.close
|
||||
expect(
|
||||
homebrew.parse_json_files([f.path]).first["hello"]["bottle"]["tags"]["big_sur"]["filename"],
|
||||
).to eq("hello-1.0.big_sur.bottle.tar.gz")
|
||||
end
|
||||
end
|
||||
|
||||
specify "::merge_json_files" do
|
||||
bottles_hash = homebrew.merge_json_files(
|
||||
[hello_hash_big_sur, hello_hash_catalina, unzip_hash_big_sur, unzip_hash_catalina],
|
||||
)
|
||||
|
||||
hello_hash = bottles_hash["hello"]
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("hello-1.0.big_sur.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("hello--1.0.big_sur.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
||||
"a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any_skip_relocation")
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("hello-1.0.catalina.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("hello--1.0.catalina.bottle.tar.gz")
|
||||
expect(hello_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
||||
"5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
)
|
||||
unzip_hash = bottles_hash["unzip"]
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("unzip-2.0.big_sur.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("unzip--2.0.big_sur.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
||||
"16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
||||
)
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any")
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("unzip-2.0.catalina.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("unzip--2.0.catalina.bottle.tar.gz")
|
||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
||||
"d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||
)
|
||||
end
|
||||
|
||||
describe "#merge_bottle_spec" do
|
||||
it "allows new bottle hash to be empty" do
|
||||
valid_keys = [:root_url, :prefix, :cellar, :rebuild, :sha256]
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.sha256("f59bc65c91e4e698f6f050e1efea0040f57372d4dcf0996cbb8f97ced320403b" => :big_sur)
|
||||
expect { homebrew.merge_bottle_spec(valid_keys, old_spec, {}) }.not_to raise_error
|
||||
end
|
||||
|
||||
it "checks for conflicting root URL" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.root_url("https://failbrew.bintray.com/bottles")
|
||||
new_hash = { "root_url" => "https://testbrew.bintray.com/bottles" }
|
||||
expect(homebrew.merge_bottle_spec([:root_url], old_spec, new_hash)).to eq [
|
||||
['root_url: old: "https://failbrew.bintray.com/bottles", new: "https://testbrew.bintray.com/bottles"'],
|
||||
[],
|
||||
]
|
||||
end
|
||||
|
||||
it "checks for conflicting prefix" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.prefix("/opt/failbrew")
|
||||
new_hash = { "prefix" => "/opt/testbrew" }
|
||||
expect(homebrew.merge_bottle_spec([:prefix], old_spec, new_hash)).to eq [
|
||||
['prefix: old: "/opt/failbrew", new: "/opt/testbrew"'],
|
||||
[],
|
||||
]
|
||||
end
|
||||
|
||||
it "checks for conflicting rebuild number" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.rebuild(1)
|
||||
new_hash = { "rebuild" => 2 }
|
||||
expect(homebrew.merge_bottle_spec([:rebuild], old_spec, new_hash)).to eq [
|
||||
['rebuild: old: "1", new: "2"'],
|
||||
[],
|
||||
]
|
||||
end
|
||||
|
||||
it "checks for conflicting checksums" do
|
||||
old_spec = BottleSpecification.new
|
||||
old_spec.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")
|
||||
old_spec.sha256(mojave: "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f")
|
||||
new_hash = { "tags" => { "catalina" => "ec6d7f08412468f28dee2be17ad8cd8b883b16b34329efcecce019b8c9736428" } }
|
||||
expected_checksum_hash = { mojave: "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f" }
|
||||
expected_checksum_hash[:cellar] = Homebrew::DEFAULT_CELLAR
|
||||
expect(homebrew.merge_bottle_spec([:sha256], old_spec, new_hash)).to eq [
|
||||
["sha256 => catalina"],
|
||||
[expected_checksum_hash],
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
describe "::generate_sha256_line" do
|
||||
it "generates a string without cellar" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", nil)).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "generates a string with cellar symbol" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", :any)).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 cellar: :any, catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "generates a string with default cellar path" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", Homebrew::DEFAULT_LINUX_CELLAR)).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
|
||||
it "generates a string with non-default cellar path" do
|
||||
expect(homebrew.generate_sha256_line(:catalina, "deadbeef", "/home/test")).to eq(
|
||||
<<~RUBY.chomp,
|
||||
sha256 cellar: "/home/test", catalina: "deadbeef"
|
||||
RUBY
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "brew bottle --merge", :integration_test do
|
||||
let(:core_tap) { CoreTap.new }
|
||||
let(:tarball) do
|
||||
if OS.linux?
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz"
|
||||
else
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz"
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
Pathname("#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json").write stub_hash(
|
||||
name: "testball",
|
||||
version: "1.0",
|
||||
path: "#{core_tap.path}/Formula/testball.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "big_sur",
|
||||
filename: "hello-1.0.big_sur.bottle.tar.gz",
|
||||
local_filename: "hello--1.0.big_sur.bottle.tar.gz",
|
||||
sha256: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
)
|
||||
|
||||
Pathname("#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json").write stub_hash(
|
||||
name: "testball",
|
||||
version: "1.0",
|
||||
path: "#{core_tap.path}/Formula/testball.rb",
|
||||
cellar: "any_skip_relocation",
|
||||
os: "catalina",
|
||||
filename: "testball-1.0.catalina.bottle.tar.gz",
|
||||
local_filename: "testball--1.0.catalina.bottle.tar.gz",
|
||||
sha256: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
)
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
|
||||
it "adds the bottle block to a formula that has none" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
|
||||
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(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
||||
it "replaces the bottle block in a formula that already has a bottle block" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball", bottle_block: <<~EOS
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
cellar :any_skip_relocation
|
||||
sha256 big_sur: "6b276491297d4052538bd2fd22d5129389f27d90a98f831987236a5b90511b98"
|
||||
sha256 catalina: "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72"
|
||||
end
|
||||
EOS
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
option "with-foo", "Build with foo"
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
end
|
||||
|
||||
def install
|
||||
(prefix/"foo"/"test").write("test") if build.with? "foo"
|
||||
prefix.install Dir["*"]
|
||||
(buildpath/"test.c").write \
|
||||
"#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
||||
it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula("testball")
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"--keep-old",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output("Error: `--keep-old` was passed but there was no existing bottle block!\n").to_stderr
|
||||
end
|
||||
|
||||
it "updates the bottle block in a formula that already has a bottle block when using --keep-old" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball", bottle_block: <<~EOS
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
cellar :any
|
||||
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
|
||||
end
|
||||
EOS
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
"--write",
|
||||
"--keep-old",
|
||||
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||
}.to output(<<~EOS).to_stdout
|
||||
==> testball
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
sha256 cellar: :any, high_sierra: "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059"
|
||||
end
|
||||
EOS
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||
class Testball < Formula
|
||||
desc "Some test"
|
||||
homepage "https://brew.sh/testball"
|
||||
url "file://#{tarball}"
|
||||
sha256 "#{tarball.sha256}"
|
||||
|
||||
option "with-foo", "Build with foo"
|
||||
|
||||
bottle do
|
||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||
sha256 cellar: :any_skip_relocation, big_sur: "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f"
|
||||
sha256 cellar: :any_skip_relocation, catalina: "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac"
|
||||
sha256 cellar: :any, high_sierra: "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059"
|
||||
end
|
||||
|
||||
def install
|
||||
(prefix/"foo"/"test").write("test") if build.with? "foo"
|
||||
prefix.install Dir["*"]
|
||||
(buildpath/"test.c").write \
|
||||
"#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
|
||||
bin.mkpath
|
||||
system ENV.cc, "test.c", "-o", bin/"test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
# something here
|
||||
|
||||
end
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.bump_cask_pr_args" do
|
||||
describe "brew bump-cask-pr" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.bump_formula_pr_args" do
|
||||
describe "brew bump-formula-pr" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.bump_revision_args" do
|
||||
describe "brew bump-revision" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.bump_unversioned_casks_args" do
|
||||
describe "brew bump-unversioned-casks" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -4,9 +4,7 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "brew bump" do
|
||||
describe "Homebrew.bump_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
describe "formula", :integration_test, :needs_network do
|
||||
it "returns data for single valid specified formula" do
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.cat_args" do
|
||||
describe "brew cat" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew cat", :integration_test do
|
||||
it "prints the content of a given Formula" do
|
||||
it "prints the content of a given Formula", :integration_test do
|
||||
formula_file = setup_test_formula "testball"
|
||||
content = formula_file.read
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.command_args" do
|
||||
describe "brew command" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew command", :integration_test do
|
||||
it "returns the file for a given command" do
|
||||
it "returns the file for a given command", :integration_test do
|
||||
expect { brew "command", "info" }
|
||||
.to output(%r{#{Regexp.escape(HOMEBREW_LIBRARY_PATH)}/cmd/info.rb}o).to_stdout
|
||||
.and be_a_success
|
||||
|
||||
@ -3,15 +3,13 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.create_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew create", :integration_test do
|
||||
describe "brew create" 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
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "creates a new Formula file for a given URL", :integration_test do
|
||||
brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
|
||||
|
||||
expect(formula_file).to exist
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.dispatch_build_bottle_args" do
|
||||
describe "brew dispatch-build-bottle" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.edit_args" do
|
||||
describe "brew edit" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew edit", :integration_test do
|
||||
it "opens a given Formula in an editor" do
|
||||
it "opens a given Formula in an editor", :integration_test do
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "init"
|
||||
end
|
||||
|
||||
@ -3,57 +3,57 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.extract_args" do
|
||||
describe "brew extract" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew extract", :integration_test do
|
||||
let!(:target) do
|
||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
(path/"Formula").mkpath
|
||||
target = Tap.from_path(path)
|
||||
core_tap = CoreTap.new
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
formula_file = setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
contents = File.read(formula_file)
|
||||
contents.gsub!("testball-0.1", "testball-0.2")
|
||||
File.write(formula_file, contents)
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.2"
|
||||
context "when extracting a formula" do
|
||||
let!(:target) do
|
||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
(path/"Formula").mkpath
|
||||
target = Tap.from_path(path)
|
||||
core_tap = CoreTap.new
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
formula_file = setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
contents = File.read(formula_file)
|
||||
contents.gsub!("testball-0.1", "testball-0.2")
|
||||
File.write(formula_file, contents)
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.2"
|
||||
end
|
||||
{ name: target.name, path: path }
|
||||
end
|
||||
{ name: target.name, path: path }
|
||||
end
|
||||
|
||||
it "retrieves the most recent version of formula" do
|
||||
path = target[:path]/"Formula/testball@0.2.rb"
|
||||
expect { brew "extract", "testball", target[:name] }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.2"
|
||||
end
|
||||
it "retrieves the most recent version of formula", :integration_test do
|
||||
path = target[:path]/"Formula/testball@0.2.rb"
|
||||
expect { brew "extract", "testball", target[:name] }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.2"
|
||||
end
|
||||
|
||||
it "retrieves the specified version of formula" do
|
||||
path = target[:path]/"Formula/testball@0.1.rb"
|
||||
expect { brew "extract", "testball", target[:name], "--version=0.1" }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.1"
|
||||
end
|
||||
it "retrieves the specified version of formula", :integration_test do
|
||||
path = target[:path]/"Formula/testball@0.1.rb"
|
||||
expect { brew "extract", "testball", target[:name], "--version=0.1" }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.1"
|
||||
end
|
||||
|
||||
it "retrieves the compatible version of formula" do
|
||||
path = target[:path]/"Formula/testball@0.rb"
|
||||
expect { brew "extract", "testball", target[:name], "--version=0" }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.2"
|
||||
it "retrieves the compatible version of formula", :integration_test do
|
||||
path = target[:path]/"Formula/testball@0.rb"
|
||||
expect { brew "extract", "testball", target[:name], "--version=0" }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.2"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.formula_args" do
|
||||
describe "brew formula" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew formula", :integration_test do
|
||||
it "prints a given Formula's path" do
|
||||
it "prints a given Formula's path", :integration_test do
|
||||
formula_file = setup_test_formula "testball"
|
||||
|
||||
expect { brew "formula", "testball" }
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.irb_args" do
|
||||
describe "brew irb" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew irb", :integration_test do
|
||||
it "starts an interactive Homebrew shell session" do
|
||||
it "starts an interactive Homebrew shell session", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
irb_test = HOMEBREW_TEMP/"irb-test.rb"
|
||||
|
||||
@ -3,17 +3,13 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.linkage_args" do
|
||||
describe "brew linkage" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew linkage", :integration_test do
|
||||
before do
|
||||
it "works when no arguments are provided", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||
end
|
||||
|
||||
it "works when no arguments are provided" do
|
||||
expect { brew "linkage" }
|
||||
.to be_a_success
|
||||
.and not_to_output.to_stdout
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.livecheck_args" do
|
||||
describe "brew livecheck" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew livecheck", :integration_test do
|
||||
it "reports the latest version of a Formula", :needs_network do
|
||||
it "reports the latest version of a Formula", :integration_test, :needs_network do
|
||||
content = <<~RUBY
|
||||
desc "Some test"
|
||||
homepage "https://github.com/Homebrew/brew"
|
||||
@ -22,7 +20,7 @@ describe "brew livecheck", :integration_test do
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "gives an error when no arguments are given and there's no watchlist" do
|
||||
it "gives an error when no arguments are given and there's no watchlist", :integration_test do
|
||||
expect { brew "livecheck" }
|
||||
.to output(/Invalid usage: A watchlist file is required when no arguments are given\./).to_stderr
|
||||
.and not_to_output.to_stdout
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.man_args" do
|
||||
describe "brew man" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.mirror_args" do
|
||||
describe "brew mirror" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.pr_automerge_args" do
|
||||
describe "brew pr-automerge" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.pr_publish_args" do
|
||||
describe "brew pr-publish" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -6,100 +6,100 @@ require "utils/git"
|
||||
require "tap"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe Homebrew do
|
||||
let(:formula_rebuild) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
desc "Helpful description"
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula_revision) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
revision 1
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula_version) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-2.0.tgz"
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula_file) { path/"Formula/foo.rb" }
|
||||
let(:path) { (Tap::TAP_DIRECTORY/"homebrew/homebrew-foo").extend(GitRepositoryExtension) }
|
||||
describe "brew pr-pull" do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
describe "Homebrew.pr_pull_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
describe Homebrew do
|
||||
let(:formula_rebuild) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
desc "Helpful description"
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula_revision) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
revision 1
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula_version) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-2.0.tgz"
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula) do
|
||||
<<~EOS
|
||||
class Foo < Formula
|
||||
url "https://brew.sh/foo-1.0.tgz"
|
||||
end
|
||||
EOS
|
||||
end
|
||||
let(:formula_file) { path/"Formula/foo.rb" }
|
||||
let(:path) { (Tap::TAP_DIRECTORY/"homebrew/homebrew-foo").extend(GitRepositoryExtension) }
|
||||
|
||||
describe "#autosquash!" do
|
||||
it "squashes a formula correctly" do
|
||||
secondary_author = "Someone Else <me@example.com>"
|
||||
(path/"Formula").mkpath
|
||||
formula_file.write(formula)
|
||||
cd path do
|
||||
safe_system Utils::Git.git, "init"
|
||||
safe_system Utils::Git.git, "add", formula_file
|
||||
safe_system Utils::Git.git, "commit", "-m", "foo 1.0 (new formula)"
|
||||
original_hash = `git rev-parse HEAD`.chomp
|
||||
File.open(formula_file, "w") { |f| f.write(formula_revision) }
|
||||
safe_system Utils::Git.git, "commit", formula_file, "-m", "revision"
|
||||
File.open(formula_file, "w") { |f| f.write(formula_version) }
|
||||
safe_system Utils::Git.git, "commit", formula_file, "-m", "version", "--author=#{secondary_author}"
|
||||
described_class.autosquash!(original_hash, path: path)
|
||||
expect(path.git_commit_message).to include("foo 2.0")
|
||||
expect(path.git_commit_message).to include("Co-authored-by: #{secondary_author}")
|
||||
describe "#autosquash!" do
|
||||
it "squashes a formula correctly" do
|
||||
secondary_author = "Someone Else <me@example.com>"
|
||||
(path/"Formula").mkpath
|
||||
formula_file.write(formula)
|
||||
cd path do
|
||||
safe_system Utils::Git.git, "init"
|
||||
safe_system Utils::Git.git, "add", formula_file
|
||||
safe_system Utils::Git.git, "commit", "-m", "foo 1.0 (new formula)"
|
||||
original_hash = `git rev-parse HEAD`.chomp
|
||||
File.open(formula_file, "w") { |f| f.write(formula_revision) }
|
||||
safe_system Utils::Git.git, "commit", formula_file, "-m", "revision"
|
||||
File.open(formula_file, "w") { |f| f.write(formula_version) }
|
||||
safe_system Utils::Git.git, "commit", formula_file, "-m", "version", "--author=#{secondary_author}"
|
||||
described_class.autosquash!(original_hash, path: path)
|
||||
expect(path.git_commit_message).to include("foo 2.0")
|
||||
expect(path.git_commit_message).to include("Co-authored-by: #{secondary_author}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#signoff!" do
|
||||
it "signs off a formula" do
|
||||
(path/"Formula").mkpath
|
||||
formula_file.write(formula)
|
||||
cd path do
|
||||
safe_system Utils::Git.git, "init"
|
||||
safe_system Utils::Git.git, "add", formula_file
|
||||
safe_system Utils::Git.git, "commit", "-m", "foo 1.0 (new formula)"
|
||||
describe "#signoff!" do
|
||||
it "signs off a formula" do
|
||||
(path/"Formula").mkpath
|
||||
formula_file.write(formula)
|
||||
cd path do
|
||||
safe_system Utils::Git.git, "init"
|
||||
safe_system Utils::Git.git, "add", formula_file
|
||||
safe_system Utils::Git.git, "commit", "-m", "foo 1.0 (new formula)"
|
||||
end
|
||||
described_class.signoff!(path)
|
||||
expect(path.git_commit_message).to include("Signed-off-by:")
|
||||
end
|
||||
described_class.signoff!(path)
|
||||
expect(path.git_commit_message).to include("Signed-off-by:")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#determine_bump_subject" do
|
||||
it "correctly bumps a new formula" do
|
||||
expect(described_class.determine_bump_subject("", formula, formula_file)).to eq("foo 1.0 (new formula)")
|
||||
end
|
||||
|
||||
it "correctly bumps a formula version" do
|
||||
expect(described_class.determine_bump_subject(formula, formula_version, formula_file)).to eq("foo 2.0")
|
||||
end
|
||||
describe "#determine_bump_subject" do
|
||||
it "correctly bumps a new formula" do
|
||||
expect(described_class.determine_bump_subject("", formula, formula_file)).to eq("foo 1.0 (new formula)")
|
||||
end
|
||||
|
||||
it "correctly bumps a formula revision with reason" do
|
||||
expect(described_class.determine_bump_subject(
|
||||
formula, formula_revision, formula_file, reason: "for fun"
|
||||
)).to eq("foo: revision for fun")
|
||||
end
|
||||
it "correctly bumps a formula version" do
|
||||
expect(described_class.determine_bump_subject(formula, formula_version, formula_file)).to eq("foo 2.0")
|
||||
end
|
||||
|
||||
it "correctly bumps a formula rebuild" do
|
||||
expect(described_class.determine_bump_subject(formula, formula_rebuild, formula_file)).to eq("foo: rebuild")
|
||||
end
|
||||
it "correctly bumps a formula revision with reason" do
|
||||
expect(described_class.determine_bump_subject(
|
||||
formula, formula_revision, formula_file, reason: "for fun"
|
||||
)).to eq("foo: revision for fun")
|
||||
end
|
||||
|
||||
it "correctly bumps a formula deletion" do
|
||||
expect(described_class.determine_bump_subject(formula, "", formula_file)).to eq("foo: delete")
|
||||
it "correctly bumps a formula rebuild" do
|
||||
expect(described_class.determine_bump_subject(formula, formula_rebuild, formula_file)).to eq("foo: rebuild")
|
||||
end
|
||||
|
||||
it "correctly bumps a formula deletion" do
|
||||
expect(described_class.determine_bump_subject(formula, "", formula_file)).to eq("foo: delete")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.pr_upload_args" do
|
||||
describe "brew pr-upload" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.prof_args" do
|
||||
describe "brew prof" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.release_notes_args" do
|
||||
describe "brew release-notes" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.release_args" do
|
||||
describe "brew release" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,30 +3,28 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.ruby_args" do
|
||||
describe "brew ruby" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew ruby", :integration_test do
|
||||
it "executes ruby code with Homebrew's libraries loaded" do
|
||||
it "executes ruby code with Homebrew's libraries loaded", :integration_test do
|
||||
expect { brew "ruby", "-e", "exit 0" }
|
||||
.to be_a_success
|
||||
.and not_to_output.to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
end
|
||||
end
|
||||
|
||||
# Doesn't actually need Linux but only running there as integration tests are slow.
|
||||
describe "brew ruby -e 'puts \"testball\".f.path'", :integration_test, :needs_linux do
|
||||
let!(:target) do
|
||||
target_path = setup_test_formula "testball"
|
||||
{ path: target_path }
|
||||
end
|
||||
# Doesn't actually need Linux but only running there as integration tests are slow.
|
||||
describe "-e 'puts \"testball\".f.path'", :integration_test, :needs_linux do
|
||||
let!(:target) do
|
||||
target_path = setup_test_formula "testball"
|
||||
{ path: target_path }
|
||||
end
|
||||
|
||||
it "prints the path of a test formula" do
|
||||
expect { brew "ruby", "-e", "puts 'testball'.f.path" }
|
||||
.to be_a_success
|
||||
.and output(/^#{target[:path]}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
it "prints the path of a test formula" do
|
||||
expect { brew "ruby", "-e", "puts 'testball'.f.path" }
|
||||
.to be_a_success
|
||||
.and output(/^#{target[:path]}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.sh_args" do
|
||||
describe "brew sh" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew sh", :integration_test do
|
||||
it "runs a shell with the Homebrew environment" do
|
||||
it "runs a shell with the Homebrew environment", :integration_test do
|
||||
expect { brew "sh", "SHELL" => which("true") }
|
||||
.to output(/Your shell has been configured/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.sponsors_args" do
|
||||
describe "brew sponsors" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.style_args" do
|
||||
describe "brew style" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.tap_new_args" do
|
||||
describe "brew tap-new" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew tap-new", :integration_test do
|
||||
it "initializes a new tap with a README file and GitHub Actions CI" do
|
||||
it "initializes a new tap with a README file and GitHub Actions CI", :integration_test do
|
||||
expect { brew "tap-new", "homebrew/foo", "--verbose" }
|
||||
.to be_a_success
|
||||
.and output(%r{homebrew/foo}).to_stdout
|
||||
|
||||
@ -3,13 +3,11 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.test_args" do
|
||||
describe "brew test" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
# randomly segfaults on Linux with portable-ruby.
|
||||
describe "brew test", :integration_test, :needs_macos do
|
||||
it "tests a given Formula" do
|
||||
# randomly segfaults on Linux with portable-ruby.
|
||||
it "tests a given Formula", :integration_test, :needs_macos do
|
||||
install_test_formula "testball", <<~'RUBY'
|
||||
test do
|
||||
assert_equal "test", shell_output("#{bin}/test")
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.typecheck_args" do
|
||||
describe "brew typecheck" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.unbottled_args" do
|
||||
describe "brew unbottled" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.unpack_args" do
|
||||
describe "brew unpack" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew unpack", :integration_test do
|
||||
it "unpacks a given Formula's archive" do
|
||||
it "unpacks a given Formula's archive", :integration_test do
|
||||
setup_test_formula "testball"
|
||||
|
||||
mktmpdir do |path|
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.update_license_data_args" do
|
||||
describe "brew update-license-data" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "brew update-python-resources" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
@ -3,6 +3,6 @@
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.vendor_gems_args" do
|
||||
describe "brew vendor-gems" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user