diff options
| author | Vicent Martà <tanoku@gmail.com> | 2012-01-24 20:35:15 -0800 |
|---|---|---|
| committer | Vicent Martà <tanoku@gmail.com> | 2012-01-24 20:35:15 -0800 |
| commit | 3fd1520cd4d8b4d6b6493a7d3dc393ffd9abf1db (patch) | |
| tree | 51b29f5d8ffeb31ba751ab2a099e4f2a32d4be07 /tests-clay/repo | |
| parent | a9fe8ae0ee1ddcc289fad53f1a671f02a3e9a88f (diff) | |
| download | libgit2-3fd1520cd4d8b4d6b6493a7d3dc393ffd9abf1db.tar.gz | |
Rename the Clay test suite to Clar
Clay is the name of a programming language on the makings, and we want
to avoid confusions. Sorry for the huge diff!
Diffstat (limited to 'tests-clay/repo')
| -rw-r--r-- | tests-clay/repo/getters.c | 70 | ||||
| -rw-r--r-- | tests-clay/repo/init.c | 106 | ||||
| -rw-r--r-- | tests-clay/repo/open.c | 55 |
3 files changed, 0 insertions, 231 deletions
diff --git a/tests-clay/repo/getters.c b/tests-clay/repo/getters.c deleted file mode 100644 index 426b83e54..000000000 --- a/tests-clay/repo/getters.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "clay_libgit2.h" - -void test_repo_getters__initialize(void) -{ - cl_fixture_sandbox("testrepo.git"); -} - -void test_repo_getters__cleanup(void) -{ - cl_fixture_cleanup("testrepo.git"); -} - -void test_repo_getters__empty(void) -{ - git_repository *repo_empty, *repo_normal; - - cl_git_pass(git_repository_open(&repo_normal, cl_fixture("testrepo.git"))); - cl_assert(git_repository_is_empty(repo_normal) == 0); - git_repository_free(repo_normal); - - cl_git_pass(git_repository_open(&repo_empty, cl_fixture("empty_bare.git"))); - cl_assert(git_repository_is_empty(repo_empty) == 1); - git_repository_free(repo_empty); -} - -void test_repo_getters__head_detached(void) -{ - git_repository *repo; - git_reference *ref; - git_oid oid; - - cl_git_pass(git_repository_open(&repo, "testrepo.git")); - - cl_assert(git_repository_head_detached(repo) == 0); - - /* detach the HEAD */ - git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd"); - cl_git_pass(git_reference_create_oid(&ref, repo, "HEAD", &oid, 1)); - cl_assert(git_repository_head_detached(repo) == 1); - git_reference_free(ref); - - /* take the reop back to it's original state */ - cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1)); - cl_assert(git_repository_head_detached(repo) == 0); - - git_reference_free(ref); - git_repository_free(repo); -} - -void test_repo_getters__head_orphan(void) -{ - git_repository *repo; - git_reference *ref; - - cl_git_pass(git_repository_open(&repo, "testrepo.git")); - - cl_assert(git_repository_head_orphan(repo) == 0); - - /* orphan HEAD */ - cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/orphan", 1)); - cl_assert(git_repository_head_orphan(repo) == 1); - git_reference_free(ref); - - /* take the reop back to it's original state */ - cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1)); - cl_assert(git_repository_head_orphan(repo) == 0); - - git_reference_free(ref); - git_repository_free(repo); -} diff --git a/tests-clay/repo/init.c b/tests-clay/repo/init.c deleted file mode 100644 index e235ffaeb..000000000 --- a/tests-clay/repo/init.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "clay_libgit2.h" -#include "fileops.h" - -enum repo_mode { - STANDARD_REPOSITORY = 0, - BARE_REPOSITORY = 1 -}; - -static git_repository *_repo; - -void test_repo_init__initialize(void) -{ - _repo = NULL; -} - -static void cleanup_repository(void *path) -{ - git_repository_free(_repo); - cl_fixture_cleanup((const char *)path); -} - -static void ensure_repository_init( - const char *working_directory, - int is_bare, - const char *expected_path_repository, - const char *expected_working_directory) -{ - const char *workdir; - - cl_git_pass(git_repository_init(&_repo, working_directory, is_bare)); - - workdir = git_repository_workdir(_repo); - if (workdir != NULL || expected_working_directory != NULL) { - cl_assert( - git__suffixcmp(workdir, expected_working_directory) == 0 - ); - } - - cl_assert( - git__suffixcmp(git_repository_path(_repo), expected_path_repository) == 0 - ); - - cl_assert(git_repository_is_bare(_repo) == is_bare); - -#ifdef GIT_WIN32 - if (!is_bare) { - cl_assert((GetFileAttributes(git_repository_path(_repo)) & FILE_ATTRIBUTE_HIDDEN) != 0); - } -#endif - - cl_assert(git_repository_is_empty(_repo)); -} - -void test_repo_init__standard_repo(void) -{ - cl_set_cleanup(&cleanup_repository, "testrepo"); - ensure_repository_init("testrepo/", 0, "testrepo/.git/", "testrepo/"); -} - -void test_repo_init__standard_repo_noslash(void) -{ - cl_set_cleanup(&cleanup_repository, "testrepo"); - ensure_repository_init("testrepo", 0, "testrepo/.git/", "testrepo/"); -} - -void test_repo_init__bare_repo(void) -{ - cl_set_cleanup(&cleanup_repository, "testrepo.git"); - ensure_repository_init("testrepo.git/", 1, "testrepo.git/", NULL); -} - -void test_repo_init__bare_repo_noslash(void) -{ - cl_set_cleanup(&cleanup_repository, "testrepo.git"); - ensure_repository_init("testrepo.git", 1, "testrepo.git/", NULL); -} - -#if 0 -BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory") - git_buf path_repository = GIT_BUF_INIT; - char current_workdir[GIT_PATH_MAX]; - const mode_t mode = 0777; - git_repository* repo; - - must_pass(p_getcwd(current_workdir, sizeof(current_workdir))); - - must_pass(git_buf_joinpath(&path_repository, TEMP_REPO_FOLDER, "a/b/c/")); - must_pass(git_futils_mkdir_r(path_repository.ptr, mode)); - - must_pass(chdir(path_repository.ptr)); - - git_buf_free(&path_repository); - - must_pass(git_repository_init(&repo, "../d/e.git", 1)); - must_pass(git__suffixcmp(git_repository_path(_repo), "/a/b/d/e.git/")); - - git_repository_free(repo); - - must_pass(git_repository_open(&repo, "../d/e.git")); - - git_repository_free(repo); - - must_pass(chdir(current_workdir)); - must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1)); -END_TEST -#endif diff --git a/tests-clay/repo/open.c b/tests-clay/repo/open.c deleted file mode 100644 index 05b01ceb2..000000000 --- a/tests-clay/repo/open.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "clay_libgit2.h" -#include "posix.h" - -void test_repo_open__bare_empty_repo(void) -{ - git_repository *repo; - - cl_git_pass(git_repository_open(&repo, cl_fixture("empty_bare.git"))); - cl_assert(git_repository_path(repo) != NULL); - cl_assert(git_repository_workdir(repo) == NULL); - - git_repository_free(repo); -} - -void test_repo_open__standard_empty_repo(void) -{ - git_repository *repo; - - cl_git_pass(git_repository_open(&repo, cl_fixture("empty_standard_repo/.gitted"))); - cl_assert(git_repository_path(repo) != NULL); - cl_assert(git_repository_workdir(repo) != NULL); - - git_repository_free(repo); -} - -/* TODO TODO */ -#if 0 -BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of the current working directory") - char current_workdir[GIT_PATH_MAX]; - git_buf new_current_workdir = GIT_BUF_INIT; - git_buf path_repository = GIT_BUF_INIT; - - const mode_t mode = 0777; - git_repository* repo; - - /* Setup the repository to open */ - must_pass(p_getcwd(current_workdir, sizeof(current_workdir))); - must_pass(git_buf_join_n(&path_repository, 3, current_workdir, TEMP_REPO_FOLDER, "a/d/e.git")); - must_pass(copydir_recurs(REPOSITORY_FOLDER, path_repository.ptr)); - git_buf_free(&path_repository); - - /* Change the current working directory */ - must_pass(git_buf_joinpath(&new_current_workdir, TEMP_REPO_FOLDER, "a/b/c/")); - must_pass(git_futils_mkdir_r(new_current_workdir.ptr, mode)); - must_pass(chdir(new_current_workdir.ptr)); - git_buf_free(&new_current_workdir); - - must_pass(git_repository_open(&repo, "../../d/e.git")); - - git_repository_free(repo); - - must_pass(chdir(current_workdir)); - must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1)); -END_TEST -#endif |
