diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-21 22:01:34 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-21 22:01:34 +0000 |
commit | b448f23e2168af1fb7fc5210e99f92317b836de9 (patch) | |
tree | 87025f77054d23597a77fad3fefed2210731cea0 /spec/ruby/optional/capi | |
parent | 2aefb19888a6c7b2be498308e32a2be1851bf918 (diff) | |
download | ruby-b448f23e2168af1fb7fc5210e99f92317b836de9.tar.gz |
Update to ruby/spec@dd828d6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional/capi')
-rw-r--r-- | spec/ruby/optional/capi/README | 2 | ||||
-rw-r--r-- | spec/ruby/optional/capi/spec_helper.rb | 23 |
2 files changed, 13 insertions, 12 deletions
diff --git a/spec/ruby/optional/capi/README b/spec/ruby/optional/capi/README index efbfb09dcb..57b0c51f01 100644 --- a/spec/ruby/optional/capi/README +++ b/spec/ruby/optional/capi/README @@ -13,4 +13,4 @@ specs: 5. Name the C functions 'array_spec_rb_ary_new'. 6. Wrap the code in the optional/capi/ext/array_spec.c in '#ifdef HAVE_RB_ARY_NEW' -6. Attach the C function to the class using the name 'rb_ary_new' +7. Attach the C function to the class using the name 'rb_ary_new' diff --git a/spec/ruby/optional/capi/spec_helper.rb b/spec/ruby/optional/capi/spec_helper.rb index d5ac1408a1..e5d1d54daa 100644 --- a/spec/ruby/optional/capi/spec_helper.rb +++ b/spec/ruby/optional/capi/spec_helper.rb @@ -1,4 +1,4 @@ -require_relative '../../spec_helper' +# Require the main spec_helper.rb at the end to let `ruby ...spec.rb` work # MRI magic to use built but not installed ruby $extmk = false @@ -6,13 +6,9 @@ $extmk = false require 'rbconfig' OBJDIR ||= File.expand_path("../../../ext/#{RUBY_ENGINE}/#{RUBY_VERSION}", __FILE__) -mkdir_p(OBJDIR) - -def extension_path - File.expand_path("../ext", __FILE__) -end def object_path + mkdir_p(OBJDIR) OBJDIR end @@ -20,6 +16,7 @@ def compile_extension(name) debug = false run_mkmf_in_process = RUBY_ENGINE == 'truffleruby' + ext_dir = File.expand_path("../ext", __FILE__) ext = "#{name}_spec" lib = "#{object_path}/#{ext}.#{RbConfig::CONFIG['DLEXT']}" ruby_header = "#{RbConfig::CONFIG['rubyhdrdir']}/ruby.h" @@ -31,8 +28,8 @@ def compile_extension(name) # not found, then compile else case # if lib is older than headers, source or libruby, then recompile - when mtime <= File.mtime("#{extension_path}/rubyspec.h") - when mtime <= File.mtime("#{extension_path}/#{ext}.c") + when mtime <= File.mtime("#{ext_dir}/rubyspec.h") + when mtime <= File.mtime("#{ext_dir}/#{ext}.c") when mtime <= File.mtime(ruby_header) when libruby_so && mtime <= File.mtime("#{RbConfig::CONFIG['libdir']}/#{libruby_so}") else @@ -45,7 +42,7 @@ def compile_extension(name) Dir.mkdir(tmpdir) begin ["rubyspec.h", "#{ext}.c"].each do |file| - cp "#{extension_path}/#{file}", "#{tmpdir}/#{file}" + cp "#{ext_dir}/#{file}", "#{tmpdir}/#{file}" end Dir.chdir(tmpdir) do @@ -108,8 +105,8 @@ end def load_extension(name) require compile_extension(name) -rescue LoadError - if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ $!.message +rescue LoadError => e + if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ e.message system('/usr/sbin/execerror', "#{RbConfig::CONFIG["bindir"]}/ruby", "(ld 3 1 main #{$1}") end raise @@ -117,3 +114,7 @@ end # Constants CAPI_SIZEOF_LONG = [0].pack('l!').size + +# Require the main spec_helper.rb only here so load_extension() is defined +# when running specs with `ruby ...spec.rb` +require_relative '../../spec_helper' |