From: Junio C Hamano <gitster@pobox.com>
To: "Chris Cowan" <chris.o.cowan@gmail.com>
Cc: git@vger.kernel.org, Brandon Casey <casey@nrlssc.navy.mil>
Subject: Re: Hacks for AIX
Date: Sun, 20 Jul 2008 01:33:46 -0700 [thread overview]
Message-ID: <7vd4l9c5ud.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7v3am9sn2p.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 16 Jul 2008 11:25:50 -0700")
Junio C Hamano <gitster@pobox.com> writes:
>> * /usr/bin/patch - really old version, doesn't do well with some
>> diff formats. I avoid using it.
>
> t4109 seems to use patch to produce expected output for the tests; we
> should ship a precomputed expected results. Do you know of any other
> places "patch" is used?
As usual, I won't commit this patch unless I hear from people who
potentially would benefit from it. I do not need such a patch myself and
I really shouldn't be spending too much of my time on these.
-- >8 --
[PATCH] do not rely on external "patch" in tests
Some of our tests assumed a working "patch" command to produce expected
results when checking "git-apply", but some systems have broken "patch".
We can compare our output with expected output that is precomputed
instead to sidestep this issue.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/t4109-apply-multifrag.sh | 119 +++++++++++++++++++++++++++++++++++---------
t/t4110-apply-scan.sh | 35 ++++++++++---
2 files changed, 123 insertions(+), 31 deletions(-)
diff --git a/t/t4109-apply-multifrag.sh b/t/t4109-apply-multifrag.sh
index bd40a21..4805863 100755
--- a/t/t4109-apply-multifrag.sh
+++ b/t/t4109-apply-multifrag.sh
@@ -138,39 +138,112 @@ diff --git a/main.c b/main.c
EOF
-test_expect_success "S = git apply (1)" \
- 'git apply patch1.patch patch2.patch'
-mv main.c main.c.git
+cat >expect_1 <<\EOF
+#include <stdlib.h>
+#include <stdio.h>
-test_expect_success "S = patch (1)" \
- 'cat patch1.patch patch2.patch | patch -p1'
+int func(int num);
+void print_int(int num);
+void print_ln();
-test_expect_success "S = cmp (1)" \
- 'cmp main.c.git main.c'
+int main() {
+ int i;
-rm -f main.c main.c.git
+ for (i = 0; i < 10; i++) {
+ print_int(func(i));
+ }
-test_expect_success "S = git apply (2)" \
- 'git apply patch1.patch patch2.patch patch3.patch'
-mv main.c main.c.git
+ print_ln();
-test_expect_success "S = patch (2)" \
- 'cat patch1.patch patch2.patch patch3.patch | patch -p1'
+ return 0;
+}
-test_expect_success "S = cmp (2)" \
- 'cmp main.c.git main.c'
+int func(int num) {
+ return num * num;
+}
-rm -f main.c main.c.git
+void print_int(int num) {
+ printf("%d", num);
+}
-test_expect_success "S = git apply (3)" \
- 'git apply patch1.patch patch4.patch'
-mv main.c main.c.git
+void print_ln() {
+ printf("\n");
+}
-test_expect_success "S = patch (3)" \
- 'cat patch1.patch patch4.patch | patch -p1'
+EOF
+
+test_expect_success 'git apply (1)' '
+ git apply patch1.patch patch2.patch &&
+ mv main.c actual &&
+ test_cmp expect_1 actual
+'
+
+cat >expect_2 <<\EOF
+#include <stdio.h>
+
+int func(int num);
+void print_int(int num);
+
+int main() {
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ print_int(func(i));
+ }
+
+ return 0;
+}
+
+int func(int num) {
+ return num * num;
+}
+
+void print_int(int num) {
+ printf("%d", num);
+}
+
+EOF
-test_expect_success "S = cmp (3)" \
- 'cmp main.c.git main.c'
+test_expect_success 'git apply (2)' '
+ rm -f main.c &&
+ git apply patch1.patch patch2.patch patch3.patch &&
+ mv main.c actual &&
+ test_cmp expect_2 actual
+'
+
+cat >expect_3 <<\EOF
+#include <stdio.h>
+
+int func(int num);
+int func2(int num);
+
+int main() {
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ printf("%d", func(i));
+ printf("%d", func3(i));
+ }
+
+ return 0;
+}
+
+int func(int num) {
+ return num * num;
+}
+
+int func2(int num) {
+ return num * num * num;
+}
+
+EOF
+
+test_expect_success 'git apply (3)' '
+ rm -f main.c &&
+ git apply patch1.patch patch4.patch &&
+ mv main.c actual &&
+ test_cmp expect_3 actual
+'
test_done
diff --git a/t/t4110-apply-scan.sh b/t/t4110-apply-scan.sh
index db60652..ae300ca 100755
--- a/t/t4110-apply-scan.sh
+++ b/t/t4110-apply-scan.sh
@@ -86,15 +86,34 @@ diff --git a/new.txt b/new.txt
+c2222
EOF
-test_expect_success "S = git apply scan" \
- 'git apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch'
-mv new.txt apply.txt
+cat >expect <<\EOF
+a1
+a11
+a111
+a1111
+b1
+b11
+b111
+b1111
+b2
+b22
+b222
+b2222
+c1
+c11
+c111
+c1111
+c2
+c22
+c222
+c2222
+EOF
-test_expect_success "S = patch scan" \
- 'cat patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch | patch'
-mv new.txt patch.txt
-test_expect_success "S = cmp" \
- 'cmp apply.txt patch.txt'
+test_expect_success 'apply series of patches' '
+ git apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch &&
+ mv new.txt actual &&
+ test_cmp expect actual
+'
test_done
next prev parent reply other threads:[~2008-07-20 8:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-16 17:57 Hacks for AIX Chris Cowan
2008-07-16 18:25 ` Junio C Hamano
2008-07-18 23:14 ` Brandon Casey
2008-07-20 8:33 ` Junio C Hamano [this message]
2008-07-21 15:39 ` Brandon Casey
2008-07-22 21:42 ` Brandon Casey
2008-07-16 18:26 ` Linus Torvalds
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=7vd4l9c5ud.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=casey@nrlssc.navy.mil \
--cc=chris.o.cowan@gmail.com \
--cc=git@vger.kernel.org \
/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).