Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RakeBuilder: avoid frozen string issue #1819

Merged
merged 4 commits into from
Jan 16, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 14 additions & 27 deletions test/rubygems/test_gem_ext_rake_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@ def setup
FileUtils.mkdir_p @ext
FileUtils.mkdir_p @dest_path
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably not be included.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for careful reading, T.

def test_class_build
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
mkrf_conf.puts <<-EO_MKRF
File.open("Rakefile","w") do |f|
f.puts "task :default"
end
EO_MKRF
end

create_temp_mkrf_file!('task :default')
output = []
realdir = nil # HACK /tmp vs. /private/tmp

Expand All @@ -43,14 +36,7 @@ def test_class_build
#
# It should not fail with a non-empty args list either
def test_class_build_with_args
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
mkrf_conf.puts <<-EO_MKRF
File.open("Rakefile","w") do |f|
f.puts "task :default"
end
EO_MKRF
end

create_temp_mkrf_file!('task :default')
output = []
realdir = nil # HACK /tmp vs. /private/tmp

Expand All @@ -70,14 +56,7 @@ def test_class_build_with_args
end

def test_class_build_fail
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
mkrf_conf.puts <<-EO_MKRF
File.open("Rakefile","w") do |f|
f.puts "task :default do abort 'fail' end"
end
EO_MKRF
end

create_temp_mkrf_file!("task :default do abort 'fail' end")
output = []

build_rake_in(false) do |rake|
Expand All @@ -90,6 +69,14 @@ def test_class_build_fail
assert_match %r%^rake failed%, error.message
end
end


def create_temp_mkrf_file!(rakefile_content)
File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
mkrf_conf.puts <<-EO_MKRF
File.open("Rakefile","w") do |f|
f.puts "#{rakefile_content}"
end
EO_MKRF
end
end
end