Hi,

Twelve test cases for rubygems fail in my environment.


| $ make test-all TESTS=rubygems
| ./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb
./runruby.rb --extout=.ext  -- "./test/runner.rb" --basedir="./test"
--runner=console rubygems
| Gem::Indexer tests are being skipped.  Install builder gem.
| Loaded suite rubygems
| Started
| ...............................FF...................................................................................................................................................................................................F......E........................................E...E..........................E...........................................................................................................................................................................................................................................................................................................EEEEE....................................................
| Finished in 21.170319349 seconds.
|
|   1) Failure:
| test_self_prefix_libdir(TestGem)
[/home/mame/work/ruby19/ruby/test/rubygems/test_gem.rb:343]:
| <nil> expected but was
| <"/home/mame/work/ruby19/ruby">.
|
|   2) Failure:
| test_self_prefix_sitelibdir(TestGem)
[/home/mame/work/ruby19/ruby/test/rubygems/test_gem.rb:356]:
| <nil> expected but was
| <"/home/mame/work/ruby19/ruby">.


I think the tests are wrong.  Here is patch.  I referred to
test_self_prefix.


Index: test/rubygems/test_gem.rb
===================================================================
--- test/rubygems/test_gem.rb	(revision 17489)
+++ test/rubygems/test_gem.rb	(working copy)
@@ -337,6 +337,7 @@

     file_name = File.expand_path __FILE__
     prefix = File.dirname File.dirname(file_name)
+    prefix = File.dirname prefix if File.basename(prefix) == 'test'

     Gem::ConfigMap[:libdir] = prefix

@@ -350,6 +351,7 @@

     file_name = File.expand_path __FILE__
     prefix = File.dirname File.dirname(file_name)
+    prefix = File.dirname prefix if File.basename(prefix) == 'test'

     Gem::ConfigMap[:sitelibdir] = prefix



