Skip to content

Commit

Permalink
⚠️ Calling Kernel#open with a leading '|' is deprecated and will be r…
Browse files Browse the repository at this point in the history
…emoved in Ruby 4.0;

use IO.popen instead
  • Loading branch information
amatsuda committed Sep 27, 2023
1 parent 07d24b5 commit f2e02de
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions spec/result_merger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,22 @@
end
CODE

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

SimpleCov::ResultMerger.synchronize_resultset do
# wait until the child process is going, and then wait some more
# so we can be sure it blocks on the lock we already have.
sleep 0.1 until other_process.gets == "running\n"
sleep 1

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

# wait for it to finish
other_process.gets
# despite the sleeps, this will be written first since we got
# the first lock
File.open(file.path, "a") { |f| f.write("process 1\n") }
end

# wait for it to finish
other_process.gets
end

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

0 comments on commit f2e02de

Please sign in to comment.