blob: f55b53f6118133fbb7eb8dfe4541eff5b646c5b6 [file] [log] [blame]
Denis Vlasenkocc2965f2008-03-25 14:15:39 +00001#!/bin/sh
2# Copyright 2008 by Denys Vlasenko
3# Licensed under GPL v2, see file LICENSE for details.
4
Mike Frysingercaa79402009-11-04 18:41:22 -05005. ./testing.sh
Denis Vlasenkocc2965f2008-03-25 14:15:39 +00006
Denys Vlasenkoa4160e12010-08-16 01:33:57 +02007# testing "test name" "command(s)" "expected result" "file input" "stdin"
Denis Vlasenkocc2965f2008-03-25 14:15:39 +00008
9testing "patch with old_file == new_file" \
Rob Landley1bbc0cd2010-08-13 15:50:26 +020010 'patch 2>&1; echo $?; cat input' \
Denis Vlasenkocc2965f2008-03-25 14:15:39 +000011"\
12patching file input
130
14qwe
15asd
16zxc
17" \
Denys Vlasenko17c838b2009-10-24 17:11:55 +020018"\
19qwe
20zxc
21" \
Denis Vlasenkocc2965f2008-03-25 14:15:39 +000022"\
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" \
Rob Landley1bbc0cd2010-08-13 15:50:26 +020032 'patch 2>&1; echo $?; cat input' \
Denis Vlasenkocc2965f2008-03-25 14:15:39 +000033"\
34patching file input
350
36qwe
37asd
38zxc
39" \
Denys Vlasenko17c838b2009-10-24 17:11:55 +020040"\
41qwe
42zxc
43" \
Denis Vlasenkocc2965f2008-03-25 14:15:39 +000044"\
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 Vlasenko08ec67b2008-03-26 13:32:30 +000053testing "patch -R with nonexistent old_file" \
Rob Landley1bbc0cd2010-08-13 15:50:26 +020054 'patch -R 2>&1; echo $?; cat input' \
Denis Vlasenko08ec67b2008-03-26 13:32:30 +000055"\
56patching file input
570
58qwe
59zxc
60" \
Denys Vlasenko17c838b2009-10-24 17:11:55 +020061"\
62qwe
63asd
64zxc
65" \
Denis Vlasenko08ec67b2008-03-26 13:32:30 +000066"\
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 Vlasenko17c838b2009-10-24 17:11:55 +020075testing "patch detects already applied hunk" \
76 'patch 2>&1; echo $?; cat input' \
77"\
Rob Landley1bbc0cd2010-08-13 15:50:26 +020078Possibly reversed hunk 1 at 2
79Hunk 1 FAILED 1/1.
80 abc
81+def
82 123
Denys Vlasenko17c838b2009-10-24 17:11:55 +020083patching file input
Denys Vlasenko17c838b2009-10-24 17:11:55 +0200841
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
Denys Vlasenko3f75d7b2010-08-16 02:56:32 +0200103testing "patch detects already applied hunk at the EOF" \
Denys Vlasenko6f2ebae2009-10-25 00:35:04 +0200104 'patch 2>&1; echo $?; cat input' \
105"\
Denys Vlasenko3f75d7b2010-08-16 02:56:32 +0200106Possibly reversed hunk 1 at 3
107Hunk 1 FAILED 1/1.
108 abc
109 123
110+456
Denys Vlasenko6f2ebae2009-10-25 00:35:04 +0200111patching file input
Denys Vlasenko6f2ebae2009-10-25 00:35:04 +02001121
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
Denys Vlasenkoa4160e12010-08-16 01:33:57 +0200131# testing "test name" "command(s)" "expected result" "file input" "stdin"
132
133testing "patch -N ignores already applied hunk" \
134 'patch -N 2>&1; echo $?; cat input' \
135"\
136patching file input
1370
138abc
139def
140123
141" \
142"\
143abc
144def
145123
146" \
147"\
148--- input
149+++ input
150@@ -1,2 +1,3 @@
151 abc
152+def
153 123
154" \
155
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +0200156rm input.orig 2>/dev/null
157
Denis Vlasenkocc2965f2008-03-25 14:15:39 +0000158exit $FAILCOUNT