source: MondoRescue/branches/2.2.9/mindi-busybox/testsuite/patch.tests@ 2725

Last change on this file since 2725 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/bin/sh
2# Copyright 2008 by Denys Vlasenko
3# Licensed under GPLv2, see file LICENSE in this source tree.
4
5. ./testing.sh
6
7# testing "test name" "command(s)" "expected result" "file input" "stdin"
8
9testing "patch with old_file == new_file" \
10 'patch 2>&1; echo $?; cat input' \
11"\
12patching file input
130
14qwe
15asd
16zxc
17" \
18"\
19qwe
20zxc
21" \
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
31testing "patch with nonexistent old_file" \
32 'patch 2>&1; echo $?; cat input' \
33"\
34patching file input
350
36qwe
37asd
38zxc
39" \
40"\
41qwe
42zxc
43" \
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
53testing "patch -R with nonexistent old_file" \
54 'patch -R 2>&1; echo $?; cat input' \
55"\
56patching file input
570
58qwe
59zxc
60" \
61"\
62qwe
63asd
64zxc
65" \
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
75testing "patch detects already applied hunk" \
76 'patch 2>&1; echo $?; cat input' \
77"\
78Possibly reversed hunk 1 at 4
79Hunk 1 FAILED 1/1.
80 abc
81+def
82 123
83patching file input
841
85abc
86def
87123
88" \
89"\
90abc
91def
92123
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
103testing "patch detects already applied hunk at the EOF" \
104 'patch 2>&1; echo $?; cat input' \
105"\
106Possibly reversed hunk 1 at 4
107Hunk 1 FAILED 1/1.
108 abc
109 123
110+456
111patching file input
1121
113abc
114123
115456
116" \
117"\
118abc
119123
120456
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
131# testing "test name" "command(s)" "expected result" "file input" "stdin"
132testing "patch -N ignores already applied hunk" \
133 'patch -N 2>&1; echo $?; cat input' \
134"\
135patching file input
1360
137abc
138def
139123
140" \
141"\
142abc
143def
144123
145" \
146"\
147--- input
148+++ input
149@@ -1,2 +1,3 @@
150 abc
151+def
152 123
153" \
154
155# testing "test name" "command(s)" "expected result" "file input" "stdin"
156testing "patch FILE PATCH" \
157 'cat >a.patch; patch input a.patch 2>&1; echo $?; cat input; rm a.patch' \
158"\
159patching file input
1600
161abc
162def
163123
164" \
165"\
166abc
167123
168" \
169"\
170--- foo.old
171+++ foo
172@@ -1,2 +1,3 @@
173 abc
174+def
175 123
176" \
177
178rm input.orig 2>/dev/null
179
180exit $FAILCOUNT
Note: See TracBrowser for help on using the repository browser.