Fix multi-word argument handling in foreman run.

This commit is contained in:
Daniel Brockman
2012-06-06 15:36:59 +02:00
parent 4a13122082
commit 3ea5de42aa
5 changed files with 26 additions and 15 deletions
+3 -3
View File
@@ -144,7 +144,7 @@ describe "Foreman::CLI", :fakefs do
before { write_procfile }
describe "and a command" do
let(:command) { ["ls", "-l"] }
let(:command) { ["ls", "-l", "foo bar"] }
before(:each) do
stub(subject).exec
@@ -160,8 +160,8 @@ describe "Foreman::CLI", :fakefs do
ENV["FOO"].should be_nil
end
it "should runute the command as a string" do
mock(subject).exec(command.join(" "))
it "should exec the argument list as a shell command" do
mock(subject).exec(command.shelljoin)
subject.run *command
end
end
+16 -2
View File
@@ -121,11 +121,25 @@ describe Foreman::Process do
output.should include('777')
end
it 'should handle arguments' do
pending
it 'should handle multi-word arguments (old test)' do
# TODO: This test used to be marked pending; it now passes,
# but is very slow. The next test is a fast replacement.
run %{ sh -c "trap '' TERM; sleep 10" }
subject.should be_alive
end
it 'should handle multi-word arguments' do
# We have to be a little clever here since Foreman will always
# print a status message that includes the command.
run %{ sh -c 'echo abcdef | tr a-c x | tr d-f y' }
output.should include('xxxyyy')
end
it 'should not clobber "$x"-subexpressions' do
pending 'this conflicts with the variable interpolation hack'
run %{ sh -c 'echo \$abcdef | tr \$ %' }
output.should include('%abcdef')
end
end
end
end