|   3) Failure:
| test_self_build(TestGemExtConfigureBuilder)
[/home/mame/work/ruby19/ruby/test/rubygems/test_gem_ext_configure_builder.rb:37]:
| <["sh ./configure --prefix=/tmp/test_rubygems_12643/prefix",
|  "",
|  "make",
|  "ok\n",
|  "make install",
|  "ok\n"]> expected but was
| <["sh ./configure --prefix=/tmp/test_rubygems_12643/prefix",
|  "",
|  "make",
|  "make[1]: Entering directory
`/tmp/test_rubygems_12643/ext'\nok\nmake[1]: Leaving directory
`/tmp/test_rubygems_12643/ext'\n",
|  "make install",
|  "make[1]: Entering directory
`/tmp/test_rubygems_12643/ext'\nok\nmake[1]: Leaving directory
`/tmp/test_rubygems_12643/ext'\n"]>.


make prints Entering/Leaving directory in my environment.


Index: test/rubygems/test_gem_ext_configure_builder.rb
===================================================================
--- test/rubygems/test_gem_ext_configure_builder.rb	(revision 17489)
+++ test/rubygems/test_gem_ext_configure_builder.rb	(working copy)
@@ -29,12 +29,12 @@
       Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
     end

-    expected = [
-      "sh ./configure --prefix=#{@dest_path}",
-      "", "make", "ok\n", "make install", "ok\n"
-    ]
-
-    assert_equal expected, output
+    assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
+    assert_equal "", output.shift
+    assert_equal "make", output.shift
+    assert_match /^ok$/m, output.shift
+    assert_equal "make install", output.shift
+    assert_match /^ok$/m, output.shift
   end

   def test_self_build_fail


|   4) Error:
| test_class_build(TestGemExtRakeBuilder):
| Gem::InstallError: rake failed:
|
| /home/mame/work/ruby19/local/bin/ruby mkrf_conf.rb
|
| rake RUBYARCHDIR=/tmp/test_rubygems_12643/prefix
RUBYLIBDIR=/tmp/test_rubygems_12643/prefix
| sh: rake: command not found
|
|     /home/mame/work/ruby19/ruby/lib/rubygems/ext/builder.rb:51:in `run'
|     /home/mame/work/ruby19/ruby/lib/rubygems/ext/rake_builder.rb:21:in `build'
|     /home/mame/work/ruby19/ruby/test/rubygems/test_gem_ext_rake_builder.rb:31:in
`block in test_class_build'
|     /home/mame/work/ruby19/ruby/test/rubygems/test_gem_ext_rake_builder.rb:29:in
`chdir'
|     /home/mame/work/ruby19/ruby/test/rubygems/test_gem_ext_rake_builder.rb:29:in
`test_class_build'


The test failed to execute rake, because I installed ruby and rake
to /home/mame/work/ruby19/local that is not included in the
environment variable PATH.
I guess this test should specify an absolute path to rake.


In addition, lib/rubygems/ext/rake_builder.rb tried to rewrite a
frozen string (which was returned from ENV object) destructively.
I think it's a bug.


Index: runruby.rb
===================================================================
--- runruby.rb	(revision 17489)
+++ runruby.rb	(working copy)
@@ -46,6 +46,7 @@
 config["bindir"] = abs_archdir
 ENV["RUBY"] = File.expand_path(ruby)
 ENV["PATH"] = [abs_archdir, ENV["PATH"]].compact.join(File::PATH_SEPARATOR)
+ENV["rake"] = ENV["RUBY"] + " " + File.join(abs_archdir, "bin", "rake")

 if pure
   libs << File.expand_path("ext", srcdir) << "-"
Index: test/rubygems/test_gem_ext_rake_builder.rb
===================================================================
--- test/rubygems/test_gem_ext_rake_builder.rb	(revision 17489)
+++ test/rubygems/test_gem_ext_rake_builder.rb	(working copy)
@@ -34,7 +34,7 @@
     expected = [
       "#{Gem.ruby} mkrf_conf.rb",
       "",
-      "rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
+      "#{ENV["rake"] || "rake"} RUBYARCHDIR=#{@dest_path}
RUBYLIBDIR=#{@dest_path}",
       "(in #{realdir})\n"
     ]

@@ -63,7 +63,7 @@

 #{Gem.ruby} mkrf_conf.rb

-rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
+#{ENV["rake"] || "rake"} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
     EOF

     assert_equal expected, error.message.split("\n")[0..4].join("\n")
Index: lib/rubygems/ext/rake_builder.rb
===================================================================
--- lib/rubygems/ext/rake_builder.rb	(revision 17489)
+++ lib/rubygems/ext/rake_builder.rb	(working copy)
@@ -16,7 +16,7 @@
     end

     cmd = ENV['rake'] || 'rake'
-    cmd << " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
+    cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"

     run cmd, results



|   7) Error:
| test_execute(TestGemOutdatedCommand):
| Gem::RemoteFetcher::FetchError: getaddrinfo: Name or service not
known (SocketError)
|         fetching size (http://gems.example.com/yaml)
|     /home/mame/work/ruby19/ruby/lib/rubygems/remote_fetcher.rb:173:in
`rescue in fetch_size'
|     /home/mame/work/ruby19/ruby/lib/rubygems/remote_fetcher.rb:153:in
`fetch_size'
|     /home/mame/work/ruby19/ruby/lib/rubygems/spec_fetcher.rb:146:in
`rescue in block in legacy_repos'
|     /home/mame/work/ruby19/ruby/lib/rubygems/spec_fetcher.rb:142:in
`block in legacy_repos'
|     /home/mame/work/ruby19/ruby/lib/rubygems/spec_fetcher.rb:138:in `reject'
|     /home/mame/work/ruby19/ruby/lib/rubygems/spec_fetcher.rb:138:in
`legacy_repos'
|     /home/mame/work/ruby19/ruby/lib/rubygems/spec_fetcher.rb:237:in
`warn_legacy'
|     /home/mame/work/ruby19/ruby/lib/rubygems/source_index.rb:310:in
`rescue in block in outdated'
|     /home/mame/work/ruby19/ruby/lib/rubygems/source_index.rb:305:in
`block in outdated'
|     /home/mame/work/ruby19/ruby/lib/rubygems/source_index.rb:302:in `each'
|     /home/mame/work/ruby19/ruby/lib/rubygems/source_index.rb:302:in `outdated'
|     /home/mame/work/ruby19/ruby/lib/rubygems/commands/outdated_command.rb:21:in
`execute'
|     /home/mame/work/ruby19/ruby/test/rubygems/test_gem_outdated_command.rb:33:in
`block in test_execute'
|     /home/mame/work/ruby19/ruby/lib/rubygems/user_interaction.rb:42:in
`use_ui'
|     /home/mame/work/ruby19/ruby/lib/rubygems/user_interaction.rb:65:in
`use_ui'
|     /home/mame/work/ruby19/ruby/test/rubygems/test_gem_outdated_command.rb:33:in
`test_execute'


The test tried to resolve gems.example.com, and of course failed.
I have no idea to remove this error.


| 664 tests, 1917 assertions, 3 failures, 9 errors
| make: *** [test-all] Error 1


Other failures and errors are removed by above patches.

What do you think?

-- 
Yusuke ENDOH <mame / tsg.ne.jp>