Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2008 by Denys Vlasenko |
| 3 | # Licensed under GPL v2, see file LICENSE for details. |
| 4 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 5 | . ./testing.sh |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 6 | |
Denys Vlasenko | a4160e1 | 2010-08-16 01:33:57 +0200 | [diff] [blame] | 7 | # testing "test name" "command(s)" "expected result" "file input" "stdin" |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 8 | |
| 9 | testing "patch with old_file == new_file" \ |
Rob Landley | 1bbc0cd | 2010-08-13 15:50:26 +0200 | [diff] [blame] | 10 | 'patch 2>&1; echo $?; cat input' \ |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 11 | "\ |
| 12 | patching file input |
| 13 | 0 |
| 14 | qwe |
| 15 | asd |
| 16 | zxc |
| 17 | " \ |
Denys Vlasenko | 17c838b | 2009-10-24 17:11:55 +0200 | [diff] [blame] | 18 | "\ |
| 19 | qwe |
| 20 | zxc |
| 21 | " \ |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 22 | "\ |
| 23 | --- input Jan 01 01:01:01 2000 |
| 24 | +++ input Jan 01 01:01:01 2000 |
| 25 | @@ -1,2 +1,3 @@ |
| 26 | qwe |
| 27 | +asd |
| 28 | zxc |
| 29 | " \ |
| 30 | |
| 31 | testing "patch with nonexistent old_file" \ |
Rob Landley | 1bbc0cd | 2010-08-13 15:50:26 +0200 | [diff] [blame] | 32 | 'patch 2>&1; echo $?; cat input' \ |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 33 | "\ |
| 34 | patching file input |
| 35 | 0 |
| 36 | qwe |
| 37 | asd |
| 38 | zxc |
| 39 | " \ |
Denys Vlasenko | 17c838b | 2009-10-24 17:11:55 +0200 | [diff] [blame] | 40 | "\ |
| 41 | qwe |
| 42 | zxc |
| 43 | " \ |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 44 | "\ |
| 45 | --- input.doesnt_exist Jan 01 01:01:01 2000 |
| 46 | +++ input Jan 01 01:01:01 2000 |
| 47 | @@ -1,2 +1,3 @@ |
| 48 | qwe |
| 49 | +asd |
| 50 | zxc |
| 51 | " \ |
| 52 | |
Denis Vlasenko | 08ec67b | 2008-03-26 13:32:30 +0000 | [diff] [blame] | 53 | testing "patch -R with nonexistent old_file" \ |
Rob Landley | 1bbc0cd | 2010-08-13 15:50:26 +0200 | [diff] [blame] | 54 | 'patch -R 2>&1; echo $?; cat input' \ |
Denis Vlasenko | 08ec67b | 2008-03-26 13:32:30 +0000 | [diff] [blame] | 55 | "\ |
| 56 | patching file input |
| 57 | 0 |
| 58 | qwe |
| 59 | zxc |
| 60 | " \ |
Denys Vlasenko | 17c838b | 2009-10-24 17:11:55 +0200 | [diff] [blame] | 61 | "\ |
| 62 | qwe |
| 63 | asd |
| 64 | zxc |
| 65 | " \ |
Denis Vlasenko | 08ec67b | 2008-03-26 13:32:30 +0000 | [diff] [blame] | 66 | "\ |
| 67 | --- input.doesnt_exist Jan 01 01:01:01 2000 |
| 68 | +++ input Jan 01 01:01:01 2000 |
| 69 | @@ -1,2 +1,3 @@ |
| 70 | qwe |
| 71 | +asd |
| 72 | zxc |
| 73 | " \ |
| 74 | |
Denys Vlasenko | 17c838b | 2009-10-24 17:11:55 +0200 | [diff] [blame] | 75 | testing "patch detects already applied hunk" \ |
| 76 | 'patch 2>&1; echo $?; cat input' \ |
| 77 | "\ |
Rob Landley | 1bbc0cd | 2010-08-13 15:50:26 +0200 | [diff] [blame] | 78 | Possibly reversed hunk 1 at 2 |
| 79 | Hunk 1 FAILED 1/1. |
| 80 | abc |
| 81 | +def |
| 82 | 123 |
Denys Vlasenko | 17c838b | 2009-10-24 17:11:55 +0200 | [diff] [blame] | 83 | patching file input |
Denys Vlasenko | 17c838b | 2009-10-24 17:11:55 +0200 | [diff] [blame] | 84 | 1 |
| 85 | abc |
| 86 | def |
| 87 | 123 |
| 88 | " \ |
| 89 | "\ |
| 90 | abc |
| 91 | def |
| 92 | 123 |
| 93 | " \ |
| 94 | "\ |
| 95 | --- input.old Jan 01 01:01:01 2000 |
| 96 | +++ input Jan 01 01:01:01 2000 |
| 97 | @@ -1,2 +1,3 @@ |
| 98 | abc |
| 99 | +def |
| 100 | 123 |
| 101 | " \ |
| 102 | |
Denys Vlasenko | 3f75d7b | 2010-08-16 02:56:32 +0200 | [diff] [blame^] | 103 | testing "patch detects already applied hunk at the EOF" \ |
Denys Vlasenko | 6f2ebae | 2009-10-25 00:35:04 +0200 | [diff] [blame] | 104 | 'patch 2>&1; echo $?; cat input' \ |
| 105 | "\ |
Denys Vlasenko | 3f75d7b | 2010-08-16 02:56:32 +0200 | [diff] [blame^] | 106 | Possibly reversed hunk 1 at 3 |
| 107 | Hunk 1 FAILED 1/1. |
| 108 | abc |
| 109 | 123 |
| 110 | +456 |
Denys Vlasenko | 6f2ebae | 2009-10-25 00:35:04 +0200 | [diff] [blame] | 111 | patching file input |
Denys Vlasenko | 6f2ebae | 2009-10-25 00:35:04 +0200 | [diff] [blame] | 112 | 1 |
| 113 | abc |
| 114 | 123 |
| 115 | 456 |
| 116 | " \ |
| 117 | "\ |
| 118 | abc |
| 119 | 123 |
| 120 | 456 |
| 121 | " \ |
| 122 | "\ |
| 123 | --- input.old Jan 01 01:01:01 2000 |
| 124 | +++ input Jan 01 01:01:01 2000 |
| 125 | @@ -1,2 +1,3 @@ |
| 126 | abc |
| 127 | 123 |
| 128 | +456 |
| 129 | " \ |
| 130 | |
Denys Vlasenko | a4160e1 | 2010-08-16 01:33:57 +0200 | [diff] [blame] | 131 | # testing "test name" "command(s)" "expected result" "file input" "stdin" |
| 132 | |
| 133 | testing "patch -N ignores already applied hunk" \ |
| 134 | 'patch -N 2>&1; echo $?; cat input' \ |
| 135 | "\ |
| 136 | patching file input |
| 137 | 0 |
| 138 | abc |
| 139 | def |
| 140 | 123 |
| 141 | " \ |
| 142 | "\ |
| 143 | abc |
| 144 | def |
| 145 | 123 |
| 146 | " \ |
| 147 | "\ |
| 148 | --- input |
| 149 | +++ input |
| 150 | @@ -1,2 +1,3 @@ |
| 151 | abc |
| 152 | +def |
| 153 | 123 |
| 154 | " \ |
| 155 | |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 156 | rm input.orig 2>/dev/null |
| 157 | |
Denis Vlasenko | cc2965f | 2008-03-25 14:15:39 +0000 | [diff] [blame] | 158 | exit $FAILCOUNT |