mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
I'm not sure why, but it seems that some tests are not running via Bazel. CI uses Bazel. So I think we should add those to test correctly. Also, I fixed some tests to pass. * Run memory tests against CRuby native implementation * These tests are for CRuby native implementation. So this doesn't work with FFI and JRuby. * Ref: https://github.com/protocolbuffers/protobuf/pull/15840/ * Run service options extension test against CRuby native implementation * It seems that JRuby doesn't support this so far. * And, service options are frozen objects. But, in CRuby FFI, can't get a Message instance if the message is frozen. So this doesn't work. *d406cae013/ruby/lib/google/protobuf/ffi/message.rb (L419)* So the service options extension test only passes in CRuby native. Closes #19870 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/19870 from y-yagi:add_some_missing_testsd51158def9PiperOrigin-RevId: 721603213
35 lines
1.1 KiB
Ruby
Executable file
35 lines
1.1 KiB
Ruby
Executable file
#!/usr/bin/ruby
|
|
#
|
|
# generated_code.rb is in the same directory as this test.
|
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
|
|
|
require 'test/unit'
|
|
require 'objspace'
|
|
require 'test_import_pb'
|
|
|
|
return if defined?(JRUBY_VERSION) || Google::Protobuf::IMPLEMENTATION != :NATIVE
|
|
|
|
$is_64bit = Google::Protobuf::Internal::SIZEOF_LONG == 8
|
|
|
|
class MemoryTest < Test::Unit::TestCase
|
|
# 40 byte is the default object size. But the real size is dependent on many things
|
|
# such as arch etc, so there's no point trying to assert the exact return value here.
|
|
# We merely assert that we return something other than the default.
|
|
def test_objspace_memsize_of_arena
|
|
if $is_64bit
|
|
assert_operator 40, :<, ObjectSpace.memsize_of(Google::Protobuf::Internal::Arena.new)
|
|
end
|
|
end
|
|
|
|
def test_objspace_memsize_of_message
|
|
if $is_64bit
|
|
assert_operator 40, :<, ObjectSpace.memsize_of(FooBar::TestImportedMessage.new)
|
|
end
|
|
end
|
|
|
|
def test_objspace_memsize_of_map
|
|
if $is_64bit
|
|
assert_operator 40, :<, ObjectSpace.memsize_of(Google::Protobuf::Map.new(:string, :int32))
|
|
end
|
|
end
|
|
end
|