diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 06:52:18 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 06:52:18 +0000 |
commit | 9694bb8cac12969300692dac5a1cf7aa4e3a46cd (patch) | |
tree | c3cb423d701f7049ba9382de052e2a937cd1302d /test/rubygems/test_gem_commands_pristine_command.rb | |
parent | 3f606b7063fc7a8b191556365ad343a314719a8d (diff) | |
download | ruby-9694bb8cac12969300692dac5a1cf7aa4e3a46cd.tar.gz |
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto.
* common.mk (prelude): Updated for RubyGems 2.0 source rearrangement.
* tool/change_maker.rb: Allow invalid UTF-8 characters in source
files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_pristine_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_pristine_command.rb | 103 |
1 files changed, 99 insertions, 4 deletions
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index 6bf6d5a56c..778ce2ee1f 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -9,20 +9,31 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute - a = quick_spec 'a' do |s| s.executables = %w[foo] end + a = quick_spec 'a' do |s| + s.executables = %w[foo] + s.files = %w[bin/foo lib/a.rb] + end + write_file File.join(@tempdir, 'lib', 'a.rb') do |fp| + fp.puts "puts __FILE__" + end write_file File.join(@tempdir, 'bin', 'foo') do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - foo_path = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo' + foo_path = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo' + a_rb_path = File.join @gemhome, 'gems', a.full_name, 'lib', 'a.rb' write_file foo_path do |io| io.puts 'I changed it!' end + write_file a_rb_path do |io| + io.puts 'I changed it!' + end + @cmd.options[:args] = %w[a] use_ui @ui do @@ -30,6 +41,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end assert_equal "#!/usr/bin/ruby\n", File.read(foo_path), foo_path + assert_equal "puts __FILE__\n", File.read(a_rb_path), a_rb_path out = @ui.output.split "\n" @@ -46,9 +58,11 @@ class TestGemCommandsPristineCommand < Gem::TestCase install_gem a - gem_bin = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo' + gem_bin = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo' + gem_stub = File.join @gemhome, 'bin', 'foo' FileUtils.rm gem_bin + FileUtils.rm gem_stub @cmd.handle_options %w[--all] @@ -57,6 +71,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end assert File.exist?(gem_bin) + assert File.exist?(gem_stub) out = @ui.output.split "\n" @@ -65,7 +80,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase assert_empty out, out.inspect end - def test_execute_no_exetension + def test_execute_no_extension a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' @@ -90,6 +105,38 @@ class TestGemCommandsPristineCommand < Gem::TestCase assert_empty out, out.inspect end + def test_execute_with_extension_with_build_args + a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end + + ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' + write_file ext_path do |io| + io.write <<-'RUBY' + File.open "Makefile", "w" do |f| + f.puts "all:\n\techo built\n" + f.puts "install:\n\techo built\n" + end + RUBY + end + + build_args = %w!--with-awesome=true --sweet! + + install_gem a, :build_args => build_args + + @cmd.options[:args] = %w[a] + + use_ui @ui do + @cmd.execute + end + + out = @ui.output.split "\n" + + assert_equal 'Restoring gems to pristine condition...', out.shift + assert_equal "Building native extensions with: '--with-awesome=true --sweet'", out.shift + assert_equal "This could take a while...", out.shift + assert_equal "Restored #{a.full_name}", out.shift + assert_empty out, out.inspect + end + def test_execute_many a = quick_spec 'a' b = quick_spec 'b' @@ -195,5 +242,53 @@ class TestGemCommandsPristineCommand < Gem::TestCase assert_match %r|at least one gem name|, e.message end + def test_execute_only_executables + a = quick_spec 'a' do |s| + s.executables = %w[foo] + s.files = %w[bin/foo lib/a.rb] + end + write_file File.join(@tempdir, 'lib', 'a.rb') do |fp| + fp.puts "puts __FILE__" + end + write_file File.join(@tempdir, 'bin', 'foo') do |fp| + fp.puts "#!/usr/bin/ruby" + end + + install_gem a + + gem_lib = File.join @gemhome, 'gems', a.full_name, 'lib', 'a.rb' + gem_exec = File.join @gemhome, 'bin', 'foo' + + FileUtils.rm gem_exec + FileUtils.rm gem_lib + + @cmd.handle_options %w[--all --only-executables] + + use_ui @ui do + @cmd.execute + end + + assert File.exist? gem_exec + refute File.exist? gem_lib + end + + def test_execute_default_gem + default_gem_spec = new_default_spec("default", "2.0.0.0", + nil, "default/gem.rb") + install_default_specs(default_gem_spec) + + @cmd.options[:args] = %w[default] + + use_ui @ui do + @cmd.execute + end + + assert_equal([ + "Restoring gems to pristine condition...", + "Skipped default-2.0.0.0, it is a default gem", + ], + @ui.output.split("\n")) + assert_empty(@ui.error) + end end |