Make filter tests somewhat more robust

The global and system config could interfere with the filter
tests by imposing CRLF filtering where it was not anticipated.
This better isolates the tests from the system settings.
This commit is contained in:
Russell Belfer 2013-09-13 09:44:30 -07:00
parent d5b1866cc3
commit ad7417d7a1
2 changed files with 13 additions and 3 deletions

View File

@ -12,7 +12,7 @@ void test_filter_blob__initialize(void)
"*.lf text eol=lf\n" "*.lf text eol=lf\n"
"*.ident text ident\n" "*.ident text ident\n"
"*.identcrlf ident text eol=crlf\n" "*.identcrlf ident text eol=crlf\n"
"*.identlf ident text eol.lf\n"); "*.identlf ident text eol=lf\n");
} }
void test_filter_blob__cleanup(void) void test_filter_blob__cleanup(void)

View File

@ -50,7 +50,8 @@ void test_filter_custom__initialize(void)
"empty_standard_repo/.gitattributes", "empty_standard_repo/.gitattributes",
"hero* bitflip reverse\n" "hero* bitflip reverse\n"
"herofile text\n" "herofile text\n"
"heroflip -reverse\n"); "heroflip -reverse binary\n"
"*.bin binary\n");
} }
void test_filter_custom__cleanup(void) void test_filter_custom__cleanup(void)
@ -229,6 +230,15 @@ void test_filter_custom__can_register_a_custom_filter_in_the_repository(void)
cl_git_pass(git_filter_list_load( cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "herocorp", GIT_FILTER_TO_WORKTREE)); &fl, g_repo, NULL, "herocorp", GIT_FILTER_TO_WORKTREE));
/* expect: bitflip, reverse - possibly crlf depending on global config */
{
size_t flen = git_filter_list_length(fl);
cl_assert(flen == 2 || flen == 3);
}
git_filter_list_free(fl);
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "hero.bin", GIT_FILTER_TO_WORKTREE));
/* expect: bitflip, reverse */ /* expect: bitflip, reverse */
cl_assert_equal_sz(2, git_filter_list_length(fl)); cl_assert_equal_sz(2, git_filter_list_length(fl));
git_filter_list_free(fl); git_filter_list_free(fl);
@ -240,7 +250,7 @@ void test_filter_custom__can_register_a_custom_filter_in_the_repository(void)
git_filter_list_free(fl); git_filter_list_free(fl);
cl_git_pass(git_filter_list_load( cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "doesntapplytome", GIT_FILTER_TO_WORKTREE)); &fl, g_repo, NULL, "doesntapplytome.bin", GIT_FILTER_TO_WORKTREE));
/* expect: none */ /* expect: none */
cl_assert_equal_sz(0, git_filter_list_length(fl)); cl_assert_equal_sz(0, git_filter_list_length(fl));
git_filter_list_free(fl); git_filter_list_free(fl);