|
5 | 5 | require 'logger' |
6 | 6 | require 'parallel' |
7 | 7 |
|
8 | | -# rubocop:disable Style/GlobalVars |
9 | 8 | describe OctocatalogDiff::Util::Parallel do |
10 | 9 | before(:each) do |
11 | | - $octocatalog_diff_util_parallel_spec_tempdir = Dir.mktmpdir |
| 10 | + ENV['OCTOCATALOG_DIFF_TEMPDIR'] = Dir.mktmpdir |
12 | 11 | end |
13 | 12 |
|
14 | 13 | after(:each) do |
15 | | - OctocatalogDiff::Spec.clean_up_tmpdir($octocatalog_diff_util_parallel_spec_tempdir) |
| 14 | + OctocatalogDiff::Spec.clean_up_tmpdir(ENV['OCTOCATALOG_DIFF_TEMPDIR']) |
| 15 | + ENV.delete('OCTOCATALOG_DIFF_TEMPDIR') |
16 | 16 | end |
17 | 17 |
|
18 | 18 | context 'with parallel processing' do |
@@ -50,13 +50,13 @@ def two(arg, _logger = nil) |
50 | 50 | it 'should handle a task that fails after other successes' do |
51 | 51 | class Foo |
52 | 52 | def one(arg, _logger = nil) |
53 | | - File.open(File.join($octocatalog_diff_util_parallel_spec_tempdir, 'one'), 'w') { |f| f.write '' } |
| 53 | + File.open(File.join(ENV['OCTOCATALOG_DIFF_TEMPDIR'], 'one'), 'w') { |f| f.write '' } |
54 | 54 | 'one ' + arg |
55 | 55 | end |
56 | 56 |
|
57 | 57 | def two(_arg, _logger = nil) |
58 | 58 | 100.times do |
59 | | - break if File.file?(File.join($octocatalog_diff_util_parallel_spec_tempdir, 'one')) |
| 59 | + break if File.file?(File.join(ENV['OCTOCATALOG_DIFF_TEMPDIR'], 'one')) |
60 | 60 | sleep 0.1 |
61 | 61 | end |
62 | 62 | # Sometimes the system will still handle the second process if it's near-simultaneous |
@@ -90,7 +90,7 @@ def two(_arg, _logger = nil) |
90 | 90 | class Foo |
91 | 91 | def one(arg, _logger = nil) |
92 | 92 | sleep 10 |
93 | | - File.open(File.join($octocatalog_diff_util_parallel_spec_tempdir, 'one'), 'w') { |f| f.write '' } |
| 93 | + File.open(File.join(ENV['OCTOCATALOG_DIFF_TEMPDIR'], 'one'), 'w') { |f| f.write '' } |
94 | 94 | 'one ' + arg |
95 | 95 | end |
96 | 96 |
|
@@ -119,7 +119,7 @@ def two(_arg, _logger = nil) |
119 | 119 | expect(two_result.exception).to be_a_kind_of(RuntimeError) |
120 | 120 | expect(two_result.exception.message).to eq('Two failed') |
121 | 121 |
|
122 | | - expect(File.file?(File.join($octocatalog_diff_util_parallel_spec_tempdir, 'one'))).to eq(false) |
| 122 | + expect(File.file?(File.join(ENV['OCTOCATALOG_DIFF_TEMPDIR'], 'one'))).to eq(false) |
123 | 123 | end |
124 | 124 |
|
125 | 125 | it 'should log debug messages' do |
@@ -480,4 +480,3 @@ def validate(arg, _logger = nil, _extra_args = {}) |
480 | 480 | end |
481 | 481 | end |
482 | 482 | end |
483 | | -# rubocop:enable Style/GlobalVars |
0 commit comments