summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-02-17 00:13:34 +0100
committerVicent Martí <tanoku@gmail.com>2012-03-06 00:43:10 +0100
commit1a48112342932e9fcd45a1ff5935f1c9c53b83d1 (patch)
treefbb18cfe64e65025c6e1790972d1a106eea4cc54 /tests
parent45d387ac78bcf3167d69b736d0b322717bc492d4 (diff)
downloadlibgit2-1a48112342932e9fcd45a1ff5935f1c9c53b83d1.tar.gz
error-handling: References
Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
Diffstat (limited to 'tests')
-rw-r--r--tests/t00-core.c2
-rw-r--r--tests/t03-objwrite.c4
-rw-r--r--tests/t08-tag.c2
-rw-r--r--tests/t10-refs.c34
-rw-r--r--tests/t12-repo.c2
-rw-r--r--tests/test_helpers.c10
6 files changed, 32 insertions, 22 deletions
diff --git a/tests/t00-core.c b/tests/t00-core.c
index 7f142ba21..10e6aaebf 100644
--- a/tests/t00-core.c
+++ b/tests/t00-core.c
@@ -485,7 +485,7 @@ BEGIN_TEST(filebuf0, "make sure git_filebuf_open doesn't delete an existing lock
must_pass(fd);
must_pass(p_close(fd));
must_fail(git_filebuf_open(&file, test, 0));
- must_pass(git_path_exists(testlock));
+ must_be_true(git_path_exists(testlock));
must_pass(p_unlink(testlock));
END_TEST
diff --git a/tests/t03-objwrite.c b/tests/t03-objwrite.c
index 1650b8060..2d4fb1ad7 100644
--- a/tests/t03-objwrite.c
+++ b/tests/t03-objwrite.c
@@ -44,9 +44,9 @@ static int make_odb_dir(void)
static int check_object_files(object_data *d)
{
- if (git_path_exists(d->dir) < 0)
+ if (git_path_exists(d->dir) == false)
return -1;
- if (git_path_exists(d->file) < 0)
+ if (git_path_exists(d->file) == false)
return -1;
return 0;
}
diff --git a/tests/t08-tag.c b/tests/t08-tag.c
index eacbb3ae1..4cbd48379 100644
--- a/tests/t08-tag.c
+++ b/tests/t08-tag.c
@@ -337,8 +337,6 @@ BEGIN_TEST(delete0, "Delete an already existing tag")
must_fail(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b"));
close_temp_repo(repo);
-
- git_reference_free(ref_tag);
END_TEST
BEGIN_SUITE(tag)
diff --git a/tests/t10-refs.c b/tests/t10-refs.c
index 63d1cb7d1..ad881726e 100644
--- a/tests/t10-refs.c
+++ b/tests/t10-refs.c
@@ -69,7 +69,6 @@ BEGIN_TEST(readtag1, "lookup a loose tag reference that doesn't exist")
must_fail(git_reference_lookup(&reference, repo, non_existing_tag_ref_name));
git_repository_free(repo);
-
git_reference_free(reference);
END_TEST
@@ -530,7 +529,7 @@ BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo")
/* Ensure the packed-refs file exists */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, GIT_PACKEDREFS_FILE));
- must_pass(git_path_exists(temp_path.ptr));
+ must_be_true(git_path_exists(temp_path.ptr));
/* Ensure the known ref can still be looked up but is now packed */
must_pass(git_reference_lookup(&reference, repo, loose_tag_ref_name));
@@ -539,7 +538,7 @@ BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo")
/* Ensure the known ref has been removed from the loose folder structure */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, loose_tag_ref_name));
- must_pass(!git_path_exists(temp_path.ptr));
+ must_be_true(!git_path_exists(temp_path.ptr));
close_temp_repo(repo);
@@ -557,7 +556,7 @@ BEGIN_TEST(rename0, "rename a loose reference")
/* Ensure the ref doesn't exist on the file system */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, new_name));
- must_pass(!git_path_exists(temp_path.ptr));
+ must_be_true(!git_path_exists(temp_path.ptr));
/* Retrieval of the reference to rename */
must_pass(git_reference_lookup(&looked_up_ref, repo, loose_tag_ref_name));
@@ -582,7 +581,7 @@ BEGIN_TEST(rename0, "rename a loose reference")
/* ...and the ref can be found in the file system */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, new_name));
- must_pass(git_path_exists(temp_path.ptr));
+ must_be_true(git_path_exists(temp_path.ptr));
close_temp_repo(repo);
@@ -601,7 +600,7 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)")
/* Ensure the ref doesn't exist on the file system */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, packed_head_name));
- must_pass(!git_path_exists(temp_path.ptr));
+ must_be_true(!git_path_exists(temp_path.ptr));
/* The reference can however be looked-up... */
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_head_name));
@@ -626,7 +625,7 @@ BEGIN_TEST(rename1, "rename a packed reference (should make it loose)")
/* ...and the ref now happily lives in the file system */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, brand_new_name));
- must_pass(git_path_exists(temp_path.ptr));
+ must_be_true(git_path_exists(temp_path.ptr));
close_temp_repo(repo);
@@ -645,7 +644,7 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference
/* Ensure the other reference exists on the file system */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, packed_test_head_name));
- must_pass(git_path_exists(temp_path.ptr));
+ must_be_true(git_path_exists(temp_path.ptr));
/* Lookup the other reference */
must_pass(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name));
@@ -670,7 +669,7 @@ BEGIN_TEST(rename2, "renaming a packed reference does not pack another reference
must_be_true(git_reference_is_packed(another_looked_up_ref) == 0);
/* Ensure the other ref still exists on the file system */
- must_pass(git_path_exists(temp_path.ptr));
+ must_be_true(git_path_exists(temp_path.ptr));
close_temp_repo(repo);
@@ -857,6 +856,18 @@ BEGIN_TEST(rename8, "can be renamed to a new name prefixed with the old name")
END_TEST
BEGIN_TEST(rename9, "can move a reference to a upper reference hierarchy")
+ /*
+ * I'm killing this test because it adds a shitton of complexity
+ * to the reference renaming code for an use case which I'd consider
+ * "clinically stupid".
+ *
+ * If somebody shows me a workflow which involves turning a reference
+ * into a folder with its same name, we'll bring back the ridiculous
+ * logic.
+ *
+ * -Vicent
+ */
+#if 0
git_reference *ref, *ref_two, *looked_up_ref;
git_repository *repo;
git_oid id;
@@ -888,6 +899,7 @@ BEGIN_TEST(rename9, "can move a reference to a upper reference hierarchy")
git_reference_free(looked_up_ref);
close_temp_repo(repo);
+#endif
END_TEST
BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove both tracks in the filesystem")
@@ -899,7 +911,7 @@ BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove
/* Ensure the loose reference exists on the file system */
must_pass(git_buf_joinpath(&temp_path, repo->path_repository, packed_test_head_name));
- must_pass(git_path_exists(temp_path.ptr));
+ must_be_true(git_path_exists(temp_path.ptr));
/* Lookup the reference */
must_pass(git_reference_lookup(&looked_up_ref, repo, packed_test_head_name));
@@ -914,7 +926,7 @@ BEGIN_TEST(delete0, "deleting a ref which is both packed and loose should remove
must_fail(git_reference_lookup(&another_looked_up_ref, repo, packed_test_head_name));
/* Ensure the loose reference doesn't exist any longer on the file system */
- must_pass(!git_path_exists(temp_path.ptr));
+ must_be_true(!git_path_exists(temp_path.ptr));
close_temp_repo(repo);
diff --git a/tests/t12-repo.c b/tests/t12-repo.c
index 6a080ecb3..7c45e0126 100644
--- a/tests/t12-repo.c
+++ b/tests/t12-repo.c
@@ -68,7 +68,7 @@ static int write_file(const char *path, const char *content)
int error;
git_file file;
- if (git_path_exists(path) == GIT_SUCCESS) {
+ if (git_path_exists(path) == true) {
error = p_unlink(path);
if (error < GIT_SUCCESS)
diff --git a/tests/test_helpers.c b/tests/test_helpers.c
index 837358453..9ed0d79d8 100644
--- a/tests/test_helpers.c
+++ b/tests/test_helpers.c
@@ -239,7 +239,7 @@ static int copy_filesystem_element_recurs(void *_data, git_buf *source)
git_buf_truncate(&data->dst, data->dst_baselen);
git_buf_puts(&data->dst, source->ptr + data->src_baselen);
- if (git_path_isdir(source->ptr) == GIT_SUCCESS)
+ if (git_path_isdir(source->ptr) == true)
return git_path_direach(source, copy_filesystem_element_recurs, _data);
else
return copy_file(source->ptr, data->dst.ptr);
@@ -253,8 +253,8 @@ int copydir_recurs(
copydir_data data = { GIT_BUF_INIT, 0, GIT_BUF_INIT, 0 };
/* Source has to exist, Destination hast to _not_ exist */
- if (git_path_isdir(source_directory_path) != GIT_SUCCESS ||
- git_path_isdir(destination_directory_path) == GIT_SUCCESS)
+ if (git_path_isdir(source_directory_path) == false ||
+ git_path_isdir(destination_directory_path) == true)
return GIT_EINVALIDPATH;
git_buf_joinpath(&data.src, source_directory_path, "");
@@ -299,7 +299,7 @@ static int remove_placeholders_recurs(void *_data, git_buf *path)
remove_data *data = (remove_data *)_data;
size_t pathlen;
- if (!git_path_isdir(path->ptr))
+ if (git_path_isdir(path->ptr) == true)
return git_path_direach(path, remove_placeholders_recurs, data);
pathlen = path->size;
@@ -322,7 +322,7 @@ int remove_placeholders(const char *directory_path, const char *filename)
remove_data data;
git_buf buffer = GIT_BUF_INIT;
- if (git_path_isdir(directory_path))
+ if (git_path_isdir(directory_path) == false)
return GIT_EINVALIDPATH;
if ((error = git_buf_sets(&buffer, directory_path)) < GIT_SUCCESS)