Skip to content

Commit 26b71d6

Browse files
committed
tests: iterator: fix iterator expecting too few items
The testcase iterator::workdir::filesystem_gunk sets up quite a lot of directories, which is why it only runs in case GITTEST_INVASIVE_SPEED is set in the environment. Because we do not run our default CI with this variable, we didn't notice commit 852c83e (refs: refuse to delete HEAD, 2020-01-15) breaking the test as it introduced a new reference to the "testrepo" repository. Fix the oversight by increasing the number of expected iterator items.
1 parent 03ac24b commit 26b71d6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/iterator/workdir.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -637,13 +637,14 @@ void test_iterator_workdir__filesystem2(void)
637637
git_iterator_free(i);
638638
}
639639

640-
/* Lots of empty dirs, or nearly empty ones, make the old workdir
641-
* iterator cry. Also, segfault.
640+
/*
641+
* Lots of empty dirs, or nearly empty ones, make the old workdir
642+
* iterator cry. Also, segfault.
642643
*/
643644
void test_iterator_workdir__filesystem_gunk(void)
644645
{
645-
git_iterator *i;
646646
git_buf parent = GIT_BUF_INIT;
647+
git_iterator *i;
647648
int n;
648649

649650
if (!cl_is_env_set("GITTEST_INVASIVE_SPEED"))
@@ -653,19 +654,18 @@ void test_iterator_workdir__filesystem_gunk(void)
653654

654655
for (n = 0; n < 100000; n++) {
655656
git_buf_clear(&parent);
656-
git_buf_printf(&parent, "%s/refs/heads/foo/%d/subdir",
657-
git_repository_path(g_repo), n);
658-
cl_assert(!git_buf_oom(&parent));
659-
657+
cl_git_pass(git_buf_printf(&parent, "%s/refs/heads/foo/%d/subdir", git_repository_path(g_repo), n));
660658
cl_git_pass(git_futils_mkdir(parent.ptr, 0775, GIT_MKDIR_PATH));
661659
}
662660

663661
cl_git_pass(git_iterator_for_filesystem(&i, "testrepo/.git/refs", NULL));
664662

665-
/* should only have 16 items, since we're not asking for trees to be
663+
/*
664+
* Should only have 17 items, since we're not asking for trees to be
666665
* returned. the goal of this test is simply to not crash.
667666
*/
668-
expect_iterator_items(i, 16, NULL, 15, NULL);
667+
expect_iterator_items(i, 17, NULL, 16, NULL);
668+
669669
git_iterator_free(i);
670670
git_buf_dispose(&parent);
671671
}

0 commit comments

Comments
 (0)