Issue #4455 has been reported by Yui NARUSE.

----------------------------------------
Bug #4455: rubygem's test fails when source directory and build directory differ
http://redmine.ruby-lang.org/issues/4455

Author: Yui NARUSE
Status: Assigned
Priority: Normal
Assignee: Eric Hodel
Category: lib
Target version: 
ruby -v: ruby 1.9.3dev (2011-03-01 trunk 30998) [x86_64-freebsd8.2] 


In lib/rubygems/test_case.rb, it sets @project_dir as Dir.pwd.
But the use cases of @project_dir are both top of source and build directory.
It breaks when they differ.

This happens when:

  cd $HOME
  mkdir bin-ruby
  svn co http://svn.ruby-lang.org/repos/ruby/trunk src-ruby
  cd ruby
  autoconf
  mkdir ../build-ruby
  cd ../build-ruby
  ../ruby/configure --prefix=$HOME/bin-ruby
  make
  make install
  make test-all

The error messages are following:
  2) Failure:
test_self_prefix(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:779]:
Expected "/home/naruse/obj/ruby", not "/home/naruse/ruby".

  3) Failure:
test_self_prefix_libdir(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:786]:
Expected "/home/naruse/ruby" to be nil.

  4) Failure:
test_self_find_files(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:655]:
Expected ["/home/naruse/obj/ruby/test/rubygems/sff/discover.rb",
 "/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-2/lib/sff/discover.rb",
 "/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-1/lib/sff/discover.rb"], not ["/home/naruse/ruby/test/rubygems/sff/discover.rb",
 "/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-2/lib/sff/discover.rb",
 "/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-1/lib/sff/discover.rb"].

  5) Failure:
test_self_prefix_sitelibdir(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:795]:
Expected "/home/naruse/ruby" to be nil.

  6) Error:
test_execute_removes_executable(TestGemCommandsUninstallCommand):
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/naruse/obj/ruby/ruby mkrf_conf.rb

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9


Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out

    /home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:32:in `block (2 levels) in test_execute_removes_executable'
    /home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:31:in `block in test_execute_removes_executable'
    /home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:30:in `test_execute_removes_executable'
    ../../ruby/test/runner.rb:10:in `<main>'

  7) Error:
test_execute_prerelease(TestGemCommandsUninstallCommand):
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/naruse/obj/ruby/ruby mkrf_conf.rb

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b/lib
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9


Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b for inspection.
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b/ext/a/gem_make.out

    /home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:100:in `block (2 levels) in test_execute_prerelease'
    /home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:99:in `block in test_execute_prerelease'
    /home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:98:in `test_execute_prerelease'
    ../../ruby/test/runner.rb:10:in `<main>'

  8) Error:
test_class_build(TestGemExtRakeBuilder):
Gem::InstallError: rake failed:

/home/naruse/obj/ruby/ruby mkrf_conf.rb

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/prefix RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/prefix
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9

    /home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:36:in `block (2 levels) in test_class_build'
    /home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:34:in `chdir'
    /home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:34:in `block in test_class_build'
    /home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:33:in `test_class_build'
    ../../ruby/test/runner.rb:10:in `<main>'

  9) Error:
test_install_ignore_dependencies(TestGemInstaller):
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9


Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out

    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:698:in `block (2 levels) in test_install_ignore_dependencies'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:697:in `block in test_install_ignore_dependencies'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:696:in `test_install_ignore_dependencies'
    ../../ruby/test/runner.rb:10:in `<main>'

 10) Error:
test_install_with_no_prior_files(TestGemInstaller):
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9


Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out

    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:594:in `block (2 levels) in test_install_with_no_prior_files'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:593:in `block in test_install_with_no_prior_files'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:592:in `test_install_with_no_prior_files'
    ../../ruby/test/runner.rb:10:in `<main>'

 11) Error:
test_install_check_dependencies_install_dir(TestGemInstaller):
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2/lib
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9


Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2 for inspection.
Results logged to /tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2/ext/a/gem_make.out

    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:673:in `block (2 levels) in test_install_check_dependencies_install_dir'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:672:in `block in test_install_check_dependencies_install_dir'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:671:in `test_install_check_dependencies_install_dir'
    ../../ruby/test/runner.rb:10:in `<main>'

 12) Error:
test_install(TestGemInstaller):
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2

rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
	from /home/naruse/ruby/lib/rubygems.rb:36:in `require'
	from /home/naruse/ruby/lib/rubygems.rb:36
	from /usr/local/bin/rake:9:in `require'
	from /usr/local/bin/rake:9


Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out

    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:560:in `block (2 levels) in test_install'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:559:in `block in test_install'
    /home/naruse/ruby/test/rubygems/test_gem_installer.rb:558:in `test_install'
    ../../ruby/test/runner.rb:10:in `<main>'


-- 
http://redmine.ruby-lang.org