Commit e385e647 by Edward Thomson

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.
parent 2a9b0102
...@@ -15,7 +15,9 @@ static git_buf expected_fixture = GIT_BUF_INIT; ...@@ -15,7 +15,9 @@ static git_buf expected_fixture = GIT_BUF_INIT;
static int unlink_file(void *payload, git_buf *path) 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); GIT_UNUSED(payload);
...@@ -36,7 +38,7 @@ void test_checkout_crlf__initialize(void) ...@@ -36,7 +38,7 @@ void test_checkout_crlf__initialize(void)
* remove the contents of the working directory so that we can * remove the contents of the working directory so that we can
* check out over it. * 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)); cl_git_pass(git_path_direach(&reponame, 0, unlink_file, NULL));
if (GIT_EOL_NATIVE == GIT_EOL_CRLF) if (GIT_EOL_NATIVE == GIT_EOL_CRLF)
...@@ -130,38 +132,38 @@ static void test_checkout(const char *autocrlf, const char *attrs) ...@@ -130,38 +132,38 @@ static void test_checkout(const char *autocrlf, const char *attrs)
struct compare_data compare_data = { NULL, autocrlf, attrs }; struct compare_data compare_data = { NULL, autocrlf, attrs };
const char *c; const char *c;
git_buf_puts(&reponame, "crlf"); cl_git_pass(git_buf_puts(&reponame, "crlf"));
git_buf_puts(&systype_and_direction, systype); cl_git_pass(git_buf_puts(&systype_and_direction, systype));
git_buf_puts(&systype_and_direction, "_to_workdir"); cl_git_pass(git_buf_puts(&systype_and_direction, "_to_workdir"));
git_buf_puts(&sandboxname, "autocrlf_"); cl_git_pass(git_buf_puts(&sandboxname, "autocrlf_"));
git_buf_puts(&sandboxname, autocrlf); cl_git_pass(git_buf_puts(&sandboxname, autocrlf));
if (*attrs) { if (*attrs) {
git_buf_puts(&sandboxname, ","); cl_git_pass(git_buf_puts(&sandboxname, ","));
for (c = attrs; *c; c++) { for (c = attrs; *c; c++) {
if (*c == ' ') if (*c == ' ')
git_buf_putc(&sandboxname, ','); cl_git_pass(git_buf_putc(&sandboxname, ','));
else if (*c == '=') else if (*c == '=')
git_buf_putc(&sandboxname, '_'); cl_git_pass(git_buf_putc(&sandboxname, '_'));
else 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_git_mkfile("crlf/.gitattributes", attrbuf.ptr);
} }
cl_repo_set_string(g_repo, "core.autocrlf", autocrlf); cl_repo_set_string(g_repo, "core.autocrlf", autocrlf);
git_buf_joinpath(&expected_dirname, systype_and_direction.ptr, sandboxname.ptr); cl_git_pass(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_fixture, "crlf_data", expected_dirname.ptr));
cl_fixture_sandbox(expected_fixture.ptr); cl_fixture_sandbox(expected_fixture.ptr);
opts.checkout_strategy = GIT_CHECKOUT_FORCE; 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; compare_data.dirname = sandboxname.ptr;
cl_git_pass(git_path_direach(&reponame, 0, compare_file, &compare_data)); 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) ...@@ -180,19 +182,20 @@ static void test_checkout(const char *autocrlf, const char *attrs)
static void empty_workdir(const char *name) static void empty_workdir(const char *name)
{ {
git_vector contents = GIT_VECTOR_INIT; git_vector contents = GIT_VECTOR_INIT;
char *basename;
int cmp;
size_t i; size_t i;
const char *fn; 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) { git_vector_foreach(&contents, i, fn) {
char *basename = git_path_basename(fn); cl_assert(basename = git_path_basename(fn));
int cmp = strncasecmp(basename, ".git", 4); cmp = strncasecmp(basename, ".git", 4);
git__free(basename); git__free(basename);
if (cmp == 0) if (cmp)
continue; cl_git_pass(p_unlink(fn));
p_unlink(fn);
} }
git_vector_free_deep(&contents); git_vector_free_deep(&contents);
} }
...@@ -364,7 +367,7 @@ void test_checkout_crlf__with_ident(void) ...@@ -364,7 +367,7 @@ void test_checkout_crlf__with_ident(void)
p_unlink("crlf/more1.identlf"); p_unlink("crlf/more1.identlf");
p_unlink("crlf/more2.identcrlf"); p_unlink("crlf/more2.identcrlf");
git_checkout_head(g_repo, &opts); cl_git_pass(git_checkout_head(g_repo, &opts));
cl_assert_equal_file( cl_assert_equal_file(
ALL_LF_TEXT_AS_CRLF ALL_LF_TEXT_AS_CRLF
...@@ -393,7 +396,7 @@ void test_checkout_crlf__autocrlf_false_no_attrs(void) ...@@ -393,7 +396,7 @@ void test_checkout_crlf__autocrlf_false_no_attrs(void)
cl_repo_set_bool(g_repo, "core.autocrlf", false); 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-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_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) ...@@ -406,7 +409,7 @@ void test_checkout_crlf__autocrlf_true_no_attrs(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true); 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-lf", ALL_LF_TEXT_AS_CRLF);
check_file_contents("./crlf/all-crlf", ALL_CRLF_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) ...@@ -419,7 +422,7 @@ void test_checkout_crlf__autocrlf_input_no_attrs(void)
cl_repo_set_string(g_repo, "core.autocrlf", "input"); 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-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_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) ...@@ -434,7 +437,7 @@ void test_checkout_crlf__autocrlf_false_text_auto_attr(void)
cl_repo_set_bool(g_repo, "core.autocrlf", false); 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) { if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_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) ...@@ -454,7 +457,7 @@ void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true); 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-lf", ALL_LF_TEXT_AS_CRLF);
check_file_contents("./crlf/all-crlf", ALL_CRLF_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) ...@@ -469,7 +472,7 @@ void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
cl_repo_set_string(g_repo, "core.autocrlf", "input"); 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-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_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) ...@@ -482,8 +485,8 @@ void test_checkout_crlf__can_write_empty_file(void)
cl_repo_set_bool(g_repo, "core.autocrlf", true); cl_repo_set_bool(g_repo, "core.autocrlf", true);
git_repository_set_head(g_repo, "refs/heads/empty-files"); cl_git_pass(git_repository_set_head(g_repo, "refs/heads/empty-files"));
git_checkout_head(g_repo, &opts); cl_git_pass(git_checkout_head(g_repo, &opts));
check_file_contents("./crlf/test1.txt", ""); check_file_contents("./crlf/test1.txt", "");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment