parallel_tests 1.3.9 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8126226af76d2ce93824461837f808b5e098af09
4
- data.tar.gz: 802444bf82a369e183f8aa0b8e5c4c788f659d2e
3
+ metadata.gz: b3512429e43f2437a7ea406a482429d0aed04bc2
4
+ data.tar.gz: ecec8c02adeb6d47fac8fa5c91ad0c381dc29091
5
5
  SHA512:
6
- metadata.gz: ec9c6cedfd0c129d4556fd6a44ffeea0d083bc7d1f8dbbdc5e3577b4a0a035bffc33ed7d9df80e3f9284458b590e7dc9e53f10f3ebf5535bf5209e68081cd241
7
- data.tar.gz: 81e5fa727c44da60db4b81e8ca1ce056a7567625b996351860d7110e2ffb726aa894014be93c170b51e4a1b5adf5d30bfb1a1025b4c1d85296348d671cafcd86
6
+ metadata.gz: 88bb06f48e8d5a1e6baf5e5a2bd647c7b521b69ea7c94e8644da3f5a460ed5d685fcf6f6623dee97cf78710a8bf4d3d9313563d42407902cdd772f7996f2ee9f
7
+ data.tar.gz: 3f2616efa9a7a319b45b7fb0be87a6e37e81a50c99d94bf0442d0462ccebc7841e547b88dc5e3f822544ba157d4669739dcaf45e97cab8af6139aadd64693ec0
data/Readme.md CHANGED
@@ -162,12 +162,17 @@ Setup for non-rails
162
162
  parallel_cucumber features/
163
163
  parallel_spinach features/
164
164
 
165
- - use ENV['TEST_ENV_NUMBER'] inside your tests to select separate db/memcache/etc.
165
+ - use `ENV['TEST_ENV_NUMBER']` inside your tests to select separate db/memcache/etc.
166
166
  - Only run selected files & folders:
167
167
 
168
- parallel_test test/bar test/baz/foo_text.rb
168
+ `parallel_test test/bar test/baz/foo_text.rb`
169
+
170
+ - Pass test-options and files via `--`:
171
+
172
+ `parallel_test -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance`
169
173
 
170
174
  Options are:
175
+ <!-- copy output from bundle exec ./bin/parallel_test -h -->
171
176
 
172
177
  -n [PROCESSES] How many processes to use, default: available CPUs
173
178
  -p, --pattern [PATTERN] run tests matching this pattern
@@ -182,7 +187,7 @@ Options are:
182
187
  -s, --single [PATTERN] Run all matching files in the same process
183
188
  -i, --isolate Do not run any other tests in the group used by --single(-s)
184
189
  --only-group INT[, INT]
185
- -e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUM']
190
+ -e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUMBER']
186
191
  -o, --test-options '[OPTIONS]' execute test commands with those options
187
192
  -t, --type [TYPE] test(default) / rspec / cucumber / spinach
188
193
  --serialize-stdout Serialize stdout output, nothing will be written until everything is done
@@ -196,7 +201,7 @@ Options are:
196
201
  -v, --version Show Version
197
202
  -h, --help Show this.
198
203
 
199
- You can run any kind of code in parallel with -e / --execute
204
+ You can run any kind of code in parallel with -e / --exec
200
205
 
201
206
  parallel_test -n 5 -e 'ruby -e "puts %[hello from process #{ENV[:TEST_ENV_NUMBER.to_s].inspect}]"'
202
207
  hello from process "2"
