diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb index 1d4dcc474..1f4da7852 100644 --- a/lib/aruba/processes/spawn_process.rb +++ b/lib/aruba/processes/spawn_process.rb @@ -83,7 +83,7 @@ def start sleep startup_wait_time end rescue ChildProcess::LaunchError => e - raise LaunchError, "It tried to start #{cmd}. " + e.message + raise LaunchError, "It tried to start #{commandline}. " + e.message end after_run diff --git a/spec/aruba/spawn_process_spec.rb b/spec/aruba/spawn_process_spec.rb index fe32a576f..cfe3fbef0 100644 --- a/spec/aruba/spawn_process_spec.rb +++ b/spec/aruba/spawn_process_spec.rb @@ -56,5 +56,35 @@ it { expect {process.start}.to raise_error Aruba::LaunchError } end + + context "with a childprocess launch error" do + let(:child) { instance_double(ChildProcess::AbstractProcess) } + let(:command) { 'foo' } + + before do + allow(ChildProcess).to receive(:build).and_return(child) + + # Simlulate the program exists (but will fail to run, e.g. EACCESS?) + allow(Aruba.platform).to receive(:which).with(command, anything).and_return("/foo") + + allow(child).to receive(:start).and_raise(ChildProcess::LaunchError, "Foobar!") + allow(child).to receive(:leader=) + + io = instance_double(ChildProcess::Unix::IO) + allow(io).to receive(:stdout=) + allow(io).to receive(:stderr=) + + allow(child).to receive(:io).and_return(io) + + allow(child).to receive(:duplex=) + allow(child).to receive(:cwd=) + + allow(child).to receive(:environment).and_return({}) + end + + it "reraises LaunchError as Aruba's LaunchError" do + expect { process.start }.to raise_error(Aruba::LaunchError, "It tried to start foo. Foobar!") + end + end end end