dev-cmd: only one integration test per command.

Integration tests are useful in detecting breakages but much slower so
let's only use one per command and install formula outside the
integration test framework (which is also slow).
This commit is contained in:
Mike McQuaid 2019-03-27 09:45:48 +00:00
parent cf4511f72a
commit 59d680a626
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
10 changed files with 46 additions and 86 deletions

View File

@ -17,6 +17,7 @@ class Keg
return if !file.elf? || !file.dynamic_elf? return if !file.elf? || !file.dynamic_elf?
patchelf = DevelopmentTools.locate "patchelf" patchelf = DevelopmentTools.locate "patchelf"
cmd_rpath = [patchelf, "--print-rpath", file] cmd_rpath = [patchelf, "--print-rpath", file]
old_rpath = Utils.popen_read(*cmd_rpath, err: :out).strip old_rpath = Utils.popen_read(*cmd_rpath, err: :out).strip

View File

@ -15,6 +15,7 @@ require "cache_store"
require "linkage_checker" require "linkage_checker"
require "install" require "install"
require "messages" require "messages"
require "cask/cask_loader"
class FormulaInstaller class FormulaInstaller
include FormulaCellarChecks include FormulaCellarChecks
@ -68,6 +69,10 @@ class FormulaInstaller
@attempted ||= Set.new @attempted ||= Set.new
end end
def self.clear_attempted
@attempted = Set.new
end
# When no build tools are available and build flags are passed through ARGV, # When no build tools are available and build flags are passed through ARGV,
# it's necessary to interrupt the user before any sort of installation # it's necessary to interrupt the user before any sort of installation
# can proceed. Only invoked when the user has no developer tools. # can proceed. Only invoked when the user has no developer tools.

View File

