Skip to content

Commit

Permalink
CI: more eval/__FILE__ fixes for 3.3.0-preview2
Browse files Browse the repository at this point in the history
- replace __FILE__ for `envfile.rb` `instance_eval` calls
- add `TODO` for __FILE__ swapping comments
  • Loading branch information
fallwith committed Sep 19, 2023
1 parent a5da5f5 commit bf5bfc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/multiverse/lib/multiverse/envfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 2 additions & 0 deletions test/new_relic/gemspec_files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")
Expand Down

0 comments on commit bf5bfc9

Please sign in to comment.