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;
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", "");
......
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