Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up old sparse tests #41

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 29 additions & 67 deletions tests/libgit2/sparse/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ struct test_case{ \
{ NULL, 0 } \
}, *one_test; \

void test_sparse_status__0(void)
void test_sparse_status__cache_attr(void)
{
define_test_cases
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));

git_attr_cache_flush(g_repo);
Expand Down Expand Up @@ -132,29 +134,29 @@ void test_sparse_status__full_checkout(void)

void test_sparse_status__no_checkout(void)
{
const char** path;
define_test_cases
g_repo = cl_git_sandbox_init("sparse");
{
char *pattern_strings[] = { "!/*" };
char *pattern_strings[] = { "!/*/" };
git_strarray patterns = { pattern_strings, ARRAY_SIZE(pattern_strings) };
cl_git_pass(git_sparse_checkout_set(g_repo, &patterns));
}

for (path = paths; *path != NULL; path++)
refute_is_checkout(*path);
for (one_test = test_cases; one_test->path != NULL; one_test++)
assert_checkout(one_test->expected, one_test->path);
}

void test_sparse_status__no_sparse_file(void)
{
const char** path;
define_test_cases
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));
cl_git_rmfile("sparse/.git/info/sparse-checkout");

for (path = paths; *path != NULL; path++)
refute_is_checkout(*path);
for (one_test = test_cases; one_test->path != NULL; one_test++)
assert_checkout(one_test->expected, one_test->path);
}

void test_sparse_status__append_folder(void)
Expand Down Expand Up @@ -208,82 +210,32 @@ void test_sparse_status__append_file(void)

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));
{
char *pattern_strings[] = { "/b/c/file7" };
git_strarray patterns = { pattern_strings, ARRAY_SIZE(pattern_strings) };
cl_git_pass(git_sparse_checkout_add(g_repo, &patterns));
}

test_cases[11].expected = 1;

for (one_test = test_cases; one_test->path != NULL; one_test++)
assert_checkout(one_test->expected, one_test->path);
}

void test_sparse_status__append_suffix(void)
{
define_test_cases
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));
{
char *pattern_strings[] = { "*.txt" };
char *pattern_strings[] = { "/b/", "!/b/*/", "/b/c/" };
git_strarray patterns = { pattern_strings, ARRAY_SIZE(pattern_strings) };
cl_git_pass(git_sparse_checkout_add(g_repo, &patterns));
}

test_cases[6].expected = 1;
test_cases[7].expected = 1;
test_cases[8].expected = 1;
test_cases[9].expected = 1;
test_cases[10].expected = 1;
test_cases[11].expected = 1;
test_cases[12].expected = 1;

for (one_test = test_cases; one_test->path != NULL; one_test++)
assert_checkout(one_test->expected, one_test->path);
}

void test_sparse_status__exclude_single_file_suffix(void)
{
define_test_cases
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));
{
char *pattern_strings[] = { "*.txt", "!file11.txt" };
git_strarray patterns = { pattern_strings, ARRAY_SIZE(pattern_strings) };
cl_git_pass(git_sparse_checkout_add(g_repo, &patterns));
}

test_cases[2].expected = 0;
test_cases[7].expected = 1;

for (one_test = test_cases; one_test->path != NULL; one_test++)
assert_checkout(one_test->expected, one_test->path);
}

void test_sparse_status__match_wildcard(void)
{
define_test_cases
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));
{
char *pattern_strings[] = { "file1*" };
git_strarray patterns = { pattern_strings, ARRAY_SIZE(pattern_strings) };
cl_git_pass(git_sparse_checkout_add(g_repo, &patterns));
}

test_cases[7].expected = 1;
test_cases[14].expected = 1;

for (one_test = test_cases; one_test->path != NULL; one_test++)
assert_checkout(one_test->expected, one_test->path);
}

void test_sparse_status__clean(void)
{
status_entry_single st;
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));

memset(&st, 0, sizeof(st));
Expand Down Expand Up @@ -314,6 +266,8 @@ void test_sparse_status__new_file(void)
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));

cl_git_mkfile("sparse/newfile", "/hello world\n");
Expand All @@ -331,6 +285,8 @@ void test_sparse_status__new_file_new_folder(void)
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));

cl_must_pass(git_futils_mkdir("sparse/new", 0777, 0));
Expand All @@ -349,6 +305,8 @@ void test_sparse_status__new_file_sparse_folder(void)
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));

cl_must_pass(git_futils_mkdir("sparse/a", 0777, 0));
Expand All @@ -367,6 +325,8 @@ void test_sparse_status__new_sparse_file_sparse_folder(void)
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));

cl_must_pass(git_futils_mkdir("sparse/a", 0777, 0));
Expand All @@ -385,6 +345,8 @@ void test_sparse_status__ignorecase(void)
git_sparse_checkout_init_options scopts = GIT_SPARSE_CHECKOUT_INIT_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("sparse");

clar__skip();

cl_git_pass(git_sparse_checkout_init(g_repo, &scopts));
{
char *pattern_strings[] = { "/b/file5" };
Expand Down
Loading