Skip to content

Commit

Permalink
test-app-options.rb: testing help/version options was killing the res…
Browse files Browse the repository at this point in the history
…t of the tests

Speaking of killing.. add more robust kill checking and fix an outright bug in name-to-number access.
  • Loading branch information
rocky committed Aug 14, 2011
1 parent b6db270 commit 303abeb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions processor/command/kill.rb
Expand Up @@ -61,16 +61,16 @@ def run(args) # :nodoc
begin
## @proc.intf.finalize if 'KILL' == sig || Signal['KILL'] == sig
Process.kill(sig, Process.pid)
rescue Errno::ESRCH
errmsg "Unable to send kill #{sig} to process #{Process.pid}"
rescue Errno::ESRCH, Errno::EINVAL, Errno::EPERM, RangeError
errmsg "Unable to send kill #{sig} to process #{Process.pid}: #{$!}"
end
end
end

if __FILE__ == $0
require_relative '../mock'
dbgr, cmd = MockDebugger::setup
%w(fooo 1 -1 HUP -9).each do |arg|
%w(fooo 100 1 -1 HUP -9).each do |arg|
puts "#{cmd.name} #{arg}"
cmd.run([cmd.name, arg])
puts '=' * 40
Expand Down
24 changes: 13 additions & 11 deletions test/unit/test-app-options.rb
Expand Up @@ -52,18 +52,20 @@ def test_binary_opts
end
end

# FIXME: have to work around the fact that exit is called by help.
def no_test_help_and_version_opts
%w(help version).each do |name|
setup
o = ["--#{name}"]
rest = @opts.parse o
assert_not_equal('', @stdout.string)
assert_equal('', @stderr.string)
assert_equal(true, @options[name.to_sym])
other_sym = 'help' == name ? :version : :help
assert_equal(false, @options.member?(other_sym))
end
omit unless Process.respond_to?(:fork)
Process.fork {
%w(help version).each do |name|
setup
o = ["--#{name}"]
rest = @opts.parse o
assert_not_equal('', @stdout.string)
assert_equal('', @stderr.string)
assert_equal(true, @options[name.to_sym])
other_sym = 'help' == name ? :version : :help
assert_equal(false, @options.member?(other_sym))
end
}
end

def test_both_client_server_opts
Expand Down

0 comments on commit 303abeb

Please sign in to comment.