diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 08:54:03 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 08:54:03 +0000 |
commit | 6d1266a879a94a6f76106e1bbdfa3576b6612a69 (patch) | |
tree | 5c88a98d9e588861138e63be7d45353627dcab43 /test | |
parent | 7de9e2dfdeefeefe6c3d4ff9ebafa8c947eca33f (diff) |
* lib/rdoc/*: Added --root option for building documentation outside
the source directory.
* test/rdoc/*: ditto
* common.mk (rdoc): Added --root to rdoc rule
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rdoc/test_rdoc_options.rb | 13 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_parser_ruby.rb | 6 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_rdoc.rb | 44 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_store.rb | 15 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_top_level.rb | 14 |
5 files changed, 89 insertions, 3 deletions
diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index be95580ee4..14ccd0de0f 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -430,6 +430,19 @@ rdoc_include: assert_equal 'tomdoc', @options.markup end + def test_parse_root + assert_equal Pathname(Dir.pwd), @options.root + + out, err = capture_io do + @options.parse %W[--root #{Dir.tmpdir}] + end + + assert_empty out + assert_empty err + + assert_equal Pathname(Dir.tmpdir), @options.root + end + def test_parse_template out, err = capture_io do @options.parse %w[--template darkfish] diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index b25a36301e..8168cd3f45 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -1026,7 +1026,7 @@ EOF stream = [ tk(:COMMENT, 0, 1, 1, nil, - "# File #{@top_level.absolute_name}, line 1"), + "# File #{@top_level.relative_name}, line 1"), RDoc::Parser::Ruby::NEWLINE_TOKEN, tk(:SPACE, 0, 1, 1, nil, ''), ] @@ -1199,7 +1199,7 @@ EOF stream = [ tk(:COMMENT, 0, 1, 1, nil, - "# File #{@top_level.absolute_name}, line 1"), + "# File #{@top_level.relative_name}, line 1"), RDoc::Parser::Ruby::NEWLINE_TOKEN, tk(:SPACE, 0, 1, 1, nil, ''), tk(:IDENTIFIER, 0, 1, 0, 'add_my_method', 'add_my_method'), @@ -1397,7 +1397,7 @@ end stream = [ tk(:COMMENT, 0, 1, 1, nil, - "# File #{@top_level.absolute_name}, line 1"), + "# File #{@top_level.relative_name}, line 1"), RDoc::Parser::Ruby::NEWLINE_TOKEN, tk(:SPACE, 0, 1, 1, nil, ''), tk(:DEF, 0, 1, 0, 'def', 'def'), diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index b0a0fadc49..5ed7ce77b0 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -141,6 +141,50 @@ class TestRDocRDoc < RDoc::TestCase assert_match %r%/dev/stdin$%, err end + def test_parse_file + pwd = Dir.pwd + + @rdoc.store = RDoc::Store.new + + temp_dir do |dir| + @rdoc.options.root = Pathname(Dir.pwd) + + open 'test.txt', 'w' do |io| + io.puts 'hi' + end + + test_txt = File.join dir, 'test.txt' + + top_level = @rdoc.parse_file 'test.txt' + + assert_equal 'test.txt', top_level.absolute_name + assert_equal 'test.txt', top_level.relative_name + end + end + + def test_parse_file_relative + pwd = Dir.pwd + + @rdoc.store = RDoc::Store.new + + temp_dir do |dir| + @rdoc.options.root = Pathname(dir) + + open 'test.txt', 'w' do |io| + io.puts 'hi' + end + + test_txt = File.join dir, 'test.txt' + + Dir.chdir pwd do + top_level = @rdoc.parse_file test_txt + + assert_equal test_txt, top_level.absolute_name + assert_equal 'test.txt', top_level.relative_name + end + end + end + def test_parse_file_encoding skip "Encoding not implemented" unless Object.const_defined? :Encoding @rdoc.options.encoding = Encoding::ISO_8859_1 diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 1b87ca6036..1bf42bc92c 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -127,6 +127,21 @@ class TestRDocStore < XrefTestCase refute_same top_level, @store.add_file('other.rb') end + def test_add_file_relative + top_level = @store.add_file 'path/file.rb', 'file.rb' + + assert_kind_of RDoc::TopLevel, top_level + assert_equal @store, top_level.store + + assert_equal 'path/file.rb', top_level.absolute_name + assert_equal 'file.rb', top_level.relative_name + + assert_includes @store.all_files, top_level + + assert_same top_level, @store.add_file('file.rb') + refute_same top_level, @store.add_file('other.rb') + end + def test_all_classes_and_modules expected = %w[ C1 C2 C2::C3 C2::C3::H1 C3 C3::H1 C3::H2 C4 C4::C4 C5 C5::C1 diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb index 61f4362d09..9c7a3db66f 100644 --- a/test/rdoc/test_rdoc_top_level.rb +++ b/test/rdoc/test_rdoc_top_level.rb @@ -9,6 +9,20 @@ class TestRDocTopLevel < XrefTestCase @top_level.parser = RDoc::Parser::Ruby end + def test_initialize + t = RDoc::TopLevel.new 'path/file.rb' + + assert_equal 'path/file.rb', t.absolute_name + assert_equal 'path/file.rb', t.relative_name + end + + def test_initialize_relative + t = RDoc::TopLevel.new 'path/file.rb', 'file.rb' + + assert_equal 'path/file.rb', t.absolute_name + assert_equal 'file.rb', t.relative_name + end + def test_add_alias a = RDoc::Alias.new nil, 'old', 'new', nil @top_level.add_alias a |