Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rubygems/ext/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})
# Set $SOURCE_DATE_EPOCH for the subprocess.
build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env)
output, status = begin
Open3.popen2e(build_env, *command, chdir: dir) do |_stdin, stdouterr, wait_thread|
Open3.popen2e(build_env, *command, chdir: dir) do |stdin, stdouterr, wait_thread|
stdin.close
output = String.new
while line = stdouterr.gets
output << line
Expand Down
16 changes: 16 additions & 0 deletions test/rubygems/test_gem_ext_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ def test_custom_make_with_options
assert_match(/install: OK/, results)
end

def test_class_run_closes_stdin
results = []
check_stdin_script = <<~'RUBY'
if IO.select([STDIN], nil, nil, 1)
puts "STDIN: #{STDIN.read.inspect}"
else
puts "NOT_READY"
end
RUBY

Gem::Ext::Builder.run([Gem.ruby, "-e", check_stdin_script], results)

command_output = results.last
assert_equal "STDIN: \"\"\n", command_output
end
Comment on lines +119 to +123

def test_build_extensions
pend "terminates on mswin" if vc_windows? && ruby_repo?

Expand Down
Loading