aruba 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.travis.yml +2 -1
- data/History.md +4 -0
- data/README.md +3 -3
- data/Rakefile +5 -4
- data/aruba.gemspec +2 -3
- data/cucumber.yml +9 -2
- data/features/exit_statuses.feature +14 -26
- data/features/file_system_commands.feature +20 -30
- data/features/flushing.feature +3 -3
- data/features/interactive.feature +6 -5
- data/features/output.feature +75 -91
- data/features/step_definitions/aruba_dev_steps.rb +1 -1
- data/features/support/jruby.rb +5 -0
- data/lib/aruba/api.rb +12 -5
- data/lib/aruba/cucumber.rb +61 -30
- data/lib/aruba/errors.rb +4 -0
- data/lib/aruba/process.rb +22 -14
- data/spec/aruba/api_spec.rb +36 -10
- data/spec/aruba/process_spec.rb +11 -1
- metadata +15 -25
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    
    
        data/History.md
    CHANGED
    
    | @@ -1,3 +1,7 @@ | |
| 1 | 
            +
            ## [v0.5.1](https://github.com/cucumber/aruba/compare/v0.5..v0.5.1)
         | 
| 2 | 
            +
            * Individual timeout settings when running commands (#124 Jarl Friis)
         | 
| 3 | 
            +
            * Varous fixes for JRuby tests, should now work on more versions of JRuby
         | 
| 4 | 
            +
             | 
| 1 5 | 
             
            ## [v0.5](https://github.com/cucumber/aruba/compare/v0.4.10..v0.5)
         | 
| 2 6 | 
             
            * Add #with_file_content to the DSL (#110 Pavel Argentov)
         | 
| 3 7 | 
             
            * Make JRuby performance tweaks optional (#102 Taylor Carpenter, #125 Andy Lindeman)
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            [](http://travis-ci.org/cucumber/aruba)
         | 
| 1 | 
            +
            [](http://travis-ci.org/cucumber/aruba) [](https://codeclimate.com/github/cucumber/aruba)
         | 
| 2 2 |  | 
| 3 3 | 
             
            Aruba is Cucumber extension for Command line applications written in any programming language. Features at a glance:
         | 
| 4 4 |  | 
| @@ -71,7 +71,7 @@ Aruba defines several tags that you can put on on individual scenarios, or on a | |
| 71 71 |  | 
| 72 72 | 
             
            To get more information on what Aruba is doing, use these tags:
         | 
| 73 73 |  | 
| 74 | 
            -
            * `@announce-cmd` - See what command is  | 
| 74 | 
            +
            * `@announce-cmd` - See what command is run
         | 
| 75 75 | 
             
            * `@announce-stdout` - See the stdout
         | 
| 76 76 | 
             
            * `@announce-stderr` - See the stderr
         | 
| 77 77 | 
             
            * `@announce-dir` - See the current directory
         | 
| @@ -119,7 +119,7 @@ or setting a hook like this example: | |
| 119 119 | 
             
            ```
         | 
| 120 120 |  | 
| 121 121 | 
             
            *Note* - no conflict resolution on the JAVA/JRuby environment options is
         | 
| 122 | 
            -
            done; only merging. | 
| 122 | 
            +
            done; only merging. For more complex settings please manually set the
         | 
| 123 123 | 
             
            environment variables in the hook or externally.
         | 
| 124 124 |  | 
| 125 125 | 
             
            A larger process timeout for java may be needed
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -7,9 +7,10 @@ Bundler::GemHelper.install_tasks | |
| 7 7 | 
             
            require 'cucumber/rake/task'
         | 
| 8 8 |  | 
| 9 9 | 
             
            Cucumber::Rake::Task.new do |t|
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Cucumber::Rake::Task.new(:cucumber_wip) do |t|
         | 
| 13 | 
            +
              t.cucumber_opts = "-p wip"
         | 
| 13 14 | 
             
            end
         | 
| 14 15 |  | 
| 15 16 | 
             
            require 'rspec/core/rake_task'
         | 
| @@ -20,6 +21,6 @@ RSpec::Core::RakeTask.new do |spec| | |
| 20 21 | 
             
            end
         | 
| 21 22 |  | 
| 22 23 | 
             
            desc "Run tests, both RSpec and Cucumber"
         | 
| 23 | 
            -
            task :test => [:spec, :cucumber]
         | 
| 24 | 
            +
            task :test => [:spec, :cucumber, :cucumber_wip]
         | 
| 24 25 |  | 
| 25 26 | 
             
            task :default => :test
         | 
    
        data/aruba.gemspec
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            Gem::Specification.new do |s|
         | 
| 4 4 | 
             
              s.name        = 'aruba'
         | 
| 5 | 
            -
              s.version     = '0.5. | 
| 5 | 
            +
              s.version     = '0.5.1'
         | 
| 6 6 | 
             
              s.authors     = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne"]
         | 
| 7 7 | 
             
              s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
         | 
| 8 8 | 
             
              s.summary     = "aruba-#{s.version}"
         | 
| @@ -10,8 +10,7 @@ Gem::Specification.new do |s| | |
| 10 10 | 
             
              s.homepage    = 'http://github.com/cucumber/aruba'
         | 
| 11 11 |  | 
| 12 12 | 
             
              s.add_runtime_dependency 'cucumber', '>= 1.1.1'
         | 
| 13 | 
            -
              s.add_runtime_dependency 'childprocess', ' | 
| 14 | 
            -
              s.add_runtime_dependency 'ffi', '>= 1.0.11'
         | 
| 13 | 
            +
              s.add_runtime_dependency 'childprocess', '~> 0.3.6'
         | 
| 15 14 | 
             
              s.add_runtime_dependency 'rspec-expectations', '>= 2.7.0'
         | 
| 16 15 | 
             
              s.add_development_dependency 'bcat', '>= 0.6.1'
         | 
| 17 16 | 
             
              s.add_development_dependency 'rdiscount', '>= 1.6.8'
         | 
    
        data/cucumber.yml
    CHANGED
    
    | @@ -1,2 +1,9 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 1 | 
            +
            <%
         | 
| 2 | 
            +
            std_opts = "--color --tags ~@wip"
         | 
| 3 | 
            +
            std_opts << " --tags ~@wip-jruby" if defined?(JRUBY_VERSION)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            wip_opts = "--color --tags @wip:3"
         | 
| 6 | 
            +
            wip_opts = "--color --tags @wip:3,@wip-jruby:3" if defined?(JRUBY_VERSION)
         | 
| 7 | 
            +
            %>
         | 
| 8 | 
            +
            default: <%= std_opts %>
         | 
| 9 | 
            +
            wip: --wip <%= wip_opts %>
         | 
| @@ -5,38 +5,26 @@ Feature: exit statuses | |
| 5 5 | 
             
              I want to use the "the exit status should be" step
         | 
| 6 6 |  | 
| 7 7 | 
             
              Scenario: exit status of 0
         | 
| 8 | 
            -
                When I run ` | 
| 8 | 
            +
                When I run `true`
         | 
| 9 9 | 
             
                Then the exit status should be 0
         | 
| 10 10 |  | 
| 11 | 
            -
              Scenario: exit status of 0 with `
         | 
| 12 | 
            -
                When I run `ruby -h`
         | 
| 13 | 
            -
                Then the exit status should be 0
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              Scenario: Not explicitly exiting at all
         | 
| 16 | 
            -
                When I run `ruby -e '42'`
         | 
| 17 | 
            -
                Then the exit status should be 0
         | 
| 18 | 
            -
                
         | 
| 19 11 | 
             
              Scenario: non-zero exit status
         | 
| 20 | 
            -
                When I run ` | 
| 21 | 
            -
                Then the exit status should be  | 
| 12 | 
            +
                When I run `false`
         | 
| 13 | 
            +
                Then the exit status should be 1
         | 
| 22 14 | 
             
                And the exit status should not be 0
         | 
| 23 15 |  | 
| 24 16 | 
             
              Scenario: Successfully run something
         | 
| 25 | 
            -
                When I successfully run ` | 
| 17 | 
            +
                When I successfully run `true`
         | 
| 26 18 |  | 
| 27 | 
            -
              Scenario: Successfully run something  | 
| 28 | 
            -
                 | 
| 19 | 
            +
              Scenario: Successfully run something for a long time
         | 
| 20 | 
            +
                Given The default aruba timeout is 0 seconds
         | 
| 21 | 
            +
                When I successfully run `ruby -e 'sleep 1'` for up to 2 seconds
         | 
| 29 22 |  | 
| 30 | 
            -
              Scenario: Unsuccessfully run something
         | 
| 31 | 
            -
                 | 
| 32 | 
            -
                 | 
| 23 | 
            +
              Scenario: Unsuccessfully run something that takes too long
         | 
| 24 | 
            +
                Given The default aruba timeout is 0 seconds
         | 
| 25 | 
            +
                When I do aruba I successfully run `ruby -e 'sleep 1'`
         | 
| 26 | 
            +
                Then aruba should fail with "process still alive after 0 seconds"
         | 
| 33 27 |  | 
| 34 | 
            -
               | 
| 35 | 
            -
             | 
| 36 | 
            -
                 | 
| 37 | 
            -
                Then the exit status should be 1
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              @posix
         | 
| 40 | 
            -
              Scenario: Try to run something that doesn't exist with `
         | 
| 41 | 
            -
                When I run `does_not_exist`
         | 
| 42 | 
            -
                Then the exit status should be 1
         | 
| 28 | 
            +
              Scenario: Unsuccessfully run something
         | 
| 29 | 
            +
                When I do aruba I successfully run `false`
         | 
| 30 | 
            +
                Then aruba should fail with ""
         | 
| @@ -6,16 +6,16 @@ Feature: file system commands | |
| 6 6 |  | 
| 7 7 | 
             
              Scenario: create a dir
         | 
| 8 8 | 
             
                Given a directory named "foo/bar"
         | 
| 9 | 
            -
                When I run ` | 
| 10 | 
            -
                Then the stdout should contain " | 
| 9 | 
            +
                When I run `file foo/bar`
         | 
| 10 | 
            +
                Then the stdout should contain "foo/bar: directory"
         | 
| 11 11 |  | 
| 12 12 | 
             
              Scenario: create a file
         | 
| 13 | 
            -
                Given a file named "foo/bar/example. | 
| 13 | 
            +
                Given a file named "foo/bar/example.txt" with:
         | 
| 14 14 | 
             
                  """
         | 
| 15 | 
            -
                   | 
| 15 | 
            +
                  hello world
         | 
| 16 16 | 
             
                  """
         | 
| 17 | 
            -
                When I run ` | 
| 18 | 
            -
                Then the output should contain "hello world"
         | 
| 17 | 
            +
                When I run `cat foo/bar/example.txt`
         | 
| 18 | 
            +
                Then the output should contain exactly "hello world"
         | 
| 19 19 |  | 
| 20 20 | 
             
              Scenario: create a fixed sized file
         | 
| 21 21 | 
             
                Given a 1048576 byte file named "test.txt"
         | 
| @@ -30,22 +30,17 @@ Feature: file system commands | |
| 30 30 | 
             
                - One
         | 
| 31 31 | 
             
                - Two
         | 
| 32 32 |  | 
| 33 | 
            -
                Given a file named "foo/bar/example. | 
| 34 | 
            -
                  """
         | 
| 35 | 
            -
                  Feature: Example
         | 
| 36 | 
            -
                    Hello World
         | 
| 33 | 
            +
                Given a file named "foo/bar/example.txt" with:
         | 
| 37 34 | 
             
                  """
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                   | 
| 40 | 
            -
                  puts "\e[31mhello world\e[0m"
         | 
| 41 | 
            -
             | 
| 35 | 
            +
                  hello world
         | 
| 36 | 
            +
                  
         | 
| 42 37 | 
             
                  """
         | 
| 43 | 
            -
                When I append to "foo/bar/example. | 
| 38 | 
            +
                When I append to "foo/bar/example.txt" with:
         | 
| 44 39 | 
             
                  """
         | 
| 45 | 
            -
                   | 
| 46 | 
            -
             | 
| 40 | 
            +
                  this was appended
         | 
| 41 | 
            +
                  
         | 
| 47 42 | 
             
                  """
         | 
| 48 | 
            -
                When I run ` | 
| 43 | 
            +
                When I run `cat foo/bar/example.txt`
         | 
| 49 44 | 
             
                Then the stdout should contain "hello world"
         | 
| 50 45 | 
             
                And the stdout should contain "this was appended"
         | 
| 51 46 |  | 
| @@ -55,28 +50,23 @@ Feature: file system commands | |
| 55 50 | 
             
                Then the file "thedir/thefile" should contain "xy"
         | 
| 56 51 |  | 
| 57 52 | 
             
              Scenario: clean up files generated in previous scenario
         | 
| 58 | 
            -
                 | 
| 59 | 
            -
                Then the exit status should be 1
         | 
| 60 | 
            -
                And the output should contain "No such file or directory -- foo/bar/example.rb"
         | 
| 53 | 
            +
                Then the file "foo/bar/example.txt" should not exist
         | 
| 61 54 |  | 
| 62 55 | 
             
              Scenario: change to a subdir
         | 
| 63 | 
            -
                Given a file named "foo/bar/example. | 
| 56 | 
            +
                Given a file named "foo/bar/example.txt" with:
         | 
| 64 57 | 
             
                  """
         | 
| 65 | 
            -
                   | 
| 58 | 
            +
                  hello world
         | 
| 59 | 
            +
                  
         | 
| 66 60 | 
             
                  """
         | 
| 67 61 | 
             
                When I cd to "foo/bar"
         | 
| 68 | 
            -
                And I run ` | 
| 62 | 
            +
                And I run `cat example.txt`
         | 
| 69 63 | 
             
                Then the output should contain "hello world"
         | 
| 70 64 |  | 
| 71 65 | 
             
              Scenario: Reset current directory from previous scenario
         | 
| 72 | 
            -
                When I run ` | 
| 73 | 
            -
                Then the  | 
| 66 | 
            +
                When I run `pwd`
         | 
| 67 | 
            +
                Then the output should match /\057tmp\057aruba$/
         | 
| 74 68 |  | 
| 75 69 | 
             
              Scenario: Holler if cd to bad dir
         | 
| 76 | 
            -
                Given a file named "foo/bar/example.rb" with:
         | 
| 77 | 
            -
                  """
         | 
| 78 | 
            -
                  puts "hello world"
         | 
| 79 | 
            -
                  """
         | 
| 80 70 | 
             
                When I do aruba I cd to "foo/nonexistant"
         | 
| 81 71 | 
             
                Then aruba should fail with "tmp/aruba/foo/nonexistant is not a directory"
         | 
| 82 72 |  | 
    
        data/features/flushing.feature
    CHANGED
    
    | @@ -5,19 +5,19 @@ Feature: Flushing output | |
| 5 5 | 
             
              I want to make sure that large amounts of output aren't buffered
         | 
| 6 6 |  | 
| 7 7 | 
             
              Scenario: A little output
         | 
| 8 | 
            -
                When I run ` | 
| 8 | 
            +
                When I run `bash -c 'for ((c=0; c<256; c = c+1)); do echo -n "a"; done'`
         | 
| 9 9 | 
             
                Then the output should contain "a"
         | 
| 10 10 | 
             
                And the output should be 256 bytes long
         | 
| 11 11 | 
             
                And the exit status should be 0
         | 
| 12 12 |  | 
| 13 13 | 
             
              Scenario: Tons of output
         | 
| 14 | 
            -
                When I run ` | 
| 14 | 
            +
                When I run `bash -c 'for ((c=0; c<65536; c = c+1)); do echo -n "a"; done'`
         | 
| 15 15 | 
             
                Then the output should contain "a"
         | 
| 16 16 | 
             
                And the output should be 65536 bytes long
         | 
| 17 17 | 
             
                And the exit status should be 0
         | 
| 18 18 |  | 
| 19 19 | 
             
              Scenario: Tons of interactive output
         | 
| 20 | 
            -
                When I run ` | 
| 20 | 
            +
                When I run `bash -c 'read size; for ((c=0; c<$size; c = c+1)); do echo -n "a"; done'` interactively
         | 
| 21 21 | 
             
                And I type "65536"
         | 
| 22 22 | 
             
                Then the output should contain "a"
         | 
| 23 23 | 
             
                And the output should be 65536 bytes long
         | 
| @@ -4,6 +4,7 @@ Feature: Interactive process control | |
| 4 4 | 
             
              As a developer using Cucumber
         | 
| 5 5 | 
             
              I want to use the interactive session steps
         | 
| 6 6 |  | 
| 7 | 
            +
              @wip-jruby
         | 
| 7 8 | 
             
              Scenario: Running ruby interactively
         | 
| 8 9 | 
             
                Given a file named "echo.rb" with:
         | 
| 9 10 | 
             
                  """
         | 
| @@ -20,14 +21,14 @@ Feature: Interactive process control | |
| 20 21 | 
             
                  dlrow ,olleh
         | 
| 21 22 | 
             
                  """
         | 
| 22 23 |  | 
| 23 | 
            -
              @posix | 
| 24 | 
            +
              @posix
         | 
| 24 25 | 
             
              Scenario: Running a native binary interactively
         | 
| 25 | 
            -
                When I run ` | 
| 26 | 
            -
                And I type " | 
| 27 | 
            -
                And I type " | 
| 26 | 
            +
                When I run `cat` interactively
         | 
| 27 | 
            +
                And I type "Hello, world"
         | 
| 28 | 
            +
                And I type ""
         | 
| 28 29 | 
             
                Then the output should contain:
         | 
| 29 30 | 
             
                  """
         | 
| 30 | 
            -
                   | 
| 31 | 
            +
                  Hello, world
         | 
| 31 32 | 
             
                  """
         | 
| 32 33 |  | 
| 33 34 | 
             
              @posix
         | 
    
        data/features/output.feature
    CHANGED
    
    | @@ -4,37 +4,24 @@ Feature: Output | |
| 4 4 | 
             
              As a developer using Cucumber
         | 
| 5 5 | 
             
              I want to use the "the output should contain" step
         | 
| 6 6 |  | 
| 7 | 
            -
              @posix
         | 
| 8 | 
            -
              Scenario: Run unknown command
         | 
| 9 | 
            -
                When I run `neverever gonna work`
         | 
| 10 | 
            -
                Then the output should contain:
         | 
| 11 | 
            -
                  """
         | 
| 12 | 
            -
                  No such file or directory - neverever
         | 
| 13 | 
            -
                  """
         | 
| 14 | 
            -
             | 
| 15 7 | 
             
              @posix
         | 
| 16 8 | 
             
              Scenario: Detect subset of one-line output
         | 
| 17 | 
            -
                When I run ` | 
| 18 | 
            -
                Then the output should contain "hello world"
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              @posix
         | 
| 21 | 
            -
              Scenario: Detect subset of one-line output
         | 
| 22 | 
            -
                When I run `echo 'hello world'`
         | 
| 9 | 
            +
                When I run `printf 'hello world'`
         | 
| 23 10 | 
             
                Then the output should contain "hello world"
         | 
| 24 11 |  | 
| 25 12 | 
             
              Scenario: Detect absence of one-line output
         | 
| 26 | 
            -
                When I run ` | 
| 13 | 
            +
                When I run `printf "hello world"`
         | 
| 27 14 | 
             
                Then the output should not contain "good-bye"
         | 
| 28 15 |  | 
| 29 16 | 
             
              Scenario: Detect subset of multiline output
         | 
| 30 | 
            -
                When I run ` | 
| 17 | 
            +
                When I run `printf "hello\nworld"`
         | 
| 31 18 | 
             
                Then the output should contain:
         | 
| 32 19 | 
             
                  """
         | 
| 33 20 | 
             
                  hello
         | 
| 34 21 | 
             
                  """
         | 
| 35 22 |  | 
| 36 | 
            -
              Scenario: Detect  | 
| 37 | 
            -
                When I run ` | 
| 23 | 
            +
              Scenario: Detect absence of multiline output
         | 
| 24 | 
            +
                When I run `printf "hello\nworld"`
         | 
| 38 25 | 
             
                Then the output should not contain:
         | 
| 39 26 | 
             
                  """
         | 
| 40 27 | 
             
                  good-bye
         | 
| @@ -42,51 +29,48 @@ Feature: Output | |
| 42 29 |  | 
| 43 30 | 
             
              @posix
         | 
| 44 31 | 
             
              Scenario: Detect exact one-line output
         | 
| 45 | 
            -
                When I run ` | 
| 32 | 
            +
                When I run `printf "hello world"`
         | 
| 46 33 | 
             
                Then the output should contain exactly:
         | 
| 47 34 | 
             
                  """
         | 
| 48 35 | 
             
                  hello world
         | 
| 49 | 
            -
                  
         | 
| 50 36 | 
             
                  """
         | 
| 51 37 |  | 
| 52 38 | 
             
              @ansi
         | 
| 53 39 | 
             
              @posix
         | 
| 54 40 | 
             
              Scenario: Detect exact one-line output with ANSI output
         | 
| 55 | 
            -
                When I run ` | 
| 41 | 
            +
                When I run `printf "\e[36mhello world\e[0m"`
         | 
| 56 42 | 
             
                Then the output should contain exactly:
         | 
| 57 43 | 
             
                  """
         | 
| 58 44 | 
             
                  \e[36mhello world\e[0m
         | 
| 59 | 
            -
             | 
| 60 45 | 
             
                  """
         | 
| 61 46 |  | 
| 62 47 | 
             
              @posix
         | 
| 63 48 | 
             
              Scenario: Detect exact one-line output with ANSI output stripped by default
         | 
| 64 | 
            -
                When I run ` | 
| 49 | 
            +
                When I run `printf "\e[36mhello world\e[0m"`
         | 
| 65 50 | 
             
                Then the output should contain exactly:
         | 
| 66 51 | 
             
                  """
         | 
| 67 52 | 
             
                  hello world
         | 
| 68 | 
            -
             | 
| 69 53 | 
             
                  """
         | 
| 54 | 
            +
             | 
| 70 55 | 
             
              @posix
         | 
| 71 56 | 
             
              Scenario: Detect exact multiline output
         | 
| 72 | 
            -
                When I run ` | 
| 57 | 
            +
                When I run `printf "hello\nworld"`
         | 
| 73 58 | 
             
                Then the output should contain exactly:
         | 
| 74 59 | 
             
                  """
         | 
| 75 60 | 
             
                  hello
         | 
| 76 61 | 
             
                  world
         | 
| 77 | 
            -
             | 
| 78 62 | 
             
                  """
         | 
| 79 63 |  | 
| 80 64 | 
             
              @announce
         | 
| 81 65 | 
             
              Scenario: Detect subset of one-line output with regex
         | 
| 82 | 
            -
                When I run `ruby | 
| 66 | 
            +
                When I run `printf "hello, ruby"`
         | 
| 83 67 | 
             
                Then the output should contain "ruby"
         | 
| 84 | 
            -
                And the output should match  | 
| 68 | 
            +
                And the output should match /^hello(, world)?/
         | 
| 85 69 |  | 
| 86 70 | 
             
              @announce
         | 
| 87 71 | 
             
              @posix
         | 
| 88 72 | 
             
              Scenario: Detect subset of multiline output with regex
         | 
| 89 | 
            -
                When I run ` | 
| 73 | 
            +
                When I run `printf "hello\nworld\nextra line1\nextra line2\nimportant line"`
         | 
| 90 74 | 
             
                Then the output should match:
         | 
| 91 75 | 
             
                  """
         | 
| 92 76 | 
             
                  he..o
         | 
| @@ -97,14 +81,14 @@ Feature: Output | |
| 97 81 |  | 
| 98 82 | 
             
              @announce
         | 
| 99 83 | 
             
              Scenario: Negative matching of one-line output with regex
         | 
| 100 | 
            -
                When I run `ruby | 
| 84 | 
            +
                When I run `printf "hello, ruby"`
         | 
| 101 85 | 
             
                Then the output should contain "ruby"
         | 
| 102 86 | 
             
                And the output should not match /ruby is a better perl$/
         | 
| 103 87 |  | 
| 104 88 | 
             
              @announce
         | 
| 105 89 | 
             
              @posix
         | 
| 106 90 | 
             
              Scenario: Negative matching of multiline output with regex
         | 
| 107 | 
            -
                When I run ` | 
| 91 | 
            +
                When I run `printf "hello\nworld\nextra line1\nextra line2\nimportant line"`
         | 
| 108 92 | 
             
                Then the output should not match:
         | 
| 109 93 | 
             
                  """
         | 
| 110 94 | 
             
                  ruby
         | 
| @@ -117,7 +101,7 @@ Feature: Output | |
| 117 101 | 
             
              @announce
         | 
| 118 102 | 
             
              @posix
         | 
| 119 103 | 
             
              Scenario: Match passing exit status and partial output
         | 
| 120 | 
            -
                When I run ` | 
| 104 | 
            +
                When I run `printf "hello\nworld"`
         | 
| 121 105 | 
             
                Then it should pass with:
         | 
| 122 106 | 
             
                  """
         | 
| 123 107 | 
             
                  hello
         | 
| @@ -125,17 +109,16 @@ Feature: Output | |
| 125 109 |  | 
| 126 110 | 
             
              @posix
         | 
| 127 111 | 
             
              Scenario: Match passing exit status and exact output
         | 
| 128 | 
            -
                When I run ` | 
| 112 | 
            +
                When I run `printf "hello\nworld"`
         | 
| 129 113 | 
             
                Then it should pass with exactly:
         | 
| 130 114 | 
             
                  """
         | 
| 131 115 | 
             
                  hello
         | 
| 132 116 | 
             
                  world
         | 
| 133 | 
            -
             | 
| 134 117 | 
             
                  """
         | 
| 135 118 |  | 
| 136 119 | 
             
              @announce-stdout
         | 
| 137 120 | 
             
              Scenario: Match failing exit status and partial output
         | 
| 138 | 
            -
                When I run ` | 
| 121 | 
            +
                When I run `bash -c '(printf "hello\nworld";exit 99)'`
         | 
| 139 122 | 
             
                Then it should fail with:
         | 
| 140 123 | 
             
                  """
         | 
| 141 124 | 
             
                  hello
         | 
| @@ -143,18 +126,17 @@ Feature: Output | |
| 143 126 |  | 
| 144 127 | 
             
              @posix
         | 
| 145 128 | 
             
              Scenario: Match failing exit status and exact output
         | 
| 146 | 
            -
                When I run ` | 
| 129 | 
            +
                When I run `bash -c '(printf "hello\nworld";exit 99)'`
         | 
| 147 130 | 
             
                Then it should fail with exactly:
         | 
| 148 131 | 
             
                  """
         | 
| 149 132 | 
             
                  hello
         | 
| 150 133 | 
             
                  world
         | 
| 151 | 
            -
             | 
| 152 134 | 
             
                  """
         | 
| 153 135 |  | 
| 154 136 | 
             
              @announce-stdout
         | 
| 155 137 | 
             
              @posix
         | 
| 156 138 | 
             
              Scenario: Match failing exit status and output with regex
         | 
| 157 | 
            -
                When I run ` | 
| 139 | 
            +
                When I run `bash -c '(printf "hello\nworld";exit 99)'`
         | 
| 158 140 | 
             
                Then it should fail with regex:
         | 
| 159 141 | 
             
                  """
         | 
| 160 142 | 
             
                  hello\s*world
         | 
| @@ -163,13 +145,13 @@ Feature: Output | |
| 163 145 | 
             
              @announce-cmd
         | 
| 164 146 | 
             
              @posix
         | 
| 165 147 | 
             
              Scenario: Match output in stdout
         | 
| 166 | 
            -
                When I run ` | 
| 148 | 
            +
                When I run `printf "hello\nworld"`
         | 
| 167 149 | 
             
                Then the stdout should contain "hello"
         | 
| 168 150 | 
             
                Then the stderr should not contain "hello"
         | 
| 169 151 |  | 
| 170 152 | 
             
              @announce
         | 
| 171 153 | 
             
              Scenario: Match output on several lines
         | 
| 172 | 
            -
                When I run ` | 
| 154 | 
            +
                When I run `printf 'GET /'`
         | 
| 173 155 | 
             
                Then the stdout should contain:
         | 
| 174 156 | 
             
                  """
         | 
| 175 157 | 
             
                  GET /
         | 
| @@ -177,91 +159,93 @@ Feature: Output | |
| 177 159 |  | 
| 178 160 | 
             
              @posix
         | 
| 179 161 | 
             
              Scenario: Match output on several lines using quotes
         | 
| 180 | 
            -
                When I run ` | 
| 162 | 
            +
                When I run `printf 'GET "/"'`
         | 
| 181 163 | 
             
                Then the stdout should contain:
         | 
| 182 164 | 
             
                  """
         | 
| 183 165 | 
             
                  GET "/"
         | 
| 184 166 | 
             
                  """
         | 
| 185 167 |  | 
| 186 | 
            -
              @posix
         | 
| 187 | 
            -
              Scenario: Match output in stdout
         | 
| 188 | 
            -
                When I run `ruby -e 'puts \"hello\\nworld\"'`
         | 
| 189 | 
            -
                Then the stdout should contain "hello"
         | 
| 190 | 
            -
                Then the stderr should not contain "hello"
         | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 168 | 
             
              @posix
         | 
| 194 169 | 
             
              Scenario: Detect output from all processes
         | 
| 195 | 
            -
                When I run ` | 
| 196 | 
            -
                And I run ` | 
| 197 | 
            -
                And I type " | 
| 170 | 
            +
                When I run `printf "hello world!\n"`
         | 
| 171 | 
            +
                And I run `cat` interactively
         | 
| 172 | 
            +
                And I type "hola"
         | 
| 173 | 
            +
                And I type ""
         | 
| 198 174 | 
             
                Then the output should contain exactly:
         | 
| 199 175 | 
             
                  """
         | 
| 200 176 | 
             
                  hello world!
         | 
| 201 | 
            -
                   | 
| 177 | 
            +
                  hola
         | 
| 202 178 |  | 
| 203 179 | 
             
                  """
         | 
| 204 180 |  | 
| 205 181 | 
             
              @posix
         | 
| 206 182 | 
             
              Scenario: Detect stdout from all processes
         | 
| 207 | 
            -
                When I run ` | 
| 208 | 
            -
                And I run ` | 
| 209 | 
            -
                And I type " | 
| 183 | 
            +
                When I run `printf "hello world!\n"`
         | 
| 184 | 
            +
                And I run `cat` interactively
         | 
| 185 | 
            +
                And I type "hola"
         | 
| 186 | 
            +
                And I type ""
         | 
| 210 187 | 
             
                Then the stdout should contain:
         | 
| 211 188 | 
             
                  """
         | 
| 212 189 | 
             
                  hello world!
         | 
| 213 | 
            -
                   | 
| 214 | 
            -
             | 
| 215 | 
            -
                And the stderr should not contain:
         | 
| 216 | 
            -
                  """
         | 
| 217 | 
            -
                  hello world!
         | 
| 218 | 
            -
                  olleh
         | 
| 190 | 
            +
                  hola
         | 
| 191 | 
            +
             | 
| 219 192 | 
             
                  """
         | 
| 193 | 
            +
                And the stderr should not contain anything
         | 
| 220 194 |  | 
| 221 195 | 
             
              @posix
         | 
| 222 196 | 
             
              Scenario: Detect stderr from all processes
         | 
| 223 | 
            -
                When I run ` | 
| 224 | 
            -
                And I run ` | 
| 225 | 
            -
                And I type " | 
| 197 | 
            +
                When I run `bash -c 'printf "hello world!\n" >&2'`
         | 
| 198 | 
            +
                And I run `bash -c 'cat >&2 '` interactively
         | 
| 199 | 
            +
                And I type "hola"
         | 
| 200 | 
            +
                And I type ""
         | 
| 226 201 | 
             
                Then the stderr should contain:
         | 
| 227 202 | 
             
                  """
         | 
| 228 203 | 
             
                  hello world!
         | 
| 229 | 
            -
                   | 
| 230 | 
            -
                  """
         | 
| 231 | 
            -
                And the stdout should not contain:
         | 
| 232 | 
            -
                  """
         | 
| 233 | 
            -
                  hello world!
         | 
| 234 | 
            -
                  olleh
         | 
| 204 | 
            +
                  hola
         | 
| 235 205 | 
             
                  """
         | 
| 206 | 
            +
                And the stdout should not contain anything
         | 
| 236 207 |  | 
| 237 208 | 
             
              Scenario: Detect output from named source
         | 
| 238 | 
            -
                When I run ` | 
| 239 | 
            -
                And I run ` | 
| 209 | 
            +
                When I run `printf 'simple'`
         | 
| 210 | 
            +
                And I run `cat` interactively
         | 
| 240 211 | 
             
                And I type "interactive"
         | 
| 241 | 
            -
                 | 
| 242 | 
            -
                 | 
| 212 | 
            +
                And I type ""
         | 
| 213 | 
            +
                Then the output from "printf 'simple'" should contain "simple"
         | 
| 214 | 
            +
                And the output from "printf 'simple'" should contain exactly "simple"
         | 
| 215 | 
            +
                And the output from "printf 'simple'" should contain exactly:
         | 
| 216 | 
            +
                  """
         | 
| 217 | 
            +
                  simple
         | 
| 218 | 
            +
                  """
         | 
| 219 | 
            +
                And the output from "cat" should not contain "simple"
         | 
| 243 220 |  | 
| 244 221 | 
             
              Scenario: Detect stdout from named source
         | 
| 245 | 
            -
                When I run ` | 
| 246 | 
            -
                And I run ` | 
| 247 | 
            -
                Then the stdout from " | 
| 248 | 
            -
                And the  | 
| 249 | 
            -
                And the stdout from " | 
| 222 | 
            +
                When I run `printf 'hello'`
         | 
| 223 | 
            +
                And I run `printf 'goodbye'`
         | 
| 224 | 
            +
                Then the stdout from "printf 'hello'" should contain "hello"
         | 
| 225 | 
            +
                And the stdout from "printf 'hello'" should contain exactly "hello"
         | 
| 226 | 
            +
                And the stdout from "printf 'hello'" should contain exactly:
         | 
| 227 | 
            +
                  """
         | 
| 228 | 
            +
                  hello
         | 
| 229 | 
            +
                  """
         | 
| 230 | 
            +
                And the stderr from "printf 'hello'" should not contain "hello"
         | 
| 231 | 
            +
                And the stdout from "printf 'goodbye'" should not contain "hello"
         | 
| 250 232 |  | 
| 251 233 | 
             
              Scenario: Detect stderr from named source
         | 
| 252 | 
            -
                When I run ` | 
| 253 | 
            -
                And I run ` | 
| 254 | 
            -
                Then the stderr from " | 
| 255 | 
            -
                And the  | 
| 256 | 
            -
                And the stderr from " | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 234 | 
            +
                When I run `bash -c 'printf hello >&2'`
         | 
| 235 | 
            +
                And I run `printf goodbye`
         | 
| 236 | 
            +
                Then the stderr from "bash -c 'printf hello >&2'" should contain "hello"
         | 
| 237 | 
            +
                And the stderr from "bash -c 'printf hello >&2'" should contain exactly "hello"
         | 
| 238 | 
            +
                And the stderr from "bash -c 'printf hello >&2'" should contain exactly:
         | 
| 239 | 
            +
                  """
         | 
| 240 | 
            +
                  hello
         | 
| 241 | 
            +
                  """
         | 
| 242 | 
            +
                And the stdout from "bash -c 'printf hello >&2'" should not contain "hello"
         | 
| 243 | 
            +
                And the stderr from "printf goodbye" should not contain "hello"
         | 
| 260 244 |  | 
| 261 245 | 
             
              Scenario: Detect second output from named source with custom name
         | 
| 262 246 | 
             
                When I set env variable "ARUBA_TEST_VAR" to "first"
         | 
| 263 | 
            -
                And I run ` | 
| 264 | 
            -
                Then the output from " | 
| 247 | 
            +
                And I run `bash -c 'printf $ARUBA_TEST_VAR'`
         | 
| 248 | 
            +
                Then the output from "bash -c 'printf $ARUBA_TEST_VAR'" should contain "first"
         | 
| 265 249 | 
             
                When I set env variable "ARUBA_TEST_VAR" to "second"
         | 
| 266 | 
            -
                And I run ` | 
| 267 | 
            -
                Then the output from " | 
| 250 | 
            +
                And I run `bash -c 'printf $ARUBA_TEST_VAR'`
         | 
| 251 | 
            +
                Then the output from "bash -c 'printf $ARUBA_TEST_VAR'" should contain "second"
         | 
    
        data/lib/aruba/api.rb
    CHANGED
    
    | @@ -23,7 +23,7 @@ module Aruba | |
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def dirs
         | 
| 26 | 
            -
                  @dirs ||= ['tmp | 
| 26 | 
            +
                  @dirs ||= ['tmp', 'aruba']
         | 
| 27 27 | 
             
                end
         | 
| 28 28 |  | 
| 29 29 | 
             
                def write_file(file_name, file_content)
         | 
| @@ -278,7 +278,8 @@ module Aruba | |
| 278 278 | 
             
                  processes.collect{ |_, process| process }
         | 
| 279 279 | 
             
                end
         | 
| 280 280 |  | 
| 281 | 
            -
                def run(cmd)
         | 
| 281 | 
            +
                def run(cmd, timeout = nil)
         | 
| 282 | 
            +
                  timeout ||= exit_timeout
         | 
| 282 283 | 
             
                  @commands ||= []
         | 
| 283 284 | 
             
                  @commands << cmd
         | 
| 284 285 |  | 
| @@ -290,7 +291,7 @@ module Aruba | |
| 290 291 | 
             
                    announcer.dir(Dir.pwd)
         | 
| 291 292 | 
             
                    announcer.cmd(cmd)
         | 
| 292 293 |  | 
| 293 | 
            -
                    process = Process.new(cmd,  | 
| 294 | 
            +
                    process = Process.new(cmd, timeout, io_wait)
         | 
| 294 295 | 
             
                    register_process(cmd, process)
         | 
| 295 296 | 
             
                    process.run!
         | 
| 296 297 |  | 
| @@ -310,8 +311,8 @@ module Aruba | |
| 310 311 | 
             
                  @aruba_io_wait_seconds || DEFAULT_IO_WAIT_SECONDS
         | 
| 311 312 | 
             
                end
         | 
| 312 313 |  | 
| 313 | 
            -
                def run_simple(cmd, fail_on_error=true)
         | 
| 314 | 
            -
                  run(cmd) do |process|
         | 
| 314 | 
            +
                def run_simple(cmd, fail_on_error=true, timeout = nil)
         | 
| 315 | 
            +
                  run(cmd, timeout) do |process|
         | 
| 315 316 | 
             
                    stop_process(process)
         | 
| 316 317 | 
             
                  end
         | 
| 317 318 | 
             
                  @timed_out = last_exit_status.nil?
         | 
| @@ -323,11 +324,17 @@ module Aruba | |
| 323 324 | 
             
                end
         | 
| 324 325 |  | 
| 325 326 | 
             
                def type(input)
         | 
| 327 | 
            +
                  return eot if "" == input ##If on Windows it is actually  (26 == 0x1A)
         | 
| 326 328 | 
             
                  _write_interactive(_ensure_newline(input))
         | 
| 327 329 | 
             
                end
         | 
| 328 330 |  | 
| 331 | 
            +
                def eot
         | 
| 332 | 
            +
                  @interactive.stdin.close
         | 
| 333 | 
            +
                end
         | 
| 334 | 
            +
             | 
| 329 335 | 
             
                def _write_interactive(input)
         | 
| 330 336 | 
             
                  @interactive.stdin.write(input)
         | 
| 337 | 
            +
                  @interactive.stdin.flush
         | 
| 331 338 | 
             
                end
         | 
| 332 339 |  | 
| 333 340 | 
             
                def _read_interactive
         | 
    
        data/lib/aruba/cucumber.rb
    CHANGED
    
    | @@ -4,6 +4,10 @@ require 'aruba/reporting' | |
| 4 4 |  | 
| 5 5 | 
             
            World(Aruba::Api)
         | 
| 6 6 |  | 
| 7 | 
            +
            Given /The default aruba timeout is (\d+) seconds/ do |seconds|
         | 
| 8 | 
            +
              @aruba_timeout_seconds = seconds.to_i
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
             | 
| 7 11 | 
             
            Given /^I'm using a clean gemset "([^"]*)"$/ do |gemset|
         | 
| 8 12 | 
             
              use_clean_gemset(gemset)
         | 
| 9 13 | 
             
            end
         | 
| @@ -62,8 +66,10 @@ When /^I successfully run "(.*)"$/ do |cmd| | |
| 62 66 | 
             
              run_simple(unescape(cmd))
         | 
| 63 67 | 
             
            end
         | 
| 64 68 |  | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 69 | 
            +
            ## I successfully run `echo -n "Hello"`
         | 
| 70 | 
            +
            ## I successfully run `sleep 29` for up to 30 seconds
         | 
| 71 | 
            +
            When /^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/ do |cmd, secs|
         | 
| 72 | 
            +
              run_simple(unescape(cmd), true, secs && secs.to_i)
         | 
| 67 73 | 
             
            end
         | 
| 68 74 |  | 
| 69 75 | 
             
            When /^I run "([^"]*)" interactively$/ do |cmd|
         | 
| @@ -112,12 +118,16 @@ Then /^the output should not contain:$/ do |unexpected| | |
| 112 118 | 
             
              assert_no_partial_output(unexpected, all_output)
         | 
| 113 119 | 
             
            end
         | 
| 114 120 |  | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 121 | 
            +
            ## the output should contain exactly "output"
         | 
| 122 | 
            +
            ## the output from `echo -n "Hello"` should contain exactly "Hello"
         | 
| 123 | 
            +
            Then /^the output(?: from "(.*?)")? should contain exactly "(.*?)"$/ do |cmd, expected|
         | 
| 124 | 
            +
              assert_exact_output(expected, cmd ? output_from(cmd) : all_output)
         | 
| 117 125 | 
             
            end
         | 
| 118 126 |  | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 127 | 
            +
            ## the output should contain exactly:
         | 
| 128 | 
            +
            ## the output from `echo -n "Hello"` should contain exactly:
         | 
| 129 | 
            +
            Then /^the output(?: from "(.*?)")? should contain exactly:$/ do |cmd, expected|
         | 
| 130 | 
            +
              assert_exact_output(expected, cmd ? output_from(cmd) : all_output)
         | 
| 121 131 | 
             
            end
         | 
| 122 132 |  | 
| 123 133 | 
             
            # "the output should match" allows regex in the partial_output, if
         | 
| @@ -162,28 +172,52 @@ Then /^it should (pass|fail) with regexp?:$/ do |pass_fail, expected| | |
| 162 172 | 
             
              assert_success(pass_fail == 'pass')
         | 
| 163 173 | 
             
            end
         | 
| 164 174 |  | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
            Then /^the stderr should contain | 
| 170 | 
            -
               | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
               | 
| 175 | 
            +
            ## the stderr should contain "hello"
         | 
| 176 | 
            +
            ## the stderr from "echo -n 'Hello'" should contain "hello"
         | 
| 177 | 
            +
            ## the stderr should contain exactly:
         | 
| 178 | 
            +
            ## the stderr from "echo -n 'Hello'" should contain exactly:
         | 
| 179 | 
            +
            Then /^the stderr(?: from "(.*?)")? should contain( exactly)? "(.*?)"$/ do |cmd, exact, expected|
         | 
| 180 | 
            +
              if exact
         | 
| 181 | 
            +
                assert_exact_output(expected, cmd ? stderr_from(cmd) : all_stderr)
         | 
| 182 | 
            +
              else
         | 
| 183 | 
            +
                assert_partial_output(expected, cmd ? stderr_from(cmd) : all_stderr)
         | 
| 184 | 
            +
              end
         | 
| 175 185 | 
             
            end
         | 
| 176 186 |  | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 187 | 
            +
            ## the stderr should contain:
         | 
| 188 | 
            +
            ## the stderr from "echo -n 'Hello'" should contain:
         | 
| 189 | 
            +
            ## the stderr should contain exactly:
         | 
| 190 | 
            +
            ## the stderr from "echo -n 'Hello'" should contain exactly:
         | 
| 191 | 
            +
            Then /^the stderr(?: from "(.*?)")? should contain( exactly)?:$/ do |cmd, exact, expected|
         | 
| 192 | 
            +
              if exact
         | 
| 193 | 
            +
                assert_exact_output(expected, cmd ? stderr_from(cmd) : all_stderr)
         | 
| 194 | 
            +
              else
         | 
| 195 | 
            +
                assert_partial_output(expected, cmd ? stderr_from(cmd) : all_stderr)
         | 
| 196 | 
            +
              end
         | 
| 179 197 | 
             
            end
         | 
| 180 198 |  | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 199 | 
            +
            ## the stdout should contain "hello"
         | 
| 200 | 
            +
            ## the stdout from "echo -n 'Hello'" should contain "hello"
         | 
| 201 | 
            +
            ## the stdout should contain exactly:
         | 
| 202 | 
            +
            ## the stdout from "echo -n 'Hello'" should contain exactly:
         | 
| 203 | 
            +
            Then /^the stdout(?: from "(.*?)")? should contain( exactly)? "(.*?)"$/ do |cmd, exact, expected|
         | 
| 204 | 
            +
              if exact
         | 
| 205 | 
            +
                assert_exact_output(expected, cmd ? stdout_from(cmd) : all_stdout)
         | 
| 206 | 
            +
              else
         | 
| 207 | 
            +
                assert_partial_output(expected, cmd ? stdout_from(cmd) : all_stdout)
         | 
| 208 | 
            +
              end
         | 
| 183 209 | 
             
            end
         | 
| 184 210 |  | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 211 | 
            +
            ## the stdout should contain:
         | 
| 212 | 
            +
            ## the stdout from "echo -n 'Hello'" should contain:
         | 
| 213 | 
            +
            ## the stdout should contain exactly:
         | 
| 214 | 
            +
            ## the stdout from "echo -n 'Hello'" should contain exactly:
         | 
| 215 | 
            +
            Then /^the stdout(?: from "(.*?)")? should contain( exactly)?:$/ do |cmd, exact, expected|
         | 
| 216 | 
            +
              if exact
         | 
| 217 | 
            +
                assert_exact_output(expected, cmd ? stdout_from(cmd) : all_stdout)
         | 
| 218 | 
            +
              else
         | 
| 219 | 
            +
                assert_partial_output(expected, cmd ? stdout_from(cmd) : all_stdout)
         | 
| 220 | 
            +
              end
         | 
| 187 221 | 
             
            end
         | 
| 188 222 |  | 
| 189 223 | 
             
            Then /^the stderr should not contain "([^"]*)"$/ do |unexpected|
         | 
| @@ -194,6 +228,11 @@ Then /^the stderr should not contain:$/ do |unexpected| | |
| 194 228 | 
             
              assert_no_partial_output(unexpected, all_stderr)
         | 
| 195 229 | 
             
            end
         | 
| 196 230 |  | 
| 231 | 
            +
            Then /^the (stderr|stdout) should not contain anything$/ do |stream_name|
         | 
| 232 | 
            +
              stream = self.send("all_#{stream_name}")
         | 
| 233 | 
            +
              stream.should be_empty
         | 
| 234 | 
            +
            end
         | 
| 235 | 
            +
             | 
| 197 236 | 
             
            Then /^the stdout should not contain "([^"]*)"$/ do |unexpected|
         | 
| 198 237 | 
             
              assert_no_partial_output(unexpected, all_stdout)
         | 
| 199 238 | 
             
            end
         | 
| @@ -202,18 +241,10 @@ Then /^the stdout should not contain:$/ do |unexpected| | |
| 202 241 | 
             
              assert_no_partial_output(unexpected, all_stdout)
         | 
| 203 242 | 
             
            end
         | 
| 204 243 |  | 
| 205 | 
            -
            Then /^the stdout from "([^"]*)" should contain "([^"]*)"$/ do |cmd, expected|
         | 
| 206 | 
            -
              assert_partial_output(expected, stdout_from(cmd))
         | 
| 207 | 
            -
            end
         | 
| 208 | 
            -
             | 
| 209 244 | 
             
            Then /^the stdout from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, unexpected|
         | 
| 210 245 | 
             
              assert_no_partial_output(unexpected, stdout_from(cmd))
         | 
| 211 246 | 
             
            end
         | 
| 212 247 |  | 
| 213 | 
            -
            Then /^the stderr from "([^"]*)" should contain "([^"]*)"$/ do |cmd, expected|
         | 
| 214 | 
            -
              assert_partial_output(expected, stderr_from(cmd))
         | 
| 215 | 
            -
            end
         | 
| 216 | 
            -
             | 
| 217 248 | 
             
            Then /^the stderr from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, unexpected|
         | 
| 218 249 | 
             
              assert_no_partial_output(unexpected, stderr_from(cmd))
         | 
| 219 250 | 
             
            end
         | 
    
        data/lib/aruba/errors.rb
    ADDED
    
    
    
        data/lib/aruba/process.rb
    CHANGED
    
    | @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            require 'childprocess'
         | 
| 2 2 | 
             
            require 'tempfile'
         | 
| 3 3 | 
             
            require 'shellwords'
         | 
| 4 | 
            +
            require 'aruba/errors'
         | 
| 4 5 |  | 
| 5 6 | 
             
            module Aruba
         | 
| 6 7 | 
             
              class Process
         | 
| @@ -10,24 +11,29 @@ module Aruba | |
| 10 11 | 
             
                  @exit_timeout = exit_timeout
         | 
| 11 12 | 
             
                  @io_wait = io_wait
         | 
| 12 13 |  | 
| 14 | 
            +
                  @cmd = cmd
         | 
| 15 | 
            +
                  @process = nil
         | 
| 16 | 
            +
                  @exit_code = nil
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def run!(&block)
         | 
| 20 | 
            +
                  @process = ChildProcess.build(*shellwords(@cmd))
         | 
| 13 21 | 
             
                  @out = Tempfile.new("aruba-out")
         | 
| 14 22 | 
             
                  @err = Tempfile.new("aruba-err")
         | 
| 15 | 
            -
                  @process = ChildProcess.build(*shellwords(cmd))
         | 
| 16 23 | 
             
                  @process.io.stdout = @out
         | 
| 17 24 | 
             
                  @process.io.stderr = @err
         | 
| 18 25 | 
             
                  @process.duplex = true
         | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                   | 
| 26 | 
            +
                  @exit_code = nil
         | 
| 27 | 
            +
                  begin
         | 
| 28 | 
            +
                    @process.start
         | 
| 29 | 
            +
                  rescue ChildProcess::LaunchError => e
         | 
| 30 | 
            +
                    raise LaunchError.new(e.message)
         | 
| 31 | 
            +
                  end
         | 
| 23 32 | 
             
                  yield self if block_given?
         | 
| 24 33 | 
             
                end
         | 
| 25 34 |  | 
| 26 35 | 
             
                def stdin
         | 
| 27 | 
            -
                   | 
| 28 | 
            -
                    @process.io.stdin.sync = true
         | 
| 29 | 
            -
                    @process.io.stdin
         | 
| 30 | 
            -
                  end
         | 
| 36 | 
            +
                  @process.io.stdin
         | 
| 31 37 | 
             
                end
         | 
| 32 38 |  | 
| 33 39 | 
             
                def output(keep_ansi)
         | 
| @@ -56,13 +62,15 @@ module Aruba | |
| 56 62 | 
             
                end
         | 
| 57 63 |  | 
| 58 64 | 
             
                def stop(reader, keep_ansi)
         | 
| 59 | 
            -
                  return unless @process
         | 
| 65 | 
            +
                  return @exit_code unless @process
         | 
| 60 66 | 
             
                  unless @process.exited?
         | 
| 61 | 
            -
                    reader.stdout stdout(keep_ansi)
         | 
| 62 | 
            -
                    reader.stderr stderr(keep_ansi)
         | 
| 63 67 | 
             
                    @process.poll_for_exit(@exit_timeout)
         | 
| 64 68 | 
             
                  end
         | 
| 65 | 
            -
                   | 
| 69 | 
            +
                  reader.stdout stdout(keep_ansi)
         | 
| 70 | 
            +
                  reader.stderr stderr(keep_ansi)
         | 
| 71 | 
            +
                  @exit_code = @process.exit_code
         | 
| 72 | 
            +
                  @process = nil
         | 
| 73 | 
            +
                  @exit_code
         | 
| 66 74 | 
             
                end
         | 
| 67 75 |  | 
| 68 76 | 
             
                def terminate(keep_ansi)
         | 
| @@ -76,7 +84,7 @@ module Aruba | |
| 76 84 | 
             
                private
         | 
| 77 85 |  | 
| 78 86 | 
             
                def wait_for_io(&block)
         | 
| 79 | 
            -
                  sleep @io_wait if @process | 
| 87 | 
            +
                  sleep @io_wait if @process
         | 
| 80 88 | 
             
                  yield
         | 
| 81 89 | 
             
                end
         | 
| 82 90 |  | 
    
        data/spec/aruba/api_spec.rb
    CHANGED
    
    | @@ -19,10 +19,14 @@ describe Aruba::Api  do | |
| 19 19 | 
             
                @file_name = "test.txt"
         | 
| 20 20 | 
             
                @file_size = 256
         | 
| 21 21 | 
             
                @file_path = File.join(@aruba.current_dir, @file_name)
         | 
| 22 | 
            -
                @directory_name = 'test_dir'
         | 
| 23 | 
            -
                @directory_path = File.join(@aruba.current_dir, @directory_name)
         | 
| 24 22 |  | 
| 25 | 
            -
                 | 
| 23 | 
            +
                (@aruba.dirs.length-1).times do |depth| #Ensure all parent dirs exists
         | 
| 24 | 
            +
                  dir = File.join(*@aruba.dirs[0..depth])
         | 
| 25 | 
            +
                  Dir.mkdir(dir) unless File.exist?(dir)
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
                raise "We must work with relative paths, everything else is dangerous" if ?/ == @aruba.current_dir[0]
         | 
| 28 | 
            +
                FileUtils.rm_rf(@aruba.current_dir)
         | 
| 29 | 
            +
                Dir.mkdir(@aruba.current_dir)
         | 
| 26 30 | 
             
              end
         | 
| 27 31 |  | 
| 28 32 | 
             
              describe 'current_dir' do
         | 
| @@ -33,6 +37,11 @@ describe Aruba::Api  do | |
| 33 37 |  | 
| 34 38 | 
             
              describe 'directories' do
         | 
| 35 39 | 
             
                context 'delete directory' do
         | 
| 40 | 
            +
                  before(:each) do
         | 
| 41 | 
            +
                    @directory_name = 'test_dir'
         | 
| 42 | 
            +
                    @directory_path = File.join(@aruba.current_dir, @directory_name)
         | 
| 43 | 
            +
                    Dir.mkdir(@directory_path)
         | 
| 44 | 
            +
                  end
         | 
| 36 45 | 
             
                  it 'should delete directory' do
         | 
| 37 46 | 
             
                    @aruba.remove_dir(@directory_name)
         | 
| 38 47 | 
             
                    File.exist?(@directory_path).should == false
         | 
| @@ -57,7 +66,9 @@ describe Aruba::Api  do | |
| 57 66 | 
             
                    @aruba.write_fixed_size_file(@file_name, @file_size)
         | 
| 58 67 | 
             
                    lambda { @aruba.check_file_size([[@file_name, @file_size + 1]]) }.should raise_error
         | 
| 59 68 | 
             
                  end
         | 
| 60 | 
            -
             | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
                context 'existing' do
         | 
| 71 | 
            +
                  before(:each) { File.open(@file_path, 'w') { |f| f << "" } }
         | 
| 61 72 | 
             
                  it "should delete file" do
         | 
| 62 73 | 
             
                    @aruba.remove_file(@file_name)
         | 
| 63 74 | 
             
                    File.exist?(@file_path).should == false
         | 
| @@ -67,12 +78,12 @@ describe Aruba::Api  do | |
| 67 78 |  | 
| 68 79 | 
             
              describe 'tags' do
         | 
| 69 80 | 
             
                describe '@announce_stdout' do
         | 
| 70 | 
            -
             | 
| 81 | 
            +
                  after(:each){@aruba.stop_processes!}
         | 
| 71 82 | 
             
                  context 'enabled' do
         | 
| 72 83 | 
             
                    it "should announce to stdout exactly once" do
         | 
| 73 84 | 
             
                      @aruba.should_receive(:announce_or_puts).once
         | 
| 74 85 | 
             
                      @aruba.set_tag(:announce_stdout, true)
         | 
| 75 | 
            -
                      @aruba.run_simple( | 
| 86 | 
            +
                      @aruba.run_simple('echo "hello world"', false)
         | 
| 76 87 | 
             
                      @aruba.all_output.should match(/hello world/)
         | 
| 77 88 | 
             
                    end
         | 
| 78 89 | 
             
                  end
         | 
| @@ -81,7 +92,7 @@ describe Aruba::Api  do | |
| 81 92 | 
             
                    it "should not announce to stdout" do
         | 
| 82 93 | 
             
                      @aruba.should_not_receive(:announce_or_puts)
         | 
| 83 94 | 
             
                      @aruba.set_tag(:announce_stdout, false)
         | 
| 84 | 
            -
                      @aruba.run_simple( | 
| 95 | 
            +
                      @aruba.run_simple('echo "hello world"', false)
         | 
| 85 96 | 
             
                      @aruba.all_output.should match(/hello world/)
         | 
| 86 97 | 
             
                    end
         | 
| 87 98 | 
             
                  end
         | 
| @@ -122,9 +133,8 @@ describe Aruba::Api  do | |
| 122 133 | 
             
              end #with_file_content
         | 
| 123 134 |  | 
| 124 135 | 
             
              describe "#assert_not_matching_output" do
         | 
| 125 | 
            -
                before | 
| 126 | 
            -
             | 
| 127 | 
            -
                end
         | 
| 136 | 
            +
                before(:each){ @aruba.run_simple("echo foo", false) }
         | 
| 137 | 
            +
                after(:each){ @aruba.stop_processes! }
         | 
| 128 138 |  | 
| 129 139 | 
             
                it "passes when the output doesn't match a regexp" do
         | 
| 130 140 | 
             
                  @aruba.assert_not_matching_output "bar", @aruba.all_output
         | 
| @@ -136,4 +146,20 @@ describe Aruba::Api  do | |
| 136 146 | 
             
                end
         | 
| 137 147 | 
             
              end
         | 
| 138 148 |  | 
| 149 | 
            +
              describe "#run_interactive" do
         | 
| 150 | 
            +
                before(:each){@aruba.run_interactive "cat"}
         | 
| 151 | 
            +
                after(:each){@aruba.stop_processes!}
         | 
| 152 | 
            +
                it "respond to input" do
         | 
| 153 | 
            +
                  @aruba.type "Hello"
         | 
| 154 | 
            +
                  @aruba.type ""
         | 
| 155 | 
            +
                  @aruba.all_output.should == "Hello\n"
         | 
| 156 | 
            +
                end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                it "respond to eot" do
         | 
| 159 | 
            +
                  @aruba.type "Hello"
         | 
| 160 | 
            +
                  @aruba.eot
         | 
| 161 | 
            +
                  @aruba.all_output.should == "Hello\n"
         | 
| 162 | 
            +
                end
         | 
| 163 | 
            +
              end
         | 
| 164 | 
            +
             | 
| 139 165 | 
             
            end # Aruba::Api
         | 
    
        data/spec/aruba/process_spec.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ require 'aruba/process' | |
| 3 3 | 
             
            module Aruba
         | 
| 4 4 | 
             
              describe Process do
         | 
| 5 5 |  | 
| 6 | 
            -
                let(:process) { Process.new('echo "yo"', 0, 0.1) }
         | 
| 6 | 
            +
                let(:process) { Process.new('echo "yo"', 0.1, 0.1) }
         | 
| 7 7 |  | 
| 8 8 | 
             
                describe "#stdout" do
         | 
| 9 9 | 
             
                  before { process.run! }
         | 
| @@ -29,5 +29,15 @@ module Aruba | |
| 29 29 | 
             
                  end
         | 
| 30 30 | 
             
                end
         | 
| 31 31 |  | 
| 32 | 
            +
                describe "#run!" do
         | 
| 33 | 
            +
                  context "upon process launch error" do
         | 
| 34 | 
            +
                    let(:process_failure) { Process.new('does_not_exists', 1, 1) }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                    it "raises a Aruba::LaunchError" do
         | 
| 37 | 
            +
                      lambda{process_failure.run!}.should raise_error(::Aruba::LaunchError)
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 32 42 | 
             
              end
         | 
| 33 43 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: aruba
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -12,7 +12,7 @@ authors: | |
| 12 12 | 
             
            autorequire: 
         | 
| 13 13 | 
             
            bindir: bin
         | 
| 14 14 | 
             
            cert_chain: []
         | 
| 15 | 
            -
            date: 2012- | 
| 15 | 
            +
            date: 2012-11-20 00:00:00.000000000 Z
         | 
| 16 16 | 
             
            dependencies:
         | 
| 17 17 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 18 18 | 
             
              name: cucumber
         | 
| @@ -35,33 +35,17 @@ dependencies: | |
| 35 35 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 36 | 
             
                none: false
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - -  | 
| 38 | 
            +
                - - ~>
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: 0. | 
| 40 | 
            +
                    version: 0.3.6
         | 
| 41 41 | 
             
              type: :runtime
         | 
| 42 42 | 
             
              prerelease: false
         | 
| 43 43 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                none: false
         | 
| 45 45 | 
             
                requirements:
         | 
| 46 | 
            -
                - -  | 
| 46 | 
            +
                - - ~>
         | 
| 47 47 | 
             
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            -
                    version: 0. | 
| 49 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 50 | 
            -
              name: ffi
         | 
| 51 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 52 | 
            -
                none: false
         | 
| 53 | 
            -
                requirements:
         | 
| 54 | 
            -
                - - ! '>='
         | 
| 55 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 56 | 
            -
                    version: 1.0.11
         | 
| 57 | 
            -
              type: :runtime
         | 
| 58 | 
            -
              prerelease: false
         | 
| 59 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 60 | 
            -
                none: false
         | 
| 61 | 
            -
                requirements:
         | 
| 62 | 
            -
                - - ! '>='
         | 
| 63 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 64 | 
            -
                    version: 1.0.11
         | 
| 48 | 
            +
                    version: 0.3.6
         | 
| 65 49 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 66 50 | 
             
              name: rspec-expectations
         | 
| 67 51 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -192,6 +176,8 @@ files: | |
| 192 176 | 
             
              ZmVhdHVyZXMvc3RlcF9kZWZpbml0aW9ucy9hcnViYV9kZXZfc3RlcHMucmI=
         | 
| 193 177 | 
             
            - !binary |-
         | 
| 194 178 | 
             
              ZmVhdHVyZXMvc3VwcG9ydC9lbnYucmI=
         | 
| 179 | 
            +
            - !binary |-
         | 
| 180 | 
            +
              ZmVhdHVyZXMvc3VwcG9ydC9qcnVieS5yYg==
         | 
| 195 181 | 
             
            - !binary |-
         | 
| 196 182 | 
             
              bGliL2FydWJhLnJi
         | 
| 197 183 | 
             
            - !binary |-
         | 
| @@ -202,6 +188,8 @@ files: | |
| 202 188 | 
             
              bGliL2FydWJhL2N1Y3VtYmVyLnJi
         | 
| 203 189 | 
             
            - !binary |-
         | 
| 204 190 | 
             
              bGliL2FydWJhL2N1Y3VtYmVyL2hvb2tzLnJi
         | 
| 191 | 
            +
            - !binary |-
         | 
| 192 | 
            +
              bGliL2FydWJhL2Vycm9ycy5yYg==
         | 
| 205 193 | 
             
            - !binary |-
         | 
| 206 194 | 
             
              bGliL2FydWJhL2pydWJ5LnJi
         | 
| 207 195 | 
             
            - !binary |-
         | 
| @@ -259,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 259 247 | 
             
                  version: '0'
         | 
| 260 248 | 
             
                  segments:
         | 
| 261 249 | 
             
                  - 0
         | 
| 262 | 
            -
                  hash:  | 
| 250 | 
            +
                  hash: 1656561211491698914
         | 
| 263 251 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 264 252 | 
             
              none: false
         | 
| 265 253 | 
             
              requirements:
         | 
| @@ -268,13 +256,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 268 256 | 
             
                  version: '0'
         | 
| 269 257 | 
             
                  segments:
         | 
| 270 258 | 
             
                  - 0
         | 
| 271 | 
            -
                  hash:  | 
| 259 | 
            +
                  hash: 1656561211491698914
         | 
| 272 260 | 
             
            requirements: []
         | 
| 273 261 | 
             
            rubyforge_project: 
         | 
| 274 262 | 
             
            rubygems_version: 1.8.24
         | 
| 275 263 | 
             
            signing_key: 
         | 
| 276 264 | 
             
            specification_version: 3
         | 
| 277 | 
            -
            summary: aruba-0.5. | 
| 265 | 
            +
            summary: aruba-0.5.1
         | 
| 278 266 | 
             
            test_files:
         | 
| 279 267 | 
             
            - !binary |-
         | 
| 280 268 | 
             
              ZmVhdHVyZXMvYmVmb3JlX2NtZF9ob29rcy5mZWF0dXJl
         | 
| @@ -294,6 +282,8 @@ test_files: | |
| 294 282 | 
             
              ZmVhdHVyZXMvc3RlcF9kZWZpbml0aW9ucy9hcnViYV9kZXZfc3RlcHMucmI=
         | 
| 295 283 | 
             
            - !binary |-
         | 
| 296 284 | 
             
              ZmVhdHVyZXMvc3VwcG9ydC9lbnYucmI=
         | 
| 285 | 
            +
            - !binary |-
         | 
| 286 | 
            +
              ZmVhdHVyZXMvc3VwcG9ydC9qcnVieS5yYg==
         | 
| 297 287 | 
             
            - !binary |-
         | 
| 298 288 | 
             
              c3BlYy9hcnViYS9hcGlfc3BlYy5yYg==
         | 
| 299 289 | 
             
            - !binary |-
         |