parallel_tests 3.7.0 → 3.8.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
  SHA256:
3
- metadata.gz: 52c2ebdfc604b9e238867ea3d7d78cb919d60c951ab45bd2ead93db8893352f4
4
- data.tar.gz: 441cf2b41a814746e1704fd794cd147638dbd261f1b294fd74b49adb9bc6d0da
3
+ metadata.gz: 3e3e1a135eda0167339276ebde8bbdc6c0620c83d08b36ca150cb19b2651bd18
4
+ data.tar.gz: 759e3dd86a759cb2217f82b2b92bdc0e83e11d6e1d17cb7226d37eaa6c7ebade
5
5
  SHA512:
6
- metadata.gz: a20853e2eac4f7b4260ea3ac3a9515b3d83fa3b47ff411a5f9567fcde257044825b2e9a81047e01f4d72722c02a6fdd2dbffba026dafb236cff8c2be2b712134
7
- data.tar.gz: 4483fac06b11b0615b2bd39dcc5487713a02105cac547cf50177ec30805a8b17ebdbbac679e88a84f57da702235998cc0f67b80e382ea0bd27e784f4e89639a0
6
+ metadata.gz: 825d480ce774744fd4caa2fc5016be513384385ca88fc14b90552efef04041b45912246aa26557217d3f09e4810fc85ac4634381aadfcf0e0375ed4413c50557
7
+ data.tar.gz: f927123ce02a41fadd99ab7045aad0e00464488c81d2cf2567e47180909c36be2d220d3c5192fbb0820f4f6c89ac29fc33f23368be5cb702d1aa55f66f419da8
data/Readme.md CHANGED
@@ -42,6 +42,9 @@ test:
42
42
 
43
43
  ### Setup environment from scratch (create db and loads schema, useful for CI)
44
44
  rake parallel:setup
45
+
46
+ ### Drop all test databases
47
+ rake parallel:drop
45
48
 
46
49
  ### Run!
47
50
  rake parallel:test # Test::Unit
@@ -182,19 +185,24 @@ Setup for non-rails
182
185
 
183
186
  gem install parallel_tests
184
187
  # go to your project dir
185
- parallel_test test/
186
- parallel_rspec spec/
187
- parallel_cucumber features/
188
- parallel_spinach features/
188
+ parallel_test
189
+ parallel_rspec
190
+ parallel_cucumber
191
+ parallel_spinach
189
192
 
190
- - use `ENV['TEST_ENV_NUMBER']` inside your tests to select separate db/memcache/etc.
191
- - Only run selected files & folders:
193
+ - use `ENV['TEST_ENV_NUMBER']` inside your tests to select separate db/memcache/etc. (docker compose: expose it)
192
194
 
195
+ - Only run a subset of files / folders:
196
+
193
197
  `parallel_test test/bar test/baz/foo_text.rb`
194
198
 
195
199
  - Pass test-options and files via `--`:
196
-
197
- `parallel_test -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance`
200
+
201
+ `parallel_rspec -- -t acceptance -f progress -- spec/foo_spec.rb spec/acceptance`
202
+
203
+ - Pass in test options, by using the -o flag (wrap everything in quotes):
204
+
205
+ `parallel_cucumber -n 2 -o '-p foo_profile --tags @only_this_tag or @only_that_tag --format summary'`
198
206
 
199
207
  Options are:
200
208
  <!-- copy output from bundle exec ./bin/parallel_test -h -->
