Permalink
Browse files
Correctly handle duplicate named targets
- Loading branch information...
Showing
with
12 additions
and
2 deletions.
-
+2
−2
lib/rubysh/command.rb
-
+10
−0
test/unit/lib/rubysh/command.rb
|
@@ -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)
|
|
|
|
@@ -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