diff --git a/Rakefile b/Rakefile index 297b2424d9..fa95bd7255 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] PARSER_FILES = %w[ lib/rdoc/rd/block_parser.ry @@ -34,10 +34,18 @@ 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.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 path = "pkg/#{Bundler::GemHelper.gemspec.full_name}" 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_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..a7d3cf4d6b 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 @@ -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 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..6720509ddb 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 @@ -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 @@ -349,8 +357,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