summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/rdoc/test_rdoc_rubygems_hook.rb77
-rw-r--r--version.h2
2 files changed, 55 insertions, 24 deletions
diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index ab7d95cac2..04f84d4bcc 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -1,31 +1,62 @@
# frozen_string_literal: true
-require 'rubygems/test_case'
+require "rubygems"
+require "fileutils"
+require "tmpdir"
require 'rdoc/rubygems_hook'
+require "test/unit"
-class TestRDocRubygemsHook < Gem::TestCase
-
+class TestRDocRubygemsHook < Test::Unit::TestCase
def setup
- super
-
- @a = util_spec 'a', 2 do |s|
+ @a = Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = "a"
+ s.version = 2
s.rdoc_options = %w[--main MyTitle]
s.extra_rdoc_files = %w[README]
end
-
- write_file File.join(@tempdir, 'lib', 'a.rb')
- write_file File.join(@tempdir, 'README')
-
- install_gem @a
+ @tempdir = File.realpath(Dir.mktmpdir("test_rubygems_hook_"))
+
+ @orig_envs = %w[
+ GEM_VENDOR
+ GEMRC
+ XDG_CACHE_HOME
+ XDG_CONFIG_HOME
+ XDG_DATA_HOME
+ SOURCE_DATE_EPOCH
+ BUNDLER_VERSION
+ HOME
+ RDOCOPT
+ ].map {|e| [e, ENV.delete(e)]}.to_h
+ ENV["HOME"] = @tempdir
+
+ Gem.configuration = nil
+
+ @a.instance_variable_set(:@doc_dir, File.join(@tempdir, "doc"))
+ @a.instance_variable_set(:@gem_dir, File.join(@tempdir, "a-2"))
+ @a.instance_variable_set(:@full_gem_path, File.join(@tempdir, "a-2"))
+ @a.loaded_from = File.join(@tempdir, 'a-2', 'a-2.gemspec')
+
+ FileUtils.mkdir_p File.join(@tempdir, 'a-2', 'lib')
+ FileUtils.touch File.join(@tempdir, 'a-2', 'lib', 'a.rb')
+ FileUtils.touch File.join(@tempdir, 'a-2', 'README')
@hook = RDoc::RubygemsHook.new @a
begin
RDoc::RubygemsHook.load_rdoc
rescue Gem::DocumentError => e
- skip e.message
+ omit e.message
end
+ @old_ui = Gem::DefaultUserInteraction.ui
+ Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
+ end
- Gem.configuration[:rdoc] = nil
+ def teardown
+ ui = Gem::DefaultUserInteraction.ui
+ Gem::DefaultUserInteraction.ui = @old_ui
+ FileUtils.rm_rf @tempdir
+ ui.close
+ ENV.update(@orig_envs)
end
def test_initialize
@@ -165,8 +196,8 @@ class TestRDocRubygemsHook < Gem::TestCase
@hook.generate
- refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
- assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
+ assert_path_not_exist File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_exist File.join(@a.doc_dir('ri'), 'cache.ri')
end
def test_generate_no_overwrite
@@ -176,8 +207,8 @@ class TestRDocRubygemsHook < Gem::TestCase
@hook.generate
- refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
- refute_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
+ assert_path_not_exist File.join(@a.doc_dir('rdoc'), 'index.html')
+ assert_path_not_exist File.join(@a.doc_dir('ri'), 'cache.ri')
end
def test_new_rdoc
@@ -201,12 +232,12 @@ class TestRDocRubygemsHook < Gem::TestCase
refute @hook.rdoc_installed?
refute @hook.ri_installed?
- assert_path_exists @a.doc_dir
+ assert_path_exist @a.doc_dir
end
def test_remove_unwritable
- skip 'chmod not supported' if Gem.win_platform?
- skip "assumes that euid is not root" if Process.euid == 0
+ omit 'chmod not supported' if Gem.win_platform?
+ omit "assumes that euid is not root" if Process.euid == 0
FileUtils.mkdir_p @a.base_dir
FileUtils.chmod 0, @a.base_dir
@@ -231,12 +262,12 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_setup
@hook.setup
- assert_path_exists @a.doc_dir
+ assert_path_exist @a.doc_dir
end
def test_setup_unwritable
- skip 'chmod not supported' if Gem.win_platform?
- skip "assumes that euid is not root" if Process.euid == 0
+ omit 'chmod not supported' if Gem.win_platform?
+ omit "assumes that euid is not root" if Process.euid == 0
FileUtils.mkdir_p @a.doc_dir
FileUtils.chmod 0, @a.doc_dir
diff --git a/version.h b/version.h
index a34639b6ea..3f82a9480f 100644
--- a/version.h
+++ b/version.h
@@ -12,7 +12,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 4
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 172
+#define RUBY_PATCHLEVEL 173
#define RUBY_RELEASE_YEAR 2022
#define RUBY_RELEASE_MONTH 2