diff --git a/.travis.yml b/.travis.yml index 4611c5e7a..0d30f7e76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,14 @@ language: ruby +dist: xenial +addons: + apt: + packages: + - libclang-6.0-dev + - llvm-6.0 rvm: - - ruby-2.0 - - ruby-2.1 + - ruby-2.4 + - ruby-2.5 - ruby-head - - rbx env: - - LLVM_CONFIG=llvm-config-3.3 - -before_install: - - sudo apt-get update - - sudo apt-get install libclang-3.3-dev llvm-3.3 + - LLVM_CONFIG=llvm-config-6.0 diff --git a/docurium.gemspec b/docurium.gemspec index 1097a92c2..ca091c7dc 100644 --- a/docurium.gemspec +++ b/docurium.gemspec @@ -20,7 +20,6 @@ Gem::Specification.new do |s| s.add_dependency "rugged", "~>0.21" s.add_dependency "redcarpet", "~>3.0" s.add_dependency "ffi-clang", "~> 0.5" - s.add_development_dependency "bundler", "~>1.0" s.add_development_dependency "rake", "~> 12" s.add_development_dependency "minitest", "~> 5.11" diff --git a/test/docurium_test.rb b/test/docurium_test.rb index 1a8e57c8c..05dd317dc 100644 --- a/test/docurium_test.rb +++ b/test/docurium_test.rb @@ -62,8 +62,64 @@ def test_can_extract_structs_and_enums def test_can_find_type_usage oid = @data[:types].assoc('git_oid') - assert_equal 10, oid[1][:used][:returns].size - assert_equal 39, oid[1][:used][:needs].size + oid_returns = [ + "git_commit_id", + "git_commit_parent_oid", + "git_commit_tree_oid", + "git_object_id", + "git_odb_object_id", + "git_oid_shorten_new", + "git_reference_oid", + "git_tag_id", + "git_tag_target_oid", + "git_tree_entry_id", + "git_tree_id" + ] + assert_equal oid_returns, oid[1][:used][:returns] + oid_needs = [ + "git_blob_create_frombuffer", + "git_blob_create_fromfile", + "git_blob_lookup", + "git_commit_create", + "git_commit_create_o", + "git_commit_create_ov", + "git_commit_create_v", + "git_commit_lookup", + "git_object_lookup", + "git_odb_exists", + "git_odb_hash", + "git_odb_open_rstream", + "git_odb_read", + "git_odb_read_header", + "git_odb_write", + "git_oid_allocfmt", + "git_oid_cmp", + "git_oid_cpy", + "git_oid_fmt", + "git_oid_mkraw", + "git_oid_mkstr", + "git_oid_pathfmt", + "git_oid_shorten_add", + "git_oid_shorten_free", + "git_oid_to_string", + "git_reference_create_oid", + "git_reference_create_oid_f", + "git_reference_set_oid", + "git_revwalk_hide", + "git_revwalk_next", + "git_revwalk_push", + "git_tag_create", + "git_tag_create_f", + "git_tag_create_fo", + "git_tag_create_frombuffer", + "git_tag_create_o", + "git_tag_lookup", + "git_tree_create_fromindex", + "git_tree_lookup", + "git_treebuilder_insert", + "git_treebuilder_write" + ] + assert_equal oid_needs, oid[1][:used][:needs].sort end def test_can_parse_normal_functions @@ -104,7 +160,12 @@ def test_can_parse_function_cast_args assert_equal 'callback', func[:args][2][:name] assert_equal 'int (*)(const char *, void *)', func[:args][2][:type] assert_equal 'Function which will be called for every listed ref', func[:args][2][:comment] - assert_equal 8, func[:comments].split("\n").size + expect_comment =<<-EOF +

The listed references may be filtered by type, or using a bitwise OR of several types. Use the magic value GIT_REF_LISTALL to obtain all references, including packed ones.

+ +

The callback function will be called for each of the references in the repository, and will receive the name of the reference and the payload value passed to this method.

+ EOF + assert_equal expect_comment.split("\n").map(&:strip), func[:comments].split("\n") end def test_can_get_the_full_description_from_multi_liners diff --git a/test/fixtures/git2/common.h b/test/fixtures/git2/common.h index 9a27ac2e5..f86d15899 100644 --- a/test/fixtures/git2/common.h +++ b/test/fixtures/git2/common.h @@ -39,6 +39,12 @@ # define GIT_END_DECL /* empty */ #endif +/* + * libclang won't consider anything with size_t to have comments unless we use + * this hack. + */ +typedef size_t size_t; + /** Declare a public function exported for application use. */ #ifdef __GNUC__ # define GIT_EXTERN(type) extern \ diff --git a/test/parser_test.rb b/test/parser_test.rb index 560cfdd54..69611920f 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -70,7 +70,7 @@ def test_single_multiline_function */ int some_function( char *string, - size_t len); + int len); EOF actual = parse(name, contents) @@ -80,10 +80,10 @@ def test_single_multiline_function :tdef => nil, :type => :function, :name => 'some_function', - :body => "int some_function(char *string, size_t len);", + :body => "int some_function(char *string, int len);", :description => ' Do something', :comments => " More explanation of what we do\n\n ", - :sig => 'char *::size_t', + :sig => 'char *::int', :args => [{ :name => 'string', :type => 'char *', @@ -91,15 +91,15 @@ def test_single_multiline_function }, { :name => 'len', - :type => 'size_t', + :type => 'int', :comment => nil }], :return => { :type => 'int', :comment => ' an integer value' }, - :decl => "int some_function(char *string, size_t len)", - :argline => "char *string, size_t len", + :decl => "int some_function(char *string, int len)", + :argline => "char *string, int len", }] assert_equal expected, actual @@ -192,7 +192,7 @@ def test_return_struct :argline => "git_tree *tree" }] - assert_equal actual, expected + assert_equal expected, actual end @@ -377,7 +377,7 @@ def test_type_reference :underlying_type => "int" }] - assert_equal actual, expected + assert_equal expected, actual name = 'typeref.h' contents = < '', }] - assert_equal actual, expected + assert_equal expected, actual end