mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-22 08:00:07 +00:00
Merge pull request #1164 from scunz/fixtestleak
Fix some leaks in tests
This commit is contained in:
commit
6b459a1ce3
@ -6,6 +6,7 @@
|
|||||||
static git_clone_options g_options;
|
static git_clone_options g_options;
|
||||||
static git_remote *g_origin;
|
static git_remote *g_origin;
|
||||||
static git_repository *g_repo;
|
static git_repository *g_repo;
|
||||||
|
static git_repository *g_repo_cloned;
|
||||||
|
|
||||||
void test_clone_empty__initialize(void)
|
void test_clone_empty__initialize(void)
|
||||||
{
|
{
|
||||||
@ -29,6 +30,9 @@ void test_clone_empty__cleanup(void)
|
|||||||
static void cleanup_repository(void *path)
|
static void cleanup_repository(void *path)
|
||||||
{
|
{
|
||||||
cl_fixture_cleanup((const char *)path);
|
cl_fixture_cleanup((const char *)path);
|
||||||
|
|
||||||
|
git_repository_free(g_repo_cloned);
|
||||||
|
g_repo_cloned = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
|
void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
|
||||||
@ -40,7 +44,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
|
|||||||
cl_git_pass(git_remote_new(&g_origin, NULL, "origin", "./empty_bare.git", GIT_REMOTE_DEFAULT_FETCH));
|
cl_git_pass(git_remote_new(&g_origin, NULL, "origin", "./empty_bare.git", GIT_REMOTE_DEFAULT_FETCH));
|
||||||
|
|
||||||
g_options.bare = true;
|
g_options.bare = true;
|
||||||
cl_git_pass(git_clone(&g_repo, g_origin, "./empty", &g_options));
|
cl_git_pass(git_clone(&g_repo_cloned, g_origin, "./empty", &g_options));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_clone_empty__can_clone_an_empty_local_repo(void)
|
void test_clone_empty__can_clone_an_empty_local_repo(void)
|
||||||
@ -51,7 +55,7 @@ void test_clone_empty__can_clone_an_empty_local_repo(void)
|
|||||||
g_origin = NULL;
|
g_origin = NULL;
|
||||||
cl_git_pass(git_remote_new(&g_origin, NULL, "origin", "./empty_bare.git", GIT_REMOTE_DEFAULT_FETCH));
|
cl_git_pass(git_remote_new(&g_origin, NULL, "origin", "./empty_bare.git", GIT_REMOTE_DEFAULT_FETCH));
|
||||||
|
|
||||||
cl_git_pass(git_clone(&g_repo, g_origin, "./empty", &g_options));
|
cl_git_pass(git_clone(&g_repo_cloned, g_origin, "./empty", &g_options));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_clone_empty__can_clone_an_empty_standard_repo(void)
|
void test_clone_empty__can_clone_an_empty_standard_repo(void)
|
||||||
@ -66,5 +70,5 @@ void test_clone_empty__can_clone_an_empty_standard_repo(void)
|
|||||||
|
|
||||||
cl_set_cleanup(&cleanup_repository, "./empty");
|
cl_set_cleanup(&cleanup_repository, "./empty");
|
||||||
|
|
||||||
cl_git_pass(git_clone(&g_repo, g_origin, "./empty", &g_options));
|
cl_git_pass(git_clone(&g_repo_cloned, g_origin, "./empty", &g_options));
|
||||||
}
|
}
|
||||||
|
@ -146,18 +146,22 @@ void test_diff_index__checks_options_version(void)
|
|||||||
const char *a_commit = "26a125ee1bf";
|
const char *a_commit = "26a125ee1bf";
|
||||||
git_tree *a = resolve_commit_oid_to_tree(g_repo, a_commit);
|
git_tree *a = resolve_commit_oid_to_tree(g_repo, a_commit);
|
||||||
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
||||||
git_diff_list *diff;
|
git_diff_list *diff = NULL;
|
||||||
const git_error *err;
|
const git_error *err;
|
||||||
|
|
||||||
opts.version = 0;
|
opts.version = 0;
|
||||||
cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
|
cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
|
||||||
err = giterr_last();
|
err = giterr_last();
|
||||||
cl_assert_equal_i(GITERR_INVALID, err->klass);
|
cl_assert_equal_i(GITERR_INVALID, err->klass);
|
||||||
|
cl_assert_equal_p(diff, NULL);
|
||||||
|
|
||||||
giterr_clear();
|
giterr_clear();
|
||||||
opts.version = 1024;
|
opts.version = 1024;
|
||||||
cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
|
cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
|
||||||
err = giterr_last();
|
err = giterr_last();
|
||||||
cl_assert_equal_i(GITERR_INVALID, err->klass);
|
cl_assert_equal_i(GITERR_INVALID, err->klass);
|
||||||
|
cl_assert_equal_p(diff, NULL);
|
||||||
|
|
||||||
|
git_tree_free(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +172,7 @@ void test_network_remotes__missing_refspecs(void)
|
|||||||
git_config *cfg;
|
git_config *cfg;
|
||||||
|
|
||||||
git_remote_free(_remote);
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
|
|
||||||
cl_git_pass(git_repository_config(&cfg, _repo));
|
cl_git_pass(git_repository_config(&cfg, _repo));
|
||||||
cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com"));
|
cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com"));
|
||||||
@ -200,11 +201,17 @@ void test_network_remotes__list(void)
|
|||||||
|
|
||||||
void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
|
void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
|
||||||
{
|
{
|
||||||
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
|
|
||||||
cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
|
cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_network_remotes__loading_with_an_invalid_name_returns_EINVALIDSPEC(void)
|
void test_network_remotes__loading_with_an_invalid_name_returns_EINVALIDSPEC(void)
|
||||||
{
|
{
|
||||||
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
|
|
||||||
cl_assert_equal_i(GIT_EINVALIDSPEC, git_remote_load(&_remote, _repo, "Inv@{id"));
|
cl_assert_equal_i(GIT_EINVALIDSPEC, git_remote_load(&_remote, _repo, "Inv@{id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,8 +227,12 @@ void test_network_remotes__loading_with_an_invalid_name_returns_EINVALIDSPEC(voi
|
|||||||
void test_network_remotes__add(void)
|
void test_network_remotes__add(void)
|
||||||
{
|
{
|
||||||
git_remote_free(_remote);
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
|
|
||||||
cl_git_pass(git_remote_add(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2"));
|
cl_git_pass(git_remote_add(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2"));
|
||||||
|
|
||||||
git_remote_free(_remote);
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
|
|
||||||
cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
|
cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
|
||||||
_refspec = git_remote_fetchspec(_remote);
|
_refspec = git_remote_fetchspec(_remote);
|
||||||
@ -252,28 +263,32 @@ void test_network_remotes__cannot_save_a_nameless_remote(void)
|
|||||||
|
|
||||||
void test_network_remotes__cannot_add_a_remote_with_an_invalid_name(void)
|
void test_network_remotes__cannot_add_a_remote_with_an_invalid_name(void)
|
||||||
{
|
{
|
||||||
git_remote *remote;
|
git_remote *remote = NULL;
|
||||||
|
|
||||||
cl_assert_equal_i(
|
cl_assert_equal_i(
|
||||||
GIT_EINVALIDSPEC,
|
GIT_EINVALIDSPEC,
|
||||||
git_remote_add(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2"));
|
git_remote_add(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2"));
|
||||||
|
cl_assert_equal_p(remote, NULL);
|
||||||
|
|
||||||
cl_assert_equal_i(
|
cl_assert_equal_i(
|
||||||
GIT_EINVALIDSPEC,
|
GIT_EINVALIDSPEC,
|
||||||
git_remote_add(&remote, _repo, "", "git://github.com/libgit2/libgit2"));
|
git_remote_add(&remote, _repo, "", "git://github.com/libgit2/libgit2"));
|
||||||
|
cl_assert_equal_p(remote, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_network_remotes__cannot_initialize_a_remote_with_an_invalid_name(void)
|
void test_network_remotes__cannot_initialize_a_remote_with_an_invalid_name(void)
|
||||||
{
|
{
|
||||||
git_remote *remote;
|
git_remote *remote = NULL;
|
||||||
|
|
||||||
cl_assert_equal_i(
|
cl_assert_equal_i(
|
||||||
GIT_EINVALIDSPEC,
|
GIT_EINVALIDSPEC,
|
||||||
git_remote_new(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2", NULL));
|
git_remote_new(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2", NULL));
|
||||||
|
cl_assert_equal_p(remote, NULL);
|
||||||
|
|
||||||
cl_assert_equal_i(
|
cl_assert_equal_i(
|
||||||
GIT_EINVALIDSPEC,
|
GIT_EINVALIDSPEC,
|
||||||
git_remote_new(&remote, _repo, "", "git://github.com/libgit2/libgit2", NULL));
|
git_remote_new(&remote, _repo, "", "git://github.com/libgit2/libgit2", NULL));
|
||||||
|
cl_assert_equal_p(remote, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_network_remotes__tagopt(void)
|
void test_network_remotes__tagopt(void)
|
||||||
@ -302,10 +317,11 @@ void test_network_remotes__tagopt(void)
|
|||||||
|
|
||||||
void test_network_remotes__cannot_load_with_an_empty_url(void)
|
void test_network_remotes__cannot_load_with_an_empty_url(void)
|
||||||
{
|
{
|
||||||
git_remote *remote;
|
git_remote *remote = NULL;
|
||||||
|
|
||||||
cl_git_fail(git_remote_load(&remote, _repo, "empty-remote-url"));
|
cl_git_fail(git_remote_load(&remote, _repo, "empty-remote-url"));
|
||||||
cl_assert(giterr_last()->klass == GITERR_INVALID);
|
cl_assert(giterr_last()->klass == GITERR_INVALID);
|
||||||
|
cl_assert_equal_p(remote, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_network_remotes__check_structure_version(void)
|
void test_network_remotes__check_structure_version(void)
|
||||||
@ -314,6 +330,7 @@ void test_network_remotes__check_structure_version(void)
|
|||||||
const git_error *err;
|
const git_error *err;
|
||||||
|
|
||||||
git_remote_free(_remote);
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
cl_git_pass(git_remote_new(&_remote, _repo, NULL, "test-protocol://localhost", NULL));
|
cl_git_pass(git_remote_new(&_remote, _repo, NULL, "test-protocol://localhost", NULL));
|
||||||
|
|
||||||
transport.version = 0;
|
transport.version = 0;
|
||||||
@ -330,6 +347,9 @@ void test_network_remotes__check_structure_version(void)
|
|||||||
|
|
||||||
void test_network_remotes__dangling(void)
|
void test_network_remotes__dangling(void)
|
||||||
{
|
{
|
||||||
|
git_remote_free(_remote);
|
||||||
|
_remote = NULL;
|
||||||
|
|
||||||
cl_git_pass(git_remote_new(&_remote, NULL, "upstream", "git://github.com/libgit2/libgit2", NULL));
|
cl_git_pass(git_remote_new(&_remote, NULL, "upstream", "git://github.com/libgit2/libgit2", NULL));
|
||||||
|
|
||||||
cl_git_pass(git_remote_rename(_remote, "newname", NULL, NULL));
|
cl_git_pass(git_remote_rename(_remote, "newname", NULL, NULL));
|
||||||
|
@ -15,6 +15,9 @@ void test_revwalk_mergebase__cleanup(void)
|
|||||||
{
|
{
|
||||||
git_repository_free(_repo);
|
git_repository_free(_repo);
|
||||||
_repo = NULL;
|
_repo = NULL;
|
||||||
|
|
||||||
|
git_repository_free(_repo2);
|
||||||
|
_repo2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_revwalk_mergebase__single1(void)
|
void test_revwalk_mergebase__single1(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user