blob: 178048d2a3a7d972dcdb85069f7a41577c0edd71 [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
5. testing.sh
6
7# testing "test name" "options" "expected result" "file input" "stdin"
8
9testing "patch with old_file == new_file" \
Denys Vlasenko17c838b2009-10-24 17:11:55 +020010 'patch; 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" \
Denys Vlasenko17c838b2009-10-24 17:11:55 +020032 'patch; 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" \
Denys Vlasenko17c838b2009-10-24 17:11:55 +020054 'patch -R; 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"\
78patching file input
79patch: hunk #1 FAILED at 1
80patch: 1 out of 1 hunk FAILED
811
82abc
83def
84123
85" \
86"\
87abc
88def
89123
90" \
91"\
92--- input.old Jan 01 01:01:01 2000
93+++ input Jan 01 01:01:01 2000
94@@ -1,2 +1,3 @@
95 abc
96+def
97 123
98" \
99
Denis Vlasenkocc2965f2008-03-25 14:15:39 +0000100exit $FAILCOUNT