Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Keep result code in Cocaine::CommandLine#exit_status

  • Loading branch information...
commit bfe0ba6842721cc45c18fb44985c12a4bc3cc74a 1 parent 4eb18d2
Alban Peignier authored February 25, 2012
4  lib/cocaine/command_line.rb
@@ -4,6 +4,8 @@ class << self
4 4
       attr_accessor :path, :logger
5 5
     end
6 6
 
  7
+    attr_reader :exit_status
  8
+
7 9
     def initialize(binary, params = "", options = {})
8 10
       @binary            = binary.dup
9 11
       @params            = params.dup
@@ -31,6 +33,8 @@ def run
31 33
         end
32 34
       rescue Errno::ENOENT
33 35
         raise Cocaine::CommandNotFoundError
  36
+      ensure
  37
+        @exit_status = $?.exitstatus
34 38
       end
35 39
       if $?.exitstatus == 127
36 40
         raise Cocaine::CommandNotFoundError
9  spec/cocaine/command_line_spec.rb
@@ -142,6 +142,15 @@
142 142
     end
143 143
   end
144 144
 
  145
+  it "should keep result code in #exitstatus" do
  146
+    cmd = Cocaine::CommandLine.new("convert")
  147
+    cmd.class.stubs(:"`").with("convert").returns(:correct_value)
  148
+    with_exitstatus_returning(1) do
  149
+      cmd.run rescue nil
  150
+    end
  151
+    cmd.exit_status.should == 1
  152
+  end
  153
+
145 154
   it "detects that the system is unix" do
146 155
     Cocaine::CommandLine.new("convert").unix?.should be_true
147 156
   end

0 notes on commit bfe0ba6

Please sign in to comment.
Something went wrong with that request. Please try again.