module Rake::TeamCity::StdCaptureHelper
Captures STDOUT and STDERR
Public Instance Methods
capture_output_end_external(old_out, old_err, new_out, new_err)
click to toggle source
returns STDOUT and STDERR content
# File lib/rspec/teamcity/utils/std_capture_helper.rb, line 62 def capture_output_end_external(old_out, old_err, new_out, new_err) STDOUT.flush STDERR.flush if isCaptureDisabled() return "", "" end reopen_stdout_stderr(old_out, old_err) return get_redirected_stdout_stderr_from_files(new_out, new_err) end
capture_output_start_external()
click to toggle source
# File lib/rspec/teamcity/utils/std_capture_helper.rb, line 32 def capture_output_start_external old_out, old_err = copy_stdout_stderr if isCaptureDisabled() return old_out, old_err, nil, nil end new_out = Tempfile.new("tempfile_out") new_err = Tempfile.new("tempfile_err") reopen_stdout_stderr(new_out, new_err) return old_out, old_err, new_out, new_err end
copy_stdout_stderr()
click to toggle source
# File lib/rspec/teamcity/utils/std_capture_helper.rb, line 47 def copy_stdout_stderr if isCaptureDisabled() return STDOUT, STDERR else return STDOUT.dup, STDERR.dup end end
get_redirected_stdout_stderr_from_files(new_out, new_err)
click to toggle source
Closes files' streams and gets its output.
# File lib/rspec/teamcity/utils/std_capture_helper.rb, line 76 def get_redirected_stdout_stderr_from_files(new_out, new_err) if isCaptureDisabled() return "", "" end begin new_out.close new_out.open s_out = new_out.readlines.join new_out.close rescue Exception => ex s_out = "Error: Teamcity agent is unable to capture STDOUT: #{ex}" end begin new_err.close new_err.open s_err = new_err.readlines.join new_err.close rescue Exception => ex s_err = "Error: Teamcity agent is unable to capture STDERR: #{ex}" end return s_out, s_err end
isCaptureDisabled()
click to toggle source
# File lib/rspec/teamcity/utils/std_capture_helper.rb, line 28 def isCaptureDisabled() ENV[TEAMCITY_RAKERUNNER_LOG_OUTPUT_CAPTURER_ENABLED_KEY] != "true" end
reopen_stdout_stderr(sout, serr)
click to toggle source
# File lib/rspec/teamcity/utils/std_capture_helper.rb, line 55 def reopen_stdout_stderr(sout, serr) STDOUT.reopen(sout) STDERR.reopen(serr) nil end