Skip to content

Commit f2e02de

Browse files
committed
⚠️ Calling Kernel#open with a leading '|' is deprecated and will be removed in Ruby 4.0;
use IO.popen instead
1 parent 07d24b5 commit f2e02de

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

spec/result_merger_spec.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,22 @@
259259
end
260260
CODE
261261

262-
# rubocop:disable Security/Open
263-
other_process = open("|ruby -e #{Shellwords.escape(test_script)} 2>/dev/null")
264-
# rubocop:enable Security/Open
262+
IO.popen("ruby -e #{Shellwords.escape(test_script)} 2>/dev/null") do |other_process|
265263

266-
SimpleCov::ResultMerger.synchronize_resultset do
267-
# wait until the child process is going, and then wait some more
268-
# so we can be sure it blocks on the lock we already have.
269-
sleep 0.1 until other_process.gets == "running\n"
270-
sleep 1
271-
272-
# despite the sleeps, this will be written first since we got
273-
# the first lock
274-
File.open(file.path, "a") { |f| f.write("process 1\n") }
275-
end
264+
SimpleCov::ResultMerger.synchronize_resultset do
265+
# wait until the child process is going, and then wait some more
266+
# so we can be sure it blocks on the lock we already have.
267+
sleep 0.1 until other_process.gets == "running\n"
268+
sleep 1
276269

277-
# wait for it to finish
278-
other_process.gets
270+
# despite the sleeps, this will be written first since we got
271+
# the first lock
272+
File.open(file.path, "a") { |f| f.write("process 1\n") }
273+
end
274+
275+
# wait for it to finish
276+
other_process.gets
277+
end
279278

280279
expect(file.read).to eq("process 1\nprocess 2\n")
281280
end

0 commit comments

Comments
 (0)