tests: do not rely on external "patch"
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>maint
parent
c79cc2e596
commit
ac2e28c0a4
|
@ -4,49 +4,32 @@
|
|||
# Copyright (c) 2005 Robert Fitzsimons
|
||||
#
|
||||
|
||||
test_description='git apply test patches with multiple fragments.
|
||||
test_description='git apply test patches with multiple fragments.'
|
||||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
cp ../t4109/patch1.patch .
|
||||
cp ../t4109/patch2.patch .
|
||||
cp ../t4109/patch3.patch .
|
||||
cp ../t4109/patch4.patch .
|
||||
cp "$TEST_DIRECTORY/t4109/patch1.patch" .
|
||||
cp "$TEST_DIRECTORY/t4109/patch2.patch" .
|
||||
cp "$TEST_DIRECTORY/t4109/patch3.patch" .
|
||||
cp "$TEST_DIRECTORY/t4109/patch4.patch" .
|
||||
|
||||
test_expect_success "S = git apply (1)" \
|
||||
'git apply patch1.patch patch2.patch'
|
||||
test_expect_success 'git apply (1)' '
|
||||
git apply patch1.patch patch2.patch &&
|
||||
test_cmp "$TEST_DIRECTORY/t4109/expect-1" main.c
|
||||
'
|
||||
rm -f main.c
|
||||
|
||||
test_expect_success 'git apply (2)' '
|
||||
git apply patch1.patch patch2.patch patch3.patch &&
|
||||
test_cmp "$TEST_DIRECTORY/t4109/expect-2" main.c
|
||||
'
|
||||
rm -f main.c
|
||||
|
||||
test_expect_success 'git apply (3)' '
|
||||
git apply patch1.patch patch4.patch &&
|
||||
test_cmp "$TEST_DIRECTORY/t4109/expect-3" main.c
|
||||
'
|
||||
mv main.c main.c.git
|
||||
|
||||
test_expect_success "S = patch (1)" \
|
||||
'cat patch1.patch patch2.patch | patch -p1'
|
||||
|
||||
test_expect_success "S = cmp (1)" \
|
||||
'cmp main.c.git main.c'
|
||||
|
||||
rm -f main.c main.c.git
|
||||
|
||||
test_expect_success "S = git apply (2)" \
|
||||
'git apply patch1.patch patch2.patch patch3.patch'
|
||||
mv main.c main.c.git
|
||||
|
||||
test_expect_success "S = patch (2)" \
|
||||
'cat patch1.patch patch2.patch patch3.patch | patch -p1'
|
||||
|
||||
test_expect_success "S = cmp (2)" \
|
||||
'cmp main.c.git main.c'
|
||||
|
||||
rm -f main.c main.c.git
|
||||
|
||||
test_expect_success "S = git apply (3)" \
|
||||
'git apply patch1.patch patch4.patch'
|
||||
mv main.c main.c.git
|
||||
|
||||
test_expect_success "S = patch (3)" \
|
||||
'cat patch1.patch patch4.patch | patch -p1'
|
||||
|
||||
test_expect_success "S = cmp (3)" \
|
||||
'cmp main.c.git main.c'
|
||||
|
||||
test_done
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int func(int num);
|
||||
void print_int(int num);
|
||||
void print_ln();
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
print_int(func(i));
|
||||
}
|
||||
|
||||
print_ln();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int func(int num) {
|
||||
return num * num;
|
||||
}
|
||||
|
||||
void print_int(int num) {
|
||||
printf("%d", num);
|
||||
}
|
||||
|
||||
void print_ln() {
|
||||
printf("\n");
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#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);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#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;
|
||||
}
|
||||
|
|
@ -9,92 +9,14 @@ test_description='git apply test for patches which require scanning forwards and
|
|||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
# setup
|
||||
|
||||
cat > patch1.patch <<\EOF
|
||||
diff --git a/new.txt b/new.txt
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/new.txt
|
||||
@@ -0,0 +1,12 @@
|
||||
+a1
|
||||
+a11
|
||||
+a111
|
||||
+a1111
|
||||
+b1
|
||||
+b11
|
||||
+b111
|
||||
+b1111
|
||||
+c1
|
||||
+c11
|
||||
+c111
|
||||
+c1111
|
||||
EOF
|
||||
cat > patch2.patch <<\EOF
|
||||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -1,7 +1,3 @@
|
||||
-a1
|
||||
-a11
|
||||
-a111
|
||||
-a1111
|
||||
b1
|
||||
b11
|
||||
b111
|
||||
EOF
|
||||
cat > patch3.patch <<\EOF
|
||||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -6,6 +6,10 @@
|
||||
b11
|
||||
b111
|
||||
b1111
|
||||
+b2
|
||||
+b22
|
||||
+b222
|
||||
+b2222
|
||||
c1
|
||||
c11
|
||||
c111
|
||||
EOF
|
||||
cat > patch4.patch <<\EOF
|
||||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -1,3 +1,7 @@
|
||||
+a1
|
||||
+a11
|
||||
+a111
|
||||
+a1111
|
||||
b1
|
||||
b11
|
||||
b111
|
||||
EOF
|
||||
cat > patch5.patch <<\EOF
|
||||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -10,3 +10,7 @@
|
||||
c11
|
||||
c111
|
||||
c1111
|
||||
+c2
|
||||
+c22
|
||||
+c222
|
||||
+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
|
||||
|
||||
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 'git apply scan' '
|
||||
git apply \
|
||||
"$TEST_DIRECTORY/t4110/patch1.patch" \
|
||||
"$TEST_DIRECTORY/t4110/patch2.patch" \
|
||||
"$TEST_DIRECTORY/t4110/patch3.patch" \
|
||||
"$TEST_DIRECTORY/t4110/patch4.patch" \
|
||||
"$TEST_DIRECTORY/t4110/patch5.patch" &&
|
||||
test_cmp new.txt "$TEST_DIRECTORY/t4110/expect"
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
a1
|
||||
a11
|
||||
a111
|
||||
a1111
|
||||
b1
|
||||
b11
|
||||
b111
|
||||
b1111
|
||||
b2
|
||||
b22
|
||||
b222
|
||||
b2222
|
||||
c1
|
||||
c11
|
||||
c111
|
||||
c1111
|
||||
c2
|
||||
c22
|
||||
c222
|
||||
c2222
|
|
@ -0,0 +1,17 @@
|
|||
diff --git a/new.txt b/new.txt
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/new.txt
|
||||
@@ -0,0 +1,12 @@
|
||||
+a1
|
||||
+a11
|
||||
+a111
|
||||
+a1111
|
||||
+b1
|
||||
+b11
|
||||
+b111
|
||||
+b1111
|
||||
+c1
|
||||
+c11
|
||||
+c111
|
||||
+c1111
|
|
@ -0,0 +1,11 @@
|
|||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -1,7 +1,3 @@
|
||||
-a1
|
||||
-a11
|
||||
-a111
|
||||
-a1111
|
||||
b1
|
||||
b11
|
||||
b111
|
|
@ -0,0 +1,14 @@
|
|||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -6,6 +6,10 @@
|
||||
b11
|
||||
b111
|
||||
b1111
|
||||
+b2
|
||||
+b22
|
||||
+b222
|
||||
+b2222
|
||||
c1
|
||||
c11
|
||||
c111
|
|
@ -0,0 +1,11 @@
|
|||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -1,3 +1,7 @@
|
||||
+a1
|
||||
+a11
|
||||
+a111
|
||||
+a1111
|
||||
b1
|
||||
b11
|
||||
b111
|
|
@ -0,0 +1,11 @@
|
|||
diff --git a/new.txt b/new.txt
|
||||
--- a/new.txt
|
||||
+++ b/new.txt
|
||||
@@ -10,3 +10,7 @@
|
||||
c11
|
||||
c111
|
||||
c1111
|
||||
+c2
|
||||
+c22
|
||||
+c222
|
||||
+c2222
|
Loading…
Reference in New Issue