diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t4109-apply-multifrag.sh | 55 | ||||
-rw-r--r-- | t/t4109/expect-1 | 31 | ||||
-rw-r--r-- | t/t4109/expect-2 | 23 | ||||
-rw-r--r-- | t/t4109/expect-3 | 24 | ||||
-rwxr-xr-x | t/t4110-apply-scan.sh | 96 | ||||
-rw-r--r-- | t/t4110/expect | 20 | ||||
-rw-r--r-- | t/t4110/patch1.patch | 17 | ||||
-rw-r--r-- | t/t4110/patch2.patch | 11 | ||||
-rw-r--r-- | t/t4110/patch3.patch | 14 | ||||
-rw-r--r-- | t/t4110/patch4.patch | 11 | ||||
-rw-r--r-- | t/t4110/patch5.patch | 11 |
11 files changed, 190 insertions, 123 deletions
diff --git a/t/t4109-apply-multifrag.sh b/t/t4109-apply-multifrag.sh index ff5fdf35f9..ac58083fe2 100755 --- a/t/t4109-apply-multifrag.sh +++ b/t/t4109-apply-multifrag.sh @@ -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 . - -test_expect_success "S = git apply (1)" \ - 'git apply patch1.patch patch2.patch' -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' +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 = cmp (2)" \ - 'cmp main.c.git main.c' +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 -rm -f main.c main.c.git +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 "S = git apply (3)" \ - 'git apply patch1.patch patch4.patch' +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 (3)" \ - 'cat patch1.patch patch4.patch | patch -p1' - -test_expect_success "S = cmp (3)" \ - 'cmp main.c.git main.c' - test_done diff --git a/t/t4109/expect-1 b/t/t4109/expect-1 new file mode 100644 index 0000000000..1db5ff1050 --- /dev/null +++ b/t/t4109/expect-1 @@ -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"); +} + diff --git a/t/t4109/expect-2 b/t/t4109/expect-2 new file mode 100644 index 0000000000..bc52924112 --- /dev/null +++ b/t/t4109/expect-2 @@ -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); +} + diff --git a/t/t4109/expect-3 b/t/t4109/expect-3 new file mode 100644 index 0000000000..cd2a475feb --- /dev/null +++ b/t/t4109/expect-3 @@ -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; +} + diff --git a/t/t4110-apply-scan.sh b/t/t4110-apply-scan.sh index db60652a37..09f58112e0 100755 --- a/t/t4110-apply-scan.sh +++ b/t/t4110-apply-scan.sh @@ -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 diff --git a/t/t4110/expect b/t/t4110/expect new file mode 100644 index 0000000000..87cc493ec8 --- /dev/null +++ b/t/t4110/expect @@ -0,0 +1,20 @@ +a1 +a11 +a111 +a1111 +b1 +b11 +b111 +b1111 +b2 +b22 +b222 +b2222 +c1 +c11 +c111 +c1111 +c2 +c22 +c222 +c2222 diff --git a/t/t4110/patch1.patch b/t/t4110/patch1.patch new file mode 100644 index 0000000000..56139080dc --- /dev/null +++ b/t/t4110/patch1.patch @@ -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 diff --git a/t/t4110/patch2.patch b/t/t4110/patch2.patch new file mode 100644 index 0000000000..04974247ec --- /dev/null +++ b/t/t4110/patch2.patch @@ -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 diff --git a/t/t4110/patch3.patch b/t/t4110/patch3.patch new file mode 100644 index 0000000000..26bd4427f8 --- /dev/null +++ b/t/t4110/patch3.patch @@ -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 diff --git a/t/t4110/patch4.patch b/t/t4110/patch4.patch new file mode 100644 index 0000000000..9ffb9c2d7e --- /dev/null +++ b/t/t4110/patch4.patch @@ -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 diff --git a/t/t4110/patch5.patch b/t/t4110/patch5.patch new file mode 100644 index 0000000000..c5ac6914f9 --- /dev/null +++ b/t/t4110/patch5.patch @@ -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 |