ruby-changes:61108
From: David <ko1@a...>
Date: Fri, 8 May 2020 14:14:25 +0900 (JST)
Subject: [ruby-changes:61108] 5400811db9 (master): [rubygems/rubygems] Refactor dummy file creation
https://git.ruby-lang.org/ruby.git/commit/?id=5400811db9 From 5400811db94361ba20e2e2467a77b75355c232e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Mon, 27 Apr 2020 21:37:03 +0200 Subject: [rubygems/rubygems] Refactor dummy file creation https://github.com/rubygems/rubygems/commit/665099fe53 diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index 140e75d..bab2707 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -20,39 +20,17 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L20 @cmd = Gem::Commands::SetupCommand.new @cmd.options[:prefix] = @install_dir - FileUtils.mkdir_p 'bin' - FileUtils.mkdir_p 'lib/rubygems/ssl_certs/rubygems.org' - - File.open 'bin/gem', 'w' do |io| - io.puts '# gem' - end - - File.open 'lib/rubygems.rb', 'w' do |io| - io.puts '# rubygems.rb' - end - - File.open 'lib/rubygems/test_case.rb', 'w' do |io| - io.puts '# test_case.rb' - end - - File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| - io.puts '# foo.pem' - end - - FileUtils.mkdir_p 'bundler/exe' - FileUtils.mkdir_p 'bundler/lib/bundler' - - File.open 'bundler/exe/bundle', 'w' do |io| - io.puts '# bundle' - end - - File.open 'bundler/lib/bundler.rb', 'w' do |io| - io.puts '# bundler.rb' - end - - File.open 'bundler/lib/bundler/b.rb', 'w' do |io| - io.puts '# b.rb' - end + filelist = %w[ + bin/gem + lib/rubygems.rb + lib/rubygems/test_case.rb + lib/rubygems/ssl_certs/rubygems.org/foo.pem + bundler/exe/bundle + bundler/lib/bundler.rb + bundler/lib/bundler/b.rb + ] + + create_dummy_files(filelist) gemspec = Gem::Specification.new gemspec.author = "Us" @@ -276,42 +254,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L254 old_format_rb = File.join lib_rubygems, 'format.rb' old_bundler_c_rb = File.join lib_bundler, 'c.rb' - FileUtils.mkdir_p lib_rubygems_defaults - FileUtils.mkdir_p lib_bundler + files_that_go = [old_builder_rb, old_format_rb, old_bundler_c_rb] + files_that_stay = [securerandom_rb, engine_defaults_rb, os_defaults_rb] - File.open securerandom_rb, 'w' do |io| - io.puts '# securerandom.rb' - end - - File.open old_builder_rb, 'w' do |io| - io.puts '# builder.rb' - end - - File.open old_format_rb, 'w' do |io| - io.puts '# format.rb' - end - - File.open old_bundler_c_rb, 'w' do |io| - io.puts '# c.rb' - end - - File.open engine_defaults_rb, 'w' do |io| - io.puts '# jruby.rb' - end - - File.open os_defaults_rb, 'w' do |io| - io.puts '# operating_system.rb' - end + create_dummy_files(files_that_go + files_that_stay) @cmd.remove_old_lib_files lib - refute_path_exists old_builder_rb - refute_path_exists old_format_rb - refute_path_exists old_bundler_c_rb + files_that_go.each {|file| refute_path_exists file } - assert_path_exists securerandom_rb - assert_path_exists engine_defaults_rb - assert_path_exists os_defaults_rb + files_that_stay.each {|file| assert_path_exists file } end def test_show_release_notes @@ -365,6 +317,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L317 private + def create_dummy_files(list) + list.each do |file| + FileUtils.mkdir_p File.dirname(file) + + File.open file, 'w' do |io| + io.puts "# #{File.basename(file)}" + end + end + end + def gem_install(name) gem = util_spec name do |s| s.executables = [name] -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/