From 0ebe38eedd3b0b0771f57e1d4a85d472a1b6b64f Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 17 Apr 2012 21:17:56 +0000 Subject: Revert r35370 due to bad source branch git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/data/null-type.gemspec.rz | Bin 553 -> 0 bytes test/rubygems/test_gem.rb | 107 +--------- test/rubygems/test_gem_commands_build_command.rb | 16 -- test/rubygems/test_gem_commands_fetch_command.rb | 25 --- test/rubygems/test_gem_commands_help_command.rb | 1 + test/rubygems/test_gem_commands_install_command.rb | 33 ---- .../test_gem_commands_specification_command.rb | 98 ---------- test/rubygems/test_gem_format.rb | 2 +- test/rubygems/test_gem_installer.rb | 212 ++------------------ test/rubygems/test_gem_platform.rb | 7 - test/rubygems/test_gem_security.rb | 1 + test/rubygems/test_gem_specification.rb | 217 +-------------------- 12 files changed, 25 insertions(+), 694 deletions(-) delete mode 100644 test/rubygems/data/null-type.gemspec.rz (limited to 'test') diff --git a/test/rubygems/data/null-type.gemspec.rz b/test/rubygems/data/null-type.gemspec.rz deleted file mode 100644 index b1d0a6d7cd..0000000000 Binary files a/test/rubygems/data/null-type.gemspec.rz and /dev/null differ diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index b7c7f41eb6..436d14c927 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -351,29 +351,6 @@ class TestGem < Gem::TestCase end end - ## - # [A] depends on - # [C] = 1.0 depends on - # [B] = 2.0 - # [B] ~> 1.0 (satisfied by 1.0) - - def test_self_activate_checks_dependencies - a, _ = util_spec 'a', '1.0' - a.add_dependency 'c', '= 1.0' - a.add_dependency 'b', '~> 1.0' - - util_spec 'b', '1.0' - util_spec 'b', '2.0' - c, _ = util_spec 'c', '1.0', 'b' => '= 2.0' - - e = assert_raises Gem::LoadError do - assert_activate nil, a, c, "b" - end - - expected = "can't satisfy 'b (~> 1.0)', already activated 'b-2.0'" - assert_equal expected, e.message - end - ## # [A] depends on # [B] ~> 1.0 (satisfied by 1.0) @@ -629,8 +606,8 @@ class TestGem < Gem::TestCase File.umask 0 Gem.ensure_gem_subdirectories @gemhome - assert_equal 0, File::Stat.new(@gemhome).mode & 002 - assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 002 + assert_equal 0, File::Stat.new(@gemhome).mode & 022 + assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 022 ensure File.umask old_umask end unless win_platform? @@ -1122,86 +1099,6 @@ class TestGem < Gem::TestCase end end - def test_gem_path_ordering - refute_equal Gem.dir, Gem.user_dir - - write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" } - write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" } - - g = new_spec 'g', '1', nil, "lib/g.rb" - m = new_spec 'm', '1', nil, "lib/m.rb" - - install_gem g, :install_dir => Gem.dir - m0 = install_gem m, :install_dir => Gem.dir - m1 = install_gem m, :install_dir => Gem.user_dir - - assert_equal m0.gem_dir, File.join(Gem.dir, "gems", "m-1") - assert_equal m1.gem_dir, File.join(Gem.user_dir, "gems", "m-1") - - tests = [ - [:dir0, [ Gem.dir, Gem.user_dir], m0], - [:dir1, [ Gem.user_dir, Gem.dir], m1] - ] - - tests.each do |_name, _paths, expected| - Gem.paths = { 'GEM_HOME' => _paths.first, 'GEM_PATH' => _paths } - Gem::Specification.reset - Gem.searcher = nil - - assert_equal Gem::Dependency.new('m','1').to_specs, - Gem::Dependency.new('m','1').to_specs.sort - - assert_equal \ - [expected.gem_dir], - Gem::Dependency.new('m','1').to_specs.map(&:gem_dir).sort, - "Wrong specs for #{_name}" - - spec = Gem::Dependency.new('m','1').to_spec - - assert_equal \ - File.join(_paths.first, "gems", "m-1"), - spec.gem_dir, - "Wrong spec before require for #{_name}" - refute spec.activated?, "dependency already activated for #{_name}" - - gem "m" - - spec = Gem::Dependency.new('m','1').to_spec - assert spec.activated?, "dependency not activated for #{_name}" - - assert_equal \ - File.join(_paths.first, "gems", "m-1"), - spec.gem_dir, - "Wrong spec after require for #{_name}" - - spec.instance_variable_set :@activated, false - Gem.loaded_specs.delete(spec.name) - $:.delete(File.join(spec.gem_dir, "lib")) - end - end - - def test_gem_path_ordering_short - write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" } - write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" } - - g = new_spec 'g', '1', nil, "lib/g.rb" - m = new_spec 'm', '1', nil, "lib/m.rb" - - install_gem g, :install_dir => Gem.dir - install_gem m, :install_dir => Gem.dir - install_gem m, :install_dir => Gem.user_dir - - Gem.paths = { - 'GEM_HOME' => Gem.dir, - 'GEM_PATH' => [ Gem.dir, Gem.user_dir] - } - - assert_equal \ - File.join(Gem.dir, "gems", "m-1"), - Gem::Dependency.new('m','1').to_spec.gem_dir, - "Wrong spec selected" - end - def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", @@project_dir) diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index 5d374542ba..55f5df6f8b 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -98,21 +98,5 @@ class TestGemCommandsBuildCommand < Gem::TestCase assert_equal "this is a summary", spec.summary end - def test_execute_force - @gem.instance_variable_set :@required_rubygems_version, nil - - gemspec_file = File.join(@tempdir, @gem.spec_name) - - File.open gemspec_file, 'w' do |gs| - gs.write @gem.to_yaml - end - - @cmd.options[:args] = [gemspec_file] - @cmd.options[:force] = true - - util_test_build_gem @gem, gemspec_file - end - - end diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb index 9017a43b80..f4fee79ea3 100644 --- a/test/rubygems/test_gem_commands_fetch_command.rb +++ b/test/rubygems/test_gem_commands_fetch_command.rb @@ -73,30 +73,5 @@ class TestGemCommandsFetchCommand < Gem::TestCase "#{@a1.full_name} not fetched" end - def test_execute_handles_sources_properly - repo = "http://gems.example.com" - @uri = URI.parse repo - - Gem.sources.replace [repo] - - util_setup_fake_fetcher - util_setup_spec_fetcher @a1, @a2 - - @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = - File.read(@a1.cache_file) - - @cmd.options[:args] = [@a2.name] - @cmd.options[:version] = Gem::Requirement.new '1' - - use_ui @ui do - Dir.chdir @tempdir do - @cmd.execute - end - end - - assert File.exist?(File.join(@tempdir, @a1.file_name)), - "#{@a1.full_name} not fetched" - end - end diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb index d626b1436a..822811101c 100644 --- a/test/rubygems/test_gem_commands_help_command.rb +++ b/test/rubygems/test_gem_commands_help_command.rb @@ -3,6 +3,7 @@ require "rubygems/test_case" require "rubygems/commands/help_command" require "rubygems/format" require "rubygems/command_manager" +require_relative "rubygems_plugin" class TestGemCommandsHelpCommand < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 2215d4d4ab..bd61db5e45 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -3,7 +3,6 @@ require 'rubygems/commands/install_command' begin gem "rdoc" - gem "json" rescue Gem::LoadError # ignore end @@ -178,38 +177,6 @@ class TestGemCommandsInstallCommand < Gem::TestCase assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error) end - def test_execute_bad_source - util_setup_fake_fetcher - util_setup_spec_fetcher - - # This is needed because we need to exercise the cache path - # within SpecFetcher - path = File.join Gem.user_home, '.gem', 'specs', "not-there.nothing%80", - "latest_specs.4.8" - - FileUtils.mkdir_p File.dirname(path) - - File.open path, "w" do |f| - f.write Marshal.dump([]) - end - - Gem.sources.replace ["http://not-there.nothing"] - - @cmd.options[:args] = %w[nonexistent] - - use_ui @ui do - e = assert_raises Gem::SystemExitException do - @cmd.execute - end - assert_equal 2, e.exit_code - end - - errs = @ui.error.split("\n") - - assert_match(/WARNING: Error fetching data/, errs.shift) - assert_match(/ould not find a valid gem 'nonexistent'/, errs.shift) - end - def test_execute_nonexistent_with_hint misspelled = "nonexistent_with_hint" correctly_spelled = "non_existent_with_hint" diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb index 978c6fe194..03c4af6823 100644 --- a/test/rubygems/test_gem_commands_specification_command.rb +++ b/test/rubygems/test_gem_commands_specification_command.rb @@ -43,24 +43,6 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase assert_equal '', @ui.error end - def test_execute_all_conflicts_with_version - quick_spec 'foo', '0.0.1' - quick_spec 'foo', '0.0.2' - - @cmd.options[:args] = %w[foo] - @cmd.options[:all] = true - @cmd.options[:version] = "1" - - assert_raises Gem::MockGemUi::TermError do - use_ui @ui do - @cmd.execute - end - end - - assert_equal '', @ui.output - assert_equal "ERROR: Specify --all or -v, not both\n", @ui.error - end - def test_execute_bad_name @cmd.options[:args] = %w[foo] @@ -140,86 +122,6 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase assert_match %r|name: foo|, @ui.output end - def test_execute_remote_with_version - foo1 = quick_gem 'foo', "1" - foo2 = quick_gem 'foo', "2" - - @fetcher = Gem::FakeFetcher.new - Gem::RemoteFetcher.fetcher = @fetcher - - util_setup_spec_fetcher foo1, foo2 - - FileUtils.rm File.join(@gemhome, 'specifications', foo1.spec_name) - FileUtils.rm File.join(@gemhome, 'specifications', foo2.spec_name) - - @cmd.options[:args] = %w[foo] - @cmd.options[:version] = "1" - @cmd.options[:domain] = :remote - - use_ui @ui do - @cmd.execute - end - - spec = Gem::Specification.from_yaml @ui.output - - assert_equal Gem::Version.new("1"), spec.version - end - - def test_execute_remote_without_prerelease - foo = new_spec 'foo', '2.0.0' - foo_pre = new_spec 'foo', '2.0.1.pre' - - install_specs foo, foo_pre - - @fetcher = Gem::FakeFetcher.new - Gem::RemoteFetcher.fetcher = @fetcher - - util_setup_spec_fetcher foo - util_setup_spec_fetcher foo_pre - - @cmd.options[:args] = %w[foo] - @cmd.options[:domain] = :remote - - use_ui @ui do - @cmd.execute - end - - assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output - assert_match %r|name: foo|, @ui.output - - spec = YAML.load @ui.output - - assert_equal Gem::Version.new("2.0.0"), spec.version - end - - def test_execute_remote_with_prerelease - foo = new_spec 'foo', '2.0.0' - foo_pre = new_spec 'foo', '2.0.1.pre' - - install_specs foo, foo_pre - - @fetcher = Gem::FakeFetcher.new - Gem::RemoteFetcher.fetcher = @fetcher - - util_setup_spec_fetcher foo - util_setup_spec_fetcher foo_pre - - @cmd.options[:args] = %w[foo] - @cmd.options[:domain] = :remote - @cmd.options[:prerelease] = true - - use_ui @ui do - @cmd.execute - end - - assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output - assert_match %r|name: foo|, @ui.output - - spec = YAML.load @ui.output - - assert_equal Gem::Version.new("2.0.1.pre"), spec.version - end - def test_execute_ruby foo = quick_spec 'foo' diff --git a/test/rubygems/test_gem_format.rb b/test/rubygems/test_gem_format.rb index 711527bf79..805455f763 100644 --- a/test/rubygems/test_gem_format.rb +++ b/test/rubygems/test_gem_format.rb @@ -57,7 +57,7 @@ class TestGemFormat < Gem::Package::TarTestCase def test_class_from_file_by_path_nonexistent assert_raises Gem::Exception do - Gem::Format.from_file_by_path '/a/path/that/is/nonexistent' + Gem::Format.from_file_by_path '/nonexistent' end end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index d40fbc93bf..3c6fb45589 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -2,23 +2,26 @@ require 'rubygems/installer_test_case' class TestGemInstaller < Gem::InstallerTestCase - def util_setup_install - @gemhome = @installer_tmp - Gem.use_paths @installer_tmp + def setup + super - @spec = Gem::Specification.find_by_name 'a' - @user_spec = Gem::Specification.find_by_name 'b' + if __name__ !~ /^test_install(_|$)/ then + @gemhome = @installer_tmp + Gem.use_paths @installer_tmp - @installer.spec = @spec - @installer.gem_home = @installer_tmp - @installer.gem_dir = @spec.gem_dir - @user_installer.spec = @user_spec - @user_installer.gem_home = @installer_tmp + @spec = Gem::Specification.find_by_name 'a' + @user_spec = Gem::Specification.find_by_name 'b' + + @installer.spec = @spec + @installer.gem_home = @installer_tmp + @installer.gem_dir = @spec.gem_dir + @user_installer.spec = @user_spec + @user_installer.gem_home = @installer_tmp + end end - def test_app_script_text - util_setup_install + def test_app_script_text @spec.version = 2 util_make_exec @spec, '' @@ -35,13 +38,9 @@ require 'rubygems' version = \">= 0\" -if ARGV.first - str = ARGV.first - str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding - if str =~ /\\A_(.*)_\\z/ - version = $1 - ARGV.shift - end +if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then + version = $1 + ARGV.shift end gem 'a', version @@ -53,8 +52,6 @@ load Gem.bin_path('a', 'executable', version) end def test_build_extensions_none - util_setup_install - use_ui @ui do @installer.build_extensions end @@ -66,8 +63,6 @@ load Gem.bin_path('a', 'executable', version) end def test_build_extensions_extconf_bad - util_setup_install - @spec.extensions << 'extconf.rb' e = assert_raises Gem::Installer::ExtensionBuildError do @@ -91,8 +86,6 @@ load Gem.bin_path('a', 'executable', version) end def test_build_extensions_unsupported - util_setup_install - gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out' @spec.extensions << nil @@ -114,8 +107,6 @@ load Gem.bin_path('a', 'executable', version) end def test_ensure_dependency - util_setup_install - dep = Gem::Dependency.new 'a', '>= 2' assert @installer.ensure_dependency(@spec, dep) @@ -128,8 +119,6 @@ load Gem.bin_path('a', 'executable', version) end def test_extract_files - util_setup_install - format = Object.new def format.file_entries [[{'size' => 7, 'mode' => 0400, 'path' => 'thefile'}, 'content']] @@ -148,8 +137,6 @@ load Gem.bin_path('a', 'executable', version) end def test_extract_files_bad_dest - util_setup_install - @installer.gem_dir = 'somedir' @installer.format = nil e = assert_raises ArgumentError do @@ -160,8 +147,6 @@ load Gem.bin_path('a', 'executable', version) end def test_extract_files_relative - util_setup_install - format = Object.new def format.file_entries [[{'size' => 10, 'mode' => 0644, 'path' => '../thefile'}, '../thefile']] @@ -181,8 +166,6 @@ load Gem.bin_path('a', 'executable', version) end def test_extract_files_absolute - util_setup_install - format = Object.new def format.file_entries [[{'size' => 8, 'mode' => 0644, 'path' => '/thefile'}, '/thefile']] @@ -200,8 +183,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_bindir - util_setup_install - @installer.wrappers = true @spec.executables = %w[executable] @@ -227,8 +208,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_bindir_with_user_install_warning - util_setup_install - bin_dir = Gem.win_platform? ? File.expand_path(ENV["WINDIR"]) : "/usr/bin" options = { @@ -248,8 +227,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script - util_setup_install - @installer.wrappers = true util_make_exec @installer.gem_dir = util_gem_dir @@ -265,8 +242,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_format - util_setup_install - @installer.format_executable = true @installer.wrappers = true util_make_exec @@ -282,8 +257,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_format_disabled - util_setup_install - @installer.wrappers = true util_make_exec @installer.gem_dir = util_gem_dir @@ -298,8 +271,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_install_dir - util_setup_install - @installer.wrappers = true @spec.executables = %w[executable] @@ -324,8 +295,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_no_execs - util_setup_install - util_execless @installer.wrappers = true @@ -335,8 +304,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_no_perms - util_setup_install - @installer.wrappers = true util_make_exec @@ -356,8 +323,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_no_shebang - util_setup_install - @installer.wrappers = true @spec.executables = %w[executable] @@ -381,8 +346,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_script_wrappers - util_setup_install - @installer.wrappers = true util_make_exec @installer.gem_dir = util_gem_dir @@ -408,8 +371,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink - util_setup_install - return if win_platform? #Windows FS do not support symlinks @installer.wrappers = false @@ -425,8 +386,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink_no_execs - util_setup_install - util_execless @installer.wrappers = false @@ -436,8 +395,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink_no_perms - util_setup_install - @installer.wrappers = false util_make_exec @installer.gem_dir = util_gem_dir @@ -458,8 +415,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink_update_newer - util_setup_install - return if win_platform? #Windows FS do not support symlinks @installer.wrappers = false @@ -491,8 +446,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink_update_older - util_setup_install - return if win_platform? #Windows FS do not support symlinks @installer.wrappers = false @@ -529,8 +482,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink_update_remove_wrapper - util_setup_install - return if win_platform? #Windows FS do not support symlinks @installer.wrappers = true @@ -562,8 +513,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_symlink_win32 - util_setup_install - old_win_platform = Gem.win_platform? Gem.win_platform = true @installer.wrappers = false @@ -588,8 +537,6 @@ load Gem.bin_path('a', 'executable', version) end def test_generate_bin_uses_default_shebang - util_setup_install - return if win_platform? #Windows FS do not support symlinks @installer.wrappers = true @@ -673,95 +620,6 @@ load Gem.bin_path('a', 'executable', version) assert_same @installer, @pre_install_hook_arg end - def test_install_creates_working_binstub - Dir.mkdir util_inst_bindir - util_setup_gem - util_clear_gems - - @installer.wrappers = true - - gemdir = File.join @gemhome, 'gems', @spec.full_name - - @newspec = nil - build_rake_in do - use_ui @ui do - @newspec = @installer.install - end - end - - exe = File.join gemdir, 'bin', 'executable' - - e = assert_raises RuntimeError do - instance_eval File.read(exe) - end - - assert_match(/ran executable/, e.message) - end - - def test_install_creates_binstub_that_understand_version - Dir.mkdir util_inst_bindir - util_setup_gem - util_clear_gems - - @installer.wrappers = true - - @newspec = nil - build_rake_in do - use_ui @ui do - @newspec = @installer.install - end - end - - exe = File.join @gemhome, 'bin', 'executable' - - ARGV.unshift "_3.0_" - - begin - Gem::Specification.reset - - e = assert_raises Gem::LoadError do - instance_eval File.read(exe) - end - ensure - ARGV.shift if ARGV.first == "_3.0_" - end - - assert_match(/\(= 3\.0\)/, e.message) - end - - def test_install_creates_binstub_that_dont_trust_encoding - skip unless "".respond_to?(:force_encoding) - - Dir.mkdir util_inst_bindir - util_setup_gem - util_clear_gems - - @installer.wrappers = true - - @newspec = nil - build_rake_in do - use_ui @ui do - @newspec = @installer.install - end - end - - exe = File.join @gemhome, 'bin', 'executable' - - ARGV.unshift "\xE4pfel".force_encoding("UTF-8") - - begin - Gem::Specification.reset - - e = assert_raises RuntimeError do - instance_eval File.read(exe) - end - ensure - ARGV.shift if ARGV.first == "\xE4pfel" - end - - assert_match(/ran executable/, e.message) - end - def test_install_with_no_prior_files Dir.mkdir util_inst_bindir util_clear_gems @@ -1031,8 +889,6 @@ load Gem.bin_path('a', 'executable', version) end def test_installation_satisfies_dependency_eh - util_setup_install - dep = Gem::Dependency.new 'a', '>= 2' assert @installer.installation_satisfies_dependency?(dep) @@ -1041,8 +897,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang - util_setup_install - util_make_exec @spec, "#!/usr/bin/ruby" shebang = @installer.shebang 'executable' @@ -1051,8 +905,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_arguments - util_setup_install - util_make_exec @spec, "#!/usr/bin/ruby -ws" shebang = @installer.shebang 'executable' @@ -1061,8 +913,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_empty - util_setup_install - util_make_exec @spec, '' shebang = @installer.shebang 'executable' @@ -1070,8 +920,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_env - util_setup_install - util_make_exec @spec, "#!/usr/bin/env ruby" shebang = @installer.shebang 'executable' @@ -1080,8 +928,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_env_arguments - util_setup_install - util_make_exec @spec, "#!/usr/bin/env ruby -ws" shebang = @installer.shebang 'executable' @@ -1090,8 +936,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_env_shebang - util_setup_install - util_make_exec @spec, '' @installer.env_shebang = true @@ -1104,8 +948,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_nested - util_setup_install - util_make_exec @spec, "#!/opt/local/ruby/bin/ruby" shebang = @installer.shebang 'executable' @@ -1114,8 +956,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_nested_arguments - util_setup_install - util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws" shebang = @installer.shebang 'executable' @@ -1124,8 +964,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_version - util_setup_install - util_make_exec @spec, "#!/usr/bin/ruby18" shebang = @installer.shebang 'executable' @@ -1134,8 +972,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_version_arguments - util_setup_install - util_make_exec @spec, "#!/usr/bin/ruby18 -ws" shebang = @installer.shebang 'executable' @@ -1144,8 +980,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_version_env - util_setup_install - util_make_exec @spec, "#!/usr/bin/env ruby18" shebang = @installer.shebang 'executable' @@ -1154,8 +988,6 @@ load Gem.bin_path('a', 'executable', version) end def test_shebang_version_env_arguments - util_setup_install - util_make_exec @spec, "#!/usr/bin/env ruby18 -ws" shebang = @installer.shebang 'executable' @@ -1164,8 +996,6 @@ load Gem.bin_path('a', 'executable', version) end def test_unpack - util_setup_install - util_setup_gem dest = File.join @gemhome, 'gems', @spec.full_name @@ -1177,8 +1007,6 @@ load Gem.bin_path('a', 'executable', version) end def test_write_spec - util_setup_install - spec_dir = File.join @gemhome, 'specifications' spec_file = File.join spec_dir, @spec.spec_name FileUtils.rm spec_file @@ -1194,8 +1022,6 @@ load Gem.bin_path('a', 'executable', version) end def test_write_spec_writes_cached_spec - util_setup_install - spec_dir = File.join @gemhome, 'specifications' spec_file = File.join spec_dir, @spec.spec_name FileUtils.rm spec_file @@ -1215,8 +1041,6 @@ load Gem.bin_path('a', 'executable', version) end def test_dir - util_setup_install - assert_match @installer.dir, %r!/installer/gems/a-2$! end diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb index f3b94ea83d..bd09b89f0a 100644 --- a/test/rubygems/test_gem_platform.rb +++ b/test/rubygems/test_gem_platform.rb @@ -43,7 +43,6 @@ class TestGemPlatform < Gem::TestCase 'sparc-solaris2.9' => ['sparc', 'solaris', '2.9'], 'universal-darwin8' => ['universal', 'darwin', '8'], 'universal-darwin9' => ['universal', 'darwin', '9'], - 'universal-macruby' => ['universal', 'macruby', nil], 'i386-cygwin' => ['x86', 'cygwin', nil], 'i686-darwin' => ['x86', 'darwin', nil], 'i686-darwin8.4.1' => ['x86', 'darwin', '8'], @@ -247,12 +246,6 @@ class TestGemPlatform < Gem::TestCase refute_match 'dotnet-2.0', Gem::Platform.local assert_match 'dotnet-4.0', Gem::Platform.local - util_set_arch 'universal-macruby-1.0' - assert_match 'universal-macruby', Gem::Platform.local - assert_match 'macruby', Gem::Platform.local - refute_match 'universal-macruby-0.10', Gem::Platform.local - assert_match 'universal-macruby-1.0', Gem::Platform.local - util_set_arch 'powerpc-darwin' assert_match 'powerpc-darwin', Gem::Platform.local diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb index df3168dce4..7f1b2e6ee3 100644 --- a/test/rubygems/test_gem_security.rb +++ b/test/rubygems/test_gem_security.rb @@ -43,6 +43,7 @@ class TestGemSecurity < Gem::TestCase :key_size => 512, :save_cert => false, :save_key => false, + :trust_dir => File.join(Gem.user_home, '.gem', 'trust'), } result = Gem::Security.build_self_signed_cert email, opt diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index c64be793fd..d63b9bd30e 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -136,7 +136,7 @@ end name: posix-spawn version: !ruby/object:Gem::Version version: 0.3.6 - prerelease: + prerelease: dependencies: - !ruby/object:Gem::Dependency name: rake-compiler @@ -159,131 +159,8 @@ bindir: Gem::Specification.from_yaml yaml end - op = new_spec.dependencies.first.requirement.requirements.first.first - refute_kind_of YAML::Syck::DefaultKey, op - - refute_match %r%DefaultKey%, new_spec.to_ruby - end - - def test_self_from_yaml_cleans_up_defaultkey - yaml = <<-YAML ---- !ruby/object:Gem::Specification -name: posix-spawn -version: !ruby/object:Gem::Version - version: 0.3.6 - prerelease: -dependencies: -- !ruby/object:Gem::Dependency - name: rake-compiler - requirement: &70243867725240 !ruby/object:Gem::Requirement - none: false - requirements: - - - !ruby/object:YAML::Syck::DefaultKey {} - - - !ruby/object:Gem::Version - version: 0.7.6 - type: :development - prerelease: false - version_requirements: *70243867725240 -platform: ruby -files: [] -test_files: [] -bindir: - YAML - - new_spec = Gem::Specification.from_yaml yaml - - op = new_spec.dependencies.first.requirement.requirements.first.first - refute_kind_of YAML::Syck::DefaultKey, op - - refute_match %r%DefaultKey%, new_spec.to_ruby - end - - def test_self_from_yaml_cleans_up_defaultkey_from_newer_192 - yaml = <<-YAML ---- !ruby/object:Gem::Specification -name: posix-spawn -version: !ruby/object:Gem::Version - version: 0.3.6 - prerelease: -dependencies: -- !ruby/object:Gem::Dependency - name: rake-compiler - requirement: &70243867725240 !ruby/object:Gem::Requirement - none: false - requirements: - - - !ruby/object:Syck::DefaultKey {} - - - !ruby/object:Gem::Version - version: 0.7.6 - type: :development - prerelease: false - version_requirements: *70243867725240 -platform: ruby -files: [] -test_files: [] -bindir: - YAML - - new_spec = Gem::Specification.from_yaml yaml - - op = new_spec.dependencies.first.requirement.requirements.first.first - refute_kind_of YAML::Syck::DefaultKey, op - refute_match %r%DefaultKey%, new_spec.to_ruby - end - - def test_self_from_yaml_cleans_up_Date_objects - yaml = <<-YAML ---- !ruby/object:Gem::Specification -rubygems_version: 0.8.1 -specification_version: 1 -name: diff-lcs -version: !ruby/object:Gem::Version - version: 1.1.2 -date: 2004-10-20 -summary: Provides a list of changes that represent the difference between two sequenced collections. -require_paths: - - lib -author: Austin Ziegler -email: diff-lcs@halostatue.ca -homepage: http://rubyforge.org/projects/ruwiki/ -rubyforge_project: ruwiki -description: "Test" -bindir: bin -has_rdoc: true -required_ruby_version: !ruby/object:Gem::Version::Requirement - requirements: - - - - ">=" - - !ruby/object:Gem::Version - version: 1.8.1 - version: -platform: ruby -files: - - tests/00test.rb -rdoc_options: - - "--title" - - "Diff::LCS -- A Diff Algorithm" - - "--main" - - README - - "--line-numbers" -extra_rdoc_files: - - README - - ChangeLog - - Install -executables: - - ldiff - - htmldiff -extensions: [] -requirements: [] -dependencies: [] - YAML - - new_spec = Gem::Specification.from_yaml yaml - - assert_kind_of Time, new_spec.date - end + end if RUBY_VERSION < '1.9' def test_self_load full_path = @a2.spec_file @@ -343,29 +220,6 @@ dependencies: [] assert_equal @a2, spec end - if defined?(Encoding) - def test_self_load_utf8_with_ascii_encoding - int_enc = Encoding.default_internal - silence_warnings { Encoding.default_internal = 'US-ASCII' } - - spec2 = @a2.dup - bin = "\u5678" - spec2.authors = [bin] - full_path = spec2.spec_file - write_file full_path do |io| - io.write spec2.to_ruby_for_cache.force_encoding('BINARY').sub("\\u{5678}", bin.force_encoding('BINARY')) - end - - spec = Gem::Specification.load full_path - - spec2.files.clear - - assert_equal spec2, spec - ensure - silence_warnings { Encoding.default_internal = int_enc } - end - end - def test_self_load_legacy_ruby spec = Gem::Deprecate.skip_during do eval LEGACY_RUBY_SPEC @@ -406,27 +260,6 @@ dependencies: [] assert_equal expected, Gem::Specification.normalize_yaml_input(input) end - DATA_PATH = File.expand_path "../data", __FILE__ - - def test_handles_private_null_type - path = File.join DATA_PATH, "null-type.gemspec.rz" - - data = Marshal.load Gem.inflate(Gem.read_binary(path)) - - assert_equal nil, data.rubyforge_project - end - - def test_emits_zulu_timestamps_properly - skip "bug only on 1.9.2" unless RUBY_VERSION =~ /1\.9\.2/ - - t = Time.utc(2012, 3, 12) - @a2.date = t - - yaml = with_psych { @a2.to_yaml } - - assert_match %r!date: 2012-03-12 00:00:00\.000000000 Z!, yaml - end - def test_initialize spec = Gem::Specification.new do |s| s.name = "blah" @@ -1208,18 +1041,6 @@ end assert_match %r|^platform: ruby$|, @a1.to_yaml end - def test_to_yaml_emits_syck_compat_yaml - if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? - @a1.add_dependency "gx", "1.0.0" - - y = @a1.to_yaml - - refute_match %r!^\s*- - =!, y - else - skip "Only validates psych yaml" - end - end - def test_validate util_setup_validate @@ -1563,15 +1384,6 @@ end assert_equal Gem::Version.new('1'), @a1.version end - def test__load_fixes_Date_objects - spec = new_spec "a", 1 - spec.instance_variable_set :@date, Date.today - - spec = Marshal.load Marshal.dump(spec) - - assert_kind_of Time, spec.date - end - def test_load_errors_contain_filename specfile = Tempfile.new(self.class.name.downcase) specfile.write "raise 'boom'" @@ -1693,29 +1505,4 @@ end # ignore end end - - def with_psych - begin - require "yaml" - old_engine = YAML::ENGINE.yamler - YAML::ENGINE.yamler = 'psych' - rescue NameError - # probably on 1.8, ignore - end - - yield - ensure - begin - YAML::ENGINE.yamler = old_engine - rescue NameError - # ignore - end - end - - def silence_warnings - old_verbose, $VERBOSE = $VERBOSE, false - yield - ensure - $VERBOSE = old_verbose - end end -- cgit v1.2.3