Class: Sevgi::Showcase::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.



52
53
54
# File 'lib/sevgi/showcase/minitest/shell.rb', line 52

def initialize
  @coathooks = 0
end

Instance Method Details

#run(*args) { ... } ⇒ Sevgi::Showcase::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



64
65
66
67
68
69
70
71
# File 'lib/sevgi/showcase/minitest/shell.rb', line 64

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.new(args:, out:, err:, exit_code: status.exitstatus)
end