Skip to content
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
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion docurium.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
67 changes: 64 additions & 3 deletions test/docurium_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
<p>The listed references may be filtered by type, or using a bitwise OR of several types. Use the magic value <code>GIT_REF_LISTALL</code> to obtain all references, including packed ones.</p>

<p>The <code>callback</code> function will be called for each of the references in the repository, and will receive the name of the reference and the <code>payload</code> value passed to this method.</p>
EOF
assert_equal expect_comment.split("\n").map(&:strip), func[:comments].split("\n")
end

def test_can_get_the_full_description_from_multi_liners
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/git2/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
18 changes: 9 additions & 9 deletions test/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_single_multiline_function
*/
int some_function(
char *string,
size_t len);
int len);
EOF

actual = parse(name, contents)
Expand All @@ -80,26 +80,26 @@ 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 *',
:comment => 'a sequence of characters'
},
{
: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
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_return_struct
:argline => "git_tree *tree"
}]

assert_equal actual, expected
assert_equal expected, actual

end

Expand Down Expand Up @@ -377,7 +377,7 @@ def test_type_reference
:underlying_type => "int"
}]

assert_equal actual, expected
assert_equal expected, actual

name = 'typeref.h'
contents = <<EOF
Expand All @@ -401,7 +401,7 @@ def test_type_reference
:comments => '',
}]

assert_equal actual, expected
assert_equal expected, actual


end
Expand Down