Skip to content

Ruby tests not passing #20336

Open
Open
@nirvdrum

Description

What version of protobuf and what language are you using?
Version: 77f65e9
Language: Ruby

What operating system (Linux, Windows, ...) and version?

Linux - Ubuntu 24.04 (6.8.0-53-generic)
macOS 15.3

What runtime / compiler are you using (e.g., python version or gcc version)

Ruby: 3.4.1

What did you do?

I'm running into test failures running the Ruby tests on a clean checkout and build. I've followed the steps in the ruby/README.md file.

Steps to reproduce the behavior:

  1. cd ruby
  2. bundle
  3. rake
  4. rake clobber_package gem
  5. rake test

What did you expect to see

I expected the tests to all pass since I've made no modifications to the source.

What did you see instead?

I'm seeing both test failures and errors.

E
=================================================================================================================================================================================
Error: test_descriptor_to_proto(BasicTest::MessageContainerTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::Descriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic.rb:688:in 'BasicTest::MessageContainerTest#test_descriptor_to_proto'
     685:     def test_descriptor_to_proto
     686:       descriptor = TestDeprecatedMessage.descriptor
     687:
  => 688:       assert_instance_of Google::Protobuf::DescriptorProto, descriptor.to_proto
     689:     end
     690:
     691:     def test_enum_descriptor_options
=================================================================================================================================================================================
E
=================================================================================================================================================================================
Error: test_enum_descriptor_to_proto(BasicTest::MessageContainerTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::EnumDescriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic.rb:701:in 'BasicTest::MessageContainerTest#test_enum_descriptor_to_proto'
     698:     def test_enum_descriptor_to_proto
     699:       enum_descriptor = TestDeprecatedEnum.descriptor
     700:
  => 701:       assert_instance_of Google::Protobuf::EnumDescriptorProto, enum_descriptor.to_proto
     702:     end
     703:
     704:     def test_oneof_descriptor_options
=================================================================================================================================================================================
E
=================================================================================================================================================================================
Error: test_field_descriptor_to_proto(BasicTest::MessageContainerTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::FieldDescriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic.rb:675:in 'BasicTest::MessageContainerTest#test_field_descriptor_to_proto'
     672:     def test_field_descriptor_to_proto
     673:       field_descriptor = TestDeprecatedMessage.descriptor.lookup("foo")
     674:
  => 675:       assert_instance_of Google::Protobuf::FieldDescriptorProto, field_descriptor.to_proto
     676:     end
     677:
     678:     def test_descriptor_options
=================================================================================================================================================================================
E
=================================================================================================================================================================================
Error: test_file_descriptor_to_proto(BasicTest::MessageContainerTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::FileDescriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic.rb:662:in 'BasicTest::MessageContainerTest#test_file_descriptor_to_proto'
     659:     def test_file_descriptor_to_proto
     660:       file_descriptor = TestMessage.descriptor.file_descriptor
     661:
  => 662:       assert_instance_of Google::Protobuf::FileDescriptorProto, file_descriptor.to_proto
     663:     end
     664:
     665:     def test_field_descriptor_options
=================================================================================================================================================================================
F
=================================================================================================================================================================================
Failure: test_map_hash(BasicTest::MessageContainerTest)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:430:in 'block (2 levels) in CommonTests#test_map_hash'
     427:         m[j] = "def"
     428:         m2 = m.dup
     429:         assert_equal m, m2
  => 430:         assert_equal m.hash, m2.hash
     431:       end
     432:     end
     433:   end
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:424:in 'Range#each'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:424:in 'block in CommonTests#test_map_hash'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:423:in 'Range#each'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:423:in 'CommonTests#test_map_hash'
<93008178> expected but was
<990637126>

diff:
? 9   3008178
?  906 7   26
?  +++ ???   ??
=================================================================================================================================================================================
E
=================================================================================================================================================================================
Error: test_oneof_descriptor_to_proto(BasicTest::MessageContainerTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::OneofDescriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic.rb:718:in 'BasicTest::MessageContainerTest#test_oneof_descriptor_to_proto'
     715:       descriptor = TestDeprecatedMessage.descriptor
     716:       oneof_descriptor = descriptor.lookup_oneof("test_deprecated_message_oneof")
     717:
  => 718:       assert_instance_of Google::Protobuf::OneofDescriptorProto, oneof_descriptor.to_proto
     719:     end
     720:
     721:     def test_nested_extension
=================================================================================================================================================================================
//home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:47: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
\/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:191: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:197: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:209: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
//home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic.rb:600: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
\/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:1656: warning: method redefined; discarding old test_time
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:1656: warning: previous definition of test_time was here
\/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/basic_proto2.rb:120: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
F
=================================================================================================================================================================================
Failure: test_map_hash(BasicTestProto2::MessageContainerTest)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:430:in 'block (2 levels) in CommonTests#test_map_hash'
     427:         m[j] = "def"
     428:         m2 = m.dup
     429:         assert_equal m, m2
  => 430:         assert_equal m.hash, m2.hash
     431:       end
     432:     end
     433:   end
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:424:in 'Range#each'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:424:in 'block in CommonTests#test_map_hash'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:423:in 'Range#each'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:423:in 'CommonTests#test_map_hash'
<93008178> expected but was
<990637126>

diff:
? 9   3008178
?  906 7   26
?  +++ ???   ??
=================================================================================================================================================================================
-/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:47: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
|/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:191: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:197: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/common_tests.rb:209: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
-/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:88: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:44: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_map_key(MarkedModifiedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:82:in 'MarkedModifiedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:44:in 'Utf8Test#test_map_key'
     41:
     42:   def test_map_key
     43:     msg = Utf8TestProtos::TestUtf8.new
  => 44:     assert_bad_utf8 { msg.map_string_string[bad_utf8_string()] = "abc" }
     45:   end
     46:
     47:   def test_map_value
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:88: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:49: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_map_value(MarkedModifiedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:82:in 'MarkedModifiedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:49:in 'Utf8Test#test_map_value'
     46:
     47:   def test_map_value
     48:     msg = Utf8TestProtos::TestUtf8.new
  => 49:     assert_bad_utf8 { msg.map_string_string["abc"] = bad_utf8_string() }
     50:   end
     51: end
     52:
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:88: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:39: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_repeated(MarkedModifiedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:82:in 'MarkedModifiedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:39:in 'Utf8Test#test_repeated'
     36:
     37:   def test_repeated
     38:     msg = Utf8TestProtos::TestUtf8.new
  => 39:     assert_bad_utf8 { msg.repeated_string << bad_utf8_string() }
     40:   end
     41:
     42:   def test_map_key
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:88: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:34: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_scalar(MarkedModifiedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:82:in 'MarkedModifiedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:34:in 'Utf8Test#test_scalar'
     31: module Utf8Test
     32:   def test_scalar
     33:     msg = Utf8TestProtos::TestUtf8.new
  => 34:     assert_bad_utf8 { msg.optional_string = bad_utf8_string() }
     35:   end
     36:
     37:   def test_repeated
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:124: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
\/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:124: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
|/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:124: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
//home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:124: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
-/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:44: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_map_key(MarkedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:59:in 'MarkedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:44:in 'Utf8Test#test_map_key'
     41:
     42:   def test_map_key
     43:     msg = Utf8TestProtos::TestUtf8.new
  => 44:     assert_bad_utf8 { msg.map_string_string[bad_utf8_string()] = "abc" }
     45:   end
     46:
     47:   def test_map_value
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:49: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_map_value(MarkedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:59:in 'MarkedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:49:in 'Utf8Test#test_map_value'
     46:
     47:   def test_map_value
     48:     msg = Utf8TestProtos::TestUtf8.new
  => 49:     assert_bad_utf8 { msg.map_string_string["abc"] = bad_utf8_string() }
     50:   end
     51: end
     52:
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:39: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_repeated(MarkedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:59:in 'MarkedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:39:in 'Utf8Test#test_repeated'
     36:
     37:   def test_repeated
     38:     msg = Utf8TestProtos::TestUtf8.new
  => 39:     assert_bad_utf8 { msg.repeated_string << bad_utf8_string() }
     40:   end
     41:
     42:   def test_map_key
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:34: warning: String is invalid UTF-8. This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_scalar(MarkedUtf8Test): <Encoding::InvalidByteSequenceError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:59:in 'MarkedUtf8Test#assert_bad_utf8'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/utf8.rb:34:in 'Utf8Test#test_scalar'
     31: module Utf8Test
     32:   def test_scalar
     33:     msg = Utf8TestProtos::TestUtf8.new
  => 34:     assert_bad_utf8 { msg.optional_string = bad_utf8_string() }
     35:   end
     36:
     37:   def test_repeated
=================================================================================================================================================================================
-/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/encode_decode_test.rb:42: warning: Empty string is not a valid number (field: basic_test_proto2.TestMessage.optional_int32). This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_empty_json_numerics(NonConformantNumericsTest): <Google::Protobuf::ParseError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/encode_decode_test.rb:41:in 'NonConformantNumericsTest#test_empty_json_numerics'
     38:
     39: class NonConformantNumericsTest < Test::Unit::TestCase
     40:   def test_empty_json_numerics
  => 41:     assert_raises Google::Protobuf::ParseError do
     42:       msg = ::BasicTestProto2::TestMessage.decode_json('{"optionalInt32":""}')
     43:     end
     44:   end
=================================================================================================================================================================================
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/encode_decode_test.rb:48: warning: Non-number characters in quoted number (field: basic_test_proto2.TestMessage.optional_double). This will be an error in a future version.
F
=================================================================================================================================================================================
Failure: test_trailing_non_numeric_characters(NonConformantNumericsTest): <Google::Protobuf::ParseError> exception was expected but none was thrown.
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/encode_decode_test.rb:47:in 'NonConformantNumericsTest#test_trailing_non_numeric_characters'
     44:   end
     45:
     46:   def test_trailing_non_numeric_characters
  => 47:     assert_raises Google::Protobuf::ParseError do
     48:       msg = ::BasicTestProto2::TestMessage.decode_json('{"optionalDouble":"123abc"}')
     49:     end
     50:   end
=================================================================================================================================================================================
|/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:271: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:272: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
|/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:53: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
//home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:82: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
\/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:120: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:121: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/repeated_field_test.rb:663: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
|No kokoro ruby version found, skipping check
E
=================================================================================================================================================================================
Error: test_method_iteration(ServiceTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::MethodDescriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/service_test.rb:28:in 'block in ServiceTest#test_method_iteration'
     25:   def test_method_iteration
     26:     @test_service.each do |method|
     27:       assert_kind_of Google::Protobuf::MethodDescriptor, method
  => 28:       assert_instance_of Google::Protobuf::MethodDescriptorProto, method.to_proto
     29:     end
     30:     assert_equal %w(UnaryOne UnaryTwo), @test_service.map { |method| method.name }.first(2)
     31:   end
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/service_test.rb:26:in 'Google::Protobuf::ServiceDescriptor#each'
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/service_test.rb:26:in 'ServiceTest#test_method_iteration'
=================================================================================================================================================================================
E
=================================================================================================================================================================================
Error: test_service_to_proto(ServiceTest): NoMethodError: undefined method 'to_proto' for an instance of Google::Protobuf::ServiceDescriptor
/home/nirvdrum/dev/workspaces/protobuf/ruby/tests/service_test.rb:45:in 'ServiceTest#test_service_to_proto'
     42:   end
     43:
     44:   def test_service_to_proto
  => 45:     assert_instance_of Google::Protobuf::ServiceDescriptorProto, @test_service.to_proto
     46:   end
     47:
     48:   def test_method_options
=================================================================================================================================================================================
Finished in 1.6853332 seconds.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
324 tests, 523376 assertions, 12 failures, 7 errors, 0 pendings, 2 omissions, 0 notifications
94.0994% passed
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
192.25 tests/s, 310547.49 assertions/s
rake aborted!

Anything else we should know about your project / environment

rake test isn't run on most platforms in the GitHub Actions config. I don't know if that's an indication that this test suite should be avoided. However, it's what new contributors are likely to run, both because of Ruby conventions as well as being the documented way to run tests in this repo.

While not documented, I ran the Bazel tests from the Ruby test config:

test //ruby/... //ruby/tests:ruby_version --test_env=KOKORO_RUBY_VERSION --test_env=BAZEL=true

Those are passing, fortunately.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions