Skip to content
Snippets Groups Projects
Commit 487294f8 authored by Markus Reiter's avatar Markus Reiter
Browse files

Remove Minitest.

parent fa34aa2a
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 420 deletions
source "https://rubygems.org"
group :test do
gem "parallel_tests"
gem "rspec"
gem "rspec-its", require: false
gem "rspec-wait", require: false
group :coverage do
gem "simplecov", require: false
gem "codecov", require: false
gem "minitest"
gem "minitest-reporters"
gem "mocha", require: false
gem "parallel_tests"
gem "rspec"
gem "rspec-its", require: false
gem "rspec-wait", require: false
end
GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
builder (3.2.3)
codecov (0.1.9)
json
simplecov
......@@ -10,15 +8,6 @@ GEM
diff-lcs (1.3)
docile (1.1.5)
json (2.0.3)
metaclass (0.0.4)
minitest (5.10.1)
minitest-reporters (1.1.14)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
mocha (1.2.1)
metaclass (~> 0.0.1)
parallel (1.10.0)
parallel_tests (2.13.0)
parallel
......@@ -40,7 +29,6 @@ GEM
rspec-support (3.5.0)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
ruby-progressbar (1.8.1)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
......@@ -53,9 +41,6 @@ PLATFORMS
DEPENDENCIES
codecov
minitest
minitest-reporters
mocha
parallel_tests
rspec
rspec-its
......@@ -63,4 +48,4 @@ DEPENDENCIES
simplecov
BUNDLED WITH
1.13.7
1.14.5
#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script>`:`<test_method>] [`--seed` <seed>] [`--trace`] [`--online`] [`--official-cmd-taps`]:
#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script>`:`<line_number>] [`--seed` <seed>] [`--online`] [`--official-cmd-taps`]:
#: Run Homebrew's unit and integration tests.
require "fileutils"
......@@ -7,27 +7,17 @@ require "tap"
module Homebrew
module_function
def run_tests(executable, files, args = [])
opts = []
opts << "--serialize-stdout" if ENV["CI"]
system "bundle", "exec", executable, *opts, "--", *args, "--", *files
return if $?.success?
Homebrew.failed = true
end
def tests
HOMEBREW_LIBRARY_PATH.cd do
ENV.delete "HOMEBREW_VERBOSE"
ENV.delete "VERBOSE"
ENV.delete("HOMEBREW_VERBOSE")
ENV.delete("VERBOSE")
ENV.delete("HOMEBREW_CASK_OPTS")
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_DEVELOPER"] = "1"
ENV["TESTOPTS"] = "-v" if ARGV.verbose?
ENV["HOMEBREW_NO_COMPAT"] = "1" if ARGV.include? "--no-compat"
ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if ARGV.include? "--generic"
ENV["HOMEBREW_NO_GITHUB_API"] = "1" unless ARGV.include? "--online"
if ARGV.include? "--official-cmd-taps"
ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] = "1"
end
......@@ -53,29 +43,29 @@ module Homebrew
system "bundle", "install"
end
# Make it easier to reproduce test runs.
ENV["SEED"] = ARGV.next if ARGV.include? "--seed"
files = Dir.glob("test/**/*_{spec,test}.rb")
.reject { |p| p =~ %r{^test/vendor/bundle} }
.reject { |p| !OS.mac? && p =~ %r{^test/(os/mac|cask)(/.*|_(test|spec)\.rb)$} }
parallel = true
test_args = []
test_args << "--trace" if ARGV.include? "--trace"
files = if ARGV.value("only")
test_name, line = ARGV.value("only").split(":", 2)
if ARGV.value("only")
test_name, test_method = ARGV.value("only").split(":", 2)
files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_{spec,test}.rb")
test_args << "--name=test_#{test_method}" if test_method
if line.nil?
Dir.glob("test/{#{test_name},#{test_name}/**/*}_spec.rb")
else
parallel = false
["test/#{test_name}_spec.rb:#{line}"]
end
else
Dir.glob("test/**/*_spec.rb").reject { |p| p =~ %r{^test/vendor/bundle/} }
end
test_files = files.select { |p| p.end_with?("_test.rb") }
spec_files = files.select { |p| p.end_with?("_spec.rb") }
opts = []
test_args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] }
run_tests "parallel_test", test_files, test_args
if ENV["CI"]
opts << "--combine-stderr"
opts << "--serialize-stdout"
end
spec_args = [
args = [
"--color",
"-I", HOMEBREW_LIBRARY_PATH/"test",
"--require", "spec_helper",
......@@ -83,18 +73,22 @@ module Homebrew
"--format", "ParallelTests::RSpec::RuntimeLogger",
"--out", "tmp/parallel_runtime_rspec.log"
]
spec_args << "--tag" << "~needs_macos" unless OS.mac?
run_tests "parallel_rspec", spec_files, spec_args
args << "--seed" << ARGV.next if ARGV.include? "--seed"
if (fs_leak_log = HOMEBREW_LIBRARY_PATH/"tmp/fs_leak.log").file?
fs_leak_log_content = fs_leak_log.read
unless fs_leak_log_content.empty?
opoo "File leak is detected"
puts fs_leak_log_content
Homebrew.failed = true
end
unless OS.mac?
args << "--tag" << "~needs_macos"
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
end
if parallel
system "bundle", "exec", "parallel_rspec", *opts, "--", *args, "--", *files
else
system "bundle", "exec", "rspec", *args, "--", *files
end
return if $?.success?
Homebrew.failed = true
end
end
end
source "https://rubygems.org"
gem "mocha"
gem "minitest"
gem "minitest-reporters"
gem "parallel_tests"
gem "rspec"
gem "rspec-its", require: false
......
GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
builder (3.2.3)
codecov (0.1.9)
json
simplecov
......@@ -10,15 +8,6 @@ GEM
diff-lcs (1.3)
docile (1.1.5)
json (2.0.3)
metaclass (0.0.4)
minitest (5.10.1)
minitest-reporters (1.1.14)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
mocha (1.2.1)
metaclass (~> 0.0.1)
parallel (1.10.0)
parallel_tests (2.13.0)
parallel
......@@ -40,7 +29,6 @@ GEM
rspec-support (3.5.0)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
ruby-progressbar (1.8.1)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
......@@ -53,9 +41,6 @@ PLATFORMS
DEPENDENCIES
codecov
minitest
minitest-reporters
mocha
parallel_tests
rspec
rspec-its
......@@ -63,4 +48,4 @@ DEPENDENCIES
simplecov
BUNDLED WITH
1.14.3
1.14.5
module Test
module Helper
module FSLeakLogger
def self.included(klass)
require "find"
logdir = HOMEBREW_LIBRARY_PATH.join("tmp")
logdir.mkpath
@@log = File.open(logdir.join("fs_leak.log"), "w")
klass.make_my_diffs_pretty!
end
def setup
@__files_before_test = []
Find.find(TEST_TMPDIR) { |f| @__files_before_test << f.sub(TEST_TMPDIR, "") }
super
end
def teardown
super
files_after_test = []
Find.find(TEST_TMPDIR) { |f| files_after_test << f.sub(TEST_TMPDIR, "") }
return if @__files_before_test == files_after_test
@@log.puts location, diff(@__files_before_test, files_after_test)
end
end
end
end
require "bundler"
require "fileutils"
require "pathname"
require "formula"
require "test/support/helper/test_case"
require "open3"
class IntegrationCommandTestCase < Homebrew::TestCase
def setup
super
@cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`.
(HOMEBREW_PREFIX/"bin").mkpath
FileUtils.touch HOMEBREW_PREFIX/"bin/brew"
end
def needs_test_cmd_taps
return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
end
def needs_macos
skip "Not on MacOS" unless OS.mac?
end
def cmd_id_from_args(args)
args_pretty = args.join(" ").gsub(TEST_TMPDIR, "@TMPDIR@")
test_pretty = "#{self.class.name}\##{name}.#{@cmd_id_index += 1}"
"[#{test_pretty}] brew #{args_pretty}"
end
def cmd_output(*args)
env = args.last.is_a?(Hash) ? args.pop : {}
env.merge!(
"HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
"HOMEBREW_INTEGRATION_TEST" => cmd_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
"HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"],
)
ruby_args = [
"-W0",
"-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib",
"-I", HOMEBREW_LIBRARY_PATH.to_s,
"-rconfig"
]
ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
ruby_args << "-rtest/support/helper/integration_mocks"
ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s
Bundler.with_original_env do
output, status = Open3.capture2e(env, RUBY_PATH, *ruby_args, *args)
[output.chomp, status]
end
end
def cmd(*args)
output, status = cmd_output(*args)
assert status.success?, <<-EOS.undent
`brew #{args.join " "}` exited with non-zero status!
#{output}
EOS
output
end
def cmd_fail(*args)
output, status = cmd_output(*args)
refute status.success?, <<-EOS.undent
`brew #{args.join " "}` exited with zero status!
#{output}
EOS
output
end
def setup_test_formula(name, content = nil)
formula_path = CoreTap.new.formula_dir/"#{name}.rb"
case name
when /^testball/
content = <<-EOS.undent
desc "Some test"
homepage "https://example.com/#{name}"
url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
sha256 "#{TESTBALL_SHA256}"
option "with-foo", "Build with foo"
def install
(prefix/"foo"/"test").write("test") if build.with? "foo"
prefix.install Dir["*"]
(buildpath/"test.c").write \
"#include <stdio.h>\\nint main(){return printf(\\"test\\");}"
bin.mkpath
system ENV.cc, "test.c", "-o", bin/"test"
end
#{content}
# something here
EOS
when "foo"
content = <<-EOS.undent
url "https://example.com/#{name}-1.0"
EOS
when "bar"
content = <<-EOS.undent
url "https://example.com/#{name}-1.0"
depends_on "foo"
EOS
end
formula_path.write <<-EOS.undent
class #{Formulary.class_s(name)} < Formula
#{content}
end
EOS
formula_path
end
def setup_remote_tap(name)
tap = Tap.fetch name
tap.install(full_clone: false, quiet: true) unless tap.installed?
tap
end
def install_and_rename_coretap_formula(old_name, new_name)
core_tap = CoreTap.new
core_tap.path.cd do
shutup do
system "git", "init"
system "git", "add", "--all"
system "git", "commit", "-m",
"#{old_name.capitalize} has not yet been renamed"
end
end
cmd("install", old_name)
(core_tap.path/"Formula/#{old_name}.rb").unlink
formula_renames = core_tap.path/"formula_renames.json"
formula_renames.write JSON.generate(old_name => new_name)
core_tap.path.cd do
shutup do
system "git", "add", "--all"
system "git", "commit", "-m",
"#{old_name.capitalize} has been renamed to #{new_name.capitalize}"
end
end
end
def testball
"#{TEST_FIXTURE_DIR}/testball.rb"
end
end
module Test
module Helper
module LifecycleEnforcer
def setup
@__setup_called = true
super
end
def teardown
@__teardown_called = true
super
end
def after_teardown
assert @__setup_called, "Expected setup to call `super` but didn't"
assert @__teardown_called, "Expected teardown to call `super` but didn't"
super
end
end
end
end
require "rspec"
require "open3"
RSpec::Matchers.define_negated_matcher :not_to_output, :output
......
require "formulary"
require "tap"
module Homebrew
class TestCase < ::Minitest::Test
require "test/support/helper/fs_leak_logger"
require "test/support/helper/lifecycle_enforcer"
require "test/support/helper/shutup"
include Test::Helper::FSLeakLogger
include Test::Helper::LifecycleEnforcer
include Test::Helper::Shutup
TEST_DIRECTORIES = [
CoreTap.instance.path/"Formula",
HOMEBREW_CACHE,
HOMEBREW_CACHE_FORMULA,
HOMEBREW_CELLAR,
HOMEBREW_LOCK_DIR,
HOMEBREW_LOGS,
HOMEBREW_TEMP,
].freeze
def setup
# These directories need to be created before
# `FSLeakLogger` is called with `super`.
TEST_DIRECTORIES.each(&:mkpath)
super
@__argv = ARGV.dup
@__env = ENV.to_hash # dup doesn't work on ENV
end
def teardown
ARGV.replace(@__argv)
ENV.replace(@__env)
Tab.clear_cache
FileUtils.rm_rf [
TEST_DIRECTORIES.map(&:children),
HOMEBREW_LINKED_KEGS,
HOMEBREW_PINNED_KEGS,
HOMEBREW_PREFIX/".git",
HOMEBREW_PREFIX/"bin",
HOMEBREW_PREFIX/"share",
HOMEBREW_PREFIX/"opt",
HOMEBREW_PREFIX/"Caskroom",
HOMEBREW_LIBRARY/"Taps/caskroom",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services",
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow",
HOMEBREW_REPOSITORY/".git",
CoreTap.instance.path/".git",
CoreTap.instance.alias_dir,
CoreTap.instance.path/"formula_renames.json",
]
super
end
def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block)
@_f = Class.new(Formula, &block).new(name, path, spec, alias_path: alias_path)
end
def mktmpdir(prefix_suffix = nil, &block)
Dir.mktmpdir(prefix_suffix, HOMEBREW_TEMP, &block)
end
def needs_compat
skip "Requires compat/ code" if ENV["HOMEBREW_NO_COMPAT"]
end
def needs_python
skip "Requires Python" unless which("python")
end
def assert_nothing_raised
yield
end
def assert_eql(exp, act, msg = nil)
msg = message(msg, "") { diff exp, act }
assert exp.eql?(act), msg
end
def refute_eql(exp, act, msg = nil)
msg = message(msg) do
"Expected #{mu_pp(act)} to not be eql to #{mu_pp(exp)}"
end
refute exp.eql?(act), msg
end
def dylib_path(name)
Pathname.new("#{TEST_FIXTURE_DIR}/mach/#{name}.dylib")
end
def bundle_path(name)
Pathname.new("#{TEST_FIXTURE_DIR}/mach/#{name}.bundle")
end
# Use a stubbed {Formulary::FormulaLoader} to make a given formula be found
# when loading from {Formulary} with `ref`.
def stub_formula_loader(formula, ref = formula.full_name)
loader = mock
loader.stubs(:get_formula).returns(formula)
Formulary.stubs(:loader_for).with(ref, from: :keg).returns(loader)
Formulary.stubs(:loader_for).with(ref, from: nil).returns(loader)
end
end
end
begin
require "minitest/autorun"
require "minitest/reporters"
Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true)
require "mocha/setup"
require "parallel_tests/test/runtime_logger"
require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
rescue LoadError
abort "Run `bundle install` before running the tests."
end
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
require "global"
require "test/support/helper/test_case"
require "test/support/helper/integration_command_test_case"
......@@ -612,7 +612,7 @@ launched with access to IRB or a shell inside the temporary test directory.</p>
not deleted.</p>
<p>Example: <code>brew install jruby &amp;&amp; brew test jruby</code></p></dd>
<dt><code>tests</code> [<code>-v</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code><var>test_script</var><code>:</code><var>test_method</var>] [<code>--seed</code> <var>seed</var>] [<code>--trace</code>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests.</p></dd>
<dt><code>tests</code> [<code>-v</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code><var>test_script</var><code>:</code><var>line_number</var>] [<code>--seed</code> <var>seed</var>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests.</p></dd>
<dt><code>update-test</code> [<code>--commit=</code><var>commit</var>] [<code>--before=</code><var>date</var>] [<code>--keep-tmp</code>]</dt><dd><p>Runs a test of <code>brew update</code> with a new repository clone.</p>
<p>If no arguments are passed, use <code>origin/master</code> as the start commit.</p>
......
......@@ -816,7 +816,7 @@ If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are n
Example: \fBbrew install jruby && brew test jruby\fR
.
.TP
\fBtests\fR [\fB\-v\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR\fItest_script\fR\fB:\fR\fItest_method\fR] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-trace\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR]
\fBtests\fR [\fB\-v\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR\fItest_script\fR\fB:\fR\fIline_number\fR] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR]
Run Homebrew\'s unit and integration tests\.
.
.TP
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment