checkout::crlf: ensure success Wrap function calls in the `checkout::crlf` tests with `cl_git_pass`, `cl_assert`, etc. to ensure that they're successful.
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
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 0ad88b5..ff3a2dc 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -15,7 +15,9 @@ static git_buf expected_fixture = GIT_BUF_INIT;
static int unlink_file(void *payload, git_buf *path)
{
- const char *fn = git_path_basename(path->ptr);
+ char *fn;
+
+ cl_assert(fn = git_path_basename(path->ptr));
GIT_UNUSED(payload);
@@ -36,7 +38,7 @@ void test_checkout_crlf__initialize(void)
* remove the contents of the working directory so that we can
* check out over it.
*/
- git_buf_puts(&reponame, "crlf");
+ cl_git_pass(git_buf_puts(&reponame, "crlf"));
cl_git_pass(git_path_direach(&reponame, 0, unlink_file, NULL));
if (GIT_EOL_NATIVE == GIT_EOL_CRLF)
@@ -130,38 +132,38 @@ static void test_checkout(const char *autocrlf, const char *attrs)
struct compare_data compare_data = { NULL, autocrlf, attrs };
const char *c;
- git_buf_puts(&reponame, "crlf");
+ cl_git_pass(git_buf_puts(&reponame, "crlf"));
- git_buf_puts(&systype_and_direction, systype);
- git_buf_puts(&systype_and_direction, "_to_workdir");
+ cl_git_pass(git_buf_puts(&systype_and_direction, systype));
+ cl_git_pass(git_buf_puts(&systype_and_direction, "_to_workdir"));
- git_buf_puts(&sandboxname, "autocrlf_");
- git_buf_puts(&sandboxname, autocrlf);
+ cl_git_pass(git_buf_puts(&sandboxname, "autocrlf_"));
+ cl_git_pass(git_buf_puts(&sandboxname, autocrlf));
if (*attrs) {
- git_buf_puts(&sandboxname, ",");
+ cl_git_pass(git_buf_puts(&sandboxname, ","));
for (c = attrs; *c; c++) {
if (*c == ' ')
- git_buf_putc(&sandboxname, ',');
+ cl_git_pass(git_buf_putc(&sandboxname, ','));
else if (*c == '=')
- git_buf_putc(&sandboxname, '_');
+ cl_git_pass(git_buf_putc(&sandboxname, '_'));
else
- git_buf_putc(&sandboxname, *c);
+ cl_git_pass(git_buf_putc(&sandboxname, *c));
}
- git_buf_printf(&attrbuf, "* %s\n", attrs);
+ cl_git_pass(git_buf_printf(&attrbuf, "* %s\n", attrs));
cl_git_mkfile("crlf/.gitattributes", attrbuf.ptr);
}
cl_repo_set_string(g_repo, "core.autocrlf", autocrlf);
- git_buf_joinpath(&expected_dirname, systype_and_direction.ptr, sandboxname.ptr);
- git_buf_joinpath(&expected_fixture, "crlf_data", expected_dirname.ptr);
+ cl_git_pass(git_buf_joinpath(&expected_dirname, systype_and_direction.ptr, sandboxname.ptr));
+ cl_git_pass(git_buf_joinpath(&expected_fixture, "crlf_data", expected_dirname.ptr));
cl_fixture_sandbox(expected_fixture.ptr);
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
compare_data.dirname = sandboxname.ptr;
cl_git_pass(git_path_direach(&reponame, 0, compare_file, &compare_data));
@@ -180,19 +182,20 @@ static void test_checkout(const char *autocrlf, const char *attrs)
static void empty_workdir(const char *name)
{
git_vector contents = GIT_VECTOR_INIT;
+ char *basename;
+ int cmp;
size_t i;
const char *fn;
- git_path_dirload(&contents, name, 0, 0);
+ cl_git_pass(git_path_dirload(&contents, name, 0, 0));
git_vector_foreach(&contents, i, fn) {
- char *basename = git_path_basename(fn);
- int cmp = strncasecmp(basename, ".git", 4);
+ cl_assert(basename = git_path_basename(fn));
+ cmp = strncasecmp(basename, ".git", 4);
git__free(basename);
- if (cmp == 0)
- continue;
- p_unlink(fn);
+ if (cmp)
+ cl_git_pass(p_unlink(fn));
}
git_vector_free_deep(&contents);
}
@@ -364,7 +367,7 @@ void test_checkout_crlf__with_ident(void)
p_unlink("crlf/more1.identlf");
p_unlink("crlf/more2.identcrlf");
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
cl_assert_equal_file(
ALL_LF_TEXT_AS_CRLF
@@ -393,7 +396,7 @@ void test_checkout_crlf__autocrlf_false_no_attrs(void)
cl_repo_set_bool(g_repo, "core.autocrlf", false);
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
@@ -406,7 +409,7 @@ void test_checkout_crlf__autocrlf_true_no_attrs(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true);
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
@@ -419,7 +422,7 @@ void test_checkout_crlf__autocrlf_input_no_attrs(void)
cl_repo_set_string(g_repo, "core.autocrlf", "input");
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
@@ -434,7 +437,7 @@ void test_checkout_crlf__autocrlf_false_text_auto_attr(void)
cl_repo_set_bool(g_repo, "core.autocrlf", false);
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
@@ -454,7 +457,7 @@ void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true);
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
@@ -469,7 +472,7 @@ void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
cl_repo_set_string(g_repo, "core.autocrlf", "input");
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
@@ -482,8 +485,8 @@ void test_checkout_crlf__can_write_empty_file(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true);
- git_repository_set_head(g_repo, "refs/heads/empty-files");
- git_checkout_head(g_repo, &opts);
+ cl_git_pass(git_repository_set_head(g_repo, "refs/heads/empty-files"));
+ cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/test1.txt", "");