File: errors.svtest

package info (click to toggle)
dovecot 1:2.2.13-12~deb8u4
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,792 kB
  • sloc: ansic: 341,472; sh: 16,920; makefile: 5,393; cpp: 1,474; perl: 265; xml: 44; python: 34; pascal: 27
file content (367 lines) | stat: -rw-r--r-- 7,981 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
require "vnd.dovecot.testsuite";

require "relational";
require "comparator-i;ascii-numeric";

/*
 * Errors triggered in the compiled scripts are pretty reduntant over the
 * tested commands, but we want to be thorough.
 */

/*
 * Lexer errors
 */

test "Lexer errors (FIXME: count only)" {
	if test_script_compile "errors/lexer.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "10" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Parser errors
 */

test "Parser errors (FIXME: count only)" {
	if test_script_compile "errors/parser.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "9" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Header test
 */

test "Header errors" {
	if test_script_compile "errors/header.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "10" {
		test_fail "wrong number of errors reported";
	}

	if not test_error :index 1 :matches
		"unknown * ':all' for * header test *" {
		test_fail "error 1 is invalid";
	}

	if not test_error :index 2 :matches
		"*header test * string list * 1 (header names), but * number *" {
		test_fail "error 2 is invalid";
	}

	if not test_error :index 3 :matches
		"*header test * string list * 2 (key list), * number *" {
		test_fail "error 3 is invalid";
	}

	if not test_error :index 4 :matches
		"* unexpected tagged argument ':tag' while *" {
		test_fail "error 4 is invalid";
	}

	if not test_error :index 5 :matches
		"* header test requires 2 *, but 1 *" {
		test_fail "error 5 is invalid";
	}

	if not test_error :index 6 :matches
		"* header test requires 2 *, but 0 *" {
		test_fail "error 6 is invalid";
	}

	if not test_error :index 7 :matches
		"*header test accepts no sub-tests* specified*" {
		test_fail "error 7 is invalid";
	}

	if not test_error :index 8 :matches
		"* use test 'header' * command*" {
		test_fail "error 8 is invalid";
	}

	if not test_error :index 9 :matches
		"* use test 'header' * command*" {
		test_fail "error 9 is invalid";
	}

	if test_error :index 4 :contains "radish" {
		test_fail "error test matched nonsense";
	}
}

/*
 * Address test
 */


test "Address errors" {
	if test_script_compile "errors/address.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "9" {
		test_fail "wrong number of errors reported";
	}

	if not test_error :index 1 :matches
		"*unknown * ':nonsense' * address test*" {
		test_fail "error 1 is invalid";
	}

	if not test_error :index 2 :matches
		"*address test expects *string list * 1 (header list),* number * found*" {
		test_fail "error 2 is invalid";
	}

	if not test_error :index 3 :matches
		"*address test expects *string list * 2 (key list),* number * found*" {
		test_fail "error 3 is invalid";
	}

	if not test_error :index 4 :matches
		"*unexpected *':is' * address test*" {
		test_fail "error 4 is invalid";
	}

	if not test_error :index 5 :matches
		"*address test * 2 positional arg*, but 1*" {
		test_fail "error 5 is invalid";
	}

	if not test_error :index 6 :matches
		"*address test * 2 positional arg*, but 0*" {
		test_fail "error 6 is invalid";
	}

	if not test_error :index 7 :matches
		"*'frop' *not allowed *address test*" {
		test_fail "error 7 is invalid";
	}

	if not test_error :index 8 :matches
		"*'frop' *not allowed *address test*" {
		test_fail "error 8 is invalid";
	}

	if test_error :index 23 :contains "radish" {
		test_fail "error test matched nonsense";
	}
}

/*
 * If command
 */

test "If errors (FIXME: count only)" {
	if test_script_compile "errors/if.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "12" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Require command
 */

test "Require errors (FIXME: count only)" {
	if test_script_compile "errors/require.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "15" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Size test
 */

test "Size errors (FIXME: count only)" {
	if test_script_compile "errors/size.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "7" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Envelope test
 */

test "Envelope errors (FIXME: count only)" {
	if test_script_compile "errors/envelope.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Stop command
 */

test "Stop errors (FIXME: count only)" {
	if test_script_compile "errors/stop.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "9" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Keep command
 */

test "Keep errors (FIXME: count only)" {
	if test_script_compile "errors/keep.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * ADDRESS-PART errors
 */

test "ADDRESS-PART errors (FIXME: count only)" {
	if test_script_compile "errors/address-part.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * MATCH-TYPE errors
 */

test "MATCH-TYPE errors (FIXME: count only)" {
	if test_script_compile "errors/match-type.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "2" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Encoded-character errors
 */

test "Encoded-character errors (FIXME: count only)" {
	if test_script_compile "errors/encoded-character.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Outgoing address errors
 */

test "Outgoing address errors (FIXME: count only)" {
	if test_script_compile "errors/out-address.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "15" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Tagged argument errors
 */

test "Tagged argument errors (FIXME: count only)" {
	if test_script_compile "errors/tag.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}
}

/*
 * Typos
 */

test "Typos" {
	if test_script_compile "errors/typos.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "6" {
		test_fail "wrong number of errors reported";
	}

	if not test_error :index 1 :matches
		"missing semicolon * fileinto *" {
		test_fail "error 1 is invalid";
	}

	if not test_error :index 2 :matches
		"*fileinto command * no *tests* specified*" {
		test_fail "error 2 is invalid";
	}

	if not test_error :index 3 :matches
		"missing semicolon * fileinto *" {
		test_fail "error 3 is invalid";
	}

	if not test_error :index 4 :matches
		"*address test requires 2 * 0 * specified" {
		test_fail "error 4 is invalid";
	}

	if not test_error :index 5 :matches
		"missing colon *matches* tag * address test" {
		test_fail "error 5 is invalid";
	}
}


/*
 * Unsupported language features
 */

test "Unsupported language features (FIXME: count only)" {
	if test_script_compile "errors/unsupported.sieve" {
		test_fail "compile should have failed.";
	}

	if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
		test_fail "wrong number of errors reported";
	}
}