Merge pull request #5938 from MikeMcQuaid/dev-cmd-tests
More dev-cmd tests cleanup
This commit is contained in:
commit
fffa7a37e6
@ -14,6 +14,8 @@ module Homebrew
|
||||
end
|
||||
|
||||
def prof
|
||||
prof_args.parse
|
||||
|
||||
Homebrew.install_gem_setup_path! "ruby-prof"
|
||||
FileUtils.mkdir_p "prof"
|
||||
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
require "extend/ENV"
|
||||
require "formula_assertions"
|
||||
require "sandbox"
|
||||
require "timeout"
|
||||
require "cli_parser"
|
||||
@ -31,8 +30,12 @@ module Homebrew
|
||||
end
|
||||
|
||||
def test
|
||||
test_args.parse
|
||||
|
||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||
|
||||
require "formula_assertions"
|
||||
|
||||
ARGV.resolved_formulae.each do |f|
|
||||
# Cannot test uninstalled formulae
|
||||
unless f.installed?
|
||||
|
||||
17
Library/Homebrew/test/cmd/shared_examples/args_parse.rb
Normal file
17
Library/Homebrew/test/cmd/shared_examples/args_parse.rb
Normal file
@ -0,0 +1,17 @@
|
||||
shared_examples "parseable arguments" do
|
||||
subject(:method_name) do |example|
|
||||
example.metadata[:example_group][:parent_example_group][:description]
|
||||
.gsub(/^Homebrew\./, "")
|
||||
end
|
||||
|
||||
let(:command_name) do
|
||||
method_name.gsub(/_args$/, "").tr("_", "-")
|
||||
end
|
||||
|
||||
it "can parse arguments" do
|
||||
require "dev-cmd/#{command_name}" unless require? "cmd/#{command_name}"
|
||||
|
||||
expect { Homebrew.send(method_name).parse({}) }
|
||||
.not_to raise_error
|
||||
end
|
||||
end
|
||||
21
Library/Homebrew/test/cmd/tap-info_spec.rb
Normal file
21
Library/Homebrew/test/cmd/tap-info_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.tap_info_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew tap-info", :integration_test do
|
||||
it "gets information for a given Tap" do
|
||||
setup_test_tap
|
||||
|
||||
expect { brew "tap-info", "homebrew/foo" }
|
||||
.to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap-info", "--json=v1", "--installed" }
|
||||
.to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
16
Library/Homebrew/test/cmd/tap_spec.rb
Normal file
16
Library/Homebrew/test/cmd/tap_spec.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.tap_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew tap", :integration_test do
|
||||
it "taps a given Tap" do
|
||||
path = setup_test_tap
|
||||
|
||||
expect { brew "tap", "--force-auto-update", "--full", "homebrew/bar", path/".git" }
|
||||
.to output(/Tapped/).to_stdout
|
||||
.and output(/Cloning/).to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
16
Library/Homebrew/test/cmd/untap_spec.rb
Normal file
16
Library/Homebrew/test/cmd/untap_spec.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.untap_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew untap", :integration_test do
|
||||
it "untaps a given Tap" do
|
||||
setup_test_tap
|
||||
|
||||
expect { brew "untap", "homebrew/foo" }
|
||||
.to output(/Untapped/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
@ -1,5 +1,10 @@
|
||||
require "dev-cmd/audit"
|
||||
require "formulary"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.audit_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
module Count
|
||||
def self.increment
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.bottle_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew bottle", :integration_test do
|
||||
it "builds a bottle for the given Formula" do
|
||||
# create stub patchelf
|
||||
@ -21,9 +27,13 @@ describe "brew bottle", :integration_test do
|
||||
FileUtils.ln_s "not-exist", "symlink"
|
||||
end
|
||||
|
||||
expect { brew "bottle", "--no-rebuild", "testball" }
|
||||
.to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
begin
|
||||
expect { brew "bottle", "--no-rebuild", "testball" }
|
||||
.to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
ensure
|
||||
FileUtils.rm_f Dir.glob("testball--0.1*.bottle.tar.gz")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
5
Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb
Normal file
5
Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.bump_formula_pr_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.create_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew create", :integration_test do
|
||||
let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
|
||||
let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" }
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.edit_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew edit", :integration_test do
|
||||
it "opens a given Formula in an editor" do
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.extract_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew extract", :integration_test do
|
||||
it "retrieves the specified version of formula, defaulting to most recent" do
|
||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.formula_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew formula", :integration_test do
|
||||
it "prints a given Formula's path" do
|
||||
formula_file = setup_test_formula "testball"
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.irb_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew irb", :integration_test do
|
||||
it "starts an interactive Homebrew shell session" do
|
||||
setup_test_formula "testball"
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.linkage_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew linkage", :integration_test do
|
||||
before do
|
||||
setup_test_formula "testball"
|
||||
|
||||
5
Library/Homebrew/test/dev-cmd/man_spec.rb
Normal file
5
Library/Homebrew/test/dev-cmd/man_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.man_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
5
Library/Homebrew/test/dev-cmd/mirror_spec.rb
Normal file
5
Library/Homebrew/test/dev-cmd/mirror_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.mirror_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
5
Library/Homebrew/test/dev-cmd/prof_spec.rb
Normal file
5
Library/Homebrew/test/dev-cmd/prof_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.prof_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.pull_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew pull", :integration_test do
|
||||
it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do
|
||||
CoreTap.instance.path.cd do
|
||||
|
||||
5
Library/Homebrew/test/dev-cmd/release-notes_spec.rb
Normal file
5
Library/Homebrew/test/dev-cmd/release-notes_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.release_notes_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.ruby_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew ruby", :integration_test do
|
||||
it "executes ruby code with Homebrew's libraries loaded" do
|
||||
expect { brew "ruby", "-e", "exit 0" }
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.tap_new_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew tap-new", :integration_test do
|
||||
it "initializes a new Tap with a ReadMe file" do
|
||||
expect { brew "tap-new", "homebrew/foo", "--verbose" }
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
describe "brew tap", :integration_test do
|
||||
it "taps a given Tap" do
|
||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
path.mkpath
|
||||
path.cd do
|
||||
system "git", "init"
|
||||
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
|
||||
FileUtils.touch "readme"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "init"
|
||||
end
|
||||
|
||||
expect { brew "tap" }
|
||||
.to output(%r{homebrew/foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap-info" }
|
||||
.to output(/2 taps/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap-info", "homebrew/foo" }
|
||||
.to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap-info", "--json=v1", "--installed" }
|
||||
.to output(%r{https://github\.com/Homebrew/homebrew-foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap-pin", "homebrew/foo" }
|
||||
.to output(%r{Pinned homebrew/foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap", "--list-pinned" }
|
||||
.to output(%r{homebrew/foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap-unpin", "homebrew/foo" }
|
||||
.to output(%r{Unpinned homebrew/foo}).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap", "homebrew/bar", path/".git" }
|
||||
.to output(/Tapped/).to_stdout
|
||||
.and output(/Cloning/).to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "untap", "homebrew/bar" }
|
||||
.to output(/Untapped/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap", "--force-auto-update", "homebrew/bar", path/".git" }
|
||||
.to output(/Tapped/).to_stdout
|
||||
.and output(/Cloning/).to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "untap", "homebrew/bar" }
|
||||
.to output(/Untapped/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
expect { brew "tap", "homebrew/bar", path/".git", "-q", "--full" }
|
||||
.to be_a_success
|
||||
.and not_to_output.to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
end
|
||||
end
|
||||
@ -1,3 +1,9 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.test_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew test", :integration_test do
|
||||
it "tests a given Formula" do
|
||||
install_test_formula "testball", <<~'RUBY'
|
||||
|
||||
5
Library/Homebrew/test/dev-cmd/vendor-gems_spec.rb
Normal file
5
Library/Homebrew/test/dev-cmd/vendor-gems_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.vendor_gems_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
@ -191,7 +191,6 @@ RSpec.configure do |config|
|
||||
CoreTap.instance.alias_dir,
|
||||
CoreTap.instance.path/"formula_renames.json",
|
||||
*Pathname.glob("#{HOMEBREW_CELLAR}/*/"),
|
||||
*Pathname.glob("testball*.bottle.tar.gz"),
|
||||
]
|
||||
|
||||
files_after_test = find_files
|
||||
|
||||
@ -184,6 +184,19 @@ RSpec.shared_context "integration test" do
|
||||
fi.finish
|
||||
end
|
||||
|
||||
def setup_test_tap
|
||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||
path.mkpath
|
||||
path.cd do
|
||||
system "git", "init"
|
||||
system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
|
||||
FileUtils.touch "readme"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "init"
|
||||
end
|
||||
path
|
||||
end
|
||||
|
||||
def setup_remote_tap(name)
|
||||
Tap.fetch(name).tap do |tap|
|
||||
next if tap.installed?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user