diff options
Diffstat (limited to 'test/rubygems/test_gem_installer.rb')
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 103 |
1 files changed, 72 insertions, 31 deletions
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index ca48065bd4..2d747bed72 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1141,47 +1141,88 @@ gem 'other', version refute_path_exists should_be_removed end - def test_find_lib_file_after_install - @spec.extensions << "extconf.rb" - write_file File.join(@tempdir, "extconf.rb") do |io| - io.write <<-RUBY - require "mkmf" + # ruby core repository needs to `depend` file for extension build. + # but 1.9.2 and earlier mkmf.rb does not create TOUCH file like depend. + if RUBY_VERSION < '1.9.3' + def test_find_lib_file_after_install + + @spec.extensions << "extconf.rb" + write_file File.join(@tempdir, "extconf.rb") do |io| + io.write <<-RUBY + require "mkmf" + create_makefile("#{@spec.name}") + RUBY + end - CONFIG['CC'] = '$(TOUCH) $@ ||' - CONFIG['LDSHARED'] = '$(TOUCH) $@ ||' - $ruby = '#{Gem.ruby}' + write_file File.join(@tempdir, "a.c") do |io| + io.write <<-C + #include <ruby.h> + void Init_a() { } + C + end - create_makefile("#{@spec.name}") - RUBY - end + Dir.mkdir File.join(@tempdir, "lib") + write_file File.join(@tempdir, 'lib', "b.rb") do |io| + io.write "# b.rb" + end - write_file File.join(@tempdir, "depend") + @spec.files += %w[extconf.rb lib/b.rb a.c] - write_file File.join(@tempdir, "a.c") do |io| - io.write <<-C - #include <ruby.h> - void Init_a() { } - C - end + use_ui @ui do + path = Gem::Package.build @spec + + installer = Gem::Installer.at path + installer.install + end - Dir.mkdir File.join(@tempdir, "lib") - write_file File.join(@tempdir, 'lib', "b.rb") do |io| - io.write "# b.rb" + expected = File.join @spec.full_require_paths.find { |path| + File.exist? File.join path, 'b.rb' + }, 'b.rb' + assert_equal expected, @spec.matches_for_glob('b.rb').first end + else + def test_find_lib_file_after_install + @spec.extensions << "extconf.rb" + write_file File.join(@tempdir, "extconf.rb") do |io| + io.write <<-RUBY + require "mkmf" - @spec.files += %w[extconf.rb lib/b.rb depend a.c] + CONFIG['CC'] = '$(TOUCH) $@ ||' + CONFIG['LDSHARED'] = '$(TOUCH) $@ ||' + $ruby = '#{Gem.ruby}' - use_ui @ui do - path = Gem::Package.build @spec + create_makefile("#{@spec.name}") + RUBY + end - installer = Gem::Installer.at path - installer.install - end + write_file File.join(@tempdir, "depend") + + write_file File.join(@tempdir, "a.c") do |io| + io.write <<-C + #include <ruby.h> + void Init_a() { } + C + end - expected = File.join @spec.full_require_paths.find { |path| - File.exist? File.join path, 'b.rb' - }, 'b.rb' - assert_equal expected, @spec.matches_for_glob('b.rb').first + Dir.mkdir File.join(@tempdir, "lib") + write_file File.join(@tempdir, 'lib', "b.rb") do |io| + io.write "# b.rb" + end + + @spec.files += %w[extconf.rb lib/b.rb depend a.c] + + use_ui @ui do + path = Gem::Package.build @spec + + installer = Gem::Installer.at path + installer.install + end + + expected = File.join @spec.full_require_paths.find { |path| + File.exist? File.join path, 'b.rb' + }, 'b.rb' + assert_equal expected, @spec.matches_for_glob('b.rb').first + end end def test_install_extension_and_script |