Commit ad7417d7a13e910d548e3e07225ce8914cdb218e

Russell Belfer 2013-09-13T09:44:30

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.

diff --git a/tests-clar/filter/blob.c b/tests-clar/filter/blob.c
index 916721e..9600a97 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 4a2ff9f..a2752ef 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);