@@ -167,6 +167,49 @@ def test_get_execv_args_rel(self):
167
167
self .assertEqual (args [0 ], '/bin/sh' )
168
168
self .assertEqual (args [1 ], ['sh' , 'foo' ])
169
169
170
+ def test_get_execv_args_rel_in_program_dir (self ):
171
+ executable = 'sh foo'
172
+ directory = "/my/program/dir/"
173
+ program = os .path .join (directory , 'sh' )
174
+ options = DummyOptions ()
175
+ config = DummyPConfig (options , 'sh' , executable , directory )
176
+ instance = self ._makeOne (config )
177
+ def stat (filename ):
178
+ if filename == program :
179
+ return True
180
+ else :
181
+ raise OSError
182
+
183
+ config .options .stat = Mock (config .options .stat , side_effect = stat )
184
+ args = instance .get_execv_args ()
185
+ self .assertEqual (len (args ), 2 )
186
+ self .assertEqual (args [0 ], program )
187
+ self .assertEqual (args [1 ], ['sh' , 'foo' ])
188
+
189
+ def test_get_execv_args_rel_in_path (self ):
190
+ executable = 'test_program foo'
191
+ directory = "/my/program/dir/"
192
+ program = os .path .join (directory , 'test_program' )
193
+ options = DummyOptions ()
194
+ config = DummyPConfig (options , 'test_program' , executable )
195
+ instance = self ._makeOne (config )
196
+ def stat (filename ):
197
+ if filename == program :
198
+ return True
199
+ else :
200
+ raise OSError
201
+
202
+ def get_path ():
203
+ return ["/usr/bin" , directory ]
204
+
205
+ config .options .stat = Mock (config .options .stat , side_effect = stat )
206
+ config .options .get_path = Mock (config .options .get_path , side_effect = get_path )
207
+
208
+ args = instance .get_execv_args ()
209
+ self .assertEqual (len (args ), 2 )
210
+ self .assertEqual (args [0 ], program )
211
+ self .assertEqual (args [1 ], ['test_program' , 'foo' ])
212
+
170
213
def test_record_spawnerr (self ):
171
214
options = DummyOptions ()
172
215
config = DummyPConfig (options , 'test' , '/test' )
0 commit comments