Class: Sevgi::Test::Shell::Runner Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sevgi/showcase/minitest/shell.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Adapted to popen3 from github.com/mina-deploy/mina Shell command runner.

Instance Method Summary collapse

Constructor Details

#initializevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a runner.



49
50
51
# File 'lib/sevgi/showcase/minitest/shell.rb', line 49

def initialize
  @coathooks = 0
end

Instance Method Details

#run(*args) { ... } ⇒ Sevgi::Test::Shell::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

The first SIGINT sends TERM and the second sends KILL outside trap context. The handler is restored after the last active run.

Runs a command and captures stdout, stderr, and exit status.

Parameters:

  • args (Array<String>)

    command and arguments

Yields:

  • optional stdin writer evaluated with stdin as receiver

Yield Returns:

  • (Object)

Returns:

Raises:

  • (StandardError)

    when the input block raises; the child is terminated and reaped before propagation



61
62
63
64
65
66
67
68
# File 'lib/sevgi/showcase/minitest/shell.rb', line 61

def run(*args, &block)
  @coathooks = 0
  out, err, status = Open3.popen3(*args) do |stdin, stdout, stderr, thread|
    capture(stdin, stdout, stderr, thread, &block)
  end

  Result[args, out, err, status.exitstatus]
end