Skip to content

Commit 2db7aec

Browse files
authored
Merge pull request #749 from aycabta/separate-off-rubygems-test
Separate off test of RDoc::RubygemsHook
2 parents 548d4d1 + ba16e44 commit 2db7aec

9 files changed

+58
-21
lines changed

Rakefile

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'rake/testtask'
55
require 'rubocop/rake_task'
66

77
task :docs => :generate
8-
task :test => :generate
8+
task :test => [:normal_test, :rubygems_test]
99

1010
PARSER_FILES = %w[
1111
lib/rdoc/rd/block_parser.ry
@@ -34,10 +34,18 @@ task ghpages: :rdoc do
3434
FileUtils.cp_r Dir.glob("/tmp/html/*"), "."
3535
end
3636

37-
Rake::TestTask.new(:test) do |t|
37+
Rake::TestTask.new(:normal_test) do |t|
3838
t.libs << "test/rdoc"
3939
t.verbose = true
40-
t.test_files = FileList['test/**/test_*.rb']
40+
t.deps = :generate
41+
t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb")
42+
end
43+
44+
Rake::TestTask.new(:rubygems_test) do |t|
45+
t.libs << "test/rdoc"
46+
t.verbose = true
47+
t.deps = :generate
48+
t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb"
4149
end
4250

4351
path = "pkg/#{Bundler::GemHelper.gemspec.full_name}"

lib/rdoc/options.rb

+18-3
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,13 @@ def finish_page_dir
555555

556556
@files << @page_dir.to_s
557557

558-
page_dir = @page_dir.expand_path.relative_path_from @root
558+
page_dir = nil
559+
begin
560+
page_dir = @page_dir.expand_path.relative_path_from @root
561+
rescue ArgumentError
562+
# On Windows, sometimes crosses different drive letters.
563+
page_dir = @page_dir.expand_path
564+
end
559565

560566
@page_dir = page_dir
561567
end
@@ -1154,8 +1160,17 @@ def sanitize_path path
11541160

11551161
path.reject do |item|
11561162
path = Pathname.new(item).expand_path
1157-
relative = path.relative_path_from(dot).to_s
1158-
relative.start_with? '..'
1163+
is_reject = nil
1164+
relative = nil
1165+
begin
1166+
relative = path.relative_path_from(dot).to_s
1167+
rescue ArgumentError
1168+
# On Windows, sometimes crosses different drive letters.
1169+
is_reject = true
1170+
else
1171+
is_reject = relative.start_with? '..'
1172+
end
1173+
is_reject
11591174
end
11601175
end
11611176

test/rdoc/test_rdoc_generator_json_index.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_generate_gzipped
168168
begin
169169
require 'zlib'
170170
rescue LoadError
171-
skip "no zlib"
171+
omit "no zlib"
172172
end
173173
@g.generate
174174
@g.generate_gzipped

test/rdoc/test_rdoc_i18n_locale.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_load_existent_po
3232
begin
3333
require 'gettext/po_parser'
3434
rescue LoadError
35-
skip 'gettext gem is not found'
35+
omit 'gettext gem is not found'
3636
end
3737

3838
fr_locale_dir = File.join @locale_dir, 'fr'

test/rdoc/test_rdoc_options.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def teardown
1717
end
1818

1919
def test_check_files
20-
skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
21-
skip "assumes that euid is not root" if Process.euid == 0
20+
omit "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
21+
omit "assumes that euid is not root" if Process.euid == 0
2222

2323
out, err = capture_output do
2424
temp_dir do
@@ -493,8 +493,14 @@ def test_parse_page_dir
493493
assert_empty out
494494
assert_empty err
495495

496-
expected =
497-
Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
496+
expected = nil
497+
begin
498+
expected =
499+
Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
500+
rescue ArgumentError
501+
# On Windows, sometimes crosses different drive letters.
502+
expected = Pathname(Dir.tmpdir).expand_path
503+
end
498504

499505
assert_equal expected, @options.page_dir
500506
assert_equal [Dir.tmpdir], @options.files

test/rdoc/test_rdoc_parser.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_class_for_executable
104104
end
105105

106106
def test_class_for_forbidden
107-
skip 'chmod not supported' if Gem.win_platform?
107+
omit 'chmod not supported' if Gem.win_platform?
108108

109109
tf = Tempfile.open 'forbidden' do |io|
110110
begin

test/rdoc/test_rdoc_rdoc.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_normalized_file_list_not_modified
163163

164164
def test_normalized_file_list_non_file_directory
165165
dev = File::NULL
166-
skip "#{dev} is not a character special" unless
166+
omit "#{dev} is not a character special" unless
167167
File.chardev? dev
168168

169169
files = nil
@@ -190,6 +190,10 @@ def test_normalized_file_list_with_dot_doc
190190
FileUtils.touch a
191191
FileUtils.touch b
192192
FileUtils.touch c
193+
# Use Dir.glob to convert short path of Dir.tmpdir to long path.
194+
a = Dir.glob(a).first
195+
b = Dir.glob(b).first
196+
c = Dir.glob(c).first
193197

194198
dot_doc = File.expand_path('.document')
195199
FileUtils.touch dot_doc
@@ -217,6 +221,10 @@ def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option
217221
FileUtils.touch a
218222
FileUtils.touch b
219223
FileUtils.touch c
224+
# Use Dir.glob to convert short path of Dir.tmpdir to long path.
225+
a = Dir.glob(a).first
226+
b = Dir.glob(b).first
227+
c = Dir.glob(c).first
220228

221229
dot_doc = File.expand_path('.document')
222230
FileUtils.touch dot_doc
@@ -349,8 +357,8 @@ def test_parse_file_encoding
349357
end
350358

351359
def test_parse_file_forbidden
352-
skip 'chmod not supported' if Gem.win_platform?
353-
skip "assumes that euid is not root" if Process.euid == 0
360+
omit 'chmod not supported' if Gem.win_platform?
361+
omit "assumes that euid is not root" if Process.euid == 0
354362

355363
@rdoc.store = RDoc::Store.new
356364

test/rdoc/test_rdoc_ri_driver.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ def test_find_store
10291029
end
10301030

10311031
def test_did_you_mean
1032-
skip 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker
1032+
omit 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker
10331033

10341034
util_ancestors_store
10351035

@@ -1227,7 +1227,7 @@ def _test_page # this test doesn't do anything anymore :(
12271227

12281228
with_dummy_pager do
12291229
@driver.page do |io|
1230-
skip "couldn't find a standard pager" if io == $stdout
1230+
omit "couldn't find a standard pager" if io == $stdout
12311231

12321232
assert @driver.paging?
12331233
end
@@ -1406,7 +1406,7 @@ def _test_setup_pager # this test doesn't do anything anymore :(
14061406

14071407
pager = with_dummy_pager do @driver.setup_pager end
14081408

1409-
skip "couldn't find a standard pager" unless pager
1409+
omit "couldn't find a standard pager" unless pager
14101410

14111411
assert @driver.paging?
14121412
ensure

test/rdoc/test_rdoc_servlet.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def test_generator_for
294294
end
295295

296296
def test_if_modified_since
297-
skip 'File.utime on directory not supported' if Gem.win_platform?
297+
omit 'File.utime on directory not supported' if Gem.win_platform?
298298

299299
temp_dir do
300300
now = Time.now
@@ -307,7 +307,7 @@ def test_if_modified_since
307307
end
308308

309309
def test_if_modified_since_not_modified
310-
skip 'File.utime on directory not supported' if Gem.win_platform?
310+
omit 'File.utime on directory not supported' if Gem.win_platform?
311311

312312
temp_dir do
313313
now = Time.now

0 commit comments

Comments
 (0)