Skip to content
This repository
  • 16 commits
  • 7 files changed
  • 0 comments
  • 4 contributors
5  History.txt
... ...
@@ -1,3 +1,8 @@
  1
+== In Git
  2
+
  3
+=== New Features
  4
+* Replaced background_process with childprocess, a cross-platform process control library. This will allow Aruba to run on Windows and JRuby in addition to *nix MRI. (#16, #27, #31 Mike Sassak, Jari Bakken, Matt Wynne, Arve Knudsen)
  5
+
1 6
 == 0.2.7
2 7
 
3 8
 === New Features
2  README.rdoc
Source Rendered
@@ -9,7 +9,7 @@ a compiled C program, a Java program, a Perl script - anything.
9 9
 
10 10
 Then, just require the library in one of your ruby files under <tt>features/support</tt>
11 11
 
12  
-  require 'aruba'
  12
+  require 'aruba/cucumber'
13 13
 
14 14
 You now have a bunch of step definitions that you can use in your features. Look at aruba/cucumber.rb
15 15
 to see all the step definitions. Look at features/*.feature for examples (which are also testing Aruba
6  aruba.gemspec
@@ -2,7 +2,7 @@
2 2
 
3 3
 Gem::Specification.new do |s|
4 4
   s.name        = 'aruba'
5  
-  s.version     = '0.2.7'
  5
+  s.version     = '0.2.8'
6 6
   s.authors     = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak"]
7 7
   s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
8 8
   s.summary     = "aruba-#{s.version}"
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
10 10
   s.homepage    = 'http://github.com/aslakhellesoy/aruba'
11 11
 
12 12
   s.add_dependency 'cucumber', '~> 0.10.0'
13  
-  s.add_dependency 'background_process' # Can't specify a version - bundler/rubygems chokes on '2.1'
14  
-  s.add_development_dependency 'rspec', '~> 2.0.1'
  13
+  s.add_dependency 'childprocess', '~> 0.1.6'
  14
+  s.add_dependency 'rspec', '~> 2.3.0'
15 15
 
16 16
   s.rubygems_version   = "1.3.7"
17 17
   s.files            = `git ls-files`.split("\n")
2  features/output.feature
@@ -8,7 +8,7 @@ Feature: Output
8 8
     When I run "neverever gonna work"
9 9
     Then the output should contain:
10 10
     """
11  
-    No such file or directory - neverever gonna work
  11
+    No such file or directory - neverever
12 12
     """
13 13
 
14 14
   Scenario: Detect subset of one-line output
13  features/support/env.rb
... ...
@@ -1,15 +1,4 @@
1 1
 $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2 2
 require 'aruba/cucumber'
3 3
 require 'fileutils'
4  
-
5  
-begin
6  
-  # rspec-2
7  
-  require 'rspec/expectations'
8  
-rescue LoadError
9  
-  # rspec-1
10  
-  require 'spec/expectations'
11  
-end
12  
-
13  
-Before do
14  
-  FileUtils.rm(Dir['config/*.yml'])
15  
-end
  4
+require 'rspec/expectations'
4  lib/aruba/api.rb
@@ -210,9 +210,11 @@ def timeout
210 210
 
211 211
     def run_simple(cmd, fail_on_error=true)
212 212
       @last_exit_status = run(cmd) do |process|
  213
+        process.stop
213 214
         announce_or_puts(process.stdout) if @announce_stdout
214 215
         announce_or_puts(process.stderr) if @announce_stderr
215  
-        process.stop
  216
+        # need to replace with process.exit_code or similar, or remove the block entirely... it doesn't add as much as I thought it would
  217
+        process.stop       
216 218
       end
217 219
       @timed_out = @last_exit_status.nil?
218 220
 
38  lib/aruba/process.rb
... ...
@@ -1,19 +1,29 @@
1  
-require 'background_process'
  1
+require 'childprocess'
  2
+require 'tempfile'
  3
+require 'shellwords'
2 4
 
3 5
 module Aruba
4 6
   class Process
  7
+    include Shellwords
  8
+
5 9
     def initialize(cmd, timeout)
6  
-      @cmd = cmd
7 10
       @timeout = timeout
  11
+      @out = Tempfile.new("aruba-out")
  12
+      @err = Tempfile.new("aruba-err")
  13
+      @process = ChildProcess.build(*shellwords(cmd))
  14
+      @process.io.stdout = @out
  15
+      @process.io.stderr = @err
  16
+      @process.duplex = true
8 17
     end
9 18
 
10 19
     def run!(&block)
11  
-      @process = BackgroundProcess.run(@cmd)
  20
+      @process.start
12 21
       yield self if block_given?
13 22
     end
14 23
 
15 24
     def stdin
16  
-      @process.stdin
  25
+      sleep 0.1
  26
+      @process.io.stdin
17 27
     end
18 28
 
19 29
     def output
@@ -21,26 +31,22 @@ def output
21 31
     end
22 32
 
23 33
     def stdout
24  
-      if @process
25  
-        @stdout ||= @process.stdout.read
26  
-      else
27  
-        ''
28  
-      end
  34
+      sleep 0.1
  35
+      @out.rewind
  36
+      @out.read
29 37
     end
30 38
 
31 39
     def stderr
32  
-      if @process
33  
-        @stderr ||= @process.stderr.read
34  
-      else
35  
-        ''
36  
-      end
  40
+      sleep 0.1
  41
+      @err.rewind
  42
+      @err.read
37 43
     end
38 44
 
39 45
     def stop
40 46
       if @process
41 47
         stdout && stderr # flush output
42  
-        status = @process.wait(@timeout)
43  
-        status && status.exitstatus
  48
+        @process.poll_for_exit(@timeout)
  49
+        @process.exit_code
44 50
       end
45 51
     end
46 52
   end

No commit comments for this range

Something went wrong with that request. Please try again.