From bf5bfc98ac3f219db2593769b4007dff6c650db3 Mon Sep 17 00:00:00 2001 From: fallwith Date: Tue, 19 Sep 2023 01:41:00 -0700 Subject: [PATCH] CI: more eval/__FILE__ fixes for 3.3.0-preview2 - replace __FILE__ for `envfile.rb` `instance_eval` calls - add `TODO` for __FILE__ swapping comments --- test/multiverse/lib/multiverse/envfile.rb | 5 +++++ test/new_relic/gemspec_files_test.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/test/multiverse/lib/multiverse/envfile.rb b/test/multiverse/lib/multiverse/envfile.rb index 4b1f139485..1cec6d1e12 100644 --- a/test/multiverse/lib/multiverse/envfile.rb +++ b/test/multiverse/lib/multiverse/envfile.rb @@ -18,6 +18,11 @@ def initialize(file_path, options = {}) @ignore_ruby_version = options[:ignore_ruby_version] if options.key?(:ignore_ruby_version) if File.exist?(file_path) @text = File.read(self.file_path) + # TODO: Test this behavior against Ruby 3.3.0 when it is out of preview + # to see if this behavior persists. Remove the gsub if not. + # With Ruby 3.3.0-preview2, eval() yields '(eval ...' as the String value + # when __FILE__ is used so swap out __FILE__ for the known agent root path + @text.gsub!('__FILE__', "'#{file_path}'") instance_eval(@text) end @gemfiles = [''] if @gemfiles.empty? diff --git a/test/new_relic/gemspec_files_test.rb b/test/new_relic/gemspec_files_test.rb index 25e0f34aad..6c0e28f7f9 100644 --- a/test/new_relic/gemspec_files_test.rb +++ b/test/new_relic/gemspec_files_test.rb @@ -11,6 +11,8 @@ def test_the_test_agent_helper_is_shipped_in_the_gem_files gem_spec_file_path = File.expand_path('../../../newrelic_rpm.gemspec', __FILE__) gem_spec_content = Gem.open_file(gem_spec_file_path, 'r:UTF-8:-', &:read) + # TODO: Test this behavior against Ruby 3.3.0 when it is out of preview + # to see if this behavior persists. Remove the gsub if not. # With Ruby 3.3.0-preview2, eval() yields '(eval ...' as the String value # when __FILE__ is used so swap out __FILE__ for the known agent root path gem_spec_content.gsub!('__FILE__', "'#{gem_spec_file_path}'")