Re: Hacks for AIX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> 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@xxxxxxxxx>
---
 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux