-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
child_process helper: fix stderr blocking for discard case. fix #2609 #2649
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,39 @@ def configure(conf) | |
assert_equal expected, ary | ||
end | ||
|
||
test 'can execute external command at just once, which can handle both of read and write. Ignore stderr message/no block' do | ||
m = Mutex.new | ||
ary = [] | ||
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do | ||
ran = false | ||
# lots of stderr message should not be blocked and message should not be printed in test. | ||
cmd = "ruby -e 'while !STDIN.eof? && line = STDIN.readline; STDERR.puts line.chomp * 1000; STDOUT.puts line.chomp; STDOUT.flush rescue nil; end'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure but it needs to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. STDERR writes lots of data so no flush call is not critical. |
||
@d.child_process_execute(:t2_and_ignore_stderr, cmd, mode: [:write, :read]) do |writeio, readio| | ||
m.lock | ||
ran = true | ||
|
||
[[1,2],[3,4],[5,6]].each do |i,j| | ||
writeio.write "my data#{i}\n" | ||
writeio.write "my data#{j}\n" | ||
writeio.flush | ||
end | ||
writeio.close | ||
|
||
while line = readio.readline | ||
ary << line | ||
end | ||
m.unlock | ||
end | ||
sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran | ||
m.lock | ||
m.unlock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mutex#unlock should be called in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch. |
||
end | ||
|
||
assert_equal [], @d.log.out.logs | ||
expected = (1..6).map{|i| "my data#{i}\n" } | ||
assert_equal expected, ary | ||
end | ||
|
||
test 'can execute external command at just once, which can handle all of read, write and stderr' do | ||
m = Mutex.new | ||
ary1 = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking, This was a bug, right?
stderrio
cannot be a:discard
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This is typo.