From 5ebb0d50f6560b35bc03deb79341a115c5f782ee Mon Sep 17 00:00:00 2001 From: Kenta Murata Date: Mon, 27 May 2019 18:53:33 +0900 Subject: [PATCH] [ruby/fiddle] Fix a failing test (#13) * Fix a failing test This commit fixes the following failure: ``` 1) Failure: Fiddle::TestImport#test_no_message_with_debug [/Users/mrkn/src/github.com/ruby/fiddle/test/fiddle/test_import.rb:152]: 1. [2/2] Assertion for "stderr" | <[]> expected but was | <["Exception `NameError' at /Users/mrkn/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fiddle/import.rb:157 - uninitialized constant Fiddle::Function::STDCALL"]>. ``` * Stop using Bundler.with_clean_env * Clear existing Ruby environment variables on test_no_message_with_debug https://github.com/ruby/fiddle/commit/13133ddec8 --- test/fiddle/test_import.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/fiddle/test_import.rb b/test/fiddle/test_import.rb index 99294ea161..e243105568 100644 --- a/test/fiddle/test_import.rb +++ b/test/fiddle/test_import.rb @@ -149,7 +149,18 @@ module Fiddle end def test_no_message_with_debug + # disable all Ruby environment variables + orig_RUBYOPT, ENV['RUBYOPT'] = ENV['RUBYOPT'], nil + orig_RUBYLIB, ENV['RUBYLIB'] = ENV['RUBYLIB'], nil + + # load development fiddle instead of bundled one + libdir = File.expand_path('../../../lib', __FILE__) + ENV['RUBYLIB'] = libdir if File.file?(File.join(libdir, "fiddle/import.rb")) + assert_in_out_err(%w[--debug --disable=gems -rfiddle/import], 'p Fiddle::Importer', ['Fiddle::Importer']) + ensure + ENV['RUBYLIB'] = orig_RUBYLIB + ENV['RUBYOPT'] = orig_RUBYOPT end end end if defined?(Fiddle)