Skip to content

Include ahead_behind in the test suite#5135

Merged
pks-t merged 1 commit into
masterfrom
unknown repository
Aug 1, 2019
Merged

Include ahead_behind in the test suite#5135
pks-t merged 1 commit into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jun 22, 2019

Copy link
Copy Markdown

This ahead_behind, inspired from descendant_of. I would like to contribute to this project, with your help along the way!

@ghost

ghost commented Jun 22, 2019

Copy link
Copy Markdown
Author

Test failures may be not related to this commit. :)
image

@ghost

ghost commented Jun 22, 2019

Copy link
Copy Markdown
Author

/rebuild

@libgit2-azure-pipelines

Copy link
Copy Markdown

Okay, @j143-bot, I started to rebuild this pull request as build #2175.

@ethomson ethomson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the tests were failing on this commit: there's a memory leak introduced. The summary only shows the first 10 lines or so of stderr, but if you click to open the full results, you'll be able to see the valgrind output.

There are a functional changes that I'd recommend in the test itself, but I'm happy to see you adding these tests.

Thanks for the pull request, and welcome to the libgit2 project.

Comment thread tests/graph/ahead_behind.c Outdated

git_commit_free(other);

cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 3));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to git_commit_free(other) at the end of this function.

Comment thread tests/graph/ahead_behind.c Outdated
git_oid_fromstr(&oid, "e90810b8df3e80c413d903f631643c716887138d");
git_oid_fromstr(&oid2, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");

cl_assert_equal_i(0, git_graph_ahead_behind(&ahead, &behind, _repo, &oid, &oid2));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be cl_git_pass(...) instead of cl_assert_equal_i(0, ...), they'll emit helpful error messages if anything failed.

Comment thread tests/graph/ahead_behind.c Outdated
cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 3));

cl_assert_equal_i(0, git_graph_ahead_behind(&ahead, &behind, _repo, git_commit_id(commit), git_commit_id(other)));
cl_assert_equal_i(0, git_graph_ahead_behind(&ahead, &behind, _repo, git_commit_id(other), git_commit_id(commit)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have several tests that ensure that git_graph_ahead_behind works, but you're not actually examining the results of ahead and behind to ensure that we're returning the correct results.

You should be able to look at the test resource directory in question (I tend to copy it to a temp folder, then rename .gitted to .git. Then run the ahead/behind counts with git itself, and use that to test ahead and behind. (eg, cl_assert_equal_sz(42, ahead)...

@ghost

ghost commented Jun 29, 2019

Copy link
Copy Markdown
Author

Repo for testing.
image

@ghost

ghost commented Jul 7, 2019

Copy link
Copy Markdown
Author

Hi @ethomson - can this reviewed. Thanks.

@ethomson

ethomson commented Jul 8, 2019

Copy link
Copy Markdown
Member

Hi @ethomson - can this reviewed. Thanks.

Sorry @j143-bot, I'm a bit slammed at the moment. I'll 👀 as soon as I can. Apologies for the delay and thanks for your patience.

@pks-t pks-t left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long to review. Only minor nits -- will merge if those were addressed :)

Comment thread tests/graph/ahead_behind.c Outdated
git_oid oid;
cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git")));

git_oid_fromstr(&oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cl_git_pass is missing here

Comment thread tests/graph/ahead_behind.c Outdated

void test_graph_ahead_behind__returns_correct_result(void)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: the empty line here is not required

Comment thread tests/graph/ahead_behind.c Outdated
git_commit *other;

git_oid_fromstr(&oid, "e90810b8df3e80c413d903f631643c716887138d");
git_oid_fromstr(&oid2, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two should be wrapped in cl_git_pass

cl_assert_equal_sz(ahead + 4, behind);

git_commit_free(other);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This newline isn't required, either

_repo = NULL;
}

void test_graph_ahead_behind__returns_correct_result(void)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: the whole function is indented with spaces instead of with tabs

static size_t ahead;
static size_t behind;

void test_graph_ahead_behind__initialize(void)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is indented with spaces, too

@j143

j143 commented Jul 22, 2019

Copy link
Copy Markdown
Contributor

Tried to keep code in 4 spaces = 1 tab style. Let me know, if there are other comments. :)

@pks-t pks-t left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now, always very happy to merge new tests! Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants