threads / patch / 27250

patchannotate.sh: Fix failing test on OS X

Subject: [PATCH] annotate.sh: Fix failing test on OS X

## tl;dr

One message between May 4, 2011 and May 4, 2011. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Arjen Laarhoven· May 4, 2011, 13:36 UTC · lore

Commit 9b01f0038b63ccdf697b2387f4fcd4b03bd249d5 ('blame: tolerate bogus e-mail addresses a bit better') introduced a test for obfuscated email addresses, but it fails on OS X and probably other platforms which don't use GNU sed. The test breaks because non-GNU seds append a newline to every line of the file, including the last one, even if it didn't have one before editing. GNU sed is smart about this (if the last line of the file doesn't have newline, it is omitted when writing the output).

Also, the text after the sed insert command is expected to start on the next line after a backslash. GNU sed apparently also understands text right after the 'i'nsert command.

The fix uses a trick used earlier in the script, which is to remove the line completely and add it again without a newline using echo and tr.

Signed-off-by: Arjen Laarhoven <arjen@yaph.org>
---
 t/annotate-tests.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Show changes to t/annotate-tests.sh +3 −1
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index abb1885..a4c6146 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -127,7 +127,9 @@ test_expect_success \
 
 test_expect_success \
     'an obfuscated email added' \
-    'sed -e "1i No robots allowed" < file > file.new &&
+    'sed -e "1i\\
+No robots allowed" -e "/^incomplete/d" < file > file.new &&
+     echo "incomplete" | tr -d "\\012" >>file.new &&
      mv file.new file &&
      GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" git commit -a -m "norobots"'
 
-- 
1.7.5.278.g5fde9

← back to recent threads