{"thread":{"id":"19297","subject":"(unknown)","startedAt":"2009-05-11T18:57:12Z","lastAt":"2009-05-11T18:57:12Z","messageCount":1,"participants":["Don Slutz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"113565","messageId":"200905111857.n4BIvCnG002317@krl.krl.com","threadId":"19297","inReplyTo":null,"subject":"(unknown)","fromName":"Don Slutz","fromEmail":"slutz@krl.com","sentAt":"2009-05-11T18:57:12Z","receivedAt":"2009-05-11T18:57:12Z","isPatch":false,"sender":{"key":"slutz@krl.com","avatar":null},"body":">From 3f0280a44185d1c7f6b653988bc0b46d239cdd17 Mon Sep 17 00:00:00 2001\nFrom: Don Slutz <Don.Slutz@SierraAtlantic.com>\nDate: Mon, 11 May 2009 11:48:54 -0400\nSubject: [PATCH 2/6] Fix tests to work with core.autocrlf=true\n\ntest-lib changes.\n\nRun the tests via:\n\n  GIT_TEST_AUTO_CRLF=true make test\n\nChange the default value of GIT_TEST_CMP to ignore whitespace changes\nwhen core.autocrlf=true\n\nAdd support functions: test_external_with_only_warning, test_eq_cat,\ntest_cat_eq, and test_ne_cat all of which will ignore CR if it is in\nthe file.\n\nSigned-off-by: Don Slutz <Don.Slutz@SierraAtlantic.com>\n---\n t/test-lib.sh |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 58 insertions(+), 1 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 218bd82..84846cd 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -59,7 +59,6 @@ export GIT_MERGE_VERBOSITY\n export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME\n export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME\n export EDITOR VISUAL\n-GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}\n \n # Protect ourselves from common misconfiguration to export\n # CDPATH into the environment\n@@ -129,6 +128,11 @@ case $(uname -s) in\n *)\n \t;;\n esac\n+if test ! -z $GIT_TEST_AUTO_CRLF && test $GIT_TEST_AUTO_CRLF = true; then\n+\tGIT_TEST_CMP=${GIT_TEST_CMP:-diff -uw}\n+else\n+\tGIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}\n+fi\n \n if test -n \"$color\"; then\n \tsay_color () {\n@@ -459,6 +463,35 @@ test_external_without_stderr () {\n \tfi\n }\n \n+# Like test_external, but in addition tests that the command generated\n+# only \"warning: LF will be replaced by CRLF\" output on stderr.\n+test_external_with_only_warning () {\n+\t# The temporary file has no (and must have no) security\n+\t# implications.\n+\ttmp=\"$TMPDIR\"; if [ -z \"$tmp\" ]; then tmp=/tmp; fi\n+\tstderr=\"$tmp/git-external-stderr.$$.tmp\"\n+\ttest_external \"$@\" 4> \"$stderr\"\n+\t[ -f \"$stderr\" ] || error \"Internal error: $stderr disappeared.\"\n+\tdescr=\"only warning: $1\"\n+\tshift\n+\tsay >&3 \"expecting only warnings from previous command\"\n+\toutput=$(grep -v \"warning: LF will be replaced by CRLF in\" $stderr)\n+\ttest_debug \"echo non-warning: $output\"\n+\tif [ -z \"$output\" ]; then\n+\t\trm \"$stderr\"\n+\t\ttest_ok_ \"$descr\"\n+\telse\n+\t\tif [ \"$verbose\" = t ]; then\n+\t\t\toutput=`echo; echo Stderr is:; cat \"$stderr\"`\n+\t\telse\n+\t\t\toutput=\n+\t\tfi\n+\t\t# rm first in case test_failure exits.\n+\t\trm \"$stderr\"\n+\t\ttest_failure_ \"$descr\" \"$@\" \"$output\"\n+\tfi\n+}\n+\n # This is not among top-level (test_expect_success | test_expect_failure)\n # but is a prefix that can be used in the test script, like:\n #\n@@ -493,6 +526,30 @@ test_cmp() {\n \t$GIT_TEST_CMP \"$@\"\n }\n \n+# test_eq_cat is a helper function to compare a 1 word file\n+# with a string.\n+# It almost the same as: test foo = $(cat bar)\n+# for: test_eq_cat foo bar\n+#\n+# However it works when core.autocrlf = true.\n+\n+test_eq_cat() {\n+\ttest \"$1\" = \"$(tr '\\015' '\\012' < \"$2\")\"\n+}\n+\n+# the but not-equal -- may not catch all cases\n+\n+test_ne_cat() {\n+\ttest \"$1\" != \"$(tr '\\015' '\\012' < \"$2\")\"\n+}\n+\n+# the same as test_eq_cat, but file is 1st.\n+\n+test_cat_eq() {\n+\ttest \"$(tr '\\015' '\\012' < \"$1\")\" = \"$2\"\n+}\n+\n+\n # Most tests can use the created repository, but some may need to create more.\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-- \n1.6.3.15.g49878\n"}]}