diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-10-15 13:51:49 +0200 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-11-25 04:02:19 +0900 |
commit | c4b1aa19a36be0beaa01d4f5b2d889ceaf82dbd6 (patch) | |
tree | bec24c3225df8132e4dc3ec76ab45aa138356393 /spec | |
parent | 3d19c2900e6d7feaff40d1e3ace62afce60b5bac (diff) |
[rubygems/rubygems] Don't replace ENV twice on non Windows platforms
https://github.com/rubygems/rubygems/commit/8dc86b7096
Diffstat (limited to 'spec')
3 files changed, 64 insertions, 0 deletions
diff --git a/spec/bundler/realworld/ffi_spec.rb b/spec/bundler/realworld/ffi_spec.rb new file mode 100644 index 0000000000..083ea38901 --- /dev/null +++ b/spec/bundler/realworld/ffi_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +RSpec.describe "loading dinamically linked library on a bundle exec context", :realworld => true do + it "passes ENV right after argv in memory" do + create_file "foo.rb", <<~RUBY + require 'ffi' + + module FOO + extend FFI::Library + ffi_lib './libfoo.so' + + attach_function :Hello, [], :void + end + + FOO.Hello() + RUBY + + create_file "libfoo.c", <<~'C' + #include <stdio.h> + + static int foo_init(int argc, char** argv, char** envp) { + if (argv[argc+1] == NULL) { + printf("FAIL\n"); + } else { + printf("OK\n"); + } + + return 0; + } + + #if defined(__APPLE__) && defined(__MACH__) + __attribute__((section("__DATA,__mod_init_func"), used, aligned(sizeof(void*)))) + #else + __attribute__((section(".init_array"))) + #endif + static void *ctr = &foo_init; + + extern char** environ; + + void Hello() { + return; + } + C + + sys_exec "gcc -g -o libfoo.so -shared -fpic libfoo.c" + + install_gemfile <<-G + source "https://rubygems.org" + + gem 'ffi' + G + + bundle "exec ruby foo.rb" + + expect(out).to eq("OK") + end +end diff --git a/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/ffi-1.15.4.gem/GET/request b/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/ffi-1.15.4.gem/GET/request new file mode 100644 index 0000000000..0c9337dad2 --- /dev/null +++ b/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/ffi-1.15.4.gem/GET/request @@ -0,0 +1,7 @@ +> GET /gems/ffi-1.15.4.gem +> accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3 +> accept: */* +> user-agent: Ruby +> connection: keep-alive +> keep-alive: 30 +> host: rubygems.org
\ No newline at end of file diff --git a/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/ffi-1.15.4.gem/GET/response b/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/ffi-1.15.4.gem/GET/response Binary files differnew file mode 100644 index 0000000000..6e2c35b670 --- /dev/null +++ b/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/ffi-1.15.4.gem/GET/response |