@@ -229,6 +234,7 @@ TIPS
229
234
  - [zeus-parallel_tests](https://github.com/sevos/zeus-parallel_tests)
230
235
  - [Distributed parallel test (e.g. Travis Support)](https://github.com/grosser/parallel_tests/wiki/Distributed-Parallel-Tests-and-Travis-Support)
231
236
  - Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser)
237
+ - Shell alias: `alias prspec='parallel_rspec -m 2 --'`
232
238
  - Contribute your own gotaches to the [Wiki](https://github.com/grosser/parallel_tests/wiki) or even better open a PR :)
233
239
 
234
240
  TODO
@@ -309,6 +315,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
309
315
  - [Mike Mueller](https://github.com/mmueller)
310
316
  - [Aaron Jensen](https://github.com/aaronjensen)
311
317
  - [Ed Slocomb](https://github.com/edslocomb)
318
+ - [Cezary Baginski](https://github.com/e2)
312
319
 
313
320
  [Michael Grosser](http://grosser.it)<br/>
314
321
  michael@grosser.it<br/>
@@ -1,6 +1,7 @@
1
1
  require 'optparse'
2
2
  require 'tempfile'
3
3
  require 'parallel_tests'
4
+ require 'shellwords'
4
5
 
5
6
  module ParallelTests
6
7
  class CLI
@@ -106,8 +107,11 @@ module ParallelTests
106
107
  opts.banner = <<-BANNER.gsub(/^ /, '')
107
108
  Run all tests in parallel, giving each process ENV['TEST_ENV_NUMBER'] ('', '2', '3', ...)
108
109
 
109
- [optional] Only run selected files & folders:
110
- parallel_test test/bar test/baz/xxx_text.rb
110
+ [optional] Only selected files & folders:
111
+ parallel_test test/bar test/baz/xxx_text.rb
112
+
113
+ [optional] Pass test-options and files via `--`:
114
+ parallel_test -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance
111
115
 
112
116
  Options are:
113
117
  BANNER
@@ -140,8 +144,8 @@ module ParallelTests
140
144
 
141
145
  opts.on("--only-group INT[, INT]", Array) { |groups| options[:only_group] = groups.map(&:to_i) }
142
146
 
143
- opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUM']") { |path| options[:execute] = path }
144
- opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg }
147
+ opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |path| options[:execute] = path }
148
+ opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg.lstrip }
145
149
  opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber / spinach") do |type|
146
150
  begin
147
151
  @runner = load_runner(type)
@@ -167,9 +171,13 @@ module ParallelTests
167
171
  options[:non_parallel] = true
168
172
  end
169
173
 
170
- abort "Pass files or folders to run" if argv.empty? && !options[:execute]
174
+ files, remaining = extract_file_paths(argv)
175
+ unless options[:execute]
176
+ abort "Pass files or folders to run" unless files.any?
177
+ options[:files] = files
178
+ end
171
179
 
172
- options[:files] = argv
180
+ append_test_options(options, remaining)
173
181
 
174
182
  options[:group_by] ||= :filesize if options[:only_group]
175
183
 
@@ -182,6 +190,25 @@ module ParallelTests
182
190
  options
183
191
  end
184
192
 
193
+ def extract_file_paths(argv)
194
+ dash_index = argv.rindex("--")
195
+ file_args_at = (dash_index || -1) + 1
196
+ [argv[file_args_at..-1], argv[0...(dash_index || 0)]]
197
+ end
198
+
199
+ def extract_test_options(argv)
200
+ dash_index = argv.index("--") || -1
201
+ argv[dash_index+1..-1]
202
+ end
203
+
204
+ def append_test_options(options, argv)
205
+ new_opts = extract_test_options(argv)
206
+ return if new_opts.empty?
207
+
208
+ prev_and_new = [options[:test_options], new_opts.shelljoin]
209
+ options[:test_options] = prev_and_new.compact.join(' ')
210
+ end
211
+
185
212
  def load_runner(type)
186
213
  require "parallel_tests/#{type}/runner"
187
214
  runner_classname = type.split("_").map(&:capitalize).join.sub("Rspec", "RSpec")
@@ -2,26 +2,24 @@ require 'parallel_tests/rspec/logger_base'
2
2
  require 'parallel_tests/rspec/runner'
3
3
 
4
4
  class ParallelTests::RSpec::FailuresLogger < ParallelTests::RSpec::LoggerBase
5
- if RSPEC_3
6
- RSpec::Core::Formatters.register self, :dump_failures, :dump_summary
7
- end
8
-
9
- # RSpec 1: does not keep track of failures, so we do
10
- def example_failed(example, *args)
11
- if RSPEC_1
12
- @failed_examples ||= []
13
- @failed_examples << example
14
- else
15
- super
5
+ if RSPEC_1
6
+ # RSpec 1: does not keep track of failures, so we do
7
+ def example_failed(example, *args)
8
+ if RSPEC_1
9
+ @failed_examples ||= []
10
+ @failed_examples << example
11
+ else
12
+ super
13
+ end
16
14
  end
17
- end
18
15
 
19
- if RSPEC_1
20
16
  def dump_failure(*args)
21
17
  end
22
- else
18
+ elsif RSPEC_2
23
19
  def dump_failures(*args)
24
20
  end
21
+ else
22
+ RSpec::Core::Formatters.register self, :dump_summary
25
23
  end
26
24
 
27
25
  def dump_summary(*args)
@@ -15,6 +15,7 @@ ParallelTests::RSpec::LoggerBaseBase = base
15
15
 
16
16
  class ParallelTests::RSpec::LoggerBase < ParallelTests::RSpec::LoggerBaseBase
17
17
  RSPEC_1 = !defined?(RSpec::Core::Formatters::BaseTextFormatter) # do not test for Spec, this will trigger deprecation warning in rspec 2
18
+ RSPEC_2 = !RSPEC_1 && RSpec::Core::Version::STRING.start_with?('2')
18
19
  RSPEC_3 = !RSPEC_1 && RSpec::Core::Version::STRING.start_with?('3')
19
20
 
20
21
  def initialize(*args)
@@ -102,7 +102,7 @@ namespace :parallel do
102
102
  # just load the schema (good for integration server <-> no development db)
103
103
  desc "load dumped schema for test databases via db:schema:load --> parallel:load_schema[num_cpus]"
104
104
  task :load_schema, :count do |t,args|
105
- command = "rake db:schema:load RAILS_ENV=#{ParallelTests::Tasks.rails_env}"
105
+ command = "rake db:test:purge db:schema:load RAILS_ENV=#{ParallelTests::Tasks.rails_env}"
106
106
  ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_output(command, "^ ->\\|^-- "), args)
107
107
  end
108
108
 
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '1.3.9'
2
+ VERSION = Version = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-05 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.2.2
84
+ rubygems_version: 2.2.3
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Run Test::Unit / RSpec / Cucumber / Spinach in parallel