From 72e3d04bf121c55134a929a5c6c7931f39b96425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 18 Feb 2019 18:05:26 +0100 Subject: [PATCH 1/8] travis: use xenial, clang 6 and ruby 2.4 and 2.5 These are relatively recent packages after several years of not running the travis tests. --- .travis.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4611c5e7a..e27485227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,15 @@ 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 From 060ad7b32c96988ef0f9656d72670db5561c771b Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Thu, 22 Mar 2018 23:10:09 +0100 Subject: [PATCH 2/8] Reorder expected <=> actual arguments logically --- test/parser_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parser_test.rb b/test/parser_test.rb index 560cfdd54..1f6ace2df 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -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 From 8d154e9e8779bb4ac3d5fce3ecb263de12cf7cee Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Thu, 22 Mar 2018 23:10:05 +0100 Subject: [PATCH 3/8] Don't test magic values --- test/docurium_test.rb | 67 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/test/docurium_test.rb b/test/docurium_test.rb index 1a8e57c8c..5b96c7623 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] 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 From 1d86b31da2d02f9c68208bba751a5cc42a25bfa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 18 Feb 2019 18:49:10 +0100 Subject: [PATCH 4/8] test: work around size_t oddities in clang This is a test for a multi-line function declaration and we don't want to be fighting here against the odd behaviour with `size_t`. --- test/parser_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parser_test.rb b/test/parser_test.rb index 1f6ace2df..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 From e5e916031d2b692ce0df7bf2e3ea1fe5170f3566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 18 Feb 2019 18:57:32 +0100 Subject: [PATCH 5/8] test: define size_t to work around libclang oddities For some reason clang 6 (and other versions) don't consider anything with `size_t` to have comments unless we do this silly `typedef`. We have a similar workaround in libgit2 itself. --- test/fixtures/git2/common.h | 6 ++++++ 1 file changed, 6 insertions(+) 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 \ From 319aebe624351b58b736d608e0129f5672eea7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 18 Feb 2019 19:06:37 +0100 Subject: [PATCH 6/8] gemspec: do not depend on bundler gem version We don't use it directly so we don't need to depend on a specific version. --- docurium.gemspec | 1 - 1 file changed, 1 deletion(-) 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" From 195dfc484fc712afc43e60bf5f6846d8992432b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 18 Feb 2019 19:12:16 +0100 Subject: [PATCH 7/8] travis: don't test against rbx --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e27485227..0d30f7e76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ rvm: - ruby-2.4 - ruby-2.5 - ruby-head - - rbx env: - LLVM_CONFIG=llvm-config-6.0 From d8374dcb1c954fb6336321ab378d0341c37dea42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 18 Feb 2019 19:13:04 +0100 Subject: [PATCH 8/8] test: sort when comparing --- test/docurium_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/docurium_test.rb b/test/docurium_test.rb index 5b96c7623..05dd317dc 100644 --- a/test/docurium_test.rb +++ b/test/docurium_test.rb @@ -119,7 +119,7 @@ def test_can_find_type_usage "git_treebuilder_insert", "git_treebuilder_write" ] - assert_equal oid_needs, oid[1][:used][:needs] + assert_equal oid_needs, oid[1][:used][:needs].sort end def test_can_parse_normal_functions