Skip to content

Commit

Permalink
Correctly handle duplicate named targets
Browse files Browse the repository at this point in the history
  • Loading branch information
gdb committed Oct 13, 2013
1 parent 80056d2 commit 22a1937
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rubysh/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def set_stdin(runner, value)
end

def status(runner)
state(runner)[:subprocess].status
(subprocess = state(runner)[:subprocess]) ? subprocess.status : nil
end

def pid(runner)
state(runner)[:subprocess].pid
(subprocess = state(runner)[:subprocess]) ? subprocess.pid : nil
end

def prepare!(runner)
Expand Down
10 changes: 10 additions & 0 deletions test/unit/lib/rubysh/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,15 @@ class CommandTest < UnitTest
assert_equal('Command: ls /tmp 2>&1 /foo', command.to_s)
end
end

describe 'when calling #run_async' do
it 'raises the expected error when duplicating a named target' do
cmd = Rubysh::Command.new(['ls', '/tmp', Rubysh.>, Rubysh.>])
error = assert_raises(Rubysh::Error::BaseError) do
cmd.run_async
end
assert_match(/already has a named target/, error.message)
end
end
end
end

0 comments on commit 22a1937

Please sign in to comment.