(imap4d_test): New flag -sort toggles on sorting of untagged responces.
Notice that -sort and -re are mutually exclusive.
Showing
1 changed file
with
38 additions
and
3 deletions
1 | # -*- tcl -*- | 1 | # -*- tcl -*- |
2 | # This file is part of Mailutils testsuite. | 2 | # This file is part of Mailutils testsuite. |
3 | # Copyright (C) 2002, Free Software Foundation | 3 | # Copyright (C) 2002, 2005, Free Software Foundation |
4 | # | 4 | # |
5 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
6 | # it under the terms of the GNU General Public License as published by | 6 | # it under the terms of the GNU General Public License as published by |
... | @@ -183,7 +183,7 @@ proc imap4d_auth {args} { | ... | @@ -183,7 +183,7 @@ proc imap4d_auth {args} { |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | # imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent] | 186 | # imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent][-sort] |
187 | # COMMAND [UNTAGGED...][TAGGED] | 187 | # COMMAND [UNTAGGED...][TAGGED] |
188 | # COMMAND - Command to send. | 188 | # COMMAND - Command to send. |
189 | # UNTAGGED - A list of untagged responses to expect in return. | 189 | # UNTAGGED - A list of untagged responses to expect in return. |
... | @@ -192,11 +192,12 @@ proc imap4d_auth {args} { | ... | @@ -192,11 +192,12 @@ proc imap4d_auth {args} { |
192 | proc imap4d_test {args} { | 192 | proc imap4d_test {args} { |
193 | global IMAP4D_TAG | 193 | global IMAP4D_TAG |
194 | global verbose | 194 | global verbose |
195 | 195 | ||
196 | set default "" | 196 | set default "" |
197 | set message "" | 197 | set message "" |
198 | set long 0 | 198 | set long 0 |
199 | set silent 0 | 199 | set silent 0 |
200 | set sort 0 | ||
200 | for {set i 0} {$i < [llength $args]} {incr i} { | 201 | for {set i 0} {$i < [llength $args]} {incr i} { |
201 | set a [lindex $args $i] | 202 | set a [lindex $args $i] |
202 | if {"$a" == "-default"} { | 203 | if {"$a" == "-default"} { |
... | @@ -209,6 +210,8 @@ proc imap4d_test {args} { | ... | @@ -209,6 +210,8 @@ proc imap4d_test {args} { |
209 | set long 1 | 210 | set long 1 |
210 | } elseif {"$a" == "-silent"} { | 211 | } elseif {"$a" == "-silent"} { |
211 | set silent 1 | 212 | set silent 1 |
213 | } elseif {"$a" == "-sort"} { | ||
214 | set sort 1 | ||
212 | } else { | 215 | } else { |
213 | set args [lrange $args $i end] | 216 | set args [lrange $args $i end] |
214 | break | 217 | break |
... | @@ -263,6 +266,7 @@ proc imap4d_test {args} { | ... | @@ -263,6 +266,7 @@ proc imap4d_test {args} { |
263 | set tagged "OK" | 266 | set tagged "OK" |
264 | } | 267 | } |
265 | 268 | ||
269 | verbose "TAGGED $tagged" | ||
266 | if {$long} { | 270 | if {$long} { |
267 | set command "$command {[string length $command_data]}" | 271 | set command "$command {[string length $command_data]}" |
268 | imap4d_command $command | 272 | imap4d_command $command |
... | @@ -282,6 +286,37 @@ proc imap4d_test {args} { | ... | @@ -282,6 +286,37 @@ proc imap4d_test {args} { |
282 | set s [split $command_data "\n"] | 286 | set s [split $command_data "\n"] |
283 | set s [lrange $s 0 [expr [llength $s] - 2]] | 287 | set s [lrange $s 0 [expr [llength $s] - 2]] |
284 | set result [mu_expect_list 360 [concat $s $pattern]] | 288 | set result [mu_expect_list 360 [concat $s $pattern]] |
289 | } elseif {$sort && [llength $pattern] > 0} { | ||
290 | set command [imap4d_make_command $command] | ||
291 | set result [mu_test $command [list "-re" "(.*)\n$IMAP4D_TAG $tagged"]] | ||
292 | if {$result == 0} { | ||
293 | if [info exists expect_out(1,string)] { | ||
294 | set out [lsort -ascii [split $expect_out(1,string) "\n"]] | ||
295 | set in [lsort -ascii $pattern] | ||
296 | if {[llength $in] == [llength $out]} { | ||
297 | for {set i 0} {$i < [llength $in]} {incr i} { | ||
298 | regexp "(\[^\r\]*)" [lindex $out $i] dummy tmp | ||
299 | if [string compare [lindex $in $i] $tmp] { | ||
300 | verbose "Item $i comparison failed" | ||
301 | set result 1 | ||
302 | break | ||
303 | } | ||
304 | } | ||
305 | } else { | ||
306 | verbose "Input and output lists have different lengths" | ||
307 | set result 1 | ||
308 | } | ||
309 | |||
310 | if {$result} { | ||
311 | verbose "Input: $in" | ||
312 | verbose "Output: $out" | ||
313 | } | ||
314 | |||
315 | } else { | ||
316 | verbose "expect_out(1,string) does not exist. Buffer: $expect_out(buffer)" | ||
317 | set result 1 | ||
318 | } | ||
319 | } | ||
285 | } else { | 320 | } else { |
286 | set command [imap4d_make_command $command] | 321 | set command [imap4d_make_command $command] |
287 | set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]] | 322 | set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]] | ... | ... |
-
Please register or sign in to post a comment