Project

General

Profile

Actions

Bug #16634

closed

DRb remote method call with keyword argument occurs warning message of deprecated on Ruby 2.7.0, and fails on Ruby 2.8.0dev

Added by TOKI.Yoshinori (仁謙 土岐) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.8.0dev (2020-02-14 master 78282d4655) [x86_64-linux]
[ruby-core:97166]

Description

DRb remote method call with keyword argument occurs warning message of deprecated on Ruby 2.7.0, and fails on Ruby 2.8.0dev

On Ruby 2.7.0 (ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]), DRb remote method call with keyword argument occurs warning message of deprecated.
On Ruby snapshot (ruby 2.8.0dev (2020-02-14 master 78282d4655) [x86_64-linux]), DRb remote method call with keyword argument fails.

Test Script:

#!/usr/bin/env ruby

require 'drb'
require 'securerandom'
require 'test/unit'

def make_drbunix_uri
  "drbunix:/tmp/#{File.basename($0, '.rb')}.#{SecureRandom.uuid}"
end

DRb.start_service(make_drbunix_uri)

class DRbRemoteMethodCallTest < Test::Unit::TestCase
  class Example
    def ping
      :pong
    end

    def foo(test: 'default')
      test
    end

    def bar(test: 'default')
      yield(test)
    end
  end

  def wait_server(remote_object)
    begin
      remote_object.ping
    rescue DRb::DRbConnError
      sleep(0.1)
      retry
    end
  end

  def setup
    @uri = make_drbunix_uri
    @pid = fork{
      DRb.start_service(@uri, Example.new)
      DRb.thread.join
    }

    @remote_object = DRbObject.new_with_uri(@uri)
    wait_server(@remote_object)
  end

  def teardown
    Process.kill(:TERM, @pid)
    Process.wait
  end

  test 'pass keyword argument to remote method call' do
    assert_equal('halo', @remote_object.foo(test: 'halo'))
  end

  test 'pass keyword argument to remote method call with block' do
    assert_equal('halo', @remote_object.bar(test: 'halo') {|t| t })
  end
end

Output (ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]):

$ ruby test_drb_kw_args.rb -v
Loaded suite test_drb_kw_args
Started
DRbRemoteMethodCallTest:
  test: pass keyword argument to remote method call:                                                                            /usr/local/lib/ruby/2.7.0/drb/drb.rb:1690: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
test_drb_kw_args.rb:19: warning: The called method `foo' is defined here
.: (0.115401)
  test: pass keyword argument to remote method call with block:                                                                 /usr/local/lib/ruby/2.7.0/drb/invokemethod.rb:15: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
test_drb_kw_args.rb:23: warning: The called method `bar' is defined here
.: (0.114446)

Finished in 0.2303479 seconds.
------------------------------------------------------------------------------------------------------------------------------------------------------
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------------------------------------------------------------------------------------------------------------------------------------------------------
8.68 tests/s, 8.68 assertions/s

Output (ruby 2.8.0dev (2020-02-14 master 78282d4655) [x86_64-linux]):

$ ruby test_drb_kw_args.rb -v
Loaded suite test_drb_kw_args
Started
DRbRemoteMethodCallTest:
  test: pass keyword argument to remote method call:                                                                            E
======================================================================================================================================================
test_drb_kw_args.rb:54:in `block in <class:DRbRemoteMethodCallTest>'
(drbunix:/tmp/test_drb_kw_args.f82f995e-265f-429c-a0fb-770e3fa8dd35) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1730:in `block in main_loop'
(drbunix:/tmp/test_drb_kw_args.f82f995e-265f-429c-a0fb-770e3fa8dd35) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1730:in `loop'
(drbunix:/tmp/test_drb_kw_args.f82f995e-265f-429c-a0fb-770e3fa8dd35) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1734:in `block (2 levels) in main_loop'
(drbunix:/tmp/test_drb_kw_args.f82f995e-265f-429c-a0fb-770e3fa8dd35) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1646:in `perform'
(drbunix:/tmp/test_drb_kw_args.f82f995e-265f-429c-a0fb-770e3fa8dd35) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1690:in `perform_without_block'
(drbunix:/tmp/test_drb_kw_args.f82f995e-265f-429c-a0fb-770e3fa8dd35) test_drb_kw_args.rb:19:in `foo'
Error: test: pass keyword argument to remote method call(DRbRemoteMethodCallTest): ArgumentError: wrong number of arguments (given 1, expected 0)
======================================================================================================================================================
: (0.021710)
  test: pass keyword argument to remote method call with block:                                                                 E
======================================================================================================================================================
test_drb_kw_args.rb:58:in `block in <class:DRbRemoteMethodCallTest>'
(drbunix:/tmp/test_drb_kw_args.cdf13d27-0876-4ebb-ae7d-b5a79c6b58b8) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1730:in `block in main_loop'
(drbunix:/tmp/test_drb_kw_args.cdf13d27-0876-4ebb-ae7d-b5a79c6b58b8) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1730:in `loop'
(drbunix:/tmp/test_drb_kw_args.cdf13d27-0876-4ebb-ae7d-b5a79c6b58b8) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1734:in `block (2 levels) in main_loop'
(drbunix:/tmp/test_drb_kw_args.cdf13d27-0876-4ebb-ae7d-b5a79c6b58b8) /usr/local/lib/ruby/2.8.0/drb/drb.rb:1644:in `perform'
(drbunix:/tmp/test_drb_kw_args.cdf13d27-0876-4ebb-ae7d-b5a79c6b58b8) /usr/local/lib/ruby/2.8.0/drb/invokemethod.rb:15:in `perform_with_block'
(drbunix:/tmp/test_drb_kw_args.cdf13d27-0876-4ebb-ae7d-b5a79c6b58b8) test_drb_kw_args.rb:23:in `bar'
Error: test: pass keyword argument to remote method call with block(DRbRemoteMethodCallTest): ArgumentError: wrong number of arguments (given 1, expected 0)
======================================================================================================================================================
: (0.009290)

Finished in 0.031537836 seconds.
------------------------------------------------------------------------------------------------------------------------------------------------------
2 tests, 0 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
------------------------------------------------------------------------------------------------------------------------------------------------------
63.42 tests/s, 0.00 assertions/s

Expected Output (ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]):

$ ruby test_drb_kw_args.rb -v
Loaded suite test_drb_kw_args
Started
DRbRemoteMethodCallTest:
  test: pass keyword argument to remote method call:                                                                            .: (0.107467)
  test: pass keyword argument to remote method call with block:                                                                 .: (0.109916)

Finished in 0.221072125 seconds.
------------------------------------------------------------------------------------------------------------------------------------------------------
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------------------------------------------------------------------------------------------------------------------------------------------------------
9.05 tests/s, 9.05 assertions/s
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0