aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAlyssa Ross2016-09-20 00:02:04 +0100
committerAlyssa Ross2016-09-20 00:02:04 +0100
commit176c82516f4d81d29d8354e99273afc8cd889338 (patch)
tree1c49286c10c8f4488cff953279c26a089bbe07c5 /Library
parentd3740ec34f1ad98311a3ac606643db972d5130e9 (diff)
downloadbrew-176c82516f4d81d29d8354e99273afc8cd889338.tar.bz2
cask-tests: run in parallel
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/Gemfile1
-rw-r--r--Library/Homebrew/cask/Gemfile.lock4
-rw-r--r--Library/Homebrew/cask/Rakefile31
-rwxr-xr-xLibrary/Homebrew/cask/cmd/brew-cask-tests.rb23
4 files changed, 24 insertions, 35 deletions
diff --git a/Library/Homebrew/cask/Gemfile b/Library/Homebrew/cask/Gemfile
index af1c8d3bc..e252b5f3d 100644
--- a/Library/Homebrew/cask/Gemfile
+++ b/Library/Homebrew/cask/Gemfile
@@ -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
diff --git a/Library/Homebrew/cask/Gemfile.lock b/Library/Homebrew/cask/Gemfile.lock
index c9c2b5cca..fa5dcf9a9 100644
--- a/Library/Homebrew/cask/Gemfile.lock
+++ b/Library/Homebrew/cask/Gemfile.lock
@@ -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
diff --git a/Library/Homebrew/cask/Rakefile b/Library/Homebrew/cask/Rakefile
index 25deee407..c30b2f671 100644
--- a/Library/Homebrew/cask/Rakefile
+++ b/Library/Homebrew/cask/Rakefile
@@ -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
diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb
index 92ef3ddd9..20f343047 100755
--- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb
+++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb
@@ -1,5 +1,9 @@
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