Skip to content

Commit 13d27ef

Browse files
committed
Add spec for Process.spawn searching the executable in the passed env PATH
* From #2419
1 parent 0c3745e commit 13d27ef

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/ruby/core/process/spawn_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@
212212
end.should output_to_fd("nil\n")
213213
end
214214

215+
it "uses the passed env['PATH'] to search the executable" do
216+
dir = tmp("spawn_path_dir")
217+
mkdir_p dir
218+
begin
219+
exe = 'process-spawn-executable-in-path'
220+
path = "#{dir}/#{exe}"
221+
File.write(path, "#!/bin/sh\necho $1")
222+
File.chmod(0755, path)
223+
224+
env = { "PATH" => "#{dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}" }
225+
Process.wait Process.spawn(env, exe, 'OK', out: @name)
226+
$?.should.success?
227+
File.read(@name).should == "OK\n"
228+
ensure
229+
rm_r dir
230+
end
231+
end
232+
215233
it "calls #to_hash to convert the environment" do
216234
o = mock("to_hash")
217235
o.should_receive(:to_hash).and_return({"FOO" => "BAR"})

0 commit comments

Comments
 (0)