PROTON-1537: [ruby] Fix all -W2 warnings in self-tests Removed excessive -W0 warning suppressions in CMakeLists, fixed all warnings in 'ctest -V -R ruby'
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0f0de8d6 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0f0de8d6 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0f0de8d6 Branch: refs/heads/go1 Commit: 0f0de8d67ce0d438c18750c30adfece9d568ae7c Parents: 9fab771 Author: Alan Conway <acon...@redhat.com> Authored: Wed Mar 28 16:52:02 2018 -0400 Committer: Alan Conway <acon...@redhat.com> Committed: Wed Mar 28 17:25:09 2018 -0400 ---------------------------------------------------------------------- proton-c/bindings/ruby/CMakeLists.txt | 9 +++++---- proton-c/bindings/ruby/lib/core/message.rb | 4 +++- proton-c/bindings/ruby/spec/hash_spec.rb | 6 +++--- proton-c/bindings/ruby/spec/message_spec.rb | 1 - proton-c/bindings/ruby/spec/spec_helper.rb | 2 -- proton-c/bindings/ruby/tests/test_interop.rb | 2 +- proton-c/bindings/ruby/tests/test_messaging_adapter.rb | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt index f6f95f7..ca7c161 100644 --- a/proton-c/bindings/ruby/CMakeLists.txt +++ b/proton-c/bindings/ruby/CMakeLists.txt @@ -114,14 +114,11 @@ if (result EQUAL 0) # Have minitest set(test_env ${env_py} -- "PATH=${PATH}" "RUBYLIB=${RUBYLIB}" "SASLPASSWD=${SASLPASSWD_EXE}") macro(add_ruby_test script) - if(${script} MATCHES "old") - set(opt "RUBYOPT=-W0") # Suppress deprecation warnings - endif() get_filename_component(name ${script} NAME_WE) string(REPLACE "_" "-" name "ruby-${name}") add_test( NAME ${name} - COMMAND ${test_env} ${opt} ${RUBY_EXECUTABLE} ${script} -v + COMMAND ${test_env} ${RUBY_EXECUTABLE} ${script} -v ${ARGN}) endmacro() @@ -132,6 +129,10 @@ if (result EQUAL 0) # Have minitest foreach(t ${TESTS} ${SPECS}) add_ruby_test(${t}) endforeach() + # Suppress deprecation warnings from backward-compatibility tests + set_tests_properties( + ruby-old-example-test ruby-test-old-adapter + PROPERTIES ENVIRONMENT "RUBYOPT=-W0") else() # No minitest message(STATUS "Ruby tests will not run, minitest is not installed") http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/lib/core/message.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/message.rb b/proton-c/bindings/ruby/lib/core/message.rb index 9f83cfd..0256387 100644 --- a/proton-c/bindings/ruby/lib/core/message.rb +++ b/proton-c/bindings/ruby/lib/core/message.rb @@ -70,7 +70,6 @@ module Qpid::Proton end end - # @private nill # @private def pre_encode # encode elements from the message @@ -89,6 +88,7 @@ module Qpid::Proton @properties = {} @instructions = {} @annotations = {} + @body = nil self.body = body unless body.nil? if !opts.nil? then opts.each do |k, v| @@ -504,6 +504,8 @@ module Qpid::Proton # @return [Object] body of the message. attr_accessor :body + def inspect() pre_encode; super; end + private def check(err) # :nodoc: http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/spec/hash_spec.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/spec/hash_spec.rb b/proton-c/bindings/ruby/spec/hash_spec.rb index 8ef4177..d9e07c1 100644 --- a/proton-c/bindings/ruby/spec/hash_spec.rb +++ b/proton-c/bindings/ruby/spec/hash_spec.rb @@ -27,8 +27,8 @@ describe "The extended hash type" do end it "can be put into an instance of Data" do - @hash.proton_data_put(@data) - result = Hash.proton_data_get(@data) + @data.map = @hash + result = @data.map result.keys.must_equal(@hash.keys) result.values.must_equal(@hash.values) end @@ -38,7 +38,7 @@ describe "The extended hash type" do @data.rewind proc { - Hash.proton_data_get(@data) + @data.map }.must_raise(TypeError) end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/spec/message_spec.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/spec/message_spec.rb b/proton-c/bindings/ruby/spec/message_spec.rb index eacabcc..5383f5a 100644 --- a/proton-c/bindings/ruby/spec/message_spec.rb +++ b/proton-c/bindings/ruby/spec/message_spec.rb @@ -580,7 +580,6 @@ module Qpid end it "has no body after being cleared" do - name = random_string(16) value = random_string(128) @message.body = value http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/spec/spec_helper.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/spec/spec_helper.rb b/proton-c/bindings/ruby/spec/spec_helper.rb index 809da52..fd5f288 100644 --- a/proton-c/bindings/ruby/spec/spec_helper.rb +++ b/proton-c/bindings/ruby/spec/spec_helper.rb @@ -17,7 +17,6 @@ # under the License. # -require 'minitest/spec' require 'minitest/autorun' require "securerandom" require "qpid_proton" @@ -65,7 +64,6 @@ end def random_list(length) result = [] (0...length).each do |element| - type = rand(8192) % 4 low = rand(512) high = rand(8192) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/tests/test_interop.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/tests/test_interop.rb b/proton-c/bindings/ruby/tests/test_interop.rb index a956fc8..ff85e76 100755 --- a/proton-c/bindings/ruby/tests/test_interop.rb +++ b/proton-c/bindings/ruby/tests/test_interop.rb @@ -23,7 +23,7 @@ class InteropTest < MiniTest::Test # Walk up the directory tree to find the tests directory. def get_data(name) path = File.join(File.dirname(__FILE__), "../../../../tests/interop/#{name}.amqp") - raise "Can't find test/interop directory from #{__FILE__}" unless File.exists?(path) + raise "Can't find test/interop directory from #{__FILE__}" unless File.exist?(path) File.open(path, "rb") { |f| f.read } end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f0de8d6/proton-c/bindings/ruby/tests/test_messaging_adapter.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/tests/test_messaging_adapter.rb b/proton-c/bindings/ruby/tests/test_messaging_adapter.rb index 942fc01..70ec0ca 100644 --- a/proton-c/bindings/ruby/tests/test_messaging_adapter.rb +++ b/proton-c/bindings/ruby/tests/test_messaging_adapter.rb @@ -112,7 +112,7 @@ class TestMessagingHandler < MiniTest::Test def test_session_error d = DriverPair.new(RecordingHandler.new, RecordingHandler.new) d.client.connection.open - s = d.client.connection.session; s.open; d.run + s = d.client.connection.default_session; s.open; d.run assert_equal [:on_connection_open, :on_session_open], d.client.handler.names assert_equal [:on_connection_open, :on_session_open], d.server.handler.names d.clear --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org