From: Wincent Colaiuta <win@wincent.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Wincent Colaiuta <win@wincent.com>
Subject: [PATCH] Fix tests for broken sed on Leopard
Date: Tue, 18 Dec 2007 20:45:58 +0100 [thread overview]
Message-ID: <1198007158-27576-1-git-send-email-win@wincent.com> (raw)
In-Reply-To: <7vzlw7zwj8.fsf@gitster.siamese.dyndns.org>
El 18/12/2007, a las 19:29, Junio C Hamano escribió:
> Could you work it around not by changing what is tested, but by changing
> the way the result (actual and expect) are compared, please? I actually
> wanted to enhance this to test with values 1023, 2047, and 4095, and
> your change will close the door for such changes.
How about the following? This swaps in perl in place of sed, which we can
hopefully rely upon to work across platforms.
Cheers,
Wincent
-------- 8< --------
Fix tests for broken sed on Leopard
The newly-added common-tail-optimization test fails on Leopard because
the broken sed implementation bails with a spurious "unterminated
substitute pattern" error because of the length of one of the
arguments.
So use perl instead of sed, and at the same time add test cases for
1024 - 1 and 4096 - 1 as suggested by Junio.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
t/t4024-diff-optimize-common.sh | 104 ++++++++++++++++++++++++++++++---------
1 files changed, 80 insertions(+), 24 deletions(-)
diff --git a/t/t4024-diff-optimize-common.sh b/t/t4024-diff-optimize-common.sh
index 20fe87b..84dfb05 100755
--- a/t/t4024-diff-optimize-common.sh
+++ b/t/t4024-diff-optimize-common.sh
@@ -7,28 +7,12 @@ test_description='common tail optimization'
z=zzzzzzzz ;# 8
z="$z$z$z$z$z$z$z$z" ;# 64
z="$z$z$z$z$z$z$z$z" ;# 512
-z="$z$z$z$z" ;# 2048
-z2047=$(expr "$z" : '.\(.*\)') ; #2047
-
-test_expect_success setup '
-
- echo "a$z2047" >file-a &&
- echo "b" >file-b &&
- echo "$z2047" >>file-b &&
- echo "c$z2047" | tr -d "\012" >file-c &&
- echo "d" >file-d &&
- echo "$z2047" | tr -d "\012" >>file-d &&
-
- git add file-a file-b file-c file-d &&
-
- echo "A$z2047" >file-a &&
- echo "B" >file-b &&
- echo "$z2047" >>file-b &&
- echo "C$z2047" | tr -d "\012" >file-c &&
- echo "D" >file-d &&
- echo "$z2047" | tr -d "\012" >>file-d
-
-'
+z1024="$z$z"
+z1023=$(expr "$z1024" : '.\(.*\)')
+z2048="$z1024$z1024"
+z2047=$(expr "$z2048" : '.\(.*\)')
+z4096="$z2048$z2048"
+z4095=$(expr "$z4096" : '.\(.*\)')
cat >expect <<\EOF
diff --git a/file-a b/file-a
@@ -59,11 +43,83 @@ diff --git a/file-d b/file-d
+D
EOF
-test_expect_success 'diff -U0' '
+test_expect_success 'setup (1023-char sequence)' '
+
+ echo "a$z1023" >file-a &&
+ echo "b" >file-b &&
+ echo "$z1023" >>file-b &&
+ echo "c$z1023" | tr -d "\012" >file-c &&
+ echo "d" >file-d &&
+ echo "$z1023" | tr -d "\012" >>file-d &&
+
+ git add file-a file-b file-c file-d &&
+
+ echo "A$z1023" >file-a &&
+ echo "B" >file-b &&
+ echo "$z1023" >>file-b &&
+ echo "C$z1023" | tr -d "\012" >file-c &&
+ echo "D" >file-d &&
+ echo "$z1023" | tr -d "\012" >>file-d
+
+'
+
+test_expect_success 'diff -U0 (1023-char sequence)' '
+ git diff -U0 | perl -pe "s/^index.+\n//g; s/$z1023/Z/g" >actual &&
+ diff -u expect actual
+
+'
+
+test_expect_success 'setup (2047-char sequence)' '
- git diff -U0 | sed -e "/^index/d" -e "s/$z2047/Z/g" >actual &&
+ echo "a$z2047" >file-a &&
+ echo "b" >file-b &&
+ echo "$z2047" >>file-b &&
+ echo "c$z2047" | tr -d "\012" >file-c &&
+ echo "d" >file-d &&
+ echo "$z2047" | tr -d "\012" >>file-d &&
+
+ git add file-a file-b file-c file-d &&
+
+ echo "A$z2047" >file-a &&
+ echo "B" >file-b &&
+ echo "$z2047" >>file-b &&
+ echo "C$z2047" | tr -d "\012" >file-c &&
+ echo "D" >file-d &&
+ echo "$z2047" | tr -d "\012" >>file-d
+
+'
+
+test_expect_success 'diff -U0 (2047-char sequence)' '
+
+ git diff -U0 | perl -pe "s/^index.+\n//g; s/$z2047/Z/g" >actual &&
diff -u expect actual
'
+test_expect_success 'setup (4095-char sequence)' '
+
+ echo "a$z4095" >file-a &&
+ echo "b" >file-b &&
+ echo "$z4095" >>file-b &&
+ echo "c$z4095" | tr -d "\012" >file-c &&
+ echo "d" >file-d &&
+ echo "$z4095" | tr -d "\012" >>file-d &&
+
+ git add file-a file-b file-c file-d &&
+
+ echo "A$z4095" >file-a &&
+ echo "B" >file-b &&
+ echo "$z4095" >>file-b &&
+ echo "C$z4095" | tr -d "\012" >file-c &&
+ echo "D" >file-d &&
+ echo "$z4095" | tr -d "\012" >>file-d
+
+'
+
+test_expect_success 'diff -U0 (4095-char sequence)' '
+
+ git diff -U0 | perl -pe "s/^index.+\n//g; s/$z4095/Z/g" >actual &&
+ diff -u expect actual
+
+'
test_done
--
1.5.4.rc0.68.g15eb8-dirty
parent reply other threads:[~2007-12-18 19:47 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <7vzlw7zwj8.fsf@gitster.siamese.dyndns.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1198007158-27576-1-git-send-email-win@wincent.com \
--to=win@wincent.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).