mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 10:37:05 +00:00
tests: add a test for tag autofollow behaviour
Also tell ctest and valgrind to run libgit2_clar with '-iall' so we run the network tests in travis.
This commit is contained in:
parent
9206976fc7
commit
a75770febc
@ -32,7 +32,7 @@ script:
|
|||||||
# Run Tests
|
# Run Tests
|
||||||
after_script:
|
after_script:
|
||||||
- ctest -V .
|
- ctest -V .
|
||||||
- if [ -f ./libgit2_clar ]; then valgrind --leak-check=full --show-reachable=yes --suppressions=../libgit2_clar.supp ./libgit2_clar; else echo "Skipping valgrind"; fi
|
- if [ -f ./libgit2_clar ]; then valgrind --leak-check=full --show-reachable=yes --suppressions=../libgit2_clar.supp ./libgit2_clar -iall; else echo "Skipping valgrind"; fi
|
||||||
|
|
||||||
# Only watch the development branch
|
# Only watch the development branch
|
||||||
branches:
|
branches:
|
||||||
|
@ -213,7 +213,7 @@ IF (BUILD_CLAR)
|
|||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
ADD_TEST(libgit2_clar libgit2_clar)
|
ADD_TEST(libgit2_clar libgit2_clar -iall)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TAGS)
|
IF (TAGS)
|
||||||
|
70
tests-clar/network/fetch.c
Normal file
70
tests-clar/network/fetch.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include "clar_libgit2.h"
|
||||||
|
|
||||||
|
CL_IN_CATEGORY("network")
|
||||||
|
|
||||||
|
static git_repository *_repo;
|
||||||
|
static int counter;
|
||||||
|
|
||||||
|
void test_network_fetch__initialize(void)
|
||||||
|
{
|
||||||
|
cl_git_pass(git_repository_init(&_repo, "./fetch", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_network_fetch__cleanup(void)
|
||||||
|
{
|
||||||
|
git_repository_free(_repo);
|
||||||
|
cl_fixture_cleanup("./fetch");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int update_tips(const char *refname, const git_oid *a, const git_oid *b, void *data)
|
||||||
|
{
|
||||||
|
refname = refname;
|
||||||
|
a = a;
|
||||||
|
b = b;
|
||||||
|
data = data;
|
||||||
|
|
||||||
|
++counter;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void do_fetch(const char *url, int flag, int n)
|
||||||
|
{
|
||||||
|
git_remote *remote;
|
||||||
|
git_off_t bytes;
|
||||||
|
git_indexer_stats stats;
|
||||||
|
git_remote_callbacks callbacks;
|
||||||
|
|
||||||
|
memset(&callbacks, 0, sizeof(git_remote_callbacks));
|
||||||
|
callbacks.update_tips = update_tips;
|
||||||
|
counter = 0;
|
||||||
|
|
||||||
|
cl_git_pass(git_remote_add(&remote, _repo, "test", url));
|
||||||
|
git_remote_set_callbacks(remote, &callbacks);
|
||||||
|
git_remote_set_autotag(remote, flag);
|
||||||
|
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
|
||||||
|
cl_git_pass(git_remote_download(remote, &bytes, &stats));
|
||||||
|
git_remote_disconnect(remote);
|
||||||
|
cl_git_pass(git_remote_update_tips(remote));
|
||||||
|
cl_assert_equal_i(counter, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_network_fetch__default_git(void)
|
||||||
|
{
|
||||||
|
do_fetch("git://github.com/libgit2/TestGitRepository.git", GIT_REMOTE_DOWNLOAD_TAGS_AUTO, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_network_fetch__default_http(void)
|
||||||
|
{
|
||||||
|
do_fetch("http://github.com/libgit2/TestGitRepository.git", GIT_REMOTE_DOWNLOAD_TAGS_AUTO, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_network_fetch__no_tags_git(void)
|
||||||
|
{
|
||||||
|
do_fetch("git://github.com/libgit2/TestGitRepository.git", GIT_REMOTE_DOWNLOAD_TAGS_NONE, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_network_fetch__no_tags_http(void)
|
||||||
|
{
|
||||||
|
do_fetch("http://github.com/libgit2/TestGitRepository.git", GIT_REMOTE_DOWNLOAD_TAGS_NONE, 3);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user