Test dev-cmd *_args methods
Also, add a few missing invocations.
This commit is contained in:
parent
ee64b7caa8
commit
aa44509be9
@ -14,6 +14,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prof
|
def prof
|
||||||
|
prof_args.parse
|
||||||
|
|
||||||
Homebrew.install_gem_setup_path! "ruby-prof"
|
Homebrew.install_gem_setup_path! "ruby-prof"
|
||||||
FileUtils.mkdir_p "prof"
|
FileUtils.mkdir_p "prof"
|
||||||
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
require "formula_assertions"
|
|
||||||
require "sandbox"
|
require "sandbox"
|
||||||
require "timeout"
|
require "timeout"
|
||||||
require "cli_parser"
|
require "cli_parser"
|
||||||
@ -31,8 +30,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test
|
def test
|
||||||
|
test_args.parse
|
||||||
|
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||||
|
|
||||||
|
require "formula_assertions"
|
||||||
|
|
||||||
ARGV.resolved_formulae.each do |f|
|
ARGV.resolved_formulae.each do |f|
|
||||||
# Cannot test uninstalled formulae
|
# Cannot test uninstalled formulae
|
||||||
unless f.installed?
|
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
|
||||||
@ -1,5 +1,10 @@
|
|||||||
require "dev-cmd/audit"
|
require "dev-cmd/audit"
|
||||||
require "formulary"
|
require "formulary"
|
||||||
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
|
describe "Homebrew.audit_args" do
|
||||||
|
it_behaves_like "parseable arguments"
|
||||||
|
end
|
||||||
|
|
||||||
module Count
|
module Count
|
||||||
def self.increment
|
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
|
describe "brew bottle", :integration_test do
|
||||||
it "builds a bottle for the given Formula" do
|
it "builds a bottle for the given Formula" do
|
||||||
# create stub patchelf
|
# create stub patchelf
|
||||||
@ -21,9 +27,13 @@ describe "brew bottle", :integration_test do
|
|||||||
FileUtils.ln_s "not-exist", "symlink"
|
FileUtils.ln_s "not-exist", "symlink"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect { brew "bottle", "--no-rebuild", "testball" }
|
begin
|
||||||
.to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout
|
expect { brew "bottle", "--no-rebuild", "testball" }
|
||||||
.and not_to_output.to_stderr
|
.to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout
|
||||||
.and be_a_success
|
.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
|
||||||
end
|
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
|
describe "brew create", :integration_test do
|
||||||
let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
|
let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
|
||||||
let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" }
|
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
|
describe "brew edit", :integration_test do
|
||||||
it "opens a given Formula in an editor" do
|
it "opens a given Formula in an editor" do
|
||||||
HOMEBREW_REPOSITORY.cd 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
|
describe "brew extract", :integration_test do
|
||||||
it "retrieves the specified version of formula, defaulting to most recent" do
|
it "retrieves the specified version of formula, defaulting to most recent" do
|
||||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
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
|
describe "brew formula", :integration_test do
|
||||||
it "prints a given Formula's path" do
|
it "prints a given Formula's path" do
|
||||||
formula_file = setup_test_formula "testball"
|
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
|
describe "brew irb", :integration_test do
|
||||||
it "starts an interactive Homebrew shell session" do
|
it "starts an interactive Homebrew shell session" do
|
||||||
setup_test_formula "testball"
|
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
|
describe "brew linkage", :integration_test do
|
||||||
before do
|
before do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|||||||
@ -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
|
describe "brew pull", :integration_test do
|
||||||
it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do
|
it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do
|
||||||
CoreTap.instance.path.cd do
|
CoreTap.instance.path.cd do
|
||||||
|
|||||||
@ -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
|
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" do
|
||||||
expect { brew "ruby", "-e", "exit 0" }
|
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
|
describe "brew tap-new", :integration_test do
|
||||||
it "initializes a new Tap with a ReadMe file" do
|
it "initializes a new Tap with a ReadMe file" do
|
||||||
expect { brew "tap-new", "homebrew/foo", "--verbose" }
|
expect { brew "tap-new", "homebrew/foo", "--verbose" }
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
|
describe "Homebrew.tap_args" do
|
||||||
|
it_behaves_like "parseable arguments"
|
||||||
|
end
|
||||||
|
|
||||||
describe "brew tap", :integration_test do
|
describe "brew tap", :integration_test do
|
||||||
it "taps a given Tap" do
|
it "taps a given Tap" do
|
||||||
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
|
||||||
|
|||||||
@ -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
|
describe "brew test", :integration_test do
|
||||||
it "tests a given Formula" do
|
it "tests a given Formula" do
|
||||||
install_test_formula "testball", <<~'RUBY'
|
install_test_formula "testball", <<~'RUBY'
|
||||||
|
|||||||
@ -191,7 +191,6 @@ RSpec.configure do |config|
|
|||||||
CoreTap.instance.alias_dir,
|
CoreTap.instance.alias_dir,
|
||||||
CoreTap.instance.path/"formula_renames.json",
|
CoreTap.instance.path/"formula_renames.json",
|
||||||
*Pathname.glob("#{HOMEBREW_CELLAR}/*/"),
|
*Pathname.glob("#{HOMEBREW_CELLAR}/*/"),
|
||||||
*Pathname.glob("testball*.bottle.tar.gz"),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
files_after_test = find_files
|
files_after_test = find_files
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user