From 2927b6e6e1529f87103278a479a4417c50bd7ede Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 27 Oct 2019 02:02:15 +0900 Subject: [PATCH 1/5] Separate off test of RDoc::RubygemsHook RDoc uses test-unit but RubyGems uses minitest. RDoc::RubygemsHook is a part of RubyGems so its test also uses minitest. Rakefile of RDoc runs both tests at one time so always only RDoc::RubygemsHook's test runs. All other tests do never be run. So modified Rakefile to be run both tests separately. --- Rakefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 297b2424d9..d348f074c0 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ require 'rake/testtask' require 'rubocop/rake_task' task :docs => :generate -task :test => :generate +task :test => [:normal_test, :rubygems_test, :generate] PARSER_FILES = %w[ lib/rdoc/rd/block_parser.ry @@ -34,10 +34,16 @@ task ghpages: :rdoc do FileUtils.cp_r Dir.glob("/tmp/html/*"), "." end -Rake::TestTask.new(:test) do |t| +Rake::TestTask.new(:normal_test) do |t| t.libs << "test/rdoc" t.verbose = true - t.test_files = FileList['test/**/test_*.rb'] + t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb") +end + +Rake::TestTask.new(:rubygems_test) do |t| + t.libs << "test/rdoc" + t.verbose = true + t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb" end path = "pkg/#{Bundler::GemHelper.gemspec.full_name}" From 1c5bf2ae1d17c43e62c147df01841d297e86f775 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 27 Oct 2019 02:28:25 +0900 Subject: [PATCH 2/5] Use omit of test-unit instead of skip of minitest --- test/rdoc/test_rdoc_generator_json_index.rb | 2 +- test/rdoc/test_rdoc_i18n_locale.rb | 2 +- test/rdoc/test_rdoc_options.rb | 4 ++-- test/rdoc/test_rdoc_parser.rb | 2 +- test/rdoc/test_rdoc_rdoc.rb | 6 +++--- test/rdoc/test_rdoc_ri_driver.rb | 6 +++--- test/rdoc/test_rdoc_servlet.rb | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index 6a95acef73..66d15d1848 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -168,7 +168,7 @@ def test_generate_gzipped begin require 'zlib' rescue LoadError - skip "no zlib" + omit "no zlib" end @g.generate @g.generate_gzipped diff --git a/test/rdoc/test_rdoc_i18n_locale.rb b/test/rdoc/test_rdoc_i18n_locale.rb index 43fd7e2197..746d659c67 100644 --- a/test/rdoc/test_rdoc_i18n_locale.rb +++ b/test/rdoc/test_rdoc_i18n_locale.rb @@ -32,7 +32,7 @@ def test_load_existent_po begin require 'gettext/po_parser' rescue LoadError - skip 'gettext gem is not found' + omit 'gettext gem is not found' end fr_locale_dir = File.join @locale_dir, 'fr' diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index 0bc6eaa9f1..43dc10c4ae 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -17,8 +17,8 @@ def teardown end def test_check_files - skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM - skip "assumes that euid is not root" if Process.euid == 0 + omit "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM + omit "assumes that euid is not root" if Process.euid == 0 out, err = capture_output do temp_dir do diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index 57b8e01a87..7cc3c2d926 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -104,7 +104,7 @@ def test_class_for_executable end def test_class_for_forbidden - skip 'chmod not supported' if Gem.win_platform? + omit 'chmod not supported' if Gem.win_platform? tf = Tempfile.open 'forbidden' do |io| begin diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index b549ba8dc8..1606a9d6b1 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -163,7 +163,7 @@ def test_normalized_file_list_not_modified def test_normalized_file_list_non_file_directory dev = File::NULL - skip "#{dev} is not a character special" unless + omit "#{dev} is not a character special" unless File.chardev? dev files = nil @@ -349,8 +349,8 @@ def test_parse_file_encoding end def test_parse_file_forbidden - 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 @rdoc.store = RDoc::Store.new diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb index 4965b3ddd8..6f17fecec9 100644 --- a/test/rdoc/test_rdoc_ri_driver.rb +++ b/test/rdoc/test_rdoc_ri_driver.rb @@ -1029,7 +1029,7 @@ def test_find_store end def test_did_you_mean - skip 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker + omit 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker util_ancestors_store @@ -1227,7 +1227,7 @@ def _test_page # this test doesn't do anything anymore :( with_dummy_pager do @driver.page do |io| - skip "couldn't find a standard pager" if io == $stdout + omit "couldn't find a standard pager" if io == $stdout assert @driver.paging? end @@ -1406,7 +1406,7 @@ def _test_setup_pager # this test doesn't do anything anymore :( pager = with_dummy_pager do @driver.setup_pager end - skip "couldn't find a standard pager" unless pager + omit "couldn't find a standard pager" unless pager assert @driver.paging? ensure diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index ff64d5670f..1127408193 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -294,7 +294,7 @@ def test_generator_for end def test_if_modified_since - skip 'File.utime on directory not supported' if Gem.win_platform? + omit 'File.utime on directory not supported' if Gem.win_platform? temp_dir do now = Time.now @@ -307,7 +307,7 @@ def test_if_modified_since end def test_if_modified_since_not_modified - skip 'File.utime on directory not supported' if Gem.win_platform? + omit 'File.utime on directory not supported' if Gem.win_platform? temp_dir do now = Time.now From 45e624eaca720324e24d535a08191096ca83a98f Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 27 Oct 2019 03:39:04 +0900 Subject: [PATCH 3/5] The normal_test task depends on generate task --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index d348f074c0..fa95bd7255 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ require 'rake/testtask' require 'rubocop/rake_task' task :docs => :generate -task :test => [:normal_test, :rubygems_test, :generate] +task :test => [:normal_test, :rubygems_test] PARSER_FILES = %w[ lib/rdoc/rd/block_parser.ry @@ -37,12 +37,14 @@ end Rake::TestTask.new(:normal_test) do |t| t.libs << "test/rdoc" t.verbose = true + t.deps = :generate t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb") end Rake::TestTask.new(:rubygems_test) do |t| t.libs << "test/rdoc" t.verbose = true + t.deps = :generate t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb" end From 946d2592e2195bfbcb40d88b0d179b6e06cb53b0 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 28 Oct 2019 01:44:09 +0900 Subject: [PATCH 4/5] Support different drive latters in include paths --- lib/rdoc/options.rb | 21 ++++++++++++++++++--- test/rdoc/test_rdoc_options.rb | 10 ++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb index 53cc3af63c..43494c85be 100644 --- a/lib/rdoc/options.rb +++ b/lib/rdoc/options.rb @@ -555,7 +555,13 @@ def finish_page_dir @files << @page_dir.to_s - page_dir = @page_dir.expand_path.relative_path_from @root + page_dir = nil + begin + page_dir = @page_dir.expand_path.relative_path_from @root + rescue ArgumentError + # On Windows, sometimes crosses different drive letters. + page_dir = @page_dir.expand_path + end @page_dir = page_dir end @@ -1154,8 +1160,17 @@ def sanitize_path path path.reject do |item| path = Pathname.new(item).expand_path - relative = path.relative_path_from(dot).to_s - relative.start_with? '..' + is_reject = nil + relative = nil + begin + relative = path.relative_path_from(dot).to_s + rescue ArgumentError + # On Windows, sometimes crosses different drive letters. + is_reject = true + else + is_reject = relative.start_with? '..' + end + is_reject end end diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index 43dc10c4ae..a7d3cf4d6b 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -493,8 +493,14 @@ def test_parse_page_dir assert_empty out assert_empty err - expected = - Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root + expected = nil + begin + expected = + Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root + rescue ArgumentError + # On Windows, sometimes crosses different drive letters. + expected = Pathname(Dir.tmpdir).expand_path + end assert_equal expected, @options.page_dir assert_equal [Dir.tmpdir], @options.files From ba16e445726fc5f11dce4bbcb7e7e4a4c4992c9b Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 28 Oct 2019 13:39:37 +0900 Subject: [PATCH 5/5] Use Dir.glob to convert short path of Dir.tmpdir to long path --- test/rdoc/test_rdoc_rdoc.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 1606a9d6b1..6720509ddb 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -190,6 +190,10 @@ def test_normalized_file_list_with_dot_doc FileUtils.touch a FileUtils.touch b FileUtils.touch c + # Use Dir.glob to convert short path of Dir.tmpdir to long path. + a = Dir.glob(a).first + b = Dir.glob(b).first + c = Dir.glob(c).first dot_doc = File.expand_path('.document') FileUtils.touch dot_doc @@ -217,6 +221,10 @@ def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option FileUtils.touch a FileUtils.touch b FileUtils.touch c + # Use Dir.glob to convert short path of Dir.tmpdir to long path. + a = Dir.glob(a).first + b = Dir.glob(b).first + c = Dir.glob(c).first dot_doc = File.expand_path('.document') FileUtils.touch dot_doc