Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate off test of RDoc::RubygemsHook #749

Merged
merged 5 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
21 changes: 18 additions & 3 deletions lib/rdoc/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_generator_json_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_i18n_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 10 additions & 4 deletions test/rdoc/test_rdoc_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions test/rdoc/test_rdoc_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions test/rdoc/test_rdoc_ri_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/rdoc/test_rdoc_servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down