parallel_tests 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +10 -0
- data/lib/parallel_tests/tasks.rb +73 -33
- data/lib/parallel_tests/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b46d1404706ddf69fdaae9b58cb24f86f894a87dcc629865ae18b664c8a1835
|
4
|
+
data.tar.gz: 00f2931c2ba28191e7ff3256edea0e43c516212b035fca3ae8a57ba154cf1014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74c9ffe885e299f8f2a603b07a0a9e6597eb4ec52529acac790e3b36e4ce8ee9c73c537fdff67131fce664819e1adefc7c376474ff139140f62393e0d32f6aa4
|
7
|
+
data.tar.gz: 72120ba7eb205d54c484a71fd58a86bfd95787e4967bf754c19857d5cf2970803a963a70f2e60dc448e61b61eea13c32b8ad7b16762106da9efc743a891d4da8
|
data/Readme.md
CHANGED
@@ -33,18 +33,28 @@ test:
|
|
33
33
|
### Create additional database(s)
|
34
34
|
rake parallel:create
|
35
35
|
|
36
|
+
### (Multi-DB) Create individual database
|
37
|
+
rake parallel:create:<database>
|
38
|
+
rake parallel:create:secondary
|
39
|
+
|
36
40
|
### Copy development schema (repeat after migrations)
|
37
41
|
rake parallel:prepare
|
38
42
|
|
39
43
|
### Run migrations in additional database(s) (repeat after migrations)
|
40
44
|
rake parallel:migrate
|
41
45
|
|
46
|
+
### (Multi-DB) Run migrations in individual database
|
47
|
+
rake parallel:migrate:<database>
|
48
|
+
|
42
49
|
### Setup environment from scratch (create db and loads schema, useful for CI)
|
43
50
|
rake parallel:setup
|
44
51
|
|
45
52
|
### Drop all test databases
|
46
53
|
rake parallel:drop
|
47
54
|
|
55
|
+
### (Multi-DB) Drop individual test database
|
56
|
+
rake parallel:drop:<database>
|
57
|
+
|
48
58
|
### Run!
|
49
59
|
rake parallel:test # Minitest
|
50
60
|
rake parallel:spec # RSpec
|
data/lib/parallel_tests/tasks.rb
CHANGED
@@ -48,6 +48,9 @@ module ParallelTests
|
|
48
48
|
activate_pipefail = "set -o pipefail"
|
49
49
|
remove_ignored_lines = %{(grep -v #{Shellwords.escape(ignore_regex)} || true)}
|
50
50
|
|
51
|
+
# remove nil values (ex: #purge_before_load returns nil)
|
52
|
+
command.compact!
|
53
|
+
|
51
54
|
if system('/bin/bash', '-c', "#{activate_pipefail} 2>/dev/null")
|
52
55
|
shell_command = "#{activate_pipefail} && (#{Shellwords.shelljoin(command)}) | #{remove_ignored_lines}"
|
53
56
|
['/bin/bash', '-c', shell_command]
|
@@ -125,6 +128,23 @@ module ParallelTests
|
|
125
128
|
command
|
126
129
|
end
|
127
130
|
|
131
|
+
def configured_databases
|
132
|
+
return [] unless defined?(ActiveRecord) && rails_61_or_greater?
|
133
|
+
|
134
|
+
@@configured_databases ||= ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
|
135
|
+
end
|
136
|
+
|
137
|
+
def for_each_database(&block)
|
138
|
+
# Use nil to represent all databases
|
139
|
+
block&.call(nil)
|
140
|
+
|
141
|
+
return unless defined?(ActiveRecord)
|
142
|
+
|
143
|
+
ActiveRecord::Tasks::DatabaseTasks.for_each(configured_databases) do |name|
|
144
|
+
block&.call(name)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
128
148
|
private
|
129
149
|
|
130
150
|
def rails_7_or_greater?
|
@@ -145,25 +165,33 @@ namespace :parallel do
|
|
145
165
|
ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args)
|
146
166
|
end
|
147
167
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
168
|
+
ParallelTests::Tasks.for_each_database do |name|
|
169
|
+
task_name = 'create'
|
170
|
+
task_name += ":#{name}" if name
|
171
|
+
desc "Create test#{" #{name}" if name} database via db:#{task_name} --> parallel:#{task_name}[num_cpus]"
|
172
|
+
task task_name.to_sym, :count do |_, args|
|
173
|
+
ParallelTests::Tasks.run_in_parallel(
|
174
|
+
[$0, "db:#{task_name}", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"],
|
175
|
+
args
|
176
|
+
)
|
177
|
+
end
|
154
178
|
end
|
155
179
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
180
|
+
ParallelTests::Tasks.for_each_database do |name|
|
181
|
+
task_name = 'drop'
|
182
|
+
task_name += ":#{name}" if name
|
183
|
+
desc "Drop test#{" #{name}" if name} database via db:#{task_name} --> parallel:#{task_name}[num_cpus]"
|
184
|
+
task task_name.to_sym, :count do |_, args|
|
185
|
+
ParallelTests::Tasks.run_in_parallel(
|
186
|
+
[
|
187
|
+
$0,
|
188
|
+
"db:#{task_name}",
|
189
|
+
"RAILS_ENV=#{ParallelTests::Tasks.rails_env}",
|
190
|
+
"DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
|
191
|
+
],
|
192
|
+
args
|
193
|
+
)
|
194
|
+
end
|
167
195
|
end
|
168
196
|
|
169
197
|
desc "Update test databases by dumping and loading --> parallel:prepare[num_cpus]"
|
@@ -190,12 +218,16 @@ namespace :parallel do
|
|
190
218
|
end
|
191
219
|
|
192
220
|
# when dumping/resetting takes too long
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
221
|
+
ParallelTests::Tasks.for_each_database do |name|
|
222
|
+
task_name = 'migrate'
|
223
|
+
task_name += ":#{name}" if name
|
224
|
+
desc "Update test#{" #{name}" if name} database via db:#{task_name} --> parallel:#{task_name}[num_cpus]"
|
225
|
+
task task_name.to_sym, :count do |_, args|
|
226
|
+
ParallelTests::Tasks.run_in_parallel(
|
227
|
+
[$0, "db:#{task_name}", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"],
|
228
|
+
args
|
229
|
+
)
|
230
|
+
end
|
199
231
|
end
|
200
232
|
|
201
233
|
desc "Rollback test databases via db:rollback --> parallel:rollback[num_cpus]"
|
@@ -207,16 +239,24 @@ namespace :parallel do
|
|
207
239
|
end
|
208
240
|
|
209
241
|
# just load the schema (good for integration server <-> no development db)
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
242
|
+
ParallelTests::Tasks.for_each_database do |name|
|
243
|
+
rails_task = 'db:schema:load'
|
244
|
+
rails_task += ":#{name}" if name
|
245
|
+
|
246
|
+
task_name = 'load_schema'
|
247
|
+
task_name += ":#{name}" if name
|
248
|
+
|
249
|
+
desc "Load dumped schema for test#{" #{name}" if name} database via #{rails_task} --> parallel:#{task_name}[num_cpus]"
|
250
|
+
task task_name.to_sym, :count do |_, args|
|
251
|
+
command = [
|
252
|
+
$0,
|
253
|
+
ParallelTests::Tasks.purge_before_load,
|
254
|
+
rails_task,
|
255
|
+
"RAILS_ENV=#{ParallelTests::Tasks.rails_env}",
|
256
|
+
"DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
|
257
|
+
]
|
258
|
+
ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args)
|
259
|
+
end
|
220
260
|
end
|
221
261
|
|
222
262
|
# load the structure from the structure.sql file
|
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: 4.
|
4
|
+
version: 4.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:
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -69,8 +69,8 @@ licenses:
|
|
69
69
|
- MIT
|
70
70
|
metadata:
|
71
71
|
bug_tracker_uri: https://github.com/grosser/parallel_tests/issues
|
72
|
-
documentation_uri: https://github.com/grosser/parallel_tests/blob/v4.
|
73
|
-
source_code_uri: https://github.com/grosser/parallel_tests/tree/v4.
|
72
|
+
documentation_uri: https://github.com/grosser/parallel_tests/blob/v4.5.0/Readme.md
|
73
|
+
source_code_uri: https://github.com/grosser/parallel_tests/tree/v4.5.0
|
74
74
|
wiki_uri: https://github.com/grosser/parallel_tests/wiki
|
75
75
|
post_install_message:
|
76
76
|
rdoc_options: []
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
90
|
+
rubygems_version: 3.4.10
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Run Test::Unit / RSpec / Cucumber / Spinach in parallel
|