<commit_before>Feature: Run command

  To run a command use the `#run_command` method. There are some configuration options
  which are relevant here:

  - `startup_wait_time`:

    Given this option `aruba` waits n seconds after it started the command.
    This is most useful when using `#run_command()` and not really makes sense for
    `#run_command_and_stop()`.

    You can use `#run_command()` + `startup_wait_time` to start background jobs.

  - `exit_timeout`:

    The exit timeout is used, when `aruba` waits for a command to finished.

  - `io_wait_timeout`:

    The io wait timeout is used, when you access `stdout` or `stderr` of a
    command.

  Background:
    Given I use a fixture named "cli-app"

  Scenario: Executable in the project's path 
    Given an executable named "bin/aruba-test-cli" with:
    """bash
    #!/bin/bash
    exit 0
    """
    And a file named "spec/run_spec.rb" with:
    """ruby
    require 'spec_helper'

    RSpec.describe 'Run command', type: :aruba do
      before(:each) { run_command('aruba-test-cli') }
      it { expect(last_command_started).to be_successfully_executed }
    end
    """
    When I run `rspec`
    Then the specs should all pass

  Scenario: Executable in a relative path in the Aruba working directory
    Given a file named "spec/run_spec.rb" with:
    """ruby
    require 'spec_helper'

    RSpec.describe 'Run command', type: :aruba do
      before do
        write_file 'bin/aruba-test-cli', <<~BASH
          #!/bin/bash
          exit 0
        BASH
        chmod 0x755, 'bin/aruba-test-cli'
      end

      it "runs the command" do
        run_command('bin/aruba-test-cli')
        expect(last_command_started).to be_successfully_executed
      end
    end
    """
    When I run `rspec`
    Then the specs should all pass

  Scenario: Non-existing executable
    Given a file named "bin/aruba-test-cli" does not exist
    And a file named "spec/run_spec.rb" with:
    """ruby
    require 'spec_helper'

    RSpec.describe 'Find path for command', type: :aruba do
      it { expect { run_command('aruba-test-cli') }.to raise_error Aruba::LaunchError, /Command "aruba-test-cli" not found in PATH-variable/ }
    end
    """
    When I run `rspec`
    Then the specs should all pass

  Scenario: Command with long startup phase

    If you have got a command with a long startup phase or use `ruby` together
    with `bundler`, you should consider using the `startup_wait_time`-option.
    Otherwise methods like `#send_signal` don't work since they require the<commit_msg>Use correct octal access mode<commit_after>Feature: Run command

  To run a command use the `#run_command` method. There are some configuration options
  which are relevant here:

  - `startup_wait_time`:

    Given this option `aruba` waits n seconds after it started the command.
    This is most useful when using `#run_command()` and not really makes sense for
    `#run_command_and_stop()`.

    You can use `#run_command()` + `startup_wait_time` to start background jobs.

  - `exit_timeout`:

    The exit timeout is used, when `aruba` waits for a command to finished.

  - `io_wait_timeout`:

    The io wait timeout is used, when you access `stdout` or `stderr` of a
    command.

  Background:
    Given I use a fixture named "cli-app"

  Scenario: Executable in the project's path 
    Given an executable named "bin/aruba-test-cli" with:
    """bash
    #!/bin/bash
    exit 0
    """
    And a file named "spec/run_spec.rb" with:
    """ruby
    require 'spec_helper'

    RSpec.describe 'Run command', type: :aruba do
      before(:each) { run_command('aruba-test-cli') }
      it { expect(last_command_started).to be_successfully_executed }
    end
    """
    When I run `rspec`
    Then the specs should all pass

  Scenario: Executable in a relative path in the Aruba working directory
    Given a file named "spec/run_spec.rb" with:
    """ruby
    require 'spec_helper'

    RSpec.describe 'Run command', type: :aruba do
      before do
        write_file 'bin/aruba-test-cli', <<~BASH
          #!/bin/bash
          exit 0
        BASH
        chmod 0o755, 'bin/aruba-test-cli'
      end

      it "runs the command" do
        run_command('bin/aruba-test-cli')
        expect(last_command_started).to be_successfully_executed
      end
    end
    """
    When I run `rspec`
    Then the specs should all pass

  Scenario: Non-existing executable
    Given a file named "bin/aruba-test-cli" does not exist
    And a file named "spec/run_spec.rb" with:
    """ruby
    require 'spec_helper'

    RSpec.describe 'Find path for command', type: :aruba do
      it { expect { run_command('aruba-test-cli') }.to raise_error Aruba::LaunchError, /Command "aruba-test-cli" not found in PATH-variable/ }
    end
    """
    When I run `rspec`
    Then the specs should all pass

  Scenario: Command with long startup phase

    If you have got a command with a long startup phase or use `ruby` together
    with `bundler`, you should consider using the `startup_wait_time`-option.
    Otherwise methods like `#send_signal` don't work since they require the
{'fraction_non_alphanumeric': 0.08941819601718079, 'fraction_numerical': 0.0023428348301444747, 'mean_word_length': 2.854778028592927, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1555760', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1541, 'n_words': 583}