This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
7523: Fix rspec stuck problem for large stderr external command r=deivid-rodriguez a=kou ### What was the end-user problem that led to this PR? This PR doesn't fix any end-user problem. This PR just fixes a developer problem. Some specs runs external commands by `sys_exec` in `spec/support/helpers.rb`. They may be stuck when they outputs many text to its stderr. ### What was your diagnosis of the problem? `sys_exec` uses `open3`. It uses pipe to communicate an external command. If `rspec` process doesn't read stderr of the external command, the external command is stuck when the external command writes many text to its stderr. Because the external command can't write to pipe infinitely. ### What is your fix for the problem, implemented in this PR? The current `sys_exec` tries to fix this situation but it's incomplete: ```ruby command_execution.stdout = Thread.new { stdout.read }.value.strip command_execution.stderr = Thread.new { stderr.read }.value.strip ``` `Thread.new { stderr.read ` isn't started until `Thread.new { stdout.read }.value` is finished. Normally, it's finished when the external command is finished. It's late. We should read stderr of the external command while the external command is alive. ### Why did you choose this fix out of the possible options? I don't have another option. Co-authored-by: Sutou Kouhei <[email protected]>
- Loading branch information