Moved more assertions inside Clar test helpers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 73b0086..0f075a0 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -26,49 +26,43 @@ static struct test_entry test_entries[] = {
// Helpers
-static int copy_file(const char *src, const char *dst)
+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;
- if (git_futils_readbuffer(&source_buf, src) < GIT_SUCCESS)
- return GIT_ENOTFOUND;
+ cl_git_pass(git_futils_readbuffer(&source_buf, src));
dst_fd = git_futils_creat_withpath(dst, 0777, 0666);
if (dst_fd < 0)
goto cleanup;
- error = p_write(dst_fd, source_buf.ptr, source_buf.size);
+ cl_git_pass(p_write(dst_fd, source_buf.ptr, source_buf.size));
cleanup:
git_buf_free(&source_buf);
p_close(dst_fd);
-
- return error;
}
-static int cmp_files(const char *a, const char *b)
+static void files_are_equal(const char *a, const char *b)
{
git_buf buf_a = GIT_BUF_INIT;
git_buf buf_b = GIT_BUF_INIT;
- int error = GIT_ERROR;
+ int pass;
if (git_futils_readbuffer(&buf_a, a) < GIT_SUCCESS)
- return GIT_ERROR;
+ cl_assert(0);
if (git_futils_readbuffer(&buf_b, b) < GIT_SUCCESS) {
git_buf_free(&buf_a);
- return GIT_ERROR;
+ cl_assert(0);
}
- if (buf_a.size == buf_b.size && !memcmp(buf_a.ptr, buf_b.ptr, buf_a.size))
- error = GIT_SUCCESS;
+ pass = (buf_a.size == buf_b.size && !memcmp(buf_a.ptr, buf_b.ptr, buf_a.size));
git_buf_free(&buf_a);
git_buf_free(&buf_b);
-
- return error;
}
@@ -168,13 +162,13 @@ void test_index_tests__write(void)
{
git_index *index;
- cl_git_pass(copy_file(TEST_INDEXBIG_PATH, "index_rewrite"));
+ copy_file(TEST_INDEXBIG_PATH, "index_rewrite");
cl_git_pass(git_index_open(&index, "index_rewrite"));
cl_assert(index->on_disk);
cl_git_pass(git_index_write(index));
- cl_git_pass(cmp_files(TEST_INDEXBIG_PATH, "index_rewrite"));
+ files_are_equal(TEST_INDEXBIG_PATH, "index_rewrite");
git_index_free(index);
diff --git a/tests-clar/object/raw/hash.c b/tests-clar/object/raw/hash.c
index 2375851..4b8b1b7 100644
--- a/tests-clar/object/raw/hash.c
+++ b/tests-clar/object/raw/hash.c
@@ -6,9 +6,13 @@
#include "data.h"
-static int hash_object(git_oid *oid, git_rawobj *obj)
+static void hash_object_pass(git_oid *oid, git_rawobj *obj)
{
- return git_odb_hash(oid, obj->data, obj->len, obj->type);
+ cl_git_pass(git_odb_hash(oid, obj->data, obj->len, obj->type));
+}
+static void hash_object_fail(git_oid *oid, git_rawobj *obj)
+{
+ cl_git_fail(git_odb_hash(oid, obj->data, obj->len, obj->type));
}
static char *hello_id = "22596363b3de40b06f981fb85d82312e8c0ed511";
@@ -74,28 +78,28 @@ void test_object_raw_hash__hash_junk_data(void)
/* invalid types: */
junk_obj.data = some_data;
- cl_git_fail(hash_object(&id, &junk_obj));
+ hash_object_fail(&id, &junk_obj);
junk_obj.type = GIT_OBJ__EXT1;
- cl_git_fail(hash_object(&id, &junk_obj));
+ hash_object_fail(&id, &junk_obj);
junk_obj.type = GIT_OBJ__EXT2;
- cl_git_fail(hash_object(&id, &junk_obj));
+ hash_object_fail(&id, &junk_obj);
junk_obj.type = GIT_OBJ_OFS_DELTA;
- cl_git_fail(hash_object(&id, &junk_obj));
+ hash_object_fail(&id, &junk_obj);
junk_obj.type = GIT_OBJ_REF_DELTA;
- cl_git_fail(hash_object(&id, &junk_obj));
+ hash_object_fail(&id, &junk_obj);
/* data can be NULL only if len is zero: */
junk_obj.type = GIT_OBJ_BLOB;
junk_obj.data = NULL;
- cl_git_pass(hash_object(&id, &junk_obj));
+ hash_object_pass(&id, &junk_obj);
cl_assert(git_oid_cmp(&id, &id_zero) == 0);
junk_obj.len = 1;
- cl_git_fail(hash_object(&id, &junk_obj));
+ hash_object_fail(&id, &junk_obj);
}
void test_object_raw_hash__hash_commit_object(void)
@@ -103,7 +107,7 @@ void test_object_raw_hash__hash_commit_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, commit_id));
- cl_git_pass(hash_object(&id2, &commit_obj));
+ hash_object_pass(&id2, &commit_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
@@ -112,7 +116,7 @@ void test_object_raw_hash__hash_tree_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, tree_id));
- cl_git_pass(hash_object(&id2, &tree_obj));
+ hash_object_pass(&id2, &tree_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
@@ -121,7 +125,7 @@ void test_object_raw_hash__hash_tag_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, tag_id));
- cl_git_pass(hash_object(&id2, &tag_obj));
+ hash_object_pass(&id2, &tag_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
@@ -130,7 +134,7 @@ void test_object_raw_hash__hash_zero_length_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, zero_id));
- cl_git_pass(hash_object(&id2, &zero_obj));
+ hash_object_pass(&id2, &zero_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
@@ -139,7 +143,7 @@ void test_object_raw_hash__hash_one_byte_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, one_id));
- cl_git_pass(hash_object(&id2, &one_obj));
+ hash_object_pass(&id2, &one_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
@@ -148,7 +152,7 @@ void test_object_raw_hash__hash_two_byte_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, two_id));
- cl_git_pass(hash_object(&id2, &two_obj));
+ hash_object_pass(&id2, &two_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
@@ -157,6 +161,6 @@ void test_object_raw_hash__hash_multi_byte_object(void)
git_oid id1, id2;
cl_git_pass(git_oid_fromstr(&id1, some_id));
- cl_git_pass(hash_object(&id2, &some_obj));
+ hash_object_pass(&id2, &some_obj);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
}
diff --git a/tests-clar/object/raw/write.c b/tests-clar/object/raw/write.c
index 873471c..885d336 100644
--- a/tests-clar/object/raw/write.c
+++ b/tests-clar/object/raw/write.c
@@ -16,73 +16,43 @@ void test_body(object_data *d, git_rawobj *o);
// Helpers
-static int remove_object_files(object_data *d)
+static void remove_object_files(object_data *d)
{
- if (p_unlink(d->file) < 0) {
- fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
- return -1;
- }
-
- if ((p_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
- fprintf(stderr, "can't remove directory \"%s\"\n", d->dir);
- return -1;
- }
-
- if (p_rmdir(odb_dir) < 0) {
- fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
- return -1;
- }
-
- return 0;
+ cl_git_pass(p_unlink(d->file));
+ cl_git_pass(p_rmdir(d->dir));
+ cl_assert(errno != ENOTEMPTY);
+ cl_git_pass(p_rmdir(odb_dir) < 0);
}
-static int streaming_write(git_oid *oid, git_odb *odb, git_rawobj *raw)
+static void streaming_write(git_oid *oid, git_odb *odb, git_rawobj *raw)
{
git_odb_stream *stream;
int error;
- if ((error = git_odb_open_wstream(&stream, odb, raw->len, raw->type)) < GIT_SUCCESS)
- return error;
-
+ cl_git_pass(git_odb_open_wstream(&stream, odb, raw->len, raw->type));
stream->write(stream, raw->data, raw->len);
-
error = stream->finalize_write(oid, stream);
stream->free(stream);
-
- return error;
+ cl_git_pass(error);
}
-static int check_object_files(object_data *d)
+static void check_object_files(object_data *d)
{
- if (git_path_exists(d->dir) < 0)
- return -1;
- if (git_path_exists(d->file) < 0)
- return -1;
- return 0;
+ cl_git_pass(git_path_exists(d->dir));
+ cl_git_pass(git_path_exists(d->file));
}
-static int cmp_objects(git_rawobj *o1, git_rawobj *o2)
+static void cmp_objects(git_rawobj *o1, git_rawobj *o2)
{
- if (o1->type != o2->type)
- return -1;
- if (o1->len != o2->len)
- return -1;
- if ((o1->len > 0) && (memcmp(o1->data, o2->data, o1->len) != 0))
- return -1;
- return 0;
+ cl_assert(o1->type == o2->type);
+ cl_assert(o1->len == o2->len);
+ if (o1->len > 0)
+ cl_assert(memcmp(o1->data, o2->data, o1->len) == 0);
}
-static int make_odb_dir(void)
+static void make_odb_dir(void)
{
- if (p_mkdir(odb_dir, GIT_OBJECT_DIR_MODE) < 0) {
- int err = errno;
- fprintf(stderr, "can't make directory \"%s\"", odb_dir);
- if (err == EEXIST)
- fprintf(stderr, " (already exists)");
- fprintf(stderr, "\n");
- return -1;
- }
- return 0;
+ cl_git_pass(p_mkdir(odb_dir, GIT_OBJECT_DIR_MODE));
}
@@ -93,20 +63,20 @@ void test_body(object_data *d, git_rawobj *o)
git_oid id1, id2;
git_odb_object *obj;
- cl_git_pass(make_odb_dir());
+ make_odb_dir();
cl_git_pass(git_odb_open(&db, odb_dir));
cl_git_pass(git_oid_fromstr(&id1, d->id));
- cl_git_pass(streaming_write(&id2, db, o));
+ streaming_write(&id2, db, o);
cl_assert(git_oid_cmp(&id1, &id2) == 0);
- cl_git_pass(check_object_files(d));
+ check_object_files(d);
cl_git_pass(git_odb_read(&obj, db, &id1));
- cl_git_pass(cmp_objects(&obj->raw, o));
+ cmp_objects(&obj->raw, o);
git_odb_object_free(obj);
git_odb_free(db);
- cl_git_pass(remove_object_files(d));
+ remove_object_files(d);
}
diff --git a/tests-clar/object/tag/read.c b/tests-clar/object/tag/read.c
index 04d4d02..812e6ee 100644
--- a/tests-clar/object/tag/read.c
+++ b/tests-clar/object/tag/read.c
@@ -12,7 +12,7 @@ static git_repository *g_repo;
// Helpers
-static int ensure_tag_pattern_match(git_repository *repo, const char *pattern, const size_t expected_matches)
+static void ensure_tag_pattern_match(git_repository *repo, const char *pattern, const size_t expected_matches)
{
git_strarray tag_list;
int error = GIT_SUCCESS;
@@ -25,7 +25,7 @@ static int ensure_tag_pattern_match(git_repository *repo, const char *pattern, c
exit:
git_strarray_free(&tag_list);
- return error;
+ cl_git_pass(error);
}
@@ -87,13 +87,13 @@ void test_object_tag_read__list(void)
void test_object_tag_read__list_pattern(void)
{
// list all tag names from the repository matching a specified pattern
- cl_git_pass(ensure_tag_pattern_match(g_repo, "", 3));
- cl_git_pass(ensure_tag_pattern_match(g_repo, "*", 3));
- cl_git_pass(ensure_tag_pattern_match(g_repo, "t*", 1));
- cl_git_pass(ensure_tag_pattern_match(g_repo, "*b", 2));
- cl_git_pass(ensure_tag_pattern_match(g_repo, "e", 0));
- cl_git_pass(ensure_tag_pattern_match(g_repo, "e90810b", 1));
- cl_git_pass(ensure_tag_pattern_match(g_repo, "e90810[ab]", 1));
+ ensure_tag_pattern_match(g_repo, "", 3);
+ ensure_tag_pattern_match(g_repo, "*", 3);
+ ensure_tag_pattern_match(g_repo, "t*", 1);
+ ensure_tag_pattern_match(g_repo, "*b", 2);
+ ensure_tag_pattern_match(g_repo, "e", 0);
+ ensure_tag_pattern_match(g_repo, "e90810b", 1);
+ ensure_tag_pattern_match(g_repo, "e90810[ab]", 1);
}
void test_object_tag_read__parse_without_tagger(void)
diff --git a/tests-clar/object/tag/write.c b/tests-clar/object/tag/write.c
index 01e9d9c..5b0b8b0 100644
--- a/tests-clar/object/tag/write.c
+++ b/tests-clar/object/tag/write.c
@@ -42,17 +42,15 @@ static void locate_loose_object(const char *repository_folder, git_object *objec
*out_folder = top_folder;
}
-static int loose_object_mode(const char *repository_folder, git_object *object)
+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);
- if (p_stat(object_path, &st) < 0)
- return 0;
+ cl_git_pass(p_stat(object_path, &st));
free(object_path);
-
- return st.st_mode;
+ cl_assert((st.st_mode & 0777) == GIT_OBJECT_FILE_MODE);
}
#endif
@@ -117,7 +115,7 @@ void test_object_tag_write__basic(void)
cl_git_pass(git_reference_delete(ref_tag));
#ifndef GIT_WIN32
// TODO: Get this to work on Linux
- // cl_assert((loose_object_mode("testrepo", (git_object *)tag) & 0777) == GIT_OBJECT_FILE_MODE);
+ //loose_object_mode("testrepo/", (git_object *)tag);
#endif
git_tag_free(tag);
diff --git a/tests-clar/refs/reflog.c b/tests-clar/refs/reflog.c
index cafb34f..b646ff6 100644
--- a/tests-clar/refs/reflog.c
+++ b/tests-clar/refs/reflog.c
@@ -13,24 +13,13 @@ static git_repository *g_repo;
// helpers
-static int assert_signature(git_signature *expected, git_signature *actual)
+static void assert_signature(git_signature *expected, git_signature *actual)
{
- if (actual == NULL)
- return GIT_ERROR;
-
- if (strcmp(expected->name, actual->name) != 0)
- return GIT_ERROR;
-
- if (strcmp(expected->email, actual->email) != 0)
- return GIT_ERROR;
-
- if (expected->when.offset != actual->when.offset)
- return GIT_ERROR;
-
- if (expected->when.time != actual->when.time)
- return GIT_ERROR;
-
- return GIT_SUCCESS;
+ cl_assert(actual);
+ cl_assert(0 == strcmp(expected->name, actual->name));
+ cl_assert(0 == strcmp(expected->email, actual->email));
+ cl_assert(expected->when.offset == actual->when.offset);
+ cl_assert(expected->when.time == actual->when.time);
}
@@ -82,7 +71,7 @@ void test_refs_reflog__write_then_read(void)
cl_assert(reflog->entries.length == 2);
entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 0);
- cl_git_pass(assert_signature(committer, entry->committer));
+ assert_signature(committer, entry->committer);
git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old);
cl_assert(strcmp("0000000000000000000000000000000000000000", oid_str) == 0);
git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur);
@@ -90,7 +79,7 @@ void test_refs_reflog__write_then_read(void)
cl_assert(entry->msg == NULL);
entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 1);
- cl_git_pass(assert_signature(committer, entry->committer));
+ assert_signature(committer, entry->committer);
git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old);
cl_assert(strcmp(current_master_tip, oid_str) == 0);
git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur);
diff --git a/tests-clar/repo/discover.c b/tests-clar/repo/discover.c
index 7281e87..afa3e2d 100644
--- a/tests-clar/repo/discover.c
+++ b/tests-clar/repo/discover.c
@@ -23,61 +23,45 @@
#define ALTERNATE_MALFORMED_FOLDER3 DISCOVER_FOLDER "/alternate_malformed_repo3"
#define ALTERNATE_NOT_FOUND_FOLDER DISCOVER_FOLDER "/alternate_not_found_repo"
-static int ensure_repository_discover(const char *start_path, const char *ceiling_dirs, const char *expected_path)
+static void ensure_repository_discover(const char *start_path, const char *ceiling_dirs, const char *expected_path)
{
- int error;
char found_path[GIT_PATH_MAX];
-
- error = git_repository_discover(found_path, sizeof(found_path), start_path, 0, ceiling_dirs);
+ cl_git_pass(git_repository_discover(found_path, sizeof(found_path), start_path, 0, ceiling_dirs));
//across_fs is always 0 as we can't automate the filesystem change tests
-
- if (error < GIT_SUCCESS)
- return error;
-
- return strcmp(found_path, expected_path) ? GIT_ERROR : GIT_SUCCESS;
+ cl_assert(0 == strcmp(found_path, expected_path));
}
-static int write_file(const char *path, const char *content)
+static void write_file(const char *path, const char *content)
{
- int error;
git_file file;
+ int error;
if (git_path_exists(path) == GIT_SUCCESS) {
- error = p_unlink(path);
-
- if (error < GIT_SUCCESS)
- return error;
+ cl_git_pass(p_unlink(path));
}
file = git_futils_creat_withpath(path, 0777, 0666);
- if (file < GIT_SUCCESS)
- return file;
+ cl_assert(file >= 0);
error = p_write(file, content, strlen(content) * sizeof(char));
-
p_close(file);
-
- return error;
+ cl_git_pass(error);
}
//no check is performed on ceiling_dirs length, so be sure it's long enough
-static int append_ceiling_dir(git_buf *ceiling_dirs, const char *path)
+static void append_ceiling_dir(git_buf *ceiling_dirs, const char *path)
{
git_buf pretty_path = GIT_BUF_INIT;
- int error;
char ceiling_separator[2] = { GIT_PATH_LIST_SEPARATOR, '\0' };
- error = git_path_prettify_dir(&pretty_path, path, NULL);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to append ceiling directory.");
+ cl_git_pass(git_path_prettify_dir(&pretty_path, path, NULL));
if (ceiling_dirs->size > 0)
git_buf_puts(ceiling_dirs, ceiling_separator);
git_buf_puts(ceiling_dirs, pretty_path.ptr);
-
- git_buf_free(&pretty_path);
-
- return git_buf_lasterror(ceiling_dirs);
+
+ git_buf_free(&pretty_path);
+ cl_git_pass(git_buf_lasterror(ceiling_dirs));
}
void test_repo_discover__0(void)
@@ -92,7 +76,7 @@ void test_repo_discover__0(void)
const mode_t mode = 0777;
git_futils_mkdir_r(DISCOVER_FOLDER, NULL, mode);
- cl_git_pass(append_ceiling_dir(&ceiling_dirs_buf, TEMP_REPO_FOLDER));
+ append_ceiling_dir(&ceiling_dirs_buf, TEMP_REPO_FOLDER);
ceiling_dirs = git_buf_cstr(&ceiling_dirs_buf);
cl_assert(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs) == GIT_ENOTAREPO);
@@ -106,33 +90,33 @@ void test_repo_discover__0(void)
cl_git_pass(git_repository_discover(sub_repository_path, sizeof(sub_repository_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
cl_git_pass(git_futils_mkdir_r(SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, NULL, mode));
- cl_git_pass(ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, ceiling_dirs, sub_repository_path));
+ ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, ceiling_dirs, sub_repository_path);
cl_git_pass(git_futils_mkdir_r(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, NULL, mode));
- cl_git_pass(write_file(REPOSITORY_ALTERNATE_FOLDER "/" DOT_GIT, "gitdir: ../" SUB_REPOSITORY_FOLDER_NAME "/" DOT_GIT));
- cl_git_pass(write_file(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB "/" DOT_GIT, "gitdir: ../../../" SUB_REPOSITORY_FOLDER_NAME "/" DOT_GIT));
- cl_git_pass(write_file(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB "/" DOT_GIT, "gitdir: ../../../../"));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path));
+ write_file(REPOSITORY_ALTERNATE_FOLDER "/" DOT_GIT, "gitdir: ../" SUB_REPOSITORY_FOLDER_NAME "/" DOT_GIT);
+ write_file(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB "/" DOT_GIT, "gitdir: ../../../" SUB_REPOSITORY_FOLDER_NAME "/" DOT_GIT);
+ write_file(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB "/" DOT_GIT, "gitdir: ../../../../");
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path);
cl_git_pass(git_futils_mkdir_r(ALTERNATE_MALFORMED_FOLDER1, NULL, mode));
- cl_git_pass(write_file(ALTERNATE_MALFORMED_FOLDER1 "/" DOT_GIT, "Anything but not gitdir:"));
+ write_file(ALTERNATE_MALFORMED_FOLDER1 "/" DOT_GIT, "Anything but not gitdir:");
cl_git_pass(git_futils_mkdir_r(ALTERNATE_MALFORMED_FOLDER2, NULL, mode));
- cl_git_pass(write_file(ALTERNATE_MALFORMED_FOLDER2 "/" DOT_GIT, "gitdir:"));
+ write_file(ALTERNATE_MALFORMED_FOLDER2 "/" DOT_GIT, "gitdir:");
cl_git_pass(git_futils_mkdir_r(ALTERNATE_MALFORMED_FOLDER3, NULL, mode));
- cl_git_pass(write_file(ALTERNATE_MALFORMED_FOLDER3 "/" DOT_GIT, "gitdir: \n\n\n"));
+ write_file(ALTERNATE_MALFORMED_FOLDER3 "/" DOT_GIT, "gitdir: \n\n\n");
cl_git_pass(git_futils_mkdir_r(ALTERNATE_NOT_FOUND_FOLDER, NULL, mode));
- cl_git_pass(write_file(ALTERNATE_NOT_FOUND_FOLDER "/" DOT_GIT, "gitdir: a_repository_that_surely_does_not_exist"));
+ write_file(ALTERNATE_NOT_FOUND_FOLDER "/" DOT_GIT, "gitdir: a_repository_that_surely_does_not_exist");
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER1, 0, ceiling_dirs));
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER2, 0, ceiling_dirs));
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER3, 0, ceiling_dirs));
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
- cl_git_pass(append_ceiling_dir(&ceiling_dirs_buf, SUB_REPOSITORY_FOLDER));
+ append_ceiling_dir(&ceiling_dirs_buf, SUB_REPOSITORY_FOLDER);
ceiling_dirs = git_buf_cstr(&ceiling_dirs_buf);
//this must pass as ceiling_directories cannot predent the current
@@ -143,10 +127,10 @@ void test_repo_discover__0(void)
cl_git_fail(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
//.gitfile redirection should not be affected by ceiling directories
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path));
- cl_git_pass(ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path));
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs, sub_repository_path);
+ ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs, repository_path);
cl_git_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
git_repository_free(repo);