Sha256: c81fdef838e03fc4c221aa453c66f53e7216ccf3189f02909fb7c75e3869eac2

Contents?: true

Size: 788 Bytes

Versions: 8

Compression:

Stored size: 788 Bytes

Contents

require_relative "../../../test_support/captures_stderr"
require_relative "../../../test_support/captures_stdout"
require_relative "lib_path"

require "open3"

# This example runner is relatively fast, but isn't available on all
# platforms.
class ForkExampleRunner

  include CapturesStderr
  include CapturesStdout
  include LibPath

  def self.supported?
    Process.respond_to?(:fork)
  end

  def run(path)
    stdout_rd, stdout_wr = IO.pipe
    stderr_rd, stderr_wr = IO.pipe
    pid = fork do
      $stdout.reopen stdout_wr
      $stderr.reopen stderr_wr
      load path
      exit! 0
    end
    Process.wait(pid)
    exit_status = $?
    stdout_wr.close
    stderr_wr.close
    stdout = stdout_rd.read
    stderr = stderr_rd.read
    yield stdout, stderr, exit_status
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cute_print-1.1.4 features/support/helpers/fork_example_runner.rb
cute_print-1.1.3 features/support/helpers/fork_example_runner.rb
cute_print-1.1.2 features/support/helpers/fork_example_runner.rb
cute_print-1.1.1 features/support/helpers/fork_example_runner.rb
cute_print-1.1.0 features/support/helpers/fork_example_runner.rb
cute_print-1.0.1 features/support/helpers/fork_example_runner.rb
cute_print-1.0.0 features/support/helpers/fork_example_runner.rb
cute_print-0.4.0 features/support/helpers/fork_example_runner.rb