From ad7417d7a13e910d548e3e07225ce8914cdb218e Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 13 Sep 2013 09:44:30 -0700 Subject: [PATCH] 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. --- tests-clar/filter/blob.c | 2 +- tests-clar/filter/custom.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests-clar/filter/blob.c b/tests-clar/filter/blob.c index 916721e12..9600a9779 100644 --- a/tests-clar/filter/blob.c +++ b/tests-clar/filter/blob.c @@ -12,7 +12,7 @@ void test_filter_blob__initialize(void) "*.lf text eol=lf\n" "*.ident text ident\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) diff --git a/tests-clar/filter/custom.c b/tests-clar/filter/custom.c index 4a2ff9fc4..a2752efa4 100644 --- a/tests-clar/filter/custom.c +++ b/tests-clar/filter/custom.c @@ -50,7 +50,8 @@ void test_filter_custom__initialize(void) "empty_standard_repo/.gitattributes", "hero* bitflip reverse\n" "herofile text\n" - "heroflip -reverse\n"); + "heroflip -reverse binary\n" + "*.bin binary\n"); } 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( &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 */ cl_assert_equal_sz(2, git_filter_list_length(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); 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 */ cl_assert_equal_sz(0, git_filter_list_length(fl)); git_filter_list_free(fl);