From 4a82d807e1df616508523d75caf7dd14b0ee3c54 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Mon, 1 Feb 2021 16:14:25 -0500 Subject: [PATCH] style: remove RSpec/MultipleDescribes violations in commands --- Library/Homebrew/test/cmd/--cache_spec.rb | 10 +- Library/Homebrew/test/cmd/--cellar_spec.rb | 6 +- Library/Homebrew/test/cmd/--env_spec.rb | 6 +- Library/Homebrew/test/cmd/--prefix_spec.rb | 10 +- .../Homebrew/test/cmd/--repository_spec.rb | 6 +- Library/Homebrew/test/cmd/--version_spec.rb | 6 +- Library/Homebrew/test/cmd/analytics_spec.rb | 6 +- Library/Homebrew/test/cmd/autoremove_spec.rb | 2 +- Library/Homebrew/test/cmd/cleanup_spec.rb | 10 +- Library/Homebrew/test/cmd/commands_spec.rb | 6 +- Library/Homebrew/test/cmd/completions_spec.rb | 4 +- Library/Homebrew/test/cmd/config_spec.rb | 6 +- Library/Homebrew/test/cmd/deps_spec.rb | 6 +- Library/Homebrew/test/cmd/desc_spec.rb | 6 +- Library/Homebrew/test/cmd/doctor_spec.rb | 6 +- Library/Homebrew/test/cmd/fetch_spec.rb | 6 +- Library/Homebrew/test/cmd/gist-logs_spec.rb | 2 +- Library/Homebrew/test/cmd/home_spec.rb | 16 +- Library/Homebrew/test/cmd/info_spec.rb | 34 +- Library/Homebrew/test/cmd/install_spec.rb | 12 +- Library/Homebrew/test/cmd/leaves_spec.rb | 10 +- Library/Homebrew/test/cmd/link_spec.rb | 6 +- Library/Homebrew/test/cmd/list_spec.rb | 10 +- Library/Homebrew/test/cmd/log_spec.rb | 6 +- Library/Homebrew/test/cmd/migrate_spec.rb | 6 +- Library/Homebrew/test/cmd/missing_spec.rb | 6 +- Library/Homebrew/test/cmd/options_spec.rb | 6 +- Library/Homebrew/test/cmd/outdated_spec.rb | 6 +- Library/Homebrew/test/cmd/pin_spec.rb | 6 +- Library/Homebrew/test/cmd/postinstall_spec.rb | 2 +- Library/Homebrew/test/cmd/readall_spec.rb | 6 +- Library/Homebrew/test/cmd/reinstall_spec.rb | 6 +- Library/Homebrew/test/cmd/search_spec.rb | 8 +- .../test/cmd/shared_examples/args_parse.rb | 10 +- Library/Homebrew/test/cmd/tap-info_spec.rb | 6 +- Library/Homebrew/test/cmd/tap_spec.rb | 6 +- Library/Homebrew/test/cmd/uninstall_spec.rb | 6 +- Library/Homebrew/test/cmd/unlink_spec.rb | 6 +- Library/Homebrew/test/cmd/unpin_spec.rb | 6 +- Library/Homebrew/test/cmd/untap_spec.rb | 6 +- .../Homebrew/test/cmd/update-report_spec.rb | 206 ++--- Library/Homebrew/test/cmd/upgrade_spec.rb | 6 +- Library/Homebrew/test/cmd/uses_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/audit_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/bottle_spec.rb | 870 +++++++++--------- .../test/dev-cmd/bump-cask-pr_spec.rb | 2 +- .../test/dev-cmd/bump-formula-pr_spec.rb | 2 +- .../test/dev-cmd/bump-revision_spec.rb | 2 +- .../dev-cmd/bump-unversioned-casks_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/bump_spec.rb | 4 +- Library/Homebrew/test/dev-cmd/cat_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/command_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/create_spec.rb | 10 +- .../dev-cmd/dispatch-build-bottle_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/edit_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/extract_spec.rb | 92 +- Library/Homebrew/test/dev-cmd/formula_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/irb_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/linkage_spec.rb | 8 +- .../Homebrew/test/dev-cmd/livecheck_spec.rb | 8 +- Library/Homebrew/test/dev-cmd/man_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/mirror_spec.rb | 2 +- .../test/dev-cmd/pr-automerge_spec.rb | 2 +- .../Homebrew/test/dev-cmd/pr-publish_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/pr-pull_spec.rb | 166 ++-- .../Homebrew/test/dev-cmd/pr-upload_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/prof_spec.rb | 2 +- .../test/dev-cmd/release-notes_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/release_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/ruby_spec.rb | 30 +- Library/Homebrew/test/dev-cmd/sh_spec.rb | 6 +- .../Homebrew/test/dev-cmd/sponsors_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/style_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/tap-new_spec.rb | 6 +- Library/Homebrew/test/dev-cmd/test_spec.rb | 8 +- .../Homebrew/test/dev-cmd/typecheck_spec.rb | 2 +- .../Homebrew/test/dev-cmd/unbottled_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/unpack_spec.rb | 6 +- .../test/dev-cmd/update-license-data_spec.rb | 2 +- .../dev-cmd/update-python-resources_spec.rb | 8 + .../Homebrew/test/dev-cmd/vendor-gems_spec.rb | 2 +- 81 files changed, 852 insertions(+), 954 deletions(-) create mode 100644 Library/Homebrew/test/dev-cmd/update-python-resources_spec.rb diff --git a/Library/Homebrew/test/cmd/--cache_spec.rb b/Library/Homebrew/test/cmd/--cache_spec.rb index b8df0c2fda..410ca72f18 100644 --- a/Library/Homebrew/test/cmd/--cache_spec.rb +++ b/Library/Homebrew/test/cmd/--cache_spec.rb @@ -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{ diff --git a/Library/Homebrew/test/cmd/--cellar_spec.rb b/Library/Homebrew/test/cmd/--cellar_spec.rb index c558c684a8..a91b8ecd3f 100644 --- a/Library/Homebrew/test/cmd/--cellar_spec.rb +++ b/Library/Homebrew/test/cmd/--cellar_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/--env_spec.rb b/Library/Homebrew/test/cmd/--env_spec.rb index d7cd44dbc2..fd8a94fb5f 100644 --- a/Library/Homebrew/test/cmd/--env_spec.rb +++ b/Library/Homebrew/test/cmd/--env_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/--prefix_spec.rb b/Library/Homebrew/test/cmd/--prefix_spec.rb index d0ed2f9422..4759af5954 100644 --- a/Library/Homebrew/test/cmd/--prefix_spec.rb +++ b/Library/Homebrew/test/cmd/--prefix_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/--repository_spec.rb b/Library/Homebrew/test/cmd/--repository_spec.rb index cb2f750247..d8c63aaaf8 100644 --- a/Library/Homebrew/test/cmd/--repository_spec.rb +++ b/Library/Homebrew/test/cmd/--repository_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/--version_spec.rb b/Library/Homebrew/test/cmd/--version_spec.rb index 11e91912e8..0717854349 100644 --- a/Library/Homebrew/test/cmd/--version_spec.rb +++ b/Library/Homebrew/test/cmd/--version_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/analytics_spec.rb b/Library/Homebrew/test/cmd/analytics_spec.rb index 519f366c42..dc4605bec7 100644 --- a/Library/Homebrew/test/cmd/analytics_spec.rb +++ b/Library/Homebrew/test/cmd/analytics_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/autoremove_spec.rb b/Library/Homebrew/test/cmd/autoremove_spec.rb index 4cd9c99f51..24069e0bb7 100644 --- a/Library/Homebrew/test/cmd/autoremove_spec.rb +++ b/Library/Homebrew/test/cmd/autoremove_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/cleanup_spec.rb b/Library/Homebrew/test/cmd/cleanup_spec.rb index d1906e5562..d9b8752e3b 100644 --- a/Library/Homebrew/test/cmd/cleanup_spec.rb +++ b/Library/Homebrew/test/cmd/cleanup_spec.rb @@ -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" diff --git a/Library/Homebrew/test/cmd/commands_spec.rb b/Library/Homebrew/test/cmd/commands_spec.rb index fb049969e7..55742996f9 100644 --- a/Library/Homebrew/test/cmd/commands_spec.rb +++ b/Library/Homebrew/test/cmd/commands_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/completions_spec.rb b/Library/Homebrew/test/cmd/completions_spec.rb index 721fa184ae..a1ab341d50 100644 --- a/Library/Homebrew/test/cmd/completions_spec.rb +++ b/Library/Homebrew/test/cmd/completions_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/config_spec.rb b/Library/Homebrew/test/cmd/config_spec.rb index 843c2a52a5..e4afba0353 100644 --- a/Library/Homebrew/test/cmd/config_spec.rb +++ b/Library/Homebrew/test/cmd/config_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/deps_spec.rb b/Library/Homebrew/test/cmd/deps_spec.rb index 540b82c51d..e04e698479 100644 --- a/Library/Homebrew/test/cmd/deps_spec.rb +++ b/Library/Homebrew/test/cmd/deps_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/desc_spec.rb b/Library/Homebrew/test/cmd/desc_spec.rb index c9e7898dc5..efb364b17b 100644 --- a/Library/Homebrew/test/cmd/desc_spec.rb +++ b/Library/Homebrew/test/cmd/desc_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/doctor_spec.rb b/Library/Homebrew/test/cmd/doctor_spec.rb index 3d0bb60203..000cd79072 100644 --- a/Library/Homebrew/test/cmd/doctor_spec.rb +++ b/Library/Homebrew/test/cmd/doctor_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/fetch_spec.rb b/Library/Homebrew/test/cmd/fetch_spec.rb index 237a769b3d..cdc4b870fb 100644 --- a/Library/Homebrew/test/cmd/fetch_spec.rb +++ b/Library/Homebrew/test/cmd/fetch_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/gist-logs_spec.rb b/Library/Homebrew/test/cmd/gist-logs_spec.rb index 10a9d0d30a..f1d628f9e1 100644 --- a/Library/Homebrew/test/cmd/gist-logs_spec.rb +++ b/Library/Homebrew/test/cmd/gist-logs_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/home_spec.rb b/Library/Homebrew/test/cmd/home_spec.rb index 6365cad537..57c6eb70b0 100644 --- a/Library/Homebrew/test/cmd/home_spec.rb +++ b/Library/Homebrew/test/cmd/home_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/info_spec.rb b/Library/Homebrew/test/cmd/info_spec.rb index 83db3945f0..9189b106d9 100644 --- a/Library/Homebrew/test/cmd/info_spec.rb +++ b/Library/Homebrew/test/cmd/info_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index c17cc00ee7..560bc3393c 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/leaves_spec.rb b/Library/Homebrew/test/cmd/leaves_spec.rb index 705a85c7d3..e8afbabed6 100644 --- a/Library/Homebrew/test/cmd/leaves_spec.rb +++ b/Library/Homebrew/test/cmd/leaves_spec.rb @@ -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" diff --git a/Library/Homebrew/test/cmd/link_spec.rb b/Library/Homebrew/test/cmd/link_spec.rb index 650fbb046e..021294dd4d 100644 --- a/Library/Homebrew/test/cmd/link_spec.rb +++ b/Library/Homebrew/test/cmd/link_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/list_spec.rb b/Library/Homebrew/test/cmd/list_spec.rb index a06fa06156..7c8d55610f 100644 --- a/Library/Homebrew/test/cmd/list_spec.rb +++ b/Library/Homebrew/test/cmd/list_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/log_spec.rb b/Library/Homebrew/test/cmd/log_spec.rb index d989c260f9..909109bd8a 100644 --- a/Library/Homebrew/test/cmd/log_spec.rb +++ b/Library/Homebrew/test/cmd/log_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/migrate_spec.rb b/Library/Homebrew/test/cmd/migrate_spec.rb index fce8954712..a562f4b9fc 100644 --- a/Library/Homebrew/test/cmd/migrate_spec.rb +++ b/Library/Homebrew/test/cmd/migrate_spec.rb @@ -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" diff --git a/Library/Homebrew/test/cmd/missing_spec.rb b/Library/Homebrew/test/cmd/missing_spec.rb index 0a5a6bb7b4..ab93d64ea2 100644 --- a/Library/Homebrew/test/cmd/missing_spec.rb +++ b/Library/Homebrew/test/cmd/missing_spec.rb @@ -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" diff --git a/Library/Homebrew/test/cmd/options_spec.rb b/Library/Homebrew/test/cmd/options_spec.rb index 9a3b495165..7205437d85 100644 --- a/Library/Homebrew/test/cmd/options_spec.rb +++ b/Library/Homebrew/test/cmd/options_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/outdated_spec.rb b/Library/Homebrew/test/cmd/outdated_spec.rb index ba4becf50c..87513a3eb8 100644 --- a/Library/Homebrew/test/cmd/outdated_spec.rb +++ b/Library/Homebrew/test/cmd/outdated_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/pin_spec.rb b/Library/Homebrew/test/cmd/pin_spec.rb index ad42715a3c..efaf4755ff 100644 --- a/Library/Homebrew/test/cmd/pin_spec.rb +++ b/Library/Homebrew/test/cmd/pin_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/postinstall_spec.rb b/Library/Homebrew/test/cmd/postinstall_spec.rb index 9be2e1288d..a705e44db8 100644 --- a/Library/Homebrew/test/cmd/postinstall_spec.rb +++ b/Library/Homebrew/test/cmd/postinstall_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/readall_spec.rb b/Library/Homebrew/test/cmd/readall_spec.rb index 046a8cbf4c..845acd1058 100644 --- a/Library/Homebrew/test/cmd/readall_spec.rb +++ b/Library/Homebrew/test/cmd/readall_spec.rb @@ -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" diff --git a/Library/Homebrew/test/cmd/reinstall_spec.rb b/Library/Homebrew/test/cmd/reinstall_spec.rb index f88fd0d3de..764f9db9bb 100644 --- a/Library/Homebrew/test/cmd/reinstall_spec.rb +++ b/Library/Homebrew/test/cmd/reinstall_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/search_spec.rb b/Library/Homebrew/test/cmd/search_spec.rb index 724a3ff0b9..01b33a088b 100644 --- a/Library/Homebrew/test/cmd/search_spec.rb +++ b/Library/Homebrew/test/cmd/search_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/shared_examples/args_parse.rb b/Library/Homebrew/test/cmd/shared_examples/args_parse.rb index 1df6117ad1..064e20ea7f 100644 --- a/Library/Homebrew/test/cmd/shared_examples/args_parse.rb +++ b/Library/Homebrew/test/cmd/shared_examples/args_parse.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/tap-info_spec.rb b/Library/Homebrew/test/cmd/tap-info_spec.rb index e2c1bebcac..bc1a68a4a6 100644 --- a/Library/Homebrew/test/cmd/tap-info_spec.rb +++ b/Library/Homebrew/test/cmd/tap-info_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/tap_spec.rb b/Library/Homebrew/test/cmd/tap_spec.rb index e54e91a5ff..1f2c389680 100644 --- a/Library/Homebrew/test/cmd/tap_spec.rb +++ b/Library/Homebrew/test/cmd/tap_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/uninstall_spec.rb b/Library/Homebrew/test/cmd/uninstall_spec.rb index d05f4025d0..c7947d5058 100644 --- a/Library/Homebrew/test/cmd/uninstall_spec.rb +++ b/Library/Homebrew/test/cmd/uninstall_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/unlink_spec.rb b/Library/Homebrew/test/cmd/unlink_spec.rb index 090a091a0c..7c6248d103 100644 --- a/Library/Homebrew/test/cmd/unlink_spec.rb +++ b/Library/Homebrew/test/cmd/unlink_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/unpin_spec.rb b/Library/Homebrew/test/cmd/unpin_spec.rb index e1aa11d677..4bf0de0419 100644 --- a/Library/Homebrew/test/cmd/unpin_spec.rb +++ b/Library/Homebrew/test/cmd/unpin_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/untap_spec.rb b/Library/Homebrew/test/cmd/untap_spec.rb index d637d960bc..2762d110d3 100644 --- a/Library/Homebrew/test/cmd/untap_spec.rb +++ b/Library/Homebrew/test/cmd/untap_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/cmd/update-report_spec.rb b/Library/Homebrew/test/cmd/update-report_spec.rb index 548d0e8457..c31b6e32ec 100644 --- a/Library/Homebrew/test/cmd/update-report_spec.rb +++ b/Library/Homebrew/test/cmd/update-report_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/upgrade_spec.rb b/Library/Homebrew/test/cmd/upgrade_spec.rb index f03b919a9d..b87dc988d4 100644 --- a/Library/Homebrew/test/cmd/upgrade_spec.rb +++ b/Library/Homebrew/test/cmd/upgrade_spec.rb @@ -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 diff --git a/Library/Homebrew/test/cmd/uses_spec.rb b/Library/Homebrew/test/cmd/uses_spec.rb index 1b1341067c..c0526538a9 100644 --- a/Library/Homebrew/test/cmd/uses_spec.rb +++ b/Library/Homebrew/test/cmd/uses_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index efd46f8e61..2efd90abd6 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/bottle_spec.rb b/Library/Homebrew/test/dev-cmd/bottle_spec.rb index 155b6219bd..3aa399ddb1 100644 --- a/Library/Homebrew/test/dev-cmd/bottle_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bottle_spec.rb @@ -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 \\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 \\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 \\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 \\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 \\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 \\nint main(){printf(\\"test\\");return 0;}" - bin.mkpath - system ENV.cc, "test.c", "-o", bin/"test" - end - - - - # something here - - end - EOS - end -end diff --git a/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb b/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb index 02ae9e8a9a..1843f20d89 100644 --- a/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump-cask-pr_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb b/Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb index 08d0907501..d785384142 100644 --- a/Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/bump-revision_spec.rb b/Library/Homebrew/test/dev-cmd/bump-revision_spec.rb index 51324ce3e7..13f8cbe136 100644 --- a/Library/Homebrew/test/dev-cmd/bump-revision_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump-revision_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb b/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb index 40ab7dee74..50b45159a7 100644 --- a/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump-unversioned-casks_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/bump_spec.rb b/Library/Homebrew/test/dev-cmd/bump_spec.rb index c4265dfe88..d3daa15e98 100644 --- a/Library/Homebrew/test/dev-cmd/bump_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/cat_spec.rb b/Library/Homebrew/test/dev-cmd/cat_spec.rb index fdeb97091a..6a5d6a6d79 100644 --- a/Library/Homebrew/test/dev-cmd/cat_spec.rb +++ b/Library/Homebrew/test/dev-cmd/cat_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/command_spec.rb b/Library/Homebrew/test/dev-cmd/command_spec.rb index 87c9dd61f3..7608269e1b 100644 --- a/Library/Homebrew/test/dev-cmd/command_spec.rb +++ b/Library/Homebrew/test/dev-cmd/command_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/create_spec.rb b/Library/Homebrew/test/dev-cmd/create_spec.rb index 54edd4b9e0..669a0b934a 100644 --- a/Library/Homebrew/test/dev-cmd/create_spec.rb +++ b/Library/Homebrew/test/dev-cmd/create_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/dispatch-build-bottle_spec.rb b/Library/Homebrew/test/dev-cmd/dispatch-build-bottle_spec.rb index 903f36c0a1..18363e6777 100644 --- a/Library/Homebrew/test/dev-cmd/dispatch-build-bottle_spec.rb +++ b/Library/Homebrew/test/dev-cmd/dispatch-build-bottle_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/edit_spec.rb b/Library/Homebrew/test/dev-cmd/edit_spec.rb index 2e8a96ea6a..59e1eebea6 100644 --- a/Library/Homebrew/test/dev-cmd/edit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/edit_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/extract_spec.rb b/Library/Homebrew/test/dev-cmd/extract_spec.rb index 5563f6079e..214db27b9f 100644 --- a/Library/Homebrew/test/dev-cmd/extract_spec.rb +++ b/Library/Homebrew/test/dev-cmd/extract_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/formula_spec.rb b/Library/Homebrew/test/dev-cmd/formula_spec.rb index e52fb82670..90af8e18be 100644 --- a/Library/Homebrew/test/dev-cmd/formula_spec.rb +++ b/Library/Homebrew/test/dev-cmd/formula_spec.rb @@ -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" } diff --git a/Library/Homebrew/test/dev-cmd/irb_spec.rb b/Library/Homebrew/test/dev-cmd/irb_spec.rb index 1d39e2d70c..9025117d54 100644 --- a/Library/Homebrew/test/dev-cmd/irb_spec.rb +++ b/Library/Homebrew/test/dev-cmd/irb_spec.rb @@ -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" diff --git a/Library/Homebrew/test/dev-cmd/linkage_spec.rb b/Library/Homebrew/test/dev-cmd/linkage_spec.rb index 1663e42c42..544042408b 100644 --- a/Library/Homebrew/test/dev-cmd/linkage_spec.rb +++ b/Library/Homebrew/test/dev-cmd/linkage_spec.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 diff --git a/Library/Homebrew/test/dev-cmd/livecheck_spec.rb b/Library/Homebrew/test/dev-cmd/livecheck_spec.rb index 56a9509f0a..abc76ac56f 100644 --- a/Library/Homebrew/test/dev-cmd/livecheck_spec.rb +++ b/Library/Homebrew/test/dev-cmd/livecheck_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/man_spec.rb b/Library/Homebrew/test/dev-cmd/man_spec.rb index 29523d832d..f95903e776 100644 --- a/Library/Homebrew/test/dev-cmd/man_spec.rb +++ b/Library/Homebrew/test/dev-cmd/man_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/mirror_spec.rb b/Library/Homebrew/test/dev-cmd/mirror_spec.rb index bc6af40e28..ef532d66f4 100644 --- a/Library/Homebrew/test/dev-cmd/mirror_spec.rb +++ b/Library/Homebrew/test/dev-cmd/mirror_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/pr-automerge_spec.rb b/Library/Homebrew/test/dev-cmd/pr-automerge_spec.rb index df6b0ef668..251f08c6ae 100644 --- a/Library/Homebrew/test/dev-cmd/pr-automerge_spec.rb +++ b/Library/Homebrew/test/dev-cmd/pr-automerge_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/pr-publish_spec.rb b/Library/Homebrew/test/dev-cmd/pr-publish_spec.rb index f0021f0f45..0d4c288f68 100644 --- a/Library/Homebrew/test/dev-cmd/pr-publish_spec.rb +++ b/Library/Homebrew/test/dev-cmd/pr-publish_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb b/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb index 47a494a016..0784cab02a 100644 --- a/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb +++ b/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb @@ -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 " - (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 " + (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 diff --git a/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb b/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb index 54530b6095..62dc5e7164 100644 --- a/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb +++ b/Library/Homebrew/test/dev-cmd/pr-upload_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/prof_spec.rb b/Library/Homebrew/test/dev-cmd/prof_spec.rb index f4a3990e89..c8a62801ae 100644 --- a/Library/Homebrew/test/dev-cmd/prof_spec.rb +++ b/Library/Homebrew/test/dev-cmd/prof_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/release-notes_spec.rb b/Library/Homebrew/test/dev-cmd/release-notes_spec.rb index 21d1b29790..5e907105fd 100644 --- a/Library/Homebrew/test/dev-cmd/release-notes_spec.rb +++ b/Library/Homebrew/test/dev-cmd/release-notes_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/release_spec.rb b/Library/Homebrew/test/dev-cmd/release_spec.rb index 509e9a220e..613f48f150 100644 --- a/Library/Homebrew/test/dev-cmd/release_spec.rb +++ b/Library/Homebrew/test/dev-cmd/release_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/ruby_spec.rb b/Library/Homebrew/test/dev-cmd/ruby_spec.rb index bac9e7dc29..582c35dd7d 100644 --- a/Library/Homebrew/test/dev-cmd/ruby_spec.rb +++ b/Library/Homebrew/test/dev-cmd/ruby_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/sh_spec.rb b/Library/Homebrew/test/dev-cmd/sh_spec.rb index 8fa4a72a0d..682114d07b 100644 --- a/Library/Homebrew/test/dev-cmd/sh_spec.rb +++ b/Library/Homebrew/test/dev-cmd/sh_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/sponsors_spec.rb b/Library/Homebrew/test/dev-cmd/sponsors_spec.rb index bee8458429..cc50843f3e 100644 --- a/Library/Homebrew/test/dev-cmd/sponsors_spec.rb +++ b/Library/Homebrew/test/dev-cmd/sponsors_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/style_spec.rb b/Library/Homebrew/test/dev-cmd/style_spec.rb index 0fb6f90c1f..4cc0a879e7 100644 --- a/Library/Homebrew/test/dev-cmd/style_spec.rb +++ b/Library/Homebrew/test/dev-cmd/style_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/tap-new_spec.rb b/Library/Homebrew/test/dev-cmd/tap-new_spec.rb index bbad80d12f..4f3c229d28 100644 --- a/Library/Homebrew/test/dev-cmd/tap-new_spec.rb +++ b/Library/Homebrew/test/dev-cmd/tap-new_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/test_spec.rb b/Library/Homebrew/test/dev-cmd/test_spec.rb index 81f46c177b..bf4ee0660f 100644 --- a/Library/Homebrew/test/dev-cmd/test_spec.rb +++ b/Library/Homebrew/test/dev-cmd/test_spec.rb @@ -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") diff --git a/Library/Homebrew/test/dev-cmd/typecheck_spec.rb b/Library/Homebrew/test/dev-cmd/typecheck_spec.rb index 31c8c3b7fe..8f886bf81d 100644 --- a/Library/Homebrew/test/dev-cmd/typecheck_spec.rb +++ b/Library/Homebrew/test/dev-cmd/typecheck_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/unbottled_spec.rb b/Library/Homebrew/test/dev-cmd/unbottled_spec.rb index 6e54f948b3..d4b973cbd5 100644 --- a/Library/Homebrew/test/dev-cmd/unbottled_spec.rb +++ b/Library/Homebrew/test/dev-cmd/unbottled_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/unpack_spec.rb b/Library/Homebrew/test/dev-cmd/unpack_spec.rb index 0799686914..5ead154d5d 100644 --- a/Library/Homebrew/test/dev-cmd/unpack_spec.rb +++ b/Library/Homebrew/test/dev-cmd/unpack_spec.rb @@ -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| diff --git a/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb b/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb index 734ee4545a..e6ff0edb19 100644 --- a/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb +++ b/Library/Homebrew/test/dev-cmd/update-license-data_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/update-python-resources_spec.rb b/Library/Homebrew/test/dev-cmd/update-python-resources_spec.rb new file mode 100644 index 0000000000..4cf8610971 --- /dev/null +++ b/Library/Homebrew/test/dev-cmd/update-python-resources_spec.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/vendor-gems_spec.rb b/Library/Homebrew/test/dev-cmd/vendor-gems_spec.rb index dc6b9b1060..276026d4c4 100644 --- a/Library/Homebrew/test/dev-cmd/vendor-gems_spec.rb +++ b/Library/Homebrew/test/dev-cmd/vendor-gems_spec.rb @@ -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