2016-02-01 15:43:26 +03:00
|
|
|
# frozen_string_literal: true
|
2013-07-09 02:41:03 +04:00
|
|
|
|
2021-06-02 06:32:47 +03:00
|
|
|
require_relative 'helper'
|
2012-11-30 08:30:12 +04:00
|
|
|
require 'rubygems/commands/setup_command'
|
|
|
|
|
|
|
|
class TestGemCommandsSetupCommand < Gem::TestCase
|
2022-04-01 14:36:59 +03:00
|
|
|
bundler_gemspec = File.expand_path('../../bundler/lib/bundler/version.rb', __dir__)
|
2018-02-16 11:08:06 +03:00
|
|
|
if File.exist?(bundler_gemspec)
|
|
|
|
BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
|
|
|
|
else
|
2019-01-22 09:28:04 +03:00
|
|
|
BUNDLER_VERS = "2.0.1".freeze
|
2018-02-16 11:08:06 +03:00
|
|
|
end
|
2018-02-06 05:58:35 +03:00
|
|
|
|
2012-11-30 08:30:12 +04:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@cmd = Gem::Commands::SetupCommand.new
|
|
|
|
|
2020-04-27 22:37:03 +03:00
|
|
|
filelist = %w[
|
|
|
|
bin/gem
|
|
|
|
lib/rubygems.rb
|
2021-05-12 12:44:16 +03:00
|
|
|
lib/rubygems/requirement.rb
|
2020-04-27 22:37:03 +03:00
|
|
|
lib/rubygems/ssl_certs/rubygems.org/foo.pem
|
|
|
|
bundler/exe/bundle
|
2021-01-04 04:09:05 +03:00
|
|
|
bundler/exe/bundler
|
2020-04-27 22:37:03 +03:00
|
|
|
bundler/lib/bundler.rb
|
|
|
|
bundler/lib/bundler/b.rb
|
2021-01-04 04:09:05 +03:00
|
|
|
bundler/bin/bundler/man/bundle-b.1
|
2020-12-08 10:33:39 +03:00
|
|
|
bundler/lib/bundler/man/bundle-b.1.ronn
|
2021-01-04 04:09:05 +03:00
|
|
|
bundler/lib/bundler/man/gemfile.5
|
2020-12-08 10:33:39 +03:00
|
|
|
bundler/lib/bundler/man/gemfile.5.ronn
|
2020-06-02 11:19:41 +03:00
|
|
|
bundler/lib/bundler/templates/.circleci/config.yml
|
|
|
|
bundler/lib/bundler/templates/.travis.yml
|
2020-04-27 22:37:03 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
create_dummy_files(filelist)
|
2017-11-29 01:30:28 +03:00
|
|
|
|
|
|
|
gemspec = Gem::Specification.new
|
2019-04-02 14:48:18 +03:00
|
|
|
gemspec.author = "Us"
|
2017-11-29 01:30:28 +03:00
|
|
|
gemspec.name = "bundler"
|
2018-02-06 05:58:35 +03:00
|
|
|
gemspec.version = BUNDLER_VERS
|
2017-11-29 01:30:28 +03:00
|
|
|
gemspec.bindir = "exe"
|
2021-01-04 04:09:05 +03:00
|
|
|
gemspec.executables = ["bundle", "bundler"]
|
2017-11-29 01:30:28 +03:00
|
|
|
|
2019-05-03 20:56:58 +03:00
|
|
|
File.open 'bundler/bundler.gemspec', 'w' do |io|
|
2017-11-29 01:30:28 +03:00
|
|
|
io.puts gemspec.to_ruby
|
|
|
|
end
|
|
|
|
|
2021-04-15 06:47:18 +03:00
|
|
|
File.open(File.join(Gem.default_specifications_dir, "bundler-1.15.4.gemspec"), 'w') do |io|
|
2017-12-23 03:38:52 +03:00
|
|
|
gemspec.version = "1.15.4"
|
|
|
|
io.puts gemspec.to_ruby
|
2017-11-29 01:30:28 +03:00
|
|
|
end
|
|
|
|
|
2019-12-21 21:37:04 +03:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download "bundler", "1.15.4"
|
2018-02-06 05:58:35 +03:00
|
|
|
|
2019-12-21 21:37:04 +03:00
|
|
|
fetcher.gem "bundler", BUNDLER_VERS
|
2018-02-06 05:58:35 +03:00
|
|
|
|
2019-12-21 21:37:04 +03:00
|
|
|
fetcher.gem "bundler-audit", "1.0.0"
|
2017-11-29 01:30:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_regenerate_binstubs
|
|
|
|
gem_bin_path = gem_install 'a'
|
|
|
|
write_file gem_bin_path do |io|
|
|
|
|
io.puts 'I changed it!'
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:document] = []
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
assert_match %r{\A#!}, File.read(gem_bin_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_no_regenerate_binstubs
|
|
|
|
gem_bin_path = gem_install 'a'
|
|
|
|
write_file gem_bin_path do |io|
|
|
|
|
io.puts 'I changed it!'
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:document] = []
|
|
|
|
@cmd.options[:regenerate_binstubs] = false
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
assert_equal "I changed it!\n", File.read(gem_bin_path)
|
2013-03-07 08:06:30 +04:00
|
|
|
end
|
|
|
|
|
2020-02-01 05:14:04 +03:00
|
|
|
def test_execute_regenerate_plugins
|
|
|
|
gem_plugin_path = gem_install_with_plugin 'a'
|
|
|
|
write_file gem_plugin_path do |io|
|
|
|
|
io.puts 'I changed it!'
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:document] = []
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
assert_match %r{\Arequire}, File.read(gem_plugin_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_no_regenerate_plugins
|
|
|
|
gem_plugin_path = gem_install_with_plugin 'a'
|
|
|
|
write_file gem_plugin_path do |io|
|
|
|
|
io.puts 'I changed it!'
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:document] = []
|
|
|
|
@cmd.options[:regenerate_plugins] = false
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
assert_equal "I changed it!\n", File.read(gem_plugin_path)
|
|
|
|
end
|
|
|
|
|
2020-03-24 09:39:24 +03:00
|
|
|
def test_execute_regenerate_plugins_creates_plugins_dir_if_not_there
|
|
|
|
gem_plugin_path = gem_install_with_plugin 'a'
|
|
|
|
|
|
|
|
# Simulate gem installed with an older rubygems without a plugins layout
|
|
|
|
FileUtils.rm_rf Gem.plugindir
|
|
|
|
|
|
|
|
@cmd.options[:document] = []
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
assert_match %r{\Arequire}, File.read(gem_plugin_path)
|
|
|
|
end
|
|
|
|
|
2019-12-20 05:50:32 +03:00
|
|
|
def test_execute_informs_about_installed_executables
|
2020-06-16 20:40:12 +03:00
|
|
|
@cmd.options[:document] = []
|
|
|
|
|
2019-12-20 05:50:32 +03:00
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
|
|
|
|
exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
|
|
|
|
assert_equal "\t#{default_gem_bin_path}", out.shift
|
|
|
|
assert_equal "\t#{default_bundle_bin_path}", out.shift
|
2021-01-04 04:09:05 +03:00
|
|
|
assert_equal "\t#{default_bundler_bin_path}", out.shift
|
2019-12-20 05:50:32 +03:00
|
|
|
end
|
|
|
|
|
2018-05-30 16:01:35 +03:00
|
|
|
def test_env_shebang_flag
|
|
|
|
gem_bin_path = gem_install 'a'
|
|
|
|
write_file gem_bin_path do |io|
|
|
|
|
io.puts 'I changed it!'
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:document] = []
|
|
|
|
@cmd.options[:env_shebang] = true
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
ruby_exec = sprintf Gem.default_exec_format, 'ruby'
|
|
|
|
|
2020-03-24 21:51:43 +03:00
|
|
|
bin_env = win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " "
|
|
|
|
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_gem_bin_path)
|
|
|
|
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundle_bin_path)
|
2021-01-04 04:09:05 +03:00
|
|
|
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundler_bin_path)
|
2020-03-24 21:51:43 +03:00
|
|
|
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path)
|
2018-05-30 16:01:35 +03:00
|
|
|
end
|
|
|
|
|
2021-11-05 22:57:41 +03:00
|
|
|
def test_destdir_flag_does_not_try_to_write_to_the_default_gem_home
|
|
|
|
FileUtils.chmod "-w", File.join(@gemhome, "plugins")
|
|
|
|
|
|
|
|
destdir = File.join(@tempdir, 'foo')
|
|
|
|
|
|
|
|
@cmd.options[:destdir] = destdir
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
spec = Gem::Specification.load("bundler/bundler.gemspec")
|
|
|
|
|
|
|
|
spec.executables.each do |e|
|
|
|
|
assert_path_exist File.join destdir, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'gems', spec.full_name, spec.bindir, e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-12-08 10:33:39 +03:00
|
|
|
def test_files_in
|
2021-05-12 12:44:16 +03:00
|
|
|
assert_equal %w[rubygems.rb rubygems/requirement.rb rubygems/ssl_certs/rubygems.org/foo.pem],
|
2020-12-08 10:33:39 +03:00
|
|
|
@cmd.files_in('lib').sort
|
2012-11-30 08:30:12 +04:00
|
|
|
end
|
|
|
|
|
2013-03-07 08:06:30 +04:00
|
|
|
def test_install_lib
|
|
|
|
@cmd.extend FileUtils
|
|
|
|
|
|
|
|
Dir.mktmpdir 'lib' do |dir|
|
|
|
|
@cmd.install_lib dir
|
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist File.join(dir, 'rubygems.rb')
|
|
|
|
assert_path_exist File.join(dir, 'rubygems/ssl_certs/rubygems.org/foo.pem')
|
2017-10-08 04:32:18 +03:00
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist File.join(dir, 'bundler.rb')
|
|
|
|
assert_path_exist File.join(dir, 'bundler/b.rb')
|
2020-06-02 11:19:41 +03:00
|
|
|
|
2021-05-28 13:47:49 +03:00
|
|
|
assert_path_exist File.join(dir, 'bundler/templates/.circleci/config.yml')
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist File.join(dir, 'bundler/templates/.travis.yml')
|
2013-03-07 08:06:30 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-29 01:30:28 +03:00
|
|
|
def test_install_default_bundler_gem
|
|
|
|
@cmd.extend FileUtils
|
|
|
|
|
2019-04-02 14:48:18 +03:00
|
|
|
bin_dir = File.join(@gemhome, 'bin')
|
|
|
|
@cmd.install_default_bundler_gem bin_dir
|
2017-11-29 01:30:28 +03:00
|
|
|
|
2019-04-02 14:48:18 +03:00
|
|
|
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
|
2019-07-22 15:31:10 +03:00
|
|
|
default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
|
2019-04-02 14:48:18 +03:00
|
|
|
spec = Gem::Specification.load(default_spec_path)
|
2017-11-29 01:30:28 +03:00
|
|
|
|
2019-04-02 14:48:18 +03:00
|
|
|
spec.executables.each do |e|
|
|
|
|
if Gem.win_platform?
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist File.join(bin_dir, "#{e}.bat")
|
2017-11-29 01:30:28 +03:00
|
|
|
end
|
2019-04-02 14:48:18 +03:00
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist File.join bin_dir, e
|
2017-11-29 01:30:28 +03:00
|
|
|
end
|
|
|
|
|
2019-07-22 15:31:10 +03:00
|
|
|
default_dir = Gem.default_specifications_dir
|
2017-11-29 01:30:28 +03:00
|
|
|
|
2018-02-06 05:58:35 +03:00
|
|
|
# expect to remove other versions of bundler gemspecs on default specification directory.
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_not_exist File.join(default_dir, "bundler-1.15.4.gemspec")
|
|
|
|
assert_path_exist File.join(default_dir, "bundler-#{BUNDLER_VERS}.gemspec")
|
2017-11-29 01:30:28 +03:00
|
|
|
|
2018-02-06 05:58:35 +03:00
|
|
|
# expect to not remove bundler-* gemspecs.
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist File.join(Gem.dir, "specifications", "bundler-audit-1.0.0.gemspec")
|
2018-02-06 05:58:35 +03:00
|
|
|
|
|
|
|
# expect to remove normal gem that was same version. because it's promoted default gems.
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_not_exist File.join(Gem.dir, "specifications", "bundler-#{BUNDLER_VERS}.gemspec")
|
2018-02-06 05:58:35 +03:00
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
assert_path_exist "#{Gem.dir}/gems/bundler-#{BUNDLER_VERS}"
|
|
|
|
assert_path_exist "#{Gem.dir}/gems/bundler-1.15.4"
|
|
|
|
assert_path_exist "#{Gem.dir}/gems/bundler-audit-1.0.0"
|
2019-04-26 14:26:21 +03:00
|
|
|
end
|
2017-11-29 01:30:28 +03:00
|
|
|
|
2019-12-20 05:50:32 +03:00
|
|
|
def test_install_default_bundler_gem_with_force_flag
|
|
|
|
@cmd.extend FileUtils
|
|
|
|
|
|
|
|
bin_dir = File.join(@gemhome, 'bin')
|
|
|
|
bundle_bin = File.join(bin_dir, 'bundle')
|
|
|
|
|
|
|
|
write_file bundle_bin do |f|
|
|
|
|
f.puts '#!/usr/bin/ruby'
|
|
|
|
f.puts ''
|
|
|
|
f.puts 'echo "hello"'
|
|
|
|
end
|
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
@cmd.options[:force] = true
|
2019-12-20 05:50:32 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
@cmd.install_default_bundler_gem bin_dir
|
2019-12-20 05:50:32 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
|
|
|
|
default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
|
|
|
|
spec = Gem::Specification.load(default_spec_path)
|
2019-12-20 05:50:32 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
spec.executables.each do |e|
|
|
|
|
if Gem.win_platform?
|
|
|
|
assert_path_exist File.join(bin_dir, "#{e}.bat")
|
2019-12-20 05:50:32 +03:00
|
|
|
end
|
2021-11-05 15:46:32 +03:00
|
|
|
|
|
|
|
assert_path_exist File.join bin_dir, e
|
2019-12-20 05:50:32 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-18 18:10:18 +03:00
|
|
|
def test_install_default_bundler_gem_with_destdir_flag
|
|
|
|
@cmd.extend FileUtils
|
|
|
|
|
2021-11-05 15:55:09 +03:00
|
|
|
FileUtils.chmod "-w", @gemhome
|
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
destdir = File.join(@tempdir, 'foo')
|
2021-11-05 15:51:11 +03:00
|
|
|
bin_dir = File.join(destdir, 'bin')
|
2019-05-18 18:10:18 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
@cmd.options[:destdir] = destdir
|
2019-05-18 18:10:18 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
@cmd.install_default_bundler_gem bin_dir
|
2019-05-18 18:10:18 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
spec = Gem::Specification.load("bundler/bundler.gemspec")
|
2019-05-18 18:10:18 +03:00
|
|
|
|
2021-11-05 15:46:32 +03:00
|
|
|
spec.executables.each do |e|
|
|
|
|
assert_path_exist File.join destdir, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'gems', spec.full_name, spec.bindir, e
|
2019-05-18 18:10:18 +03:00
|
|
|
end
|
2022-02-22 05:58:54 +03:00
|
|
|
ensure
|
|
|
|
FileUtils.chmod "+w", @gemhome
|
2019-05-18 18:10:18 +03:00
|
|
|
end
|
|
|
|
|
2021-11-04 21:27:17 +03:00
|
|
|
def test_install_default_bundler_gem_with_destdir_and_prefix_flags
|
|
|
|
@cmd.extend FileUtils
|
|
|
|
|
|
|
|
destdir = File.join(@tempdir, 'foo')
|
|
|
|
bin_dir = File.join(destdir, 'bin')
|
|
|
|
|
|
|
|
@cmd.options[:destdir] = destdir
|
|
|
|
@cmd.options[:prefix] = "/"
|
|
|
|
|
|
|
|
@cmd.install_default_bundler_gem bin_dir
|
|
|
|
|
|
|
|
spec = Gem::Specification.load("bundler/bundler.gemspec")
|
|
|
|
|
|
|
|
spec.executables.each do |e|
|
|
|
|
assert_path_exist File.join destdir, 'gems', spec.full_name, spec.bindir, e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-30 08:30:12 +04:00
|
|
|
def test_remove_old_lib_files
|
2021-11-04 22:20:47 +03:00
|
|
|
lib = RbConfig::CONFIG["sitelibdir"]
|
2013-03-12 01:29:32 +04:00
|
|
|
lib_rubygems = File.join lib, 'rubygems'
|
2017-10-08 04:32:18 +03:00
|
|
|
lib_bundler = File.join lib, 'bundler'
|
2013-03-12 01:29:32 +04:00
|
|
|
lib_rubygems_defaults = File.join lib_rubygems, 'defaults'
|
2020-06-02 11:24:32 +03:00
|
|
|
lib_bundler_templates = File.join lib_bundler, 'templates'
|
2012-11-30 08:30:12 +04:00
|
|
|
|
2019-08-22 18:36:29 +03:00
|
|
|
securerandom_rb = File.join lib, 'securerandom.rb'
|
2012-11-30 08:30:12 +04:00
|
|
|
|
2013-03-12 01:29:32 +04:00
|
|
|
engine_defaults_rb = File.join lib_rubygems_defaults, 'jruby.rb'
|
|
|
|
os_defaults_rb = File.join lib_rubygems_defaults, 'operating_system.rb'
|
2012-11-30 08:30:12 +04:00
|
|
|
|
2020-05-04 14:08:29 +03:00
|
|
|
old_gauntlet_rubygems_rb = File.join lib, 'gauntlet_rubygems.rb'
|
|
|
|
|
2013-03-12 01:29:32 +04:00
|
|
|
old_builder_rb = File.join lib_rubygems, 'builder.rb'
|
|
|
|
old_format_rb = File.join lib_rubygems, 'format.rb'
|
2017-10-08 04:32:18 +03:00
|
|
|
old_bundler_c_rb = File.join lib_bundler, 'c.rb'
|
2020-06-02 11:24:32 +03:00
|
|
|
old_bundler_ci = File.join lib_bundler_templates, '.lecacy_ci', 'config.yml'
|
2013-03-12 01:29:32 +04:00
|
|
|
|
2020-06-02 11:24:32 +03:00
|
|
|
files_that_go = [old_gauntlet_rubygems_rb, old_builder_rb, old_format_rb, old_bundler_c_rb, old_bundler_ci]
|
2020-04-27 22:37:03 +03:00
|
|
|
files_that_stay = [securerandom_rb, engine_defaults_rb, os_defaults_rb]
|
2013-03-12 01:29:32 +04:00
|
|
|
|
2020-04-27 22:37:03 +03:00
|
|
|
create_dummy_files(files_that_go + files_that_stay)
|
2012-11-30 08:30:12 +04:00
|
|
|
|
|
|
|
@cmd.remove_old_lib_files lib
|
|
|
|
|
2021-05-28 13:47:49 +03:00
|
|
|
files_that_go.each {|file| assert_path_not_exist(file) unless file == old_bundler_ci }
|
2013-03-12 01:29:32 +04:00
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
files_that_stay.each {|file| assert_path_exist file }
|
2012-11-30 08:30:12 +04:00
|
|
|
end
|
|
|
|
|
2020-04-27 20:27:32 +03:00
|
|
|
def test_remove_old_man_files
|
2021-11-04 22:20:47 +03:00
|
|
|
man = File.join RbConfig::CONFIG['mandir'], 'man'
|
2020-04-27 20:27:32 +03:00
|
|
|
|
|
|
|
ruby_1 = File.join man, 'man1', 'ruby.1'
|
|
|
|
bundle_b_1 = File.join man, 'man1', 'bundle-b.1'
|
2020-10-15 07:25:27 +03:00
|
|
|
bundle_b_1_ronn = File.join man, 'man1', 'bundle-b.1.ronn'
|
2020-04-27 20:27:32 +03:00
|
|
|
bundle_b_1_txt = File.join man, 'man1', 'bundle-b.1.txt'
|
|
|
|
gemfile_5 = File.join man, 'man5', 'gemfile.5'
|
2020-10-15 07:25:27 +03:00
|
|
|
gemfile_5_ronn = File.join man, 'man5', 'gemfile.5.ronn'
|
2020-04-27 20:27:32 +03:00
|
|
|
gemfile_5_txt = File.join man, 'man5', 'gemfile.5.txt'
|
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
files_that_go = [bundle_b_1, bundle_b_1_txt, bundle_b_1_ronn, gemfile_5, gemfile_5_txt, gemfile_5_ronn]
|
|
|
|
files_that_stay = [ruby_1]
|
2020-04-27 20:27:32 +03:00
|
|
|
|
|
|
|
create_dummy_files(files_that_go + files_that_stay)
|
|
|
|
|
|
|
|
@cmd.remove_old_man_files man
|
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
files_that_go.each {|file| assert_path_not_exist file }
|
2020-04-27 20:27:32 +03:00
|
|
|
|
2020-05-25 15:05:45 +03:00
|
|
|
files_that_stay.each {|file| assert_path_exist file }
|
2020-04-27 20:27:32 +03:00
|
|
|
end
|
|
|
|
|
2013-07-09 02:41:03 +04:00
|
|
|
def test_show_release_notes
|
2018-05-30 16:01:35 +03:00
|
|
|
@default_external = @ui.outs.external_encoding
|
|
|
|
@ui.outs.set_encoding Encoding::US_ASCII
|
2013-07-09 02:41:03 +04:00
|
|
|
|
|
|
|
@cmd.options[:previous_version] = Gem::Version.new '2.0.2'
|
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
File.open 'CHANGELOG.md', 'w' do |io|
|
2020-04-20 19:32:51 +03:00
|
|
|
io.puts <<-HISTORY_TXT
|
2021-01-04 04:09:05 +03:00
|
|
|
# #{Gem::VERSION} / 2013-03-26
|
2013-07-09 02:41:03 +04:00
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
## Bug fixes:
|
2013-07-09 02:41:03 +04:00
|
|
|
* Fixed release note display for LANG=C when installing rubygems
|
|
|
|
* π is tasty
|
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
# 2.0.2 / 2013-03-06
|
2013-07-09 02:41:03 +04:00
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
## Bug fixes:
|
2013-07-09 02:41:03 +04:00
|
|
|
* Other bugs fixed
|
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
# 2.0.1 / 2013-03-05
|
2013-07-09 02:41:03 +04:00
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
## Bug fixes:
|
2013-07-09 02:41:03 +04:00
|
|
|
* Yet more bugs fixed
|
2020-04-20 19:32:51 +03:00
|
|
|
HISTORY_TXT
|
2013-07-09 02:41:03 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.show_release_notes
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2021-01-04 04:09:05 +03:00
|
|
|
# #{Gem::VERSION} / 2013-03-26
|
2014-09-14 07:30:02 +04:00
|
|
|
|
2021-01-04 04:09:05 +03:00
|
|
|
## Bug fixes:
|
2014-09-14 07:30:02 +04:00
|
|
|
* Fixed release note display for LANG=C when installing rubygems
|
|
|
|
* π is tasty
|
|
|
|
|
2013-07-09 02:41:03 +04:00
|
|
|
EXPECTED
|
|
|
|
|
2014-09-14 07:30:02 +04:00
|
|
|
output = @ui.output
|
2018-05-30 16:01:35 +03:00
|
|
|
output.force_encoding Encoding::UTF_8
|
2014-09-14 07:30:02 +04:00
|
|
|
|
2014-09-18 11:30:19 +04:00
|
|
|
assert_equal expected, output
|
2013-07-09 02:41:03 +04:00
|
|
|
ensure
|
2014-09-18 11:30:19 +04:00
|
|
|
@ui.outs.set_encoding @default_external if @default_external
|
2013-07-09 02:41:03 +04:00
|
|
|
end
|
|
|
|
|
2019-12-20 05:50:32 +03:00
|
|
|
private
|
|
|
|
|
2020-04-27 22:37:03 +03:00
|
|
|
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
|
|
|
|
|
2020-04-27 20:19:35 +03:00
|
|
|
def gem_install(name)
|
|
|
|
gem = util_spec name do |s|
|
|
|
|
s.executables = [name]
|
|
|
|
s.files = %W[bin/#{name}]
|
|
|
|
end
|
|
|
|
write_file File.join @tempdir, 'bin', name do |f|
|
|
|
|
f.puts '#!/usr/bin/ruby'
|
|
|
|
end
|
|
|
|
install_gem gem
|
|
|
|
File.join @gemhome, 'bin', name
|
|
|
|
end
|
|
|
|
|
|
|
|
def gem_install_with_plugin(name)
|
|
|
|
gem = util_spec name do |s|
|
|
|
|
s.files = %W[lib/rubygems_plugin.rb]
|
|
|
|
end
|
|
|
|
write_file File.join @tempdir, 'lib', 'rubygems_plugin.rb' do |f|
|
|
|
|
f.puts "require '#{gem.plugins.first}'"
|
|
|
|
end
|
|
|
|
install_gem gem
|
|
|
|
|
|
|
|
File.join Gem.plugindir, "#{name}_plugin.rb"
|
|
|
|
end
|
|
|
|
|
2019-12-20 05:50:32 +03:00
|
|
|
def default_gem_bin_path
|
2021-11-04 22:20:47 +03:00
|
|
|
File.join RbConfig::CONFIG['bindir'], 'gem'
|
2019-12-20 05:50:32 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def default_bundle_bin_path
|
2021-11-04 22:20:47 +03:00
|
|
|
File.join RbConfig::CONFIG['bindir'], 'bundle'
|
2019-12-20 05:50:32 +03:00
|
|
|
end
|
2021-01-04 04:09:05 +03:00
|
|
|
|
|
|
|
def default_bundler_bin_path
|
2021-11-04 22:20:47 +03:00
|
|
|
File.join RbConfig::CONFIG['bindir'], 'bundler'
|
2021-01-04 04:09:05 +03:00
|
|
|
end
|
2019-06-01 12:45:11 +03:00
|
|
|
end unless Gem.java_platform?
|