]>
git.saurik.com Git - apt.git/blob - test/integration/test-method-rred
4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'i386'
10 echo 'Package: coolstuff
12 Description: collection of stuff
13 A lot, too much to iterate all, but at least this:
22 Description: collection of outdated stuff
23 A lot, but of no use nowadays, but at least this:
28 And a dog.' > Packages
33 echo -n '' > Packages.ed
35 echo "$3" > Packages.ed
38 cat Packages | runapt "${METHODSDIR}/rred
" "$@
"
40 testsuccessequal "$4" --nomsg rred -f Packages.ed
41 testsuccess runapt "${METHODSDIR}/rred
" -t Packages Packages-patched Packages.ed
42 testfileequal Packages-patched "$4"
45 testrred 'Remove' 'first line' '1d' "$(tail -n +2 ./Packages)"
46 testrred 'Remove' 'empty line' '10d' "$(head -n 9 ./Packages)
47 $(tail -n 9 ./Packages)"
48 testrred 'Remove' 'line in a paragraph' '5d' "$(head -n 4 ./Packages)
49 $(tail -n 14 ./Packages)"
50 testrred 'Remove' 'last line' '19d' "$(head -n -1 ./Packages)"
51 testrred 'Remove' 'multiple single lines' '17d
52 7d' "$(sed -e '/^ - even more stuff$/ d' ./Packages)"
53 testrred 'Remove' 'first paragraph' '1,10d' "$(tail -n 9 ./Packages)"
54 testrred 'Remove' 'a few lines in the middle' '5,14d' "$(head -n 4 ./Packages)
55 $(tail -n 5 ./Packages)"
56 testrred 'Remove' 'second paragraph' '10,19d' "$(head -n 9 ./Packages)"
57 testrred 'Mass Remove' 'all stuff lines' '15,17d
62 1d' "$(sed '/stuff/ d' ./Packages)"
64 testrred 'Single line add' 'first line' '0a
66 .' "Format
: 3.0 (native
)
68 testrred 'Single line add' 'last line' '19a
72 testrred 'Single line add' 'middle' '9a
74 .' "$(head -n 9 ./Packages)
76 $(tail -n 10 ./Packages)"
78 testrred 'Multi line add' 'first line' '0a
81 .' "Format
: 3.0 (native
)
84 testrred 'Multi line add' 'last line' '19a
86 Homepage: https://debian.org
89 Homepage
: https
://debian.org
"
90 testrred 'Multi line add' 'middle' '9a
92 Homepage: https://debian.org
93 .' "$(head -n 9 ./Packages)
95 Homepage
: https
://debian.org
96 $(tail -n 10 ./Packages)"
98 testrred 'Single line change' 'first line' '1c
99 Package: supercoolstuff
100 .' "Package
: supercoolstuff
101 $(tail -n +2 ./Packages)"
102 testrred 'Single line change' 'in the middle' '9c
104 .' "$(head -n 8 ./Packages)
106 $(tail -n 10 ./Packages)"
107 testrred 'Single line change' 'an empty line' '10c
109 .' "$(head -n 9 ./Packages)
111 $(tail -n 9 ./Packages)"
112 testrred 'Single line change' 'a spacy line' '10c
114 .' "$(head -n 9 ./Packages)
116 $(tail -n 9 ./Packages)"
117 testrred 'Single line change' 'last line' '19c
119 .' "$(head -n -1 ./Packages)
122 testrred 'Multi line change' 'exchange' '5,7c
125 - even more good stuff
126 .' "$(head -n 4 ./Packages)
129 - even
more good stuff
130 $(tail -n 12 ./Packages)"
131 testrred 'Multi line change' 'less' '5,7c
134 .' "$(head -n 4 ./Packages)
137 $(tail -n 12 ./Packages)"
138 testrred 'Multi line change' 'more' '5,7c
141 - even more good stuff
143 .' "$(head -n 4 ./Packages)
146 - even
more good stuff
148 $(tail -n 12 ./Packages)"
151 msgtest 'Failure caused by' "$1"
152 echo "$2" > Packages.ed
154 cat Packages | runapt "${METHODSDIR}/rred
" "$@
"
156 testfailure --nomsg rred -f Packages.ed
157 testfailure runapt "${METHODSDIR}/rred
" -t Packages Packages-patched Packages.ed
160 failrred 'Bogus content' '<html>
163 # not a problem per-se, but we want our parser to be really strict
164 failrred 'Empty patch file' ''
165 failrred 'Empty line patch file' '
167 failrred 'Empty line before command' '
169 failrred 'Empty line after command' '1d
171 failrred 'Empty line between commands' '17d
174 failrred 'Empty spaces lines before command' '
176 failrred 'Empty spaces lines after command' '1d
178 failrred 'Empty spaces lines between commands' '17d
182 # the line before the first one can't be deleted/changed
183 failrred 'zero line delete' '0d'
184 failrred 'zero line change' '0c
185 Package: supercoolstuff
187 # and this makes no sense at all
188 failrred 'negative line delete' '-1d'
189 failrred 'negative line change' '-1c
190 Package: supercoolstuff
192 failrred 'negative line add' '-1a
193 Package: supercoolstuff
195 failrred 'Wrong order of commands' '7d
197 failrred 'End before start' '7,6d'