@ -1,23 +1,19 @@
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
begin # create stub patchelf
expect { brew "install", "--build-bottle", testball } if OS.linux?
.to be_a_success
setup_test_formula "patchelf" setup_test_formula "patchelf"
(HOMEBREW_CELLAR/"patchelf/1.0/bin").mkpath patchelf = HOMEBREW_CELLAR/"patchelf/1.0/bin/patchelf"
patchelf.dirname.mkpath
patchelf.write <<~EOS
#!/bin/sh
exit 0
EOS
FileUtils.chmod "+x", patchelf
FileUtils.ln_s patchelf, HOMEBREW_PREFIX/"bin/patchelf"
end
expect { brew "bottle", "--no-rebuild", testball } install_test_formula "testball", build_bottle: true
.to output(/Formula not from core or any installed taps/).to_stderr
.and not_to_output.to_stdout
.and be_a_failure
expect { brew "bottle", "--root-url" }
.to output(/missing argument: --root-url/).to_stderr
.and not_to_output.to_stdout
.and be_a_failure
setup_test_formula "testball"
# `brew bottle` should not fail with dead symlink # `brew bottle` should not fail with dead symlink
# https://github.com/Homebrew/legacy-homebrew/issues/49007 # https://github.com/Homebrew/legacy-homebrew/issues/49007
@ -29,8 +25,5 @@ describe "brew bottle", :integration_test do
.to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout .to output(/testball--0\.1.*\.bottle\.tar\.gz/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
ensure
FileUtils.rm_f Dir.glob("testball--0.1*.bottle.tar.gz")
end
end end
end end

View File

@ -15,12 +15,6 @@ describe "brew extract", :integration_test do
system "git", "add", "--all" system "git", "add", "--all"
system "git", "commit", "-m", "testball 0.2" system "git", "commit", "-m", "testball 0.2"
end end
expect { brew "extract", "testball", target.name }
.to be_a_success
expect(path/"Formula/testball@0.2.rb").to exist
expect(Formulary.factory(path/"Formula/testball@0.2.rb").version).to be == "0.2"
expect { brew "extract", "testball", target.name, "--version=0.1" } expect { brew "extract", "testball", target.name, "--version=0.1" }
.to be_a_success .to be_a_success

View File

@ -14,11 +14,4 @@ describe "brew irb", :integration_test do
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end
specify "--examples" do
expect { brew "irb", "--examples" }
.to output(/'v8'\.f # => instance of the v8 formula/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end end

View File

@ -10,10 +10,4 @@ describe "brew linkage", :integration_test do
.and not_to_output.to_stdout .and not_to_output.to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
end end
it "works when one argument is provided" do
expect { brew "linkage", "testball" }
.to be_a_success
.and not_to_output.to_stderr
end
end end

View File

@ -5,24 +5,6 @@ describe "brew pull", :integration_test do
system "git", "checkout", "-b", "new-branch" system "git", "checkout", "-b", "new-branch"
end end
expect { brew "pull", "https://jenkins.brew.sh/job/Homebrew\%20Testing/1028/" }
.to output(/Testing URLs require `\-\-bottle`!/).to_stderr
.and not_to_output.to_stdout
.and be_a_failure
# Needs Homebrew/homebrew-core
if OS.mac?
expect { brew "pull", "1" }
.to output(/Fetching patch/).to_stdout
.and output(/Current branch is new\-branch/).to_stderr
.and be_a_failure
end
expect { brew "pull", "--bump", "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122" }
.to output(/Fetching patch/).to_stdout
.and output(/Can only bump one changed formula/).to_stderr
.and be_a_failure
expect { brew "pull", "https://github.com/Homebrew/brew/pull/1249" } expect { brew "pull", "https://github.com/Homebrew/brew/pull/1249" }
.to output(/Fetching patch/).to_stdout .to output(/Fetching patch/).to_stdout
.and output(/Patch failed to apply/).to_stderr .and output(/Patch failed to apply/).to_stderr

View File

@ -1,27 +1,12 @@
describe "brew test", :integration_test do describe "brew test", :integration_test do
it "tests a given Formula" do it "tests a given Formula" do
setup_test_formula "testball", <<~RUBY install_test_formula "testball", <<~'RUBY'
head "https://github.com/example/testball2.git"
devel do
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 "#{TESTBALL_SHA256}"
end
keg_only "just because"
test do test do
assert_equal "test", shell_output("#{bin}/test")
end end
RUBY RUBY
expect { brew "install", "testball" }.to be_a_success expect { brew "test", "--verbose", "testball" }
expect { brew "test", "--HEAD", "testball" }
.to output(/Testing testball/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
expect { brew "test", "--devel", "testball" }
.to output(/Testing testball/).to_stdout .to output(/Testing testball/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success

View File

@ -140,6 +140,7 @@ RSpec.configure do |config|
begin begin
Tap.clear_cache Tap.clear_cache
FormulaInstaller.clear_attempted
TEST_DIRECTORIES.each(&:mkpath) TEST_DIRECTORIES.each(&:mkpath)
@ -189,6 +190,7 @@ RSpec.configure do |config|
CoreTap.instance.path/".git", CoreTap.instance.path/".git",
CoreTap.instance.alias_dir, CoreTap.instance.alias_dir,
CoreTap.instance.path/"formula_renames.json", CoreTap.instance.path/"formula_renames.json",
*Pathname.glob("#{HOMEBREW_CELLAR}/*/"),
] ]
files_after_test = find_files files_after_test = find_files

View File

@ -1,5 +1,7 @@
require "open3" require "open3"
require "formula_installer"
RSpec::Matchers.define_negated_matcher :be_a_failure, :be_a_success RSpec::Matchers.define_negated_matcher :be_a_failure, :be_a_success
RSpec.shared_context "integration test" do RSpec.shared_context "integration test" do
@ -140,7 +142,7 @@ RSpec.shared_context "integration test" do
(prefix/"foo"/"test").write("test") if build.with? "foo" (prefix/"foo"/"test").write("test") if build.with? "foo"
prefix.install Dir["*"] prefix.install Dir["*"]
(buildpath/"test.c").write \ (buildpath/"test.c").write \
"#include <stdio.h>\\nint main(){return printf(\\"test\\");}" "#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
bin.mkpath bin.mkpath
system ENV.cc, "test.c", "-o", bin/"test" system ENV.cc, "test.c", "-o", bin/"test"
end end
@ -173,6 +175,15 @@ RSpec.shared_context "integration test" do
end end
end end
def install_test_formula(name, content = nil, build_bottle: false)
setup_test_formula(name, content)
fi = FormulaInstaller.new(Formula[name])
fi.build_bottle = build_bottle
fi.prelude
fi.install
fi.finish
end
def setup_remote_tap(name) def setup_remote_tap(name)
Tap.fetch(name).tap do |tap| Tap.fetch(name).tap do |tap|
next if tap.installed? next if tap.installed?