@@ -393,6 +401,7 @@ inspired by [pivotal labs](https://blog.pivotal.io/labs/labs/parallelize-your-rs
393
401
  - [Nathan Broadbent](https://github.com/ndbroadbent)
394
402
  - [Vikram B Kumar](https://github.com/v-kumar)
395
403
  - [Joshua Pinter](https://github.com/joshuapinter)
404
+ - [Zach Dennis](https://github.com/zdennis)
396
405
 
397
406
  [Michael Grosser](http://grosser.it)<br/>
398
407
  michael@grosser.it<br/>
@@ -322,12 +322,12 @@ module ParallelTests
322
322
  def extract_file_paths(argv)
323
323
  dash_index = argv.rindex("--")
324
324
  file_args_at = (dash_index || -1) + 1
325
- [argv[file_args_at..-1], argv[0...(dash_index || 0)]]
325
+ [argv[file_args_at..], argv[0...(dash_index || 0)]]
326
326
  end
327
327
 
328
328
  def extract_test_options(argv)
329
329
  dash_index = argv.index("--") || -1
330
- argv[dash_index + 1..-1]
330
+ argv[dash_index + 1..]
331
331
  end
332
332
 
333
333
  def append_test_options(options, argv)
@@ -27,7 +27,7 @@ module ParallelTests
27
27
  example_tags = example.tags.map(&:name)
28
28
  example_tags = scenario_tags + example_tags
29
29
  next unless matches_tags?(example_tags)
30
- example.rows[1..-1].each do |row|
30
+ example.rows[1..].each do |row|
31
31
  test_line = row.source_line
32
32
  next if line_numbers.any? && !line_numbers.include?(test_line)
33
33
 
@@ -24,8 +24,8 @@ module ParallelTests
24
24
  cmd = [
25
25
  executable,
26
26
  (runtime_logging if File.directory?(File.dirname(runtime_log))),
27
- cucumber_opts(options[:test_options]),
28
- *sanitized_test_files
27
+ *sanitized_test_files,
28
+ cucumber_opts(options[:test_options])
29
29
  ].compact.reject(&:empty?).join(' ')
30
30
  execute_command(cmd, process_number, num_processes, options)
31
31
  end
@@ -62,7 +62,7 @@ module ParallelTests
62
62
  plural = "s" if (word == group) && (number != 1)
63
63
  "#{number} #{word}#{plural}"
64
64
  end
65
- "#{sums[0]} (#{sums[1..-1].join(", ")})"
65
+ "#{sums[0]} (#{sums[1..].join(", ")})"
66
66
  end.compact.join("\n")
67
67
  end
68
68
 
@@ -38,7 +38,7 @@ module ParallelTests
38
38
  # add all files that should run in a multiple isolated processes to their own groups
39
39
  group_features_by_size(items_to_group(single_items), groups[0..(isolate_count - 1)])
40
40
  # group the non-isolated by size
41
- group_features_by_size(items_to_group(items), groups[isolate_count..-1])
41
+ group_features_by_size(items_to_group(items), groups[isolate_count..])
42
42
  else
43
43
  # add all files that should run in a single non-isolated process to first group
44
44
  single_items.each { |item, size| add_to_group(groups.first, item, size) }
@@ -43,14 +43,14 @@ module ParallelTests
43
43
 
44
44
  def read
45
45
  sync do
46
- contents = IO.read(file_path)
46
+ contents = File.read(file_path)
47
47
  return if contents.empty?
48
48
  @pids = JSON.parse(contents)
49
49
  end
50
50
  end
51
51
 
52
52
  def save
53
- sync { IO.write(file_path, pids.to_json) }
53
+ sync { File.write(file_path, pids.to_json) }
54
54
  end
55
55
 
56
56
  def sync(&block)
@@ -92,6 +92,32 @@ module ParallelTests
92
92
 
93
93
  [num_processes, pattern.to_s, options.to_s, pass_through.to_s]
94
94
  end
95
+
96
+ def schema_format_based_on_rails_version
97
+ if rails_7_or_greater?
98
+ ActiveRecord.schema_format
99
+ else
100
+ ActiveRecord::Base.schema_format
101
+ end
102
+ end
103
+
104
+ def schema_type_based_on_rails_version
105
+ if rails_61_or_greater? || schema_format_based_on_rails_version == :ruby
106
+ "schema"
107
+ else
108
+ "structure"
109
+ end
110
+ end
111
+
112
+ private
113
+
114
+ def rails_7_or_greater?
115
+ Gem::Version.new(Rails.version) >= Gem::Version.new('7.0')
116
+ end
117
+
118
+ def rails_61_or_greater?
119
+ Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0')
120
+ end
95
121
  end
96
122
  end
97
123
  end
@@ -121,14 +147,10 @@ namespace :parallel do
121
147
  desc "Update test databases by dumping and loading --> parallel:prepare[num_cpus]"
122
148
  task(:prepare, [:count]) do |_, args|
123
149
  ParallelTests::Tasks.check_for_pending_migrations
124
- if defined?(ActiveRecord::Base) && [:ruby, :sql].include?(ActiveRecord::Base.schema_format)
150
+
151
+ if defined?(ActiveRecord) && [:ruby, :sql].include?(ParallelTests::Tasks.schema_format_based_on_rails_version)
125
152
  # fast: dump once, load in parallel
126
- type =
127
- if Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0')
128
- "schema"
129
- else
130
- ActiveRecord::Base.schema_format == :ruby ? "schema" : "structure"
131
- end
153
+ type = ParallelTests::Tasks.schema_type_based_on_rails_version
132
154
 
133
155
  Rake::Task["db:#{type}:dump"].invoke
134
156
 
@@ -163,7 +185,8 @@ namespace :parallel do
163
185
  # just load the schema (good for integration server <-> no development db)
164
186
  desc "Load dumped schema for test databases via db:schema:load --> parallel:load_schema[num_cpus]"
165
187
  task :load_schema, :count do |_, args|
166
- command = "#{ParallelTests::Tasks.rake_bin} #{ParallelTests::Tasks.purge_before_load} " \
188
+ command =
189
+ "#{ParallelTests::Tasks.rake_bin} #{ParallelTests::Tasks.purge_before_load} " \
167
190
  "db:schema:load RAILS_ENV=#{ParallelTests::Tasks.rails_env} DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
168
191
  ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args)
169
192
  end
@@ -211,7 +234,8 @@ namespace :parallel do
211
234
  # Using the relative path to find the binary allow to run a specific version of it
212
235
  executable = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')
213
236
 
214
- command = "#{ParallelTests.with_ruby_binary(Shellwords.escape(executable))} #{type} " \
237
+ command =
238
+ "#{ParallelTests.with_ruby_binary(Shellwords.escape(executable))} #{type} " \
215
239
  "--type #{test_framework} " \
216
240
  "-n #{count} " \
217
241
  "--pattern '#{pattern}' " \
@@ -24,7 +24,7 @@ module ParallelTests
24
24
  end
25
25
 
26
26
  def run_tests(test_files, process_number, num_processes, options)
27
- require_list = test_files.map { |file| file.sub(" ", "\\ ") }.join(" ")
27
+ require_list = test_files.map { |file| file.gsub(" ", "\\ ") }.join(" ")
28
28
  cmd = "#{executable} -Itest -e '%w[#{require_list}].each { |f| require %{./\#{f}} }' -- #{options[:test_options]}"
29
29
  execute_command(cmd, process_number, num_processes, options)
30
30
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ParallelTests
3
- VERSION = '3.7.0'
3
+ VERSION = '3.8.0'
4
4
  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: 3.7.0
4
+ version: 3.8.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: 2021-04-08 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -68,8 +68,8 @@ licenses:
68
68
  - MIT
69
69
  metadata:
70
70
  bug_tracker_uri: https://github.com/grosser/parallel_tests/issues
71
- documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.7.0/Readme.md
72
- source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.7.0
71
+ documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.8.0/Readme.md
72
+ source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.8.0
73
73
  wiki_uri: https://github.com/grosser/parallel_tests/wiki
74
74
  post_install_message:
75
75
  rdoc_options: []
@@ -79,14 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 2.5.0
82
+ version: 2.7.0
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.1.3
89
+ rubygems_version: 3.1.6
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Run Test::Unit / RSpec / Cucumber / Spinach in parallel