Permalink
Browse files

tests: Cleanup & fix test suite

  • Loading branch information...
1 parent 16eaa15 commit 471bb8b120fab5969df5778aa5c8d1c22c30d876 @vmg vmg committed Apr 3, 2012
View
4 tests-clar/commit/write.c
@@ -77,10 +77,6 @@ void test_commit_write__from_memory(void)
cl_assert(committer1->when.offset == 60);
cl_assert(strcmp(git_commit_message(commit), commit_message) == 0);
-
-#ifndef GIT_WIN32
- cl_assert((loose_object_mode(REPOSITORY_FOLDER, (git_object *)commit) & 0777) == GIT_OBJECT_FILE_MODE);
-#endif
}
View
1 tests-clar/index/tests.c
@@ -30,7 +30,6 @@ static void copy_file(const char *src, const char *dst)
{
git_buf source_buf = GIT_BUF_INIT;
git_file dst_fd;
- int error = GIT_ERROR;
cl_git_pass(git_futils_readbuffer(&source_buf, src));
View
68 tests-clar/object/tag/write.c
@@ -9,56 +9,6 @@ static const char *tagged_commit = "e90810b8df3e80c413d903f631643c716887138d";
static git_repository *g_repo;
-
-// Helpers
-#ifndef GIT_WIN32
-#include "odb.h"
-
-static void locate_loose_object(const char *repository_folder,
- git_object *object,
- char **out,
- char **out_folder)
-{
- static const char *objects_folder = "objects/";
-
- char *ptr, *full_path, *top_folder;
- int path_length, objects_length;
-
- assert(repository_folder && object);
-
- objects_length = strlen(objects_folder);
- path_length = strlen(repository_folder);
- ptr = full_path = git__malloc(path_length + objects_length + GIT_OID_HEXSZ + 3);
-
- strcpy(ptr, repository_folder);
- strcpy(ptr + path_length, objects_folder);
-
- ptr = top_folder = ptr + path_length + objects_length;
- *ptr++ = '/';
- git_oid_pathfmt(ptr, git_object_id(object));
- ptr += GIT_OID_HEXSZ + 1;
- *ptr = 0;
-
- *out = full_path;
-
- if (out_folder)
- *out_folder = top_folder;
-}
-
-static void loose_object_mode(const char *repository_folder, git_object *object)
-{
- char *object_path;
- struct stat st;
-
- locate_loose_object(repository_folder, object, &object_path, NULL);
- cl_git_pass(p_stat(object_path, &st));
- free(object_path);
- cl_assert((st.st_mode & 0777) == GIT_OBJECT_FILE_MODE);
-}
-#endif
-
-
-
// Fixture setup and teardown
void test_object_tag_write__initialize(void)
{
@@ -70,8 +20,6 @@ void test_object_tag_write__cleanup(void)
cl_git_sandbox_cleanup();
}
-
-
void test_object_tag_write__basic(void)
{
// write a tag to the repository and read it again
@@ -88,14 +36,10 @@ void test_object_tag_write__basic(void)
/* create signature */
cl_git_pass(git_signature_new(&tagger, tagger_name, tagger_email, 123456789, 60));
- cl_git_pass(git_tag_create(
- &tag_id, /* out id */
- g_repo,
- "the-tag",
- target,
- tagger,
- tagger_message,
- 0));
+ cl_git_pass(
+ git_tag_create(&tag_id, g_repo,
+ "the-tag", target, tagger, tagger_message, 0)
+ );
git_object_free(target);
git_signature_free(tagger);
@@ -116,10 +60,6 @@ void test_object_tag_write__basic(void)
cl_git_pass(git_reference_lookup(&ref_tag, g_repo, "refs/tags/the-tag"));
cl_assert(git_oid_cmp(git_reference_oid(ref_tag), &tag_id) == 0);
cl_git_pass(git_reference_delete(ref_tag));
-#ifndef GIT_WIN32
- // TODO: Get this to work on Linux
- //loose_object_mode("testrepo/", (git_object *)tag);
-#endif
git_tag_free(tag);
}
View
88 tests-clar/object/tree/write.c
@@ -39,74 +39,6 @@ static int print_tree(git_repository *repo, const git_oid *tree_oid, int depth)
return GIT_SUCCESS;
}
-static void locate_loose_object(const char *repository_folder,
- git_object *object,
- char **out,
- char **out_folder)
-{
- static const char *objects_folder = "objects/";
-
- char *ptr, *full_path, *top_folder;
- int path_length, objects_length;
-
- assert(repository_folder && object);
-
- objects_length = strlen(objects_folder);
- path_length = strlen(repository_folder);
- ptr = full_path = git__malloc(path_length + objects_length + GIT_OID_HEXSZ + 3);
-
- strcpy(ptr, repository_folder);
- strcpy(ptr + path_length, objects_folder);
-
- ptr = top_folder = ptr + path_length + objects_length;
- *ptr++ = '/';
- git_oid_pathfmt(ptr, git_object_id(object));
- ptr += GIT_OID_HEXSZ + 1;
- *ptr = 0;
-
- *out = full_path;
-
- if (out_folder)
- *out_folder = top_folder;
-}
-
-static int loose_object_mode(const char *repository_folder, git_object *object)
-{
- char *object_path;
- struct stat st;
-
- locate_loose_object(repository_folder, object, &object_path, NULL);
- if (p_stat(object_path, &st) < 0)
- return 0;
- free(object_path);
-
- return st.st_mode;
-}
-
-static int loose_object_dir_mode(const char *repository_folder, git_object *object)
-{
- char *object_path;
- size_t pos;
- struct stat st;
-
- locate_loose_object(repository_folder, object, &object_path, NULL);
-
- pos = strlen(object_path);
- while (pos--) {
- if (object_path[pos] == '/') {
- object_path[pos] = 0;
- break;
- }
- }
-
- if (p_stat(object_path, &st) < 0)
- return 0;
- free(object_path);
-
- return st.st_mode;
-}
-
-
// Fixture setup and teardown
void test_object_tree_write__initialize(void)
{
@@ -118,21 +50,6 @@ void test_object_tree_write__cleanup(void)
cl_git_sandbox_cleanup();
}
-
-#if 0
-void xtest_object_tree_write__print(void)
-{
- // write a tree from an index
- git_index *index;
- git_oid tree_oid;
-
- cl_git_pass(git_repository_index(&index, g_repo));
-
- cl_git_pass(git_tree_create_fromindex(&tree_oid, index));
- cl_git_pass(print_tree(g_repo, &tree_oid, 0));
-}
-#endif
-
void test_object_tree_write__from_memory(void)
{
// write a tree from a memory
@@ -193,10 +110,5 @@ void test_object_tree_write__subtree(void)
// check data is correct
cl_git_pass(git_tree_lookup(&tree, g_repo, &id_hiearar));
cl_assert(2 == git_tree_entrycount(tree));
-#ifndef GIT_WIN32
- // TODO: fix these
- //cl_assert((loose_object_dir_mode("testrepo", (git_object *)tree) & 0777) == GIT_OBJECT_DIR_MODE);
- //cl_assert((loose_object_mode("testrespo", (git_object *)tree) & 0777) == GIT_OBJECT_FILE_MODE);
-#endif
git_tree_free(tree);
}
View
16 tests-clar/refs/create.c
@@ -9,21 +9,17 @@ static const char *current_head_target = "refs/heads/master";
static git_repository *g_repo;
-
-
-void test_ref_create__initialize(void)
+void test_refs_create__initialize(void)
{
g_repo = cl_git_sandbox_init("testrepo");
}
-void test_ref_create__cleanup(void)
+void test_refs_create__cleanup(void)
{
cl_git_sandbox_cleanup();
}
-
-
-void test_ref_create__symbolic(void)
+void test_refs_create__symbolic(void)
{
// create a new symbolic reference
git_reference *new_reference, *looked_up_ref, *resolved_ref;
@@ -71,7 +67,7 @@ void test_ref_create__symbolic(void)
git_reference_free(resolved_ref);
}
-void test_ref_create__deep_symbolic(void)
+void test_refs_create__deep_symbolic(void)
{
// create a deep symbolic reference
git_reference *new_reference, *looked_up_ref, *resolved_ref;
@@ -94,7 +90,7 @@ void test_ref_create__deep_symbolic(void)
git_buf_free(&ref_path);
}
-void test_ref_create__oid(void)
+void test_refs_create__oid(void)
{
// create a new OID reference
git_reference *new_reference, *looked_up_ref;
@@ -135,7 +131,7 @@ void test_ref_create__oid(void)
git_buf_free(&ref_path);
}
-void test_ref_create__oid_unknown(void)
+void test_refs_create__oid_unknown(void)
{
// Can not create a new OID reference which targets at an unknown id
git_reference *new_reference, *looked_up_ref;
View
16 tests-clar/refs/overwrite.c
@@ -11,21 +11,17 @@ static const char *ref_test_name = "refs/heads/test";
static git_repository *g_repo;
-
-
-void test_ref_overwrite__initialize(void)
+void test_refs_overwrite__initialize(void)
{
g_repo = cl_git_sandbox_init("testrepo");
}
-void test_ref_overwrite__cleanup(void)
+void test_refs_overwrite__cleanup(void)
{
cl_git_sandbox_cleanup();
}
-
-
-void test_ref_overwrite__symbolic(void)
+void test_refs_overwrite__symbolic(void)
{
// Overwrite an existing symbolic reference
git_reference *ref, *branch_ref;
@@ -55,7 +51,7 @@ void test_ref_overwrite__symbolic(void)
git_reference_free(branch_ref);
}
-void test_ref_overwrite__object_id(void)
+void test_refs_overwrite__object_id(void)
{
// Overwrite an existing object id reference
git_reference *ref;
@@ -87,7 +83,7 @@ void test_ref_overwrite__object_id(void)
git_reference_free(ref);
}
-void test_ref_overwrite__object_id_with_symbolic(void)
+void test_refs_overwrite__object_id_with_symbolic(void)
{
// Overwrite an existing object id reference with a symbolic one
git_reference *ref;
@@ -112,7 +108,7 @@ void test_ref_overwrite__object_id_with_symbolic(void)
git_reference_free(ref);
}
-void test_ref_overwrite__symbolic_with_object_id(void)
+void test_refs_overwrite__symbolic_with_object_id(void)
{
// Overwrite an existing symbolic reference with an object id one
git_reference *ref;
View
12 tests-clar/refs/pack.c
@@ -8,21 +8,17 @@ static const char *loose_tag_ref_name = "refs/tags/e90810b";
static git_repository *g_repo;
-
-
-void test_ref_pack__initialize(void)
+void test_refs_pack__initialize(void)
{
g_repo = cl_git_sandbox_init("testrepo");
}
-void test_ref_pack__cleanup(void)
+void test_refs_pack__cleanup(void)
{
cl_git_sandbox_cleanup();
}
-
-
-void test_ref_pack__empty(void)
+void test_refs_pack__empty(void)
{
// create a packfile for an empty folder
git_buf temp_path = GIT_BUF_INIT;
@@ -34,7 +30,7 @@ void test_ref_pack__empty(void)
cl_git_pass(git_reference_packall(g_repo));
}
-void test_ref_pack__loose(void)
+void test_refs_pack__loose(void)
{
// create a packfile from all the loose rn a repo
git_reference *reference;
View
25 tests-clar/refs/read.c
@@ -4,7 +4,6 @@
#include "git2/reflog.h"
#include "reflog.h"
-
static const char *loose_tag_ref_name = "refs/tags/e90810b";
static const char *non_existing_tag_ref_name = "refs/tags/i-do-not-exist";
static const char *head_tracker_sym_ref_name = "head-tracker";
@@ -15,21 +14,17 @@ static const char *packed_test_head_name = "refs/heads/packed-test";
static git_repository *g_repo;
-
-
-void test_ref_read__initialize(void)
+void test_refs_read__initialize(void)
{
g_repo = cl_git_sandbox_init("testrepo");
}
-void test_ref_read__cleanup(void)
+void test_refs_read__cleanup(void)
{
cl_git_sandbox_cleanup();
}
-
-
-void test_ref_read__loose_tag(void)
+void test_refs_read__loose_tag(void)
{
// lookup a loose tag reference
git_reference *reference;
@@ -55,7 +50,7 @@ void test_ref_read__loose_tag(void)
git_reference_free(reference);
}
-void test_ref_read__nonexisting_tag(void)
+void test_refs_read__nonexisting_tag(void)
{
// lookup a loose tag reference that doesn't exist
git_reference *reference;
@@ -66,7 +61,7 @@ void test_ref_read__nonexisting_tag(void)
}
-void test_ref_read__symbolic(void)
+void test_refs_read__symbolic(void)
{
// lookup a symbolic reference
git_reference *reference, *resolved_ref;
@@ -94,7 +89,7 @@ void test_ref_read__symbolic(void)
git_reference_free(resolved_ref);
}
-void test_ref_read__nested_symbolic(void)
+void test_refs_read__nested_symbolic(void)
{
// lookup a nested symbolic reference
git_reference *reference, *resolved_ref;
@@ -122,7 +117,7 @@ void test_ref_read__nested_symbolic(void)
git_reference_free(resolved_ref);
}
-void test_ref_read__head_then_master(void)
+void test_refs_read__head_then_master(void)
{
// lookup the HEAD and resolve the master branch
git_reference *reference, *resolved_ref, *comp_base_ref;
@@ -146,7 +141,7 @@ void test_ref_read__head_then_master(void)
git_reference_free(comp_base_ref);
}
-void test_ref_read__master_then_head(void)
+void test_refs_read__master_then_head(void)
{
// lookup the master branch and then the HEAD
git_reference *reference, *master_ref, *resolved_ref;
@@ -163,7 +158,7 @@ void test_ref_read__master_then_head(void)
}
-void test_ref_read__packed(void)
+void test_refs_read__packed(void)
{
// lookup a packed reference
git_reference *reference;
@@ -183,7 +178,7 @@ void test_ref_read__packed(void)
git_reference_free(reference);
}
-void test_ref_read__loose_first(void)
+void test_refs_read__loose_first(void)
{
// assure that a loose reference is looked up before a packed reference
git_reference *reference;

0 comments on commit 471bb8b

Please sign in to comment.