zeus-parallel_tests 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +12 -0
- data/Appraisals +19 -0
- data/README.md +3 -2
- data/Rakefile +2 -13
- data/bin/zeus-parallel_tests +8 -10
- data/circle.yml +39 -0
- data/gemfiles/rails_3_zeus_0.13.gemfile +8 -0
- data/gemfiles/rails_3_zeus_0.15.gemfile +8 -0
- data/gemfiles/rails_4_zeus_0.13.gemfile +8 -0
- data/gemfiles/rails_4_zeus_0.15.gemfile +8 -0
- data/lib/zeus/parallel_tests.rb +1 -1
- data/lib/zeus/parallel_tests/rails.rb +21 -13
- data/lib/zeus/parallel_tests/version.rb +1 -1
- data/lib/zeus/parallel_tests/worker.rb +44 -45
- data/spec/dummy/Guardfile +4 -4
- data/spec/dummy/config/application.rb +2 -9
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/development.rb +0 -8
- data/spec/dummy/config/environments/production.rb +0 -6
- data/spec/dummy/config/environments/test.rb +1 -4
- data/spec/dummy/custom_plan.rb +1 -0
- data/spec/dummy/features/support/env.rb +1 -2
- data/spec/dummy/lib/tasks/cucumber.rake +43 -44
- data/spec/dummy/spec/spec_helper.rb +4 -4
- data/spec/dummy/spec/unit_test_a_spec.rb +3 -3
- data/spec/dummy/spec/unit_test_b_spec.rb +3 -3
- data/spec/lib/zeus/parallel_tests/worker_spec.rb +28 -30
- data/spec/parallel_spec.rb +56 -0
- data/spec/spec_helper.rb +2 -10
- data/spec/zeus_parallel_tests_spec.rb +16 -0
- data/zeus-parallel_tests.gemspec +23 -14
- metadata +120 -19
- data/.travis.yml +0 -5
- data/spec/dummy/Gemfile +0 -31
- data/spec/slow/parallel_rspec_spec.rb +0 -56
- data/spec/slow/zeus-parallel_tests_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1ed74925120942d4780e3f7743b2c0f0fe7180d
|
4
|
+
data.tar.gz: cbf15519f8c68a45ba260885c8f4370c2eee0b95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d16d2f0583ff8b5e4bd472bb80e1cb84beb8db0342d14038b46ffc370a343cf034eb2201127e08a1ae86ae7b3a6a92bc70f7a8f836f396be9035b431a31ad7
|
7
|
+
data.tar.gz: 90e2c837d5f0fd9fa7c4c8ae8f779e63356ae6ce9163cfbc639b8873a452e56aa24edcae81d3fc04b1f28df99fca363baecd27e29760c5636fcaeb29014f70f4
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
data/Appraisals
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
appraise 'rails-3-zeus-0.15' do
|
2
|
+
gem 'rails', '3.2.21'
|
3
|
+
gem 'zeus', '0.15.4'
|
4
|
+
end
|
5
|
+
|
6
|
+
appraise 'rails-4-zeus-0.15' do
|
7
|
+
gem 'rails', '4.2.3'
|
8
|
+
gem 'zeus', '0.15.4'
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise 'rails-3-zeus-0.13' do
|
12
|
+
gem 'rails', '3.2.21'
|
13
|
+
gem 'zeus', '0.13.3'
|
14
|
+
end
|
15
|
+
|
16
|
+
appraise 'rails-4-zeus-0.13' do
|
17
|
+
gem 'rails', '4.2.3'
|
18
|
+
gem 'zeus', '0.13.3'
|
19
|
+
end
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Zeus::ParallelTests
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/sevos/zeus-parallel_tests)
|
4
4
|
[](https://gemnasium.com/sevos/zeus-parallel_tests)
|
5
|
+
[](http://badge.fury.io/rb/zeus-parallel_tests)
|
5
6
|
|
6
7
|
[Zeus](https://github.com/burke/zeus) is a tool for speeding up your tests by preloading a Rails app.
|
7
8
|
[parallel_tests](https://github.com/grosser/parallel_tests) also speeds up your tests by running them, well,
|
@@ -86,7 +87,7 @@ This will create two files in your project:
|
|
86
87
|
|
87
88
|
### RVM
|
88
89
|
|
89
|
-
For RVM users it is recommended to install
|
90
|
+
For RVM users it is recommended to install rubygems-bundler gem.
|
90
91
|
|
91
92
|
## Usage
|
92
93
|
|
data/Rakefile
CHANGED
@@ -1,17 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
task :
|
7
|
-
namespace :travis do
|
8
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
9
|
-
file_list = FileList['spec/**/*_spec.rb']
|
10
|
-
|
11
|
-
%w(slow).each do |exclude|
|
12
|
-
file_list = file_list.exclude("spec/#{exclude}/**/*_spec.rb")
|
13
|
-
end
|
14
|
-
|
15
|
-
task.pattern = file_list
|
16
|
-
end
|
17
|
-
end
|
6
|
+
task default: :spec
|
data/bin/zeus-parallel_tests
CHANGED
@@ -2,25 +2,23 @@
|
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
unless ARGV == [
|
6
|
-
puts
|
5
|
+
unless ARGV == ['init']
|
6
|
+
puts 'Usage:'
|
7
7
|
puts " zeus-parallel_specs init\t\tInitializes custom plan and script/spec"
|
8
8
|
exit 1
|
9
9
|
end
|
10
10
|
|
11
11
|
def copy(file, target_dir)
|
12
|
-
templates_dir = File.expand_path(
|
12
|
+
templates_dir = File.expand_path('../../lib/zeus/parallel_tests/templates/', __FILE__)
|
13
13
|
source_file = File.join(templates_dir, file)
|
14
14
|
dest_file = File.join(File.expand_path(target_dir), file)
|
15
15
|
puts "Creating #{dest_file}"
|
16
|
-
if File.
|
17
|
-
print
|
18
|
-
unless $stdin.gets.chomp ==
|
19
|
-
puts "skipped"
|
20
|
-
end
|
16
|
+
if File.exist?(dest_file)
|
17
|
+
print 'File exists, overwrite? [y/n} '
|
18
|
+
puts 'skipped' unless $stdin.gets.chomp == 'y'
|
21
19
|
end
|
22
20
|
FileUtils.cp(source_file, dest_file)
|
23
21
|
end
|
24
22
|
|
25
|
-
copy
|
26
|
-
copy
|
23
|
+
copy 'custom_plan.rb', './'
|
24
|
+
copy 'zeus.json', './'
|
data/circle.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
dependencies:
|
2
|
+
pre:
|
3
|
+
- echo rvm_autoupdate_flag=0 >> ~/.rvmrc
|
4
|
+
- rvm install 2.2
|
5
|
+
- rvm install 2.1
|
6
|
+
- rvm install 2.0
|
7
|
+
- rvm install 1.9
|
8
|
+
|
9
|
+
cache_directories:
|
10
|
+
- /home/ubuntu/.rvm/gems/ruby-2.2.0
|
11
|
+
- /home/ubuntu/.rvm/gems/ruby-2.1.5
|
12
|
+
- /home/ubuntu/.rvm/gems/ruby-2.0.0-p598
|
13
|
+
- /home/ubuntu/.rvm/gems/ruby-1.9.3-p551
|
14
|
+
|
15
|
+
override:
|
16
|
+
- rvm-exec 2.2 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.15.gemfile'
|
17
|
+
- rvm-exec 2.2 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.15.gemfile'
|
18
|
+
- rvm-exec 2.2 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.13.gemfile'
|
19
|
+
- rvm-exec 2.2 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.13.gemfile'
|
20
|
+
- rvm-exec 2.1 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.15.gemfile'
|
21
|
+
- rvm-exec 2.1 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.15.gemfile'
|
22
|
+
- rvm-exec 2.1 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.13.gemfile'
|
23
|
+
- rvm-exec 2.1 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.13.gemfile'
|
24
|
+
- rvm-exec 2.0 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.15.gemfile'
|
25
|
+
- rvm-exec 2.0 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.15.gemfile'
|
26
|
+
- rvm-exec 2.0 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.13.gemfile'
|
27
|
+
- rvm-exec 2.0 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.13.gemfile'
|
28
|
+
- rvm-exec 1.9 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.15.gemfile'
|
29
|
+
- rvm-exec 1.9 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.15.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.15.gemfile'
|
30
|
+
- rvm-exec 1.9 bash -c 'bundle check --gemfile=gemfiles/rails_3_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_3_zeus_0.13.gemfile'
|
31
|
+
- rvm-exec 1.9 bash -c 'bundle check --gemfile=gemfiles/rails_4_zeus_0.13.gemfile || bundle install --gemfile=gemfiles/rails_4_zeus_0.13.gemfile'
|
32
|
+
|
33
|
+
test:
|
34
|
+
override:
|
35
|
+
- rvm-exec 2.2 bash -c 'bundle exec appraisal rspec'
|
36
|
+
- rvm-exec 2.1 bash -c 'bundle exec appraisal rspec'
|
37
|
+
- rvm-exec 2.0 bash -c 'bundle exec appraisal rspec'
|
38
|
+
- rvm-exec 1.9 bash -c 'bundle exec appraisal rspec'
|
39
|
+
- rvm-exec 2.2 bash -c 'bundle exec rubocop'
|
data/lib/zeus/parallel_tests.rb
CHANGED
@@ -5,14 +5,18 @@ module Zeus
|
|
5
5
|
module ParallelTests
|
6
6
|
class Rails < ::Zeus::Rails
|
7
7
|
def parallel_cucumber
|
8
|
-
|
8
|
+
if ENV.key?('RAILS_ENV')
|
9
|
+
puts "Warning: Deleting RAILS_ENV (which is `#{ENV['RAILS_ENV']}` as Zeus will complain about it."
|
10
|
+
ENV.delete('RAILS_ENV')
|
11
|
+
end
|
12
|
+
exec parallel_runner_command 'cucumber', ARGV
|
9
13
|
end
|
10
14
|
|
11
15
|
def parallel_rspec
|
12
16
|
argv = ARGV.dup
|
13
|
-
argv.delete(
|
14
|
-
argv.delete(
|
15
|
-
exec parallel_runner_command
|
17
|
+
argv.delete('--color') # remove this argument from list
|
18
|
+
argv.delete('--colour') # because it was causing bug #14
|
19
|
+
exec parallel_runner_command 'rspec', argv
|
16
20
|
end
|
17
21
|
|
18
22
|
def parallel_cucumber_worker
|
@@ -35,11 +39,13 @@ module Zeus
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
42
|
+
def cucumber_environment
|
43
|
+
require 'cucumber/rspec/disable_option_parser'
|
44
|
+
require 'cucumber/cli/main'
|
45
|
+
end
|
46
|
+
|
38
47
|
def cucumber(argv = ARGV)
|
39
|
-
|
40
|
-
had_failures = cucumber_main.execute!(@cucumber_runtime)
|
41
|
-
exit_code = had_failures ? 1 : 0
|
42
|
-
exit exit_code
|
48
|
+
::Cucumber::Cli::Main.execute(argv)
|
43
49
|
end
|
44
50
|
|
45
51
|
# End of patches for Zeus
|
@@ -47,20 +53,20 @@ module Zeus
|
|
47
53
|
private
|
48
54
|
|
49
55
|
def parallel_runner_command(suite, argv)
|
50
|
-
env_slave_path = %
|
56
|
+
env_slave_path = %(PARALLEL_TESTS_EXECUTABLE='#{Worker.command suite}')
|
51
57
|
"#{env_slave_path} parallel_#{suite} #{merge_argv(argv)}"
|
52
58
|
end
|
53
59
|
|
54
60
|
def merge_argv(argv)
|
55
|
-
argv.map
|
56
|
-
arg.include?(' ') ? %
|
57
|
-
|
61
|
+
argv.map do |arg|
|
62
|
+
arg.include?(' ') ? %("#{arg}") : arg
|
63
|
+
end.join(' ')
|
58
64
|
end
|
59
65
|
|
60
66
|
def spawn_slave
|
61
67
|
worker, workers_count, args_file = ARGV
|
62
68
|
# Parallels spec reuse main test db instead of db with "1" appended
|
63
|
-
ENV['TEST_ENV_NUMBER'] = test_env_number = (worker ==
|
69
|
+
ENV['TEST_ENV_NUMBER'] = test_env_number = (worker == '1' ? nil : worker)
|
64
70
|
ENV['PARALLEL_TEST_GROUPS'] = workers_count
|
65
71
|
|
66
72
|
reconfigure_activerecord test_env_number
|
@@ -72,6 +78,7 @@ module Zeus
|
|
72
78
|
File.readlines(path).map(&:chomp)
|
73
79
|
end
|
74
80
|
|
81
|
+
# rubocop:disable HandleExceptions
|
75
82
|
def reconfigure_activerecord(test_env_number)
|
76
83
|
return unless defined?(ActiveRecord::Base)
|
77
84
|
begin
|
@@ -87,6 +94,7 @@ module Zeus
|
|
87
94
|
rescue ActiveRecord::AdapterNotSpecified
|
88
95
|
end
|
89
96
|
end
|
97
|
+
# rubocop:enable HandleExceptions
|
90
98
|
end
|
91
99
|
end
|
92
100
|
end
|
@@ -1,55 +1,54 @@
|
|
1
1
|
require_relative '../parallel_tests'
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
-
module Zeus
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
4
|
+
module Zeus
|
5
|
+
module ParallelTests
|
6
|
+
class Worker
|
7
|
+
def self.run(argv, env)
|
8
|
+
dumped_argv = argv.dup
|
9
|
+
new(dumped_argv.shift, env, dumped_argv).spawn
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.command(suite)
|
13
|
+
"ruby #{__FILE__} #{suite}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(suite, env, argv)
|
17
|
+
@env = env
|
18
|
+
@argv = argv
|
19
|
+
@suite = suite
|
20
|
+
end
|
21
|
+
|
22
|
+
def spawn
|
23
|
+
system %(zeus parallel_#{@suite}_worker #{parallel_tests_attributes})
|
24
|
+
args_file.unlink
|
25
|
+
$CHILD_STATUS.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def parallel_tests_attributes
|
31
|
+
[test_env_number.to_s,
|
32
|
+
@env['PARALLEL_TEST_GROUPS'],
|
33
|
+
args_file.path].join(' ')
|
34
|
+
end
|
35
|
+
|
36
|
+
def args_file
|
37
|
+
@args_file ||= begin
|
38
|
+
Tempfile.new('rspec_args').tap do |file|
|
39
|
+
@argv.each do |arg|
|
40
|
+
file.puts arg
|
41
|
+
end
|
42
|
+
file.close
|
40
43
|
end
|
41
|
-
file.close
|
42
44
|
end
|
43
|
-
|
44
|
-
end
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
def test_env_number
|
48
|
+
@env['TEST_ENV_NUMBER'] != '' && @env['TEST_ENV_NUMBER'] || 1
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
if $PROGRAM_NAME == __FILE__
|
53
|
-
exit Zeus::ParallelTests::Worker.run(ARGV, ENV)
|
54
|
-
end
|
55
|
-
|
54
|
+
exit Zeus::ParallelTests::Worker.run(ARGV, ENV) if $PROGRAM_NAME == __FILE__
|
data/spec/dummy/Guardfile
CHANGED
@@ -4,15 +4,15 @@
|
|
4
4
|
guard 'rspec', zeus: true, parallel: true do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
-
watch('spec/spec_helper.rb') {
|
7
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
8
8
|
|
9
9
|
# Rails example
|
10
10
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
11
|
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
12
|
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
-
watch(%r{^spec/support/(.+)\.rb$}) {
|
14
|
-
watch('config/routes.rb') {
|
15
|
-
watch('app/controllers/application_controller.rb') {
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
|
14
|
+
watch('config/routes.rb') { 'spec/routing' }
|
15
|
+
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
|
16
16
|
|
17
17
|
# Capybara features specs
|
18
18
|
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
@@ -12,7 +12,7 @@ require 'rails/all'
|
|
12
12
|
|
13
13
|
if defined?(Bundler)
|
14
14
|
# If you precompile assets before deploying to production, use this line
|
15
|
-
Bundler.require(*Rails.groups(:
|
15
|
+
Bundler.require(*Rails.groups(assets: %w(development test)))
|
16
16
|
# If you want your assets lazily compiled in production, use this line
|
17
17
|
# Bundler.require(:default, :assets, Rails.env)
|
18
18
|
end
|
@@ -42,7 +42,7 @@ module Dummy
|
|
42
42
|
# config.i18n.default_locale = :de
|
43
43
|
|
44
44
|
# Configure the default encoding used in templates for Ruby 1.9.
|
45
|
-
config.encoding =
|
45
|
+
config.encoding = 'utf-8'
|
46
46
|
|
47
47
|
# Configure sensitive parameters which will be filtered from the log file.
|
48
48
|
config.filter_parameters += [:password]
|
@@ -54,12 +54,5 @@ module Dummy
|
|
54
54
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
55
55
|
# like if you have constraints or database-specific column types
|
56
56
|
# config.active_record.schema_format = :sql
|
57
|
-
|
58
|
-
# Enforce whitelist mode for mass assignment.
|
59
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
60
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
61
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
62
|
-
config.active_record.whitelist_attributes = true
|
63
|
-
|
64
57
|
end
|
65
58
|
end
|