-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,43 @@ 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 | ||
begin | ||
sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran | ||
m.lock | ||
rescue | ||
ensure | ||
m.unlock | ||
end | ||
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 = [] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.