From 8444791e73145bb08353ead2865ccd4e17b76260 Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 30 Aug 2020 02:42:08 +0200 Subject: [PATCH] jruby fixes --- lib/ffi/platform.rb | 2 +- spec/ffi/library_spec.rb | 2 +- spec/ffi/long_double_spec.rb | 2 +- spec/ffi/rbx/attach_function_spec.rb | 2 +- spec/ffi/struct_spec.rb | 8 ++++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ffi/platform.rb b/lib/ffi/platform.rb index 0690bc135..32d7f9cc7 100644 --- a/lib/ffi/platform.rb +++ b/lib/ffi/platform.rb @@ -128,7 +128,7 @@ def self.is_os(os) end LIBC = if IS_WINDOWS - if RbConfig::CONFIG['host_os'] =~ /mingw/i + if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll' else "ucrtbase.dll" diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb index ca28974c9..cca4fc7b5 100644 --- a/spec/ffi/library_spec.rb +++ b/spec/ffi/library_spec.rb @@ -64,7 +64,7 @@ class StructUCDP < FFI::Struct end end - if RbConfig::CONFIG['host_os'] =~ /mingw/ + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ # See https://github.com/ffi/ffi/issues/788 it "libc functions shouldn't call an invalid parameter handler" do mod = Module.new do diff --git a/spec/ffi/long_double_spec.rb b/spec/ffi/long_double_spec.rb index 3128d9686..c2b22cf58 100644 --- a/spec/ffi/long_double_spec.rb +++ b/spec/ffi/long_double_spec.rb @@ -47,4 +47,4 @@ module LibTest expect(v).to be_within(0.01).of(0.1) end end -end if RUBY_ENGINE != "truffleruby" +end unless ['truffleruby', 'jruby'].include?(RUBY_ENGINE) diff --git a/spec/ffi/rbx/attach_function_spec.rb b/spec/ffi/rbx/attach_function_spec.rb index 35772a99f..b83f91e9c 100644 --- a/spec/ffi/rbx/attach_function_spec.rb +++ b/spec/ffi/rbx/attach_function_spec.rb @@ -35,4 +35,4 @@ module LibC expect(t[:tv_usec]).to be_kind_of(Numeric) end end -end +end unless RUBY_ENGINE == 'jruby' diff --git a/spec/ffi/struct_spec.rb b/spec/ffi/struct_spec.rb index f1f4bcc5e..d73088a47 100644 --- a/spec/ffi/struct_spec.rb +++ b/spec/ffi/struct_spec.rb @@ -364,13 +364,17 @@ def self.int_field_test(type, values) int_field_test(:int, [ 0, 0x7fffffff, -0x80000000, -1 ]) int_field_test(:uint, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ]) int_field_test(:long_long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ]) - int_field_test(:ulong_long, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) + if RUBY_ENGINE != 'jruby' # https://github.com/jnr/jffi/issues/87 + int_field_test(:ulong_long, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) + end if FFI::Platform::LONG_SIZE == 32 int_field_test(:long, [ 0, 0x7fffffff, -0x80000000, -1 ]) int_field_test(:ulong, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ]) else int_field_test(:long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ]) - int_field_test(:ulong, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) + if RUBY_ENGINE != 'jruby' # https://github.com/jruby/jruby/issues/6376 + int_field_test(:ulong, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ]) + end end it ":float field r/w" do