parallel_tests 2.21.0 → 2.21.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b21c43a2b0797b545335a094d846b070d300c576
4
- data.tar.gz: 7ce394c192647e4aed53937d42494a8bfd2ae4b8
3
+ metadata.gz: 859dbc6f86dedda88f0eddc04d5f07e949e737ff
4
+ data.tar.gz: c62eacaa3c1d018957fd94d47d025df1e06e9d6d
5
5
  SHA512:
6
- metadata.gz: cfe3cf7c94d8af96f075cb72b1cb100a85c4fc08e7f682c8e6f1b72f9dfd89e3090c8cd4507b14db72f81fad74ed8d3b9e903729a87c662d9b540898d64d61f7
7
- data.tar.gz: 800d91f9284cbb94e0d16d7f93b9e21309818c1271c89eee80e934da80bc5eb32c12d5162710001085659555b2fb71e09519a07bb3ee87a3bea4f63953fd3380
6
+ metadata.gz: b306f589ad75ed0ac4ad636cbdda41f370ab58f036d1013536c997a2dc80fce8662e0ed83e157e7809b514ba2c149b88588af6c252d56531b84daaf775f14fc9
7
+ data.tar.gz: ebf66916a6ddb13e185013251f8e1f3a1b5a7be8d84d4815ad79e8adb336e2c6878cd036d4d2e9afa0e9e420cefecf99991f3e894a3b1fc01c14e343e2cd8d8f
@@ -20,12 +20,27 @@ module ParallelTests
20
20
  ].detect{|c| not c.to_s.strip.empty? }.to_i
21
21
  end
22
22
 
23
+ def with_pid_file
24
+ Tempfile.open('parallel_tests-pidfile') do |f|
25
+ begin
26
+ ENV['PARALLEL_PID_FILE'] = f.path
27
+ # Pids object should be created before threads will start adding pids to it
28
+ # Otherwise we would have to use Mutex to prevent creation of several instances
29
+ @pids = pids
30
+ yield
31
+ ensure
32
+ ENV['PARALLEL_PID_FILE'] = nil
33
+ @pids = nil
34
+ end
35
+ end
36
+ end
37
+
23
38
  def pids
24
39
  @pids ||= Pids.new(pid_file_path)
25
40
  end
26
41
 
27
42
  def pid_file_path
28
- ENV['PARALLEL_PID_FILE'] ||= Tempfile.new('parallel-tests-pidfile').path
43
+ ENV.fetch('PARALLEL_PID_FILE')
29
44
  end
30
45
 
31
46
  def stop_all_processes
@@ -39,17 +39,18 @@ module ParallelTests
39
39
 
40
40
  def execute_in_parallel(items, num_processes, options)
41
41
  Tempfile.open 'parallel_tests-lock' do |lock|
42
- progress_indicator = simulate_output_for_ci if options[:serialize_stdout]
43
-
44
- ParallelTests.pids # setup the class vars here so we dont initialize in the threads
45
- Parallel.map(items, :in_threads => num_processes) do |item|
46
- result = yield(item)
47
- if progress_indicator && progress_indicator.alive?
48
- progress_indicator.exit
49
- puts
42
+ ParallelTests.with_pid_file do
43
+ progress_indicator = simulate_output_for_ci if options[:serialize_stdout]
44
+
45
+ Parallel.map(items, :in_threads => num_processes) do |item|
46
+ result = yield(item)
47
+ if progress_indicator && progress_indicator.alive?
48
+ progress_indicator.exit
49
+ puts
50
+ end
51
+ reprint_output(result, lock.path) if options[:serialize_stdout]
52
+ result
50
53
  end
51
- reprint_output(result, lock.path) if options[:serialize_stdout]
52
- result
53
54
  end
54
55
  end
55
56
  end
@@ -276,8 +277,10 @@ module ParallelTests
276
277
  (0...num_processes).to_a
277
278
  end
278
279
  results = if options[:non_parallel]
279
- runs.map do |i|
280
- ParallelTests::Test::Runner.execute_command(command, i, num_processes, options)
280
+ ParallelTests.with_pid_file do
281
+ runs.map do |i|
282
+ ParallelTests::Test::Runner.execute_command(command, i, num_processes, options)
283
+ end
281
284
  end
282
285
  else
283
286
  execute_in_parallel(runs, runs.size, options) do |i|
@@ -1,4 +1,3 @@
1
- require 'tempfile'
2
1
  require 'json'
3
2
 
4
3
  module ParallelTests
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '2.21.0'
2
+ VERSION = Version = '2.21.1'
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: 2.21.0
4
+ version: 2.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel