public
Description: A process execution library which doesn't suck.
Clone URL: git://github.com/codahale/ropen.git
Search Repo:
Also check to make sure we can actually run the damn thing before we 
initialize.
codahale (author)
Thu May 15 14:43:25 -0700 2008
commit  0c2fa7886f32f108f8a4dfefedbbab2e17361596
tree    bb0994710d2eb510ad500d66ac87a416e9283b63
parent  0c3f82c6448d804018252b8ef6b996977f9a446d
...
12
13
14
15
16
17
 
18
19
20
...
54
55
56
 
 
 
 
 
 
 
 
 
 
57
58
59
...
12
13
14
 
 
 
15
16
17
18
...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -12,9 +12,7 @@
0
   def initialize(executable, *arguments)
0
     @executable = File.expand_path(executable)
0
     @arguments = arguments
0
- unless File.exist?(@executable)
0
- raise Ropen::InvalidExecutableError.new("#{executable} does not exist")
0
- end
0
+ check_executable(executable)
0
     @stdout_events = Ropen::Events.new
0
     @stderr_events = Ropen::Events.new
0
     @stdin_spool = Ropen::Spool.new
0
@@ -54,6 +52,16 @@
0
   end
0
   
0
 private
0
+
0
+ def check_executable(executable)
0
+ unless File.exist?(@executable)
0
+ raise Ropen::InvalidExecutableError.new("#{executable} does not exist")
0
+ end
0
+
0
+ unless File.executable?(@executable)
0
+ raise Ropen::InvalidExecutableError.new("#{executable} is not executable")
0
+ end
0
+ end
0
   
0
   def initialize_streams
0
     @stdin = Ropen::Pipe.new
...
 
...
1
0
@@ -1 +1,2 @@
0
+puts "no shebang, no +x, no service"
...
9
10
11
 
12
13
14
...
26
27
28
 
 
 
 
 
 
29
30
31
...
9
10
11
12
13
14
15
...
27
28
29
30
31
32
33
34
35
36
37
38
0
@@ -9,6 +9,7 @@
0
     @exits_with_error = fixture(:exits_with_error)
0
     @asks_for_name = fixture(:asks_for_name)
0
     @processes_data = fixture(:processes_data)
0
+ @unexecutable = fixture(:unexecutable)
0
   end
0
   
0
   describe "initializing" do
0
@@ -26,6 +27,12 @@
0
       lambda {
0
         Ropen::Command.new("bleepblorp")
0
       }.should raise_error(Ropen::InvalidExecutableError, "bleepblorp does not exist")
0
+ end
0
+
0
+ it "should raise a Ropen::InvalidExecutableError if the executable isn't executable" do
0
+ lambda {
0
+ Ropen::Command.new(@unexecutable)
0
+ }.should raise_error(Ropen::InvalidExecutableError, "./spec/fixtures/unexecutable.rb is not executable")
0
     end
0
     
0
     it "should accept a set of arguments" do

Comments

    No one has commented yet.