Skip to content
Snippets Groups Projects
Commit 176c8251 authored by Alyssa Ross's avatar Alyssa Ross
Browse files

cask-tests: run in parallel

parent d3740ec3
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ group :test do
gem "minitest", "5.4.1"
gem "minitest-reporters"
gem "mocha", "1.1.0", require: false
gem "parallel_tests"
gem "rspec", "~> 3.0.0"
gem "rspec-its", require: false
gem "rspec-wait", require: false
......
......@@ -23,6 +23,9 @@ GEM
ruby-progressbar
mocha (1.1.0)
metaclass (~> 0.0.1)
parallel (1.9.0)
parallel_tests (2.9.0)
parallel
parser (2.3.1.2)
ast (~> 2.2)
powerpack (0.1.1)
......@@ -80,6 +83,7 @@ DEPENDENCIES
minitest (= 5.4.1)
minitest-reporters
mocha (= 1.1.0)
parallel_tests
pry
pry-byebug
rake
......
......@@ -6,40 +6,11 @@ homebrew_repo = `brew --repository`.chomp
$LOAD_PATH.unshift(File.expand_path("#{homebrew_repo}/Library/Homebrew"))
$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
namespace :test do
Rake::TestTask.new(:minitest) do |t|
# TODO: setting the --seed here is an ugly temporary hack, to remain only
# until test-suite glitches are fixed.
ENV["TESTOPTS"] = "--seed=14830" if ENV["TRAVIS"]
t.pattern = "test/**/*_test.rb"
t.libs << "test"
end
RSpec::Core::RakeTask.new(:rspec)
desc "Run tests for minitest and RSpec with coverage"
task :coverage do
ENV["HOMEBREW_TESTS_COVERAGE"] = "1"
Rake::Task[:test].invoke
if ENV["CODECOV_TOKEN"]
require "simplecov"
require "codecov"
formatter = SimpleCov::Formatter::Codecov.new
formatter.format(SimpleCov::ResultMerger.merged_result)
end
end
end
desc "Run tests for minitest and RSpec"
task test: ["test:minitest", "test:rspec"]
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ["--force-exclusion"]
end
task default: [:test, :rubocop]
task default: [:rubocop]
desc "Open a REPL for debugging and experimentation"
task :console do
......
require "English"
def run_tests(executable, files, args = [])
system "bundle", "exec", executable, "--", *args, "--", *files
end
repo_root = Pathname(__FILE__).realpath.parent.parent
repo_root.cd do
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
......@@ -9,12 +13,21 @@ repo_root.cd do
system "bundle", "install", "--path", "vendor/bundle"
end
test_task = "test"
%w[rspec minitest coverage].each do |subtask|
next unless ARGV.flag?("--#{subtask}")
test_task = "test:#{subtask}"
rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest")
minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec")
ENV["TESTOPTS"] = "--seed=14830" if ENV["TRAVIS"]
ENV["HOMEBREW_TESTS_COVERAGE"] = "1" if ARGV.flag?("--coverage")
run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"] if rspec
run_tests "parallel_test", Dir["test/**/*_test.rb"] if minitest
if ENV["CODECOV_TOKEN"]
require "simplecov"
require "codecov"
formatter = SimpleCov::Formatter::Codecov.new
formatter.format(SimpleCov::ResultMerger.merged_result)
end
system "bundle", "exec", "rake", test_task
Homebrew.failed = !$CHILD_STATUS.success?
end
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