1 | # -*- tcl -*- |
---|
2 | # Commands covered: pkg |
---|
3 | # |
---|
4 | # This file contains a collection of tests for one or more of the Tcl |
---|
5 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
6 | # generates output for errors. No output means no errors were found. |
---|
7 | # |
---|
8 | # Copyright (c) 1995-1996 Sun Microsystems, Inc. |
---|
9 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and redistribution |
---|
12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | # |
---|
14 | # RCS: @(#) $Id: pkg.test,v 1.29 2007/12/13 15:26:07 dgp Exp $ |
---|
15 | |
---|
16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
17 | package require tcltest 2 |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | |
---|
21 | # Do all this in a slave interp to avoid garbaging the |
---|
22 | # package list |
---|
23 | set i [interp create] |
---|
24 | interp eval $i [list set argv $argv] |
---|
25 | interp eval $i [list package require tcltest 2] |
---|
26 | interp eval $i [list namespace import -force ::tcltest::*] |
---|
27 | interp eval $i { |
---|
28 | |
---|
29 | package forget {*}[package names] |
---|
30 | set oldPkgUnknown [package unknown] |
---|
31 | package unknown {} |
---|
32 | set oldPath $auto_path |
---|
33 | set auto_path "" |
---|
34 | |
---|
35 | test pkg-1.1 {Tcl_PkgProvide procedure} { |
---|
36 | package forget t |
---|
37 | package provide t 2.3 |
---|
38 | } {} |
---|
39 | test pkg-1.2 {Tcl_PkgProvide procedure} { |
---|
40 | package forget t |
---|
41 | package provide t 2.3 |
---|
42 | list [catch {package provide t 2.2} msg] $msg |
---|
43 | } {1 {conflicting versions provided for package "t": 2.3, then 2.2}} |
---|
44 | test pkg-1.3 {Tcl_PkgProvide procedure} { |
---|
45 | package forget t |
---|
46 | package provide t 2.3 |
---|
47 | list [catch {package provide t 2.4} msg] $msg |
---|
48 | } {1 {conflicting versions provided for package "t": 2.3, then 2.4}} |
---|
49 | test pkg-1.4 {Tcl_PkgProvide procedure} { |
---|
50 | package forget t |
---|
51 | package provide t 2.3 |
---|
52 | list [catch {package provide t 3.3} msg] $msg |
---|
53 | } {1 {conflicting versions provided for package "t": 2.3, then 3.3}} |
---|
54 | test pkg-1.5 {Tcl_PkgProvide procedure} { |
---|
55 | package forget t |
---|
56 | package provide t 2.3 |
---|
57 | package provide t 2.3 |
---|
58 | } {} |
---|
59 | |
---|
60 | test pkg-1.6 {Tcl_PkgProvide procedure} { |
---|
61 | package forget t |
---|
62 | package provide t 2.3a1 |
---|
63 | } {} |
---|
64 | |
---|
65 | set n 0 |
---|
66 | foreach v { |
---|
67 | 2.3k1 2a3a2 2ab3 2.a4 2.b4 2b.4 2a.4 2ba4 2a4b1 |
---|
68 | 2b4a1 2b3b2 |
---|
69 | } { |
---|
70 | test pkg-1.7.$n {Tcl_PkgProvide procedure} { |
---|
71 | package forget t |
---|
72 | list [catch {package provide t $v} msg] $msg |
---|
73 | } [list 1 "expected version number but got \"$v\""] |
---|
74 | incr n |
---|
75 | } |
---|
76 | |
---|
77 | test pkg-2.1 {Tcl_PkgRequire procedure, picking best version} { |
---|
78 | package forget t |
---|
79 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
80 | package ifneeded t $i "set x $i; package provide t $i" |
---|
81 | } |
---|
82 | set x xxx |
---|
83 | package require t |
---|
84 | set x |
---|
85 | } {3.4} |
---|
86 | test pkg-2.2 {Tcl_PkgRequire procedure, picking best version} { |
---|
87 | package forget t |
---|
88 | foreach i {1.4 3.4 2.3 2.4 2.2 3.5 3.2} { |
---|
89 | package ifneeded t $i "set x $i; package provide t $i" |
---|
90 | } |
---|
91 | set x xxx |
---|
92 | package require t |
---|
93 | set x |
---|
94 | } {3.5} |
---|
95 | test pkg-2.3 {Tcl_PkgRequire procedure, picking best version} { |
---|
96 | package forget t |
---|
97 | foreach i {3.5 2.1 2.3} { |
---|
98 | package ifneeded t $i "set x $i; package provide t $i" |
---|
99 | } |
---|
100 | set x xxx |
---|
101 | package require t 2.2 |
---|
102 | set x |
---|
103 | } {2.3} |
---|
104 | test pkg-2.4 {Tcl_PkgRequire procedure, picking best version} { |
---|
105 | package forget t |
---|
106 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
107 | package ifneeded t $i "set x $i; package provide t $i" |
---|
108 | } |
---|
109 | set x xxx |
---|
110 | package require -exact t 2.3 |
---|
111 | set x |
---|
112 | } {2.3} |
---|
113 | test pkg-2.5 {Tcl_PkgRequire procedure, picking best version} { |
---|
114 | package forget t |
---|
115 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
116 | package ifneeded t $i "set x $i; package provide t $i" |
---|
117 | } |
---|
118 | set x xxx |
---|
119 | package require t 2.1 |
---|
120 | set x |
---|
121 | } {2.4} |
---|
122 | test pkg-2.6 {Tcl_PkgRequire procedure, can't find suitable version} { |
---|
123 | package forget t |
---|
124 | package unknown {} |
---|
125 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
126 | package ifneeded t $i "set x $i" |
---|
127 | } |
---|
128 | list [catch {package require t 2.5} msg] $msg |
---|
129 | } {1 {can't find package t 2.5}} |
---|
130 | test pkg-2.7 {Tcl_PkgRequire procedure, can't find suitable version} { |
---|
131 | package forget t |
---|
132 | package unknown {} |
---|
133 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
134 | package ifneeded t $i "set x $i" |
---|
135 | } |
---|
136 | list [catch {package require t 4.1} msg] $msg |
---|
137 | } {1 {can't find package t 4.1}} |
---|
138 | test pkg-2.8 {Tcl_PkgRequire procedure, can't find suitable version} { |
---|
139 | package forget t |
---|
140 | package unknown {} |
---|
141 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
142 | package ifneeded t $i "set x $i" |
---|
143 | } |
---|
144 | list [catch {package require -exact t 1.3} msg] $msg |
---|
145 | } {1 {can't find package t exactly 1.3}} |
---|
146 | test pkg-2.9 {Tcl_PkgRequire procedure, can't find suitable version} { |
---|
147 | package forget t |
---|
148 | package unknown {} |
---|
149 | list [catch {package require t} msg] $msg |
---|
150 | } {1 {can't find package t}} |
---|
151 | test pkg-2.10 {Tcl_PkgRequire procedure, error in ifneeded script} -body { |
---|
152 | package forget t |
---|
153 | package ifneeded t 2.1 {package provide t 2.1; error "ifneeded test"} |
---|
154 | list [catch {package require t 2.1} msg] $msg $::errorInfo |
---|
155 | } -match glob -result {1 {ifneeded test} {ifneeded test |
---|
156 | while executing |
---|
157 | "error "ifneeded test"" |
---|
158 | ("package ifneeded*" script) |
---|
159 | invoked from within |
---|
160 | "package require t 2.1"}} |
---|
161 | test pkg-2.11 {Tcl_PkgRequire procedure, ifneeded script doesn't provide package} -body { |
---|
162 | package forget t |
---|
163 | package ifneeded t 2.1 "set x invoked" |
---|
164 | set x xxx |
---|
165 | list [catch {package require t 2.1} msg] $msg $x |
---|
166 | } -match glob -result {1 * invoked} |
---|
167 | test pkg-2.12 {Tcl_PkgRequire procedure, self-deleting script} { |
---|
168 | package forget t |
---|
169 | package ifneeded t 1.2 "package forget t; set x 1.2; package provide t 1.2" |
---|
170 | set x xxx |
---|
171 | package require t 1.2 |
---|
172 | set x |
---|
173 | } {1.2} |
---|
174 | test pkg-2.13 {Tcl_PkgRequire procedure, "package unknown" support} { |
---|
175 | proc pkgUnknown args { |
---|
176 | # args = name requirement |
---|
177 | # requirement = v-v (for exact version) |
---|
178 | global x |
---|
179 | set x $args |
---|
180 | package provide [lindex $args 0] [lindex [split [lindex $args 1] -] 0] |
---|
181 | } |
---|
182 | package forget t |
---|
183 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
184 | package ifneeded t $i "set x $i" |
---|
185 | } |
---|
186 | package unknown pkgUnknown |
---|
187 | set x xxx |
---|
188 | package require -exact t 1.5 |
---|
189 | package unknown {} |
---|
190 | set x |
---|
191 | } {t 1.5-1.5} |
---|
192 | test pkg-2.14 {Tcl_PkgRequire procedure, "package unknown" support} { |
---|
193 | proc pkgUnknown args { |
---|
194 | package ifneeded t 1.2 "set x loaded; package provide t 1.2" |
---|
195 | } |
---|
196 | package forget t |
---|
197 | package unknown pkgUnknown |
---|
198 | set x xxx |
---|
199 | set result [list [package require t] $x] |
---|
200 | package unknown {} |
---|
201 | set result |
---|
202 | } {1.2 loaded} |
---|
203 | test pkg-2.15 {Tcl_PkgRequire procedure, "package unknown" support} { |
---|
204 | proc pkgUnknown args { |
---|
205 | global x |
---|
206 | set x $args |
---|
207 | package provide [lindex $args 0] 2.0 |
---|
208 | } |
---|
209 | package forget {a b} |
---|
210 | package unknown pkgUnknown |
---|
211 | set x xxx |
---|
212 | package require {a b} |
---|
213 | package unknown {} |
---|
214 | set x |
---|
215 | } {{a b} 0-} |
---|
216 | test pkg-2.16 {Tcl_PkgRequire procedure, "package unknown" error} { |
---|
217 | proc pkgUnknown args { |
---|
218 | error "testing package unknown" |
---|
219 | } |
---|
220 | package forget t |
---|
221 | package unknown pkgUnknown |
---|
222 | set result [list [catch {package require t} msg] $msg $::errorInfo] |
---|
223 | package unknown {} |
---|
224 | set result |
---|
225 | } {1 {testing package unknown} {testing package unknown |
---|
226 | while executing |
---|
227 | "error "testing package unknown"" |
---|
228 | (procedure "pkgUnknown" line 2) |
---|
229 | invoked from within |
---|
230 | "pkgUnknown t 0-" |
---|
231 | ("package unknown" script) |
---|
232 | invoked from within |
---|
233 | "package require t"}} |
---|
234 | test pkg-2.17 {Tcl_PkgRequire procedure, "package unknown" doesn't load package} { |
---|
235 | proc pkgUnknown args { |
---|
236 | global x |
---|
237 | set x $args |
---|
238 | } |
---|
239 | package forget t |
---|
240 | foreach i {1.4 3.4 2.3 2.4 2.2} { |
---|
241 | package ifneeded t $i "set x $i" |
---|
242 | } |
---|
243 | package unknown pkgUnknown |
---|
244 | set x xxx |
---|
245 | set result [list [catch {package require -exact t 1.5} msg] $msg $x] |
---|
246 | package unknown {} |
---|
247 | set result |
---|
248 | } {1 {can't find package t exactly 1.5} {t 1.5-1.5}} |
---|
249 | test pkg-2.18 {Tcl_PkgRequire procedure, version checks} { |
---|
250 | package forget t |
---|
251 | package provide t 2.3 |
---|
252 | package require t |
---|
253 | } {2.3} |
---|
254 | test pkg-2.19 {Tcl_PkgRequire procedure, version checks} { |
---|
255 | package forget t |
---|
256 | package provide t 2.3 |
---|
257 | package require t 2.1 |
---|
258 | } {2.3} |
---|
259 | test pkg-2.20 {Tcl_PkgRequire procedure, version checks} { |
---|
260 | package forget t |
---|
261 | package provide t 2.3 |
---|
262 | package require t 2.3 |
---|
263 | } {2.3} |
---|
264 | test pkg-2.21 {Tcl_PkgRequire procedure, version checks} { |
---|
265 | package forget t |
---|
266 | package provide t 2.3 |
---|
267 | list [catch {package require t 2.4} msg] $msg |
---|
268 | } {1 {version conflict for package "t": have 2.3, need 2.4}} |
---|
269 | test pkg-2.22 {Tcl_PkgRequire procedure, version checks} { |
---|
270 | package forget t |
---|
271 | package provide t 2.3 |
---|
272 | list [catch {package require t 1.2} msg] $msg |
---|
273 | } {1 {version conflict for package "t": have 2.3, need 1.2}} |
---|
274 | test pkg-2.23 {Tcl_PkgRequire procedure, version checks} { |
---|
275 | package forget t |
---|
276 | package provide t 2.3 |
---|
277 | package require -exact t 2.3 |
---|
278 | } {2.3} |
---|
279 | test pkg-2.24 {Tcl_PkgRequire procedure, version checks} { |
---|
280 | package forget t |
---|
281 | package provide t 2.3 |
---|
282 | list [catch {package require -exact t 2.2} msg] $msg |
---|
283 | } {1 {version conflict for package "t": have 2.3, need exactly 2.2}} |
---|
284 | test pkg-2.25 {Tcl_PkgRequire procedure, error in ifneeded script} -body { |
---|
285 | package forget t |
---|
286 | package ifneeded t 2.1 {package provide t 2.1; error "ifneeded test" EI} |
---|
287 | list [catch {package require t 2.1} msg] $msg $::errorInfo |
---|
288 | } -match glob -result {1 {ifneeded test} {EI |
---|
289 | ("package ifneeded*" script) |
---|
290 | invoked from within |
---|
291 | "package require t 2.1"}} |
---|
292 | test pkg-2.26 {Tcl_PkgRequire procedure, error in ifneeded script} -body { |
---|
293 | package forget t |
---|
294 | package ifneeded t 2.1 {package provide t 2.1; foreach x 1 {error "ifneeded test" EI}} |
---|
295 | list [catch {package require t 2.1} msg] $msg $::errorInfo |
---|
296 | } -match glob -result {1 {ifneeded test} {EI |
---|
297 | ("foreach" body line 1) |
---|
298 | invoked from within |
---|
299 | "foreach x 1 {error "ifneeded test" EI}" |
---|
300 | ("package ifneeded*" script) |
---|
301 | invoked from within |
---|
302 | "package require t 2.1"}} |
---|
303 | test pkg-2.27 {Tcl_PkgRequire: circular dependency} -setup { |
---|
304 | package forget foo |
---|
305 | } -body { |
---|
306 | package ifneeded foo 1 {package require foo 1} |
---|
307 | package require foo 1 |
---|
308 | } -cleanup { |
---|
309 | package forget foo |
---|
310 | } -returnCodes error -match glob -result {circular package dependency:*} |
---|
311 | test pkg-2.28 {Tcl_PkgRequire: circular dependency} -setup { |
---|
312 | package forget foo |
---|
313 | } -body { |
---|
314 | package ifneeded foo 1 {package require foo 2} |
---|
315 | package require foo 1 |
---|
316 | } -cleanup { |
---|
317 | package forget foo |
---|
318 | } -returnCodes error -match glob -result {circular package dependency:*} |
---|
319 | test pkg-2.29 {Tcl_PkgRequire: circular dependency} -setup { |
---|
320 | package forget foo |
---|
321 | package forget bar |
---|
322 | } -body { |
---|
323 | package ifneeded foo 1 {package require bar 1; package provide foo 1} |
---|
324 | package ifneeded bar 1 {package require foo 1; package provide bar 1} |
---|
325 | package require foo 1 |
---|
326 | } -cleanup { |
---|
327 | package forget foo |
---|
328 | package forget bar |
---|
329 | } -returnCodes error -match glob -result {circular package dependency:*} |
---|
330 | test pkg-2.30 {Tcl_PkgRequire: circular dependency} -setup { |
---|
331 | package forget foo |
---|
332 | package forget bar |
---|
333 | } -body { |
---|
334 | package ifneeded foo 1 {package require bar 1; package provide foo 1} |
---|
335 | package ifneeded foo 2 {package provide foo 2} |
---|
336 | package ifneeded bar 1 {package require foo 2; package provide bar 1} |
---|
337 | package require foo 1 |
---|
338 | } -cleanup { |
---|
339 | package forget foo |
---|
340 | package forget bar |
---|
341 | } -returnCodes error -match glob -result {circular package dependency:*} |
---|
342 | test pkg-2.31 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
343 | package forget foo |
---|
344 | } -body { |
---|
345 | package ifneeded foo 1 {package provide foo 1; error foo} |
---|
346 | package require foo 1 |
---|
347 | } -cleanup { |
---|
348 | package forget foo |
---|
349 | } -returnCodes error -match glob -result foo |
---|
350 | test pkg-2.32 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
351 | package forget foo |
---|
352 | } -body { |
---|
353 | package ifneeded foo 1 {package provide foo 1; error foo} |
---|
354 | catch {package require foo 1} |
---|
355 | package provide foo |
---|
356 | } -cleanup { |
---|
357 | package forget foo |
---|
358 | } -result {} |
---|
359 | test pkg-2.33 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
360 | package forget foo |
---|
361 | } -body { |
---|
362 | package ifneeded foo 1 {package provide foo 2} |
---|
363 | package require foo 1 |
---|
364 | } -cleanup { |
---|
365 | package forget foo |
---|
366 | } -returnCodes error -match glob -result {attempt to provide package * failed:*} |
---|
367 | test pkg-2.34 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
368 | package forget foo |
---|
369 | } -body { |
---|
370 | package ifneeded foo 1 {package provide foo 1.1} |
---|
371 | package require foo 1 |
---|
372 | } -cleanup { |
---|
373 | package forget foo |
---|
374 | } -returnCodes error -match glob -result {attempt to provide package * failed:*} |
---|
375 | test pkg-2.34.1 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
376 | package forget foo |
---|
377 | } -body { |
---|
378 | package ifneeded foo 1.1 {package provide foo 1} |
---|
379 | package require foo 1 |
---|
380 | } -cleanup { |
---|
381 | package forget foo |
---|
382 | } -returnCodes error -match glob -result {attempt to provide package * failed:*} |
---|
383 | test pkg-2.34.2 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
384 | package forget foo |
---|
385 | } -body { |
---|
386 | package ifneeded foo 1.1 {package provide foo 1} |
---|
387 | package require foo 1.1 |
---|
388 | } -cleanup { |
---|
389 | package forget foo |
---|
390 | } -returnCodes error -match glob -result {attempt to provide package * failed:*} |
---|
391 | test pkg-2.35 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
392 | package forget foo |
---|
393 | } -body { |
---|
394 | package ifneeded foo 1 {} |
---|
395 | package require foo 1 |
---|
396 | } -cleanup { |
---|
397 | package forget foo |
---|
398 | } -returnCodes error -match glob -result {attempt to provide package * failed:*} |
---|
399 | test pkg-2.35.1 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
400 | package forget foo |
---|
401 | } -body { |
---|
402 | package ifneeded foo 1 {break} |
---|
403 | package require foo 1 |
---|
404 | } -cleanup { |
---|
405 | package forget foo |
---|
406 | } -returnCodes error -match glob \ |
---|
407 | -result {attempt to provide package * failed: bad return code:*} |
---|
408 | test pkg-2.36 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
409 | package forget foo |
---|
410 | } -body { |
---|
411 | package ifneeded foo 1 {continue} |
---|
412 | package require foo 1 |
---|
413 | } -cleanup { |
---|
414 | package forget foo |
---|
415 | } -returnCodes error -match glob \ |
---|
416 | -result {attempt to provide package * failed: bad return code:*} |
---|
417 | test pkg-2.37 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
418 | package forget foo |
---|
419 | } -body { |
---|
420 | package ifneeded foo 1 {return} |
---|
421 | package require foo 1 |
---|
422 | } -cleanup { |
---|
423 | package forget foo |
---|
424 | } -returnCodes error -match glob \ |
---|
425 | -result {attempt to provide package * failed: bad return code:*} |
---|
426 | test pkg-2.38 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
427 | package forget foo |
---|
428 | } -body { |
---|
429 | package ifneeded foo 1 {return -level 0 -code 10} |
---|
430 | package require foo 1 |
---|
431 | } -cleanup { |
---|
432 | package forget foo |
---|
433 | } -returnCodes error -match glob \ |
---|
434 | -result {attempt to provide package * failed: bad return code:*} |
---|
435 | test pkg-2.39 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
436 | package forget foo |
---|
437 | set saveUnknown [package unknown] |
---|
438 | package unknown {package provide foo 2 ;#} |
---|
439 | } -body { |
---|
440 | package require foo 1 |
---|
441 | } -cleanup { |
---|
442 | package forget foo |
---|
443 | package unknown $saveUnknown |
---|
444 | } -returnCodes error -match glob -result * |
---|
445 | test pkg-2.40 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
446 | package forget foo |
---|
447 | set saveUnknown [package unknown] |
---|
448 | package unknown {break ;#} |
---|
449 | } -body { |
---|
450 | package require foo 1 |
---|
451 | } -cleanup { |
---|
452 | package forget foo |
---|
453 | package unknown $saveUnknown |
---|
454 | } -returnCodes error -match glob -result {bad return code:*} |
---|
455 | test pkg-2.41 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
456 | package forget foo |
---|
457 | set saveUnknown [package unknown] |
---|
458 | package unknown {continue ;#} |
---|
459 | } -body { |
---|
460 | package require foo 1 |
---|
461 | } -cleanup { |
---|
462 | package forget foo |
---|
463 | package unknown $saveUnknown |
---|
464 | } -returnCodes error -match glob -result {bad return code:*} |
---|
465 | test pkg-2.42 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
466 | package forget foo |
---|
467 | set saveUnknown [package unknown] |
---|
468 | package unknown {return ;#} |
---|
469 | } -body { |
---|
470 | package require foo 1 |
---|
471 | } -cleanup { |
---|
472 | package forget foo |
---|
473 | package unknown $saveUnknown |
---|
474 | } -returnCodes error -match glob -result {bad return code:*} |
---|
475 | test pkg-2.43 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
---|
476 | package forget foo |
---|
477 | set saveUnknown [package unknown] |
---|
478 | package unknown {return -level 0 -code 10 ;#} |
---|
479 | } -body { |
---|
480 | package require foo 1 |
---|
481 | } -cleanup { |
---|
482 | package forget foo |
---|
483 | package unknown $saveUnknown |
---|
484 | } -returnCodes error -match glob -result {bad return code:*} |
---|
485 | test pkg-2.44 {Tcl_PkgRequire: exact version matching (1578344)} -setup { |
---|
486 | package provide demo 1.2.3 |
---|
487 | } -body { |
---|
488 | package require -exact demo 1.2 |
---|
489 | } -cleanup { |
---|
490 | package forget demo |
---|
491 | } -returnCodes error -result {version conflict for package "demo": have 1.2.3, need exactly 1.2} |
---|
492 | |
---|
493 | |
---|
494 | test pkg-2.50 {Tcl_PkgRequire procedure, picking best stable version} { |
---|
495 | package forget t |
---|
496 | foreach i {1.4 3.4 4.0a1 2.3 2.4 2.2} { |
---|
497 | package ifneeded t $i "set x $i; package provide t $i" |
---|
498 | } |
---|
499 | set x xxx |
---|
500 | package require t |
---|
501 | set x |
---|
502 | } {3.4} |
---|
503 | |
---|
504 | test pkg-2.51 {Tcl_PkgRequire procedure, picking best stable version} { |
---|
505 | package forget t |
---|
506 | foreach i {1.2b1 1.2 1.3a2 1.3} { |
---|
507 | package ifneeded t $i "set x $i; package provide t $i" |
---|
508 | } |
---|
509 | set x xxx |
---|
510 | package require t |
---|
511 | set x |
---|
512 | } {1.3} |
---|
513 | |
---|
514 | test pkg-2.52 {Tcl_PkgRequire procedure, picking best stable version} { |
---|
515 | package forget t |
---|
516 | foreach i {1.2b1 1.2 1.3 1.3a2} { |
---|
517 | package ifneeded t $i "set x $i; package provide t $i" |
---|
518 | } |
---|
519 | set x xxx |
---|
520 | package require t |
---|
521 | set x |
---|
522 | } {1.3} |
---|
523 | |
---|
524 | |
---|
525 | |
---|
526 | test pkg-3.1 {Tcl_PackageCmd procedure} { |
---|
527 | list [catch {package} msg] $msg |
---|
528 | } {1 {wrong # args: should be "package option ?arg arg ...?"}} |
---|
529 | test pkg-3.2 {Tcl_PackageCmd procedure, "forget" option} { |
---|
530 | foreach i [package names] { |
---|
531 | package forget $i |
---|
532 | } |
---|
533 | package names |
---|
534 | } {} |
---|
535 | test pkg-3.3 {Tcl_PackageCmd procedure, "forget" option} { |
---|
536 | foreach i [package names] { |
---|
537 | package forget $i |
---|
538 | } |
---|
539 | package forget foo |
---|
540 | } {} |
---|
541 | test pkg-3.4 {Tcl_PackageCmd procedure, "forget" option} { |
---|
542 | foreach i [package names] { |
---|
543 | package forget $i |
---|
544 | } |
---|
545 | package ifneeded t 1.1 {first script} |
---|
546 | package ifneeded t 2.3 {second script} |
---|
547 | package ifneeded x 1.4 {x's script} |
---|
548 | set result {} |
---|
549 | lappend result [lsort [package names]] [package versions t] |
---|
550 | package forget t |
---|
551 | lappend result [lsort [package names]] [package versions t] |
---|
552 | } {{t x} {1.1 2.3} x {}} |
---|
553 | test pkg-3.5 {Tcl_PackageCmd procedure, "forget" option} { |
---|
554 | foreach i [package names] { |
---|
555 | package forget $i |
---|
556 | } |
---|
557 | package ifneeded a 1.1 {first script} |
---|
558 | package ifneeded b 2.3 {second script} |
---|
559 | package ifneeded c 1.4 {third script} |
---|
560 | package forget |
---|
561 | set result [list [lsort [package names]]] |
---|
562 | package forget a c |
---|
563 | lappend result [lsort [package names]] |
---|
564 | } {{a b c} b} |
---|
565 | test pkg-3.5.1 {Tcl_PackageCmd procedure, "forget" option} { |
---|
566 | # Test for Bug 415273 |
---|
567 | package ifneeded a 1 "I should have been forgotten" |
---|
568 | package forget no-such-package a |
---|
569 | set x [package ifneeded a 1] |
---|
570 | package forget a |
---|
571 | set x |
---|
572 | } {} |
---|
573 | test pkg-3.6 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
574 | list [catch {package ifneeded a} msg] $msg |
---|
575 | } {1 {wrong # args: should be "package ifneeded package version ?script?"}} |
---|
576 | test pkg-3.7 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
577 | list [catch {package ifneeded a b c d} msg] $msg |
---|
578 | } {1 {wrong # args: should be "package ifneeded package version ?script?"}} |
---|
579 | test pkg-3.8 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
580 | list [catch {package ifneeded t xyz} msg] $msg |
---|
581 | } {1 {expected version number but got "xyz"}} |
---|
582 | test pkg-3.9 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
583 | foreach i [package names] { |
---|
584 | package forget $i |
---|
585 | } |
---|
586 | list [package ifneeded foo 1.1] [package names] |
---|
587 | } {{} {}} |
---|
588 | test pkg-3.10 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
589 | package forget t |
---|
590 | package ifneeded t 1.4 "script for t 1.4" |
---|
591 | list [package names] [package ifneeded t 1.4] [package versions t] |
---|
592 | } {t {script for t 1.4} 1.4} |
---|
593 | test pkg-3.11 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
594 | package forget t |
---|
595 | package ifneeded t 1.4 "script for t 1.4" |
---|
596 | list [package ifneeded t 1.5] [package names] [package versions t] |
---|
597 | } {{} t 1.4} |
---|
598 | test pkg-3.12 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
599 | package forget t |
---|
600 | package ifneeded t 1.4 "script for t 1.4" |
---|
601 | package ifneeded t 1.4 "second script for t 1.4" |
---|
602 | list [package ifneeded t 1.4] [package names] [package versions t] |
---|
603 | } {{second script for t 1.4} t 1.4} |
---|
604 | test pkg-3.13 {Tcl_PackageCmd procedure, "ifneeded" option} { |
---|
605 | package forget t |
---|
606 | package ifneeded t 1.4 "script for t 1.4" |
---|
607 | package ifneeded t 1.2 "second script" |
---|
608 | package ifneeded t 3.1 "last script" |
---|
609 | list [package ifneeded t 1.2] [package versions t] |
---|
610 | } {{second script} {1.4 1.2 3.1}} |
---|
611 | test pkg-3.14 {Tcl_PackageCmd procedure, "names" option} { |
---|
612 | list [catch {package names a} msg] $msg |
---|
613 | } {1 {wrong # args: should be "package names"}} |
---|
614 | test pkg-3.15 {Tcl_PackageCmd procedure, "names" option} { |
---|
615 | foreach i [package names] { |
---|
616 | package forget $i |
---|
617 | } |
---|
618 | package names |
---|
619 | } {} |
---|
620 | test pkg-3.16 {Tcl_PackageCmd procedure, "names" option} { |
---|
621 | foreach i [package names] { |
---|
622 | package forget $i |
---|
623 | } |
---|
624 | package ifneeded x 1.2 {dummy} |
---|
625 | package provide x 1.3 |
---|
626 | package provide y 2.4 |
---|
627 | catch {package require z 47.16} |
---|
628 | lsort [package names] |
---|
629 | } {x y} |
---|
630 | test pkg-3.17 {Tcl_PackageCmd procedure, "provide" option} { |
---|
631 | list [catch {package provide} msg] $msg |
---|
632 | } {1 {wrong # args: should be "package provide package ?version?"}} |
---|
633 | test pkg-3.18 {Tcl_PackageCmd procedure, "provide" option} { |
---|
634 | list [catch {package provide a b c} msg] $msg |
---|
635 | } {1 {wrong # args: should be "package provide package ?version?"}} |
---|
636 | test pkg-3.19 {Tcl_PackageCmd procedure, "provide" option} { |
---|
637 | package forget t |
---|
638 | package provide t |
---|
639 | } {} |
---|
640 | test pkg-3.20 {Tcl_PackageCmd procedure, "provide" option} { |
---|
641 | package forget t |
---|
642 | package provide t 2.3 |
---|
643 | package provide t |
---|
644 | } {2.3} |
---|
645 | test pkg-3.21 {Tcl_PackageCmd procedure, "provide" option} { |
---|
646 | package forget t |
---|
647 | list [catch {package provide t a.b} msg] $msg |
---|
648 | } {1 {expected version number but got "a.b"}} |
---|
649 | test pkg-3.22 {Tcl_PackageCmd procedure, "require" option} { |
---|
650 | list [catch {package require} msg] $msg |
---|
651 | } {1 {wrong # args: should be "package require ?-exact? package ?requirement...?"}} |
---|
652 | |
---|
653 | test pkg-3.24 {Tcl_PackageCmd procedure, "require" option} { |
---|
654 | list [catch {package require -exact a b c} msg] $msg |
---|
655 | # Exact syntax: -exact name version |
---|
656 | # name ?requirement...? |
---|
657 | } {1 {wrong # args: should be "package require ?-exact? package ?requirement...?"}} |
---|
658 | |
---|
659 | test pkg-3.26 {Tcl_PackageCmd procedure, "require" option} { |
---|
660 | list [catch {package require x a.b} msg] $msg |
---|
661 | } {1 {expected version number but got "a.b"}} |
---|
662 | test pkg-3.27 {Tcl_PackageCmd procedure, "require" option} { |
---|
663 | list [catch {package require -exact x a.b} msg] $msg |
---|
664 | } {1 {expected version number but got "a.b"}} |
---|
665 | test pkg-3.28 {Tcl_PackageCmd procedure, "require" option} { |
---|
666 | list [catch {package require -exact x} msg] $msg |
---|
667 | } {1 {wrong # args: should be "package require ?-exact? package ?requirement...?"}} |
---|
668 | test pkg-3.29 {Tcl_PackageCmd procedure, "require" option} { |
---|
669 | list [catch {package require -exact} msg] $msg |
---|
670 | } {1 {wrong # args: should be "package require ?-exact? package ?requirement...?"}} |
---|
671 | test pkg-3.30 {Tcl_PackageCmd procedure, "require" option} { |
---|
672 | package forget t |
---|
673 | package provide t 2.3 |
---|
674 | package require t 2.1 |
---|
675 | } {2.3} |
---|
676 | test pkg-3.31 {Tcl_PackageCmd procedure, "require" option} { |
---|
677 | package forget t |
---|
678 | list [catch {package require t} msg] $msg |
---|
679 | } {1 {can't find package t}} |
---|
680 | test pkg-3.32 {Tcl_PackageCmd procedure, "require" option} { |
---|
681 | package forget t |
---|
682 | package ifneeded t 2.3 "error {synthetic error}" |
---|
683 | list [catch {package require t 2.3} msg] $msg |
---|
684 | } {1 {synthetic error}} |
---|
685 | test pkg-3.33 {Tcl_PackageCmd procedure, "unknown" option} { |
---|
686 | list [catch {package unknown a b} msg] $msg |
---|
687 | } {1 {wrong # args: should be "package unknown ?command?"}} |
---|
688 | test pkg-3.34 {Tcl_PackageCmd procedure, "unknown" option} { |
---|
689 | package unknown "test script" |
---|
690 | package unknown |
---|
691 | } {test script} |
---|
692 | test pkg-3.35 {Tcl_PackageCmd procedure, "unknown" option} { |
---|
693 | package unknown "test script" |
---|
694 | package unknown {} |
---|
695 | package unknown |
---|
696 | } {} |
---|
697 | test pkg-3.36 {Tcl_PackageCmd procedure, "vcompare" option} { |
---|
698 | list [catch {package vcompare a} msg] $msg |
---|
699 | } {1 {wrong # args: should be "package vcompare version1 version2"}} |
---|
700 | test pkg-3.37 {Tcl_PackageCmd procedure, "vcompare" option} { |
---|
701 | list [catch {package vcompare a b c} msg] $msg |
---|
702 | } {1 {wrong # args: should be "package vcompare version1 version2"}} |
---|
703 | test pkg-3.38 {Tcl_PackageCmd procedure, "vcompare" option} { |
---|
704 | list [catch {package vcompare x.y 3.4} msg] $msg |
---|
705 | } {1 {expected version number but got "x.y"}} |
---|
706 | test pkg-3.39 {Tcl_PackageCmd procedure, "vcompare" option} { |
---|
707 | list [catch {package vcompare 2.1 a.b} msg] $msg |
---|
708 | } {1 {expected version number but got "a.b"}} |
---|
709 | test pkg-3.40 {Tcl_PackageCmd procedure, "vcompare" option} { |
---|
710 | package vc 2.1 2.3 |
---|
711 | } {-1} |
---|
712 | test pkg-3.41 {Tcl_PackageCmd procedure, "vcompare" option} { |
---|
713 | package vc 2.2.4 2.2.4 |
---|
714 | } {0} |
---|
715 | test pkg-3.42 {Tcl_PackageCmd procedure, "versions" option} { |
---|
716 | list [catch {package versions} msg] $msg |
---|
717 | } {1 {wrong # args: should be "package versions package"}} |
---|
718 | test pkg-3.43 {Tcl_PackageCmd procedure, "versions" option} { |
---|
719 | list [catch {package versions a b} msg] $msg |
---|
720 | } {1 {wrong # args: should be "package versions package"}} |
---|
721 | test pkg-3.44 {Tcl_PackageCmd procedure, "versions" option} { |
---|
722 | package forget t |
---|
723 | package versions t |
---|
724 | } {} |
---|
725 | test pkg-3.45 {Tcl_PackageCmd procedure, "versions" option} { |
---|
726 | package forget t |
---|
727 | package provide t 2.3 |
---|
728 | package versions t |
---|
729 | } {} |
---|
730 | test pkg-3.46 {Tcl_PackageCmd procedure, "versions" option} { |
---|
731 | package forget t |
---|
732 | package ifneeded t 2.3 x |
---|
733 | package ifneeded t 2.4 y |
---|
734 | package versions t |
---|
735 | } {2.3 2.4} |
---|
736 | test pkg-3.47 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
737 | list [catch {package vsatisfies a} msg] $msg |
---|
738 | } {1 {wrong # args: should be "package vsatisfies version requirement requirement..."}} |
---|
739 | |
---|
740 | test pkg-3.49 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
741 | list [catch {package vsatisfies x.y 3.4} msg] $msg |
---|
742 | } {1 {expected version number but got "x.y"}} |
---|
743 | test pkg-3.50 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
744 | list [catch {package vcompare 2.1 a.b} msg] $msg |
---|
745 | } {1 {expected version number but got "a.b"}} |
---|
746 | test pkg-3.51 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
747 | package vs 2.3 2.1 |
---|
748 | } {1} |
---|
749 | test pkg-3.52 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
750 | package vs 2.3 1.2 |
---|
751 | } {0} |
---|
752 | test pkg-3.53 {Tcl_PackageCmd procedure, "versions" option} { |
---|
753 | list [catch {package foo} msg] $msg |
---|
754 | } {1 {bad option "foo": must be forget, ifneeded, names, prefer, present, provide, require, unknown, vcompare, versions, or vsatisfies}} |
---|
755 | |
---|
756 | test pkg-3.54 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
757 | list [catch {package vsatisfies 2.1 2.1-3.2-4.5} msg] $msg |
---|
758 | } {1 {expected versionMin-versionMax but got "2.1-3.2-4.5"}} |
---|
759 | |
---|
760 | test pkg-3.55 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
761 | list [catch {package vsatisfies 2.1 3.2-x.y} msg] $msg |
---|
762 | } {1 {expected version number but got "x.y"}} |
---|
763 | |
---|
764 | test pkg-3.56 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
---|
765 | list [catch {package vsatisfies 2.1 x.y-3.2} msg] $msg |
---|
766 | } {1 {expected version number but got "x.y"}} |
---|
767 | |
---|
768 | |
---|
769 | # No tests for FindPackage; can't think up anything detectable |
---|
770 | # errors. |
---|
771 | |
---|
772 | test pkg-4.1 {TclFreePackageInfo procedure} { |
---|
773 | interp create foo |
---|
774 | foo eval { |
---|
775 | package ifneeded t 2.3 x |
---|
776 | package ifneeded t 2.4 y |
---|
777 | package ifneeded x 3.1 z |
---|
778 | package provide q 4.3 |
---|
779 | package unknown "will this get freed?" |
---|
780 | } |
---|
781 | interp delete foo |
---|
782 | } {} |
---|
783 | test pkg-4.2 {TclFreePackageInfo procedure} -body { |
---|
784 | interp create foo |
---|
785 | foo eval { |
---|
786 | package ifneeded t 2.3 x |
---|
787 | package ifneeded t 2.4 y |
---|
788 | package ifneeded x 3.1 z |
---|
789 | package provide q 4.3 |
---|
790 | } |
---|
791 | foo alias z kill |
---|
792 | proc kill {} { |
---|
793 | interp delete foo |
---|
794 | } |
---|
795 | foo eval package require x 3.1 |
---|
796 | } -returnCodes error -match glob -result * |
---|
797 | |
---|
798 | test pkg-5.1 {CheckVersion procedure} { |
---|
799 | list [catch {package vcompare 1 2.1} msg] $msg |
---|
800 | } {0 -1} |
---|
801 | test pkg-5.2 {CheckVersion procedure} { |
---|
802 | list [catch {package vcompare .1 2.1} msg] $msg |
---|
803 | } {1 {expected version number but got ".1"}} |
---|
804 | test pkg-5.3 {CheckVersion procedure} { |
---|
805 | list [catch {package vcompare 111.2a.3 2.1} msg] $msg |
---|
806 | } {1 {expected version number but got "111.2a.3"}} |
---|
807 | test pkg-5.4 {CheckVersion procedure} { |
---|
808 | list [catch {package vcompare 1.2.3. 2.1} msg] $msg |
---|
809 | } {1 {expected version number but got "1.2.3."}} |
---|
810 | test pkg-5.5 {CheckVersion procedure} { |
---|
811 | list [catch {package vcompare 1.2..3 2.1} msg] $msg |
---|
812 | } {1 {expected version number but got "1.2..3"}} |
---|
813 | |
---|
814 | test pkg-6.1 {ComparePkgVersions procedure} { |
---|
815 | package vcompare 1.23 1.22 |
---|
816 | } {1} |
---|
817 | test pkg-6.2 {ComparePkgVersions procedure} { |
---|
818 | package vcompare 1.22.1.2.3 1.22.1.2.3 |
---|
819 | } {0} |
---|
820 | test pkg-6.3 {ComparePkgVersions procedure} { |
---|
821 | package vcompare 1.21 1.22 |
---|
822 | } {-1} |
---|
823 | test pkg-6.4 {ComparePkgVersions procedure} { |
---|
824 | package vcompare 1.21 1.21.2 |
---|
825 | } {-1} |
---|
826 | test pkg-6.5 {ComparePkgVersions procedure} { |
---|
827 | package vcompare 1.21.1 1.21 |
---|
828 | } {1} |
---|
829 | test pkg-6.6 {ComparePkgVersions procedure} { |
---|
830 | package vsatisfies 1.21.1 1.21 |
---|
831 | } {1} |
---|
832 | test pkg-6.7 {ComparePkgVersions procedure} { |
---|
833 | package vsatisfies 2.22.3 1.21 |
---|
834 | } {0} |
---|
835 | test pkg-6.8 {ComparePkgVersions procedure} { |
---|
836 | package vsatisfies 1 1 |
---|
837 | } {1} |
---|
838 | test pkg-6.9 {ComparePkgVersions procedure} { |
---|
839 | package vsatisfies 2 1 |
---|
840 | } {0} |
---|
841 | |
---|
842 | test pkg-7.1 {Tcl_PkgPresent procedure, any version} { |
---|
843 | package forget t |
---|
844 | package provide t 2.4 |
---|
845 | package present t |
---|
846 | } {2.4} |
---|
847 | test pkg-7.2 {Tcl_PkgPresent procedure, correct version} { |
---|
848 | package forget t |
---|
849 | package provide t 2.4 |
---|
850 | package present t 2.4 |
---|
851 | } {2.4} |
---|
852 | test pkg-7.3 {Tcl_PkgPresent procedure, satisfying version} { |
---|
853 | package forget t |
---|
854 | package provide t 2.4 |
---|
855 | package present t 2.0 |
---|
856 | } {2.4} |
---|
857 | test pkg-7.4 {Tcl_PkgPresent procedure, not satisfying version} { |
---|
858 | package forget t |
---|
859 | package provide t 2.4 |
---|
860 | list [catch {package present t 2.6} msg] $msg |
---|
861 | } {1 {version conflict for package "t": have 2.4, need 2.6}} |
---|
862 | test pkg-7.5 {Tcl_PkgPresent procedure, not satisfying version} { |
---|
863 | package forget t |
---|
864 | package provide t 2.4 |
---|
865 | list [catch {package present t 1.0} msg] $msg |
---|
866 | } {1 {version conflict for package "t": have 2.4, need 1.0}} |
---|
867 | test pkg-7.6 {Tcl_PkgPresent procedure, exact version} { |
---|
868 | package forget t |
---|
869 | package provide t 2.4 |
---|
870 | package present -exact t 2.4 |
---|
871 | } {2.4} |
---|
872 | test pkg-7.7 {Tcl_PkgPresent procedure, not exact version} { |
---|
873 | package forget t |
---|
874 | package provide t 2.4 |
---|
875 | list [catch {package present -exact t 2.3} msg] $msg |
---|
876 | } {1 {version conflict for package "t": have 2.4, need exactly 2.3}} |
---|
877 | test pkg-7.8 {Tcl_PkgPresent procedure, unknown package} { |
---|
878 | package forget t |
---|
879 | list [catch {package present t} msg] $msg |
---|
880 | } {1 {package t is not present}} |
---|
881 | test pkg-7.9 {Tcl_PkgPresent procedure, unknown package} { |
---|
882 | package forget t |
---|
883 | list [catch {package present t 2.4} msg] $msg |
---|
884 | } {1 {package t 2.4 is not present}} |
---|
885 | test pkg-7.10 {Tcl_PkgPresent procedure, unknown package} { |
---|
886 | package forget t |
---|
887 | list [catch {package present -exact t 2.4} msg] $msg |
---|
888 | } {1 {package t 2.4 is not present}} |
---|
889 | test pkg-7.11 {Tcl_PackageCmd procedure, "present" option} { |
---|
890 | list [catch {package present} msg] $msg |
---|
891 | } {1 {wrong # args: should be "package present ?-exact? package ?requirement...?"}} |
---|
892 | test pkg-7.12 {Tcl_PackageCmd procedure, "present" option} { |
---|
893 | list [catch {package present a b c} msg] $msg |
---|
894 | } {1 {expected version number but got "b"}} |
---|
895 | test pkg-7.13 {Tcl_PackageCmd procedure, "present" option} { |
---|
896 | list [catch {package present -exact a b c} msg] $msg |
---|
897 | } {1 {wrong # args: should be "package present ?-exact? package ?requirement...?"}} |
---|
898 | test pkg-7.14 {Tcl_PackageCmd procedure, "present" option} { |
---|
899 | list [catch {package present -bs a b} msg] $msg |
---|
900 | } {1 {expected version number but got "a"}} |
---|
901 | test pkg-7.15 {Tcl_PackageCmd procedure, "present" option} { |
---|
902 | list [catch {package present x a.b} msg] $msg |
---|
903 | } {1 {expected version number but got "a.b"}} |
---|
904 | test pkg-7.16 {Tcl_PackageCmd procedure, "present" option} { |
---|
905 | list [catch {package present -exact x a.b} msg] $msg |
---|
906 | } {1 {expected version number but got "a.b"}} |
---|
907 | test pkg-7.17 {Tcl_PackageCmd procedure, "present" option} { |
---|
908 | list [catch {package present -exact x} msg] $msg |
---|
909 | } {1 {wrong # args: should be "package present ?-exact? package ?requirement...?"}} |
---|
910 | test pkg-7.18 {Tcl_PackageCmd procedure, "present" option} { |
---|
911 | list [catch {package present -exact} msg] $msg |
---|
912 | } {1 {wrong # args: should be "package present ?-exact? package ?requirement...?"}} |
---|
913 | |
---|
914 | |
---|
915 | |
---|
916 | |
---|
917 | set n 0 |
---|
918 | foreach {r p vs vc} { |
---|
919 | 8.5a0 8.5a5 1 -1 |
---|
920 | 8.5a0 8.5b1 1 -1 |
---|
921 | 8.5a0 8.5.1 1 -1 |
---|
922 | 8.5a0 8.6a0 1 -1 |
---|
923 | 8.5a0 8.6b0 1 -1 |
---|
924 | 8.5a0 8.6.0 1 -1 |
---|
925 | 8.5a6 8.5a5 0 1 |
---|
926 | 8.5a6 8.5b1 1 -1 |
---|
927 | 8.5a6 8.5.1 1 -1 |
---|
928 | 8.5a6 8.6a0 1 -1 |
---|
929 | 8.5a6 8.6b0 1 -1 |
---|
930 | 8.5a6 8.6.0 1 -1 |
---|
931 | 8.5b0 8.5a5 0 1 |
---|
932 | 8.5b0 8.5b1 1 -1 |
---|
933 | 8.5b0 8.5.1 1 -1 |
---|
934 | 8.5b0 8.6a0 1 -1 |
---|
935 | 8.5b0 8.6b0 1 -1 |
---|
936 | 8.5b0 8.6.0 1 -1 |
---|
937 | 8.5b2 8.5a5 0 1 |
---|
938 | 8.5b2 8.5b1 0 1 |
---|
939 | 8.5b2 8.5.1 1 -1 |
---|
940 | 8.5b2 8.6a0 1 -1 |
---|
941 | 8.5b2 8.6b0 1 -1 |
---|
942 | 8.5b2 8.6.0 1 -1 |
---|
943 | 8.5 8.5a5 1 1 |
---|
944 | 8.5 8.5b1 1 1 |
---|
945 | 8.5 8.5.1 1 -1 |
---|
946 | 8.5 8.6a0 1 -1 |
---|
947 | 8.5 8.6b0 1 -1 |
---|
948 | 8.5 8.6.0 1 -1 |
---|
949 | 8.5.0 8.5a5 0 1 |
---|
950 | 8.5.0 8.5b1 0 1 |
---|
951 | 8.5.0 8.5.1 1 -1 |
---|
952 | 8.5.0 8.6a0 1 -1 |
---|
953 | 8.5.0 8.6b0 1 -1 |
---|
954 | 8.5.0 8.6.0 1 -1 |
---|
955 | 10 8 0 1 |
---|
956 | 8 10 0 -1 |
---|
957 | 0.0.1.2 0.1.2 1 -1 |
---|
958 | } { |
---|
959 | test package-vsatisfies-1.$n {package vsatisfies} { |
---|
960 | package vsatisfies $p $r |
---|
961 | } $vs |
---|
962 | |
---|
963 | test package-vcompare-1.$n {package vcompare} { |
---|
964 | package vcompare $r $p |
---|
965 | } $vc |
---|
966 | |
---|
967 | incr n |
---|
968 | } |
---|
969 | |
---|
970 | test package-vcompare-2.0 {package vcompare at 32bit boundary} { |
---|
971 | package vcompare [expr {1<<31}] [expr {(1<<31)-1}] |
---|
972 | } 1 |
---|
973 | |
---|
974 | # Note: It is correct that the result of the very first test, |
---|
975 | # i.e. "5.0 5.0a0" is 1, i.e. that version 5.0a0 satisfies a 5.0 |
---|
976 | # requirement. |
---|
977 | |
---|
978 | # The requirement "5.0" internally translates first to "5.0-6", and |
---|
979 | # then to its final form of "5.0a0-6a0". These translations are |
---|
980 | # explicitly specified by the TIP (Search for "padded/extended |
---|
981 | # internally with 'a0'"). This was done intentionally for exactly the |
---|
982 | # tested case, that an alpha package can satisfy a requirement for the |
---|
983 | # regular package. An example would be a package FOO requiring Tcl 8.X |
---|
984 | # for its operation. It can be used with Tcl 8.Xa0. Without our |
---|
985 | # translation that would not be possible. |
---|
986 | |
---|
987 | set n 0 |
---|
988 | foreach {required provided satisfied} { |
---|
989 | 5.0 5.0a0 1 |
---|
990 | 5.0a0 5.0 1 |
---|
991 | |
---|
992 | 8.5a0- 8.5a5 1 |
---|
993 | 8.5a0- 8.5b1 1 |
---|
994 | 8.5a0- 8.5.1 1 |
---|
995 | 8.5a0- 8.6a0 1 |
---|
996 | 8.5a0- 8.6b0 1 |
---|
997 | 8.5a0- 8.6.0 1 |
---|
998 | 8.5a6- 8.5a5 0 |
---|
999 | 8.5a6- 8.5b1 1 |
---|
1000 | 8.5a6- 8.5.1 1 |
---|
1001 | 8.5a6- 8.6a0 1 |
---|
1002 | 8.5a6- 8.6b0 1 |
---|
1003 | 8.5a6- 8.6.0 1 |
---|
1004 | 8.5b0- 8.5a5 0 |
---|
1005 | 8.5b0- 8.5b1 1 |
---|
1006 | 8.5b0- 8.5.1 1 |
---|
1007 | 8.5b0- 8.6a0 1 |
---|
1008 | 8.5b0- 8.6b0 1 |
---|
1009 | 8.5b0- 8.6.0 1 |
---|
1010 | 8.5b2- 8.5a5 0 |
---|
1011 | 8.5b2- 8.5b1 0 |
---|
1012 | 8.5b2- 8.5.1 1 |
---|
1013 | 8.5b2- 8.6a0 1 |
---|
1014 | 8.5b2- 8.6b0 1 |
---|
1015 | 8.5b2- 8.6.0 1 |
---|
1016 | 8.5- 8.5a5 1 |
---|
1017 | 8.5- 8.5b1 1 |
---|
1018 | 8.5- 8.5.1 1 |
---|
1019 | 8.5- 8.6a0 1 |
---|
1020 | 8.5- 8.6b0 1 |
---|
1021 | 8.5- 8.6.0 1 |
---|
1022 | 8.5.0- 8.5a5 0 |
---|
1023 | 8.5.0- 8.5b1 0 |
---|
1024 | 8.5.0- 8.5.1 1 |
---|
1025 | 8.5.0- 8.6a0 1 |
---|
1026 | 8.5.0- 8.6b0 1 |
---|
1027 | 8.5.0- 8.6.0 1 |
---|
1028 | 8.5a0-7 8.5a5 0 |
---|
1029 | 8.5a0-7 8.5b1 0 |
---|
1030 | 8.5a0-7 8.5.1 0 |
---|
1031 | 8.5a0-7 8.6a0 0 |
---|
1032 | 8.5a0-7 8.6b0 0 |
---|
1033 | 8.5a0-7 8.6.0 0 |
---|
1034 | 8.5a6-7 8.5a5 0 |
---|
1035 | 8.5a6-7 8.5b1 0 |
---|
1036 | 8.5a6-7 8.5.1 0 |
---|
1037 | 8.5a6-7 8.6a0 0 |
---|
1038 | 8.5a6-7 8.6b0 0 |
---|
1039 | 8.5a6-7 8.6.0 0 |
---|
1040 | 8.5b0-7 8.5a5 0 |
---|
1041 | 8.5b0-7 8.5b1 0 |
---|
1042 | 8.5b0-7 8.5.1 0 |
---|
1043 | 8.5b0-7 8.6a0 0 |
---|
1044 | 8.5b0-7 8.6b0 0 |
---|
1045 | 8.5b0-7 8.6.0 0 |
---|
1046 | 8.5b2-7 8.5a5 0 |
---|
1047 | 8.5b2-7 8.5b1 0 |
---|
1048 | 8.5b2-7 8.5.1 0 |
---|
1049 | 8.5b2-7 8.6a0 0 |
---|
1050 | 8.5b2-7 8.6b0 0 |
---|
1051 | 8.5b2-7 8.6.0 0 |
---|
1052 | 8.5-7 8.5a5 0 |
---|
1053 | 8.5-7 8.5b1 0 |
---|
1054 | 8.5-7 8.5.1 0 |
---|
1055 | 8.5-7 8.6a0 0 |
---|
1056 | 8.5-7 8.6b0 0 |
---|
1057 | 8.5-7 8.6.0 0 |
---|
1058 | 8.5.0-7 8.5a5 0 |
---|
1059 | 8.5.0-7 8.5b1 0 |
---|
1060 | 8.5.0-7 8.5.1 0 |
---|
1061 | 8.5.0-7 8.6a0 0 |
---|
1062 | 8.5.0-7 8.6b0 0 |
---|
1063 | 8.5.0-7 8.6.0 0 |
---|
1064 | 8.5a0-8.6.1 8.5a5 1 |
---|
1065 | 8.5a0-8.6.1 8.5b1 1 |
---|
1066 | 8.5a0-8.6.1 8.5.1 1 |
---|
1067 | 8.5a0-8.6.1 8.6a0 1 |
---|
1068 | 8.5a0-8.6.1 8.6b0 1 |
---|
1069 | 8.5a0-8.6.1 8.6.0 1 |
---|
1070 | 8.5a6-8.6.1 8.5a5 0 |
---|
1071 | 8.5a6-8.6.1 8.5b1 1 |
---|
1072 | 8.5a6-8.6.1 8.5.1 1 |
---|
1073 | 8.5a6-8.6.1 8.6a0 1 |
---|
1074 | 8.5a6-8.6.1 8.6b0 1 |
---|
1075 | 8.5a6-8.6.1 8.6.0 1 |
---|
1076 | 8.5b0-8.6.1 8.5a5 0 |
---|
1077 | 8.5b0-8.6.1 8.5b1 1 |
---|
1078 | 8.5b0-8.6.1 8.5.1 1 |
---|
1079 | 8.5b0-8.6.1 8.6a0 1 |
---|
1080 | 8.5b0-8.6.1 8.6b0 1 |
---|
1081 | 8.5b0-8.6.1 8.6.0 1 |
---|
1082 | 8.5b2-8.6.1 8.5a5 0 |
---|
1083 | 8.5b2-8.6.1 8.5b1 0 |
---|
1084 | 8.5b2-8.6.1 8.5.1 1 |
---|
1085 | 8.5b2-8.6.1 8.6a0 1 |
---|
1086 | 8.5b2-8.6.1 8.6b0 1 |
---|
1087 | 8.5b2-8.6.1 8.6.0 1 |
---|
1088 | 8.5-8.6.1 8.5a5 1 |
---|
1089 | 8.5-8.6.1 8.5b1 1 |
---|
1090 | 8.5-8.6.1 8.5.1 1 |
---|
1091 | 8.5-8.6.1 8.6a0 1 |
---|
1092 | 8.5-8.6.1 8.6b0 1 |
---|
1093 | 8.5-8.6.1 8.6.0 1 |
---|
1094 | 8.5.0-8.6.1 8.5a5 0 |
---|
1095 | 8.5.0-8.6.1 8.5b1 0 |
---|
1096 | 8.5.0-8.6.1 8.5.1 1 |
---|
1097 | 8.5.0-8.6.1 8.6a0 1 |
---|
1098 | 8.5.0-8.6.1 8.6b0 1 |
---|
1099 | 8.5.0-8.6.1 8.6.0 1 |
---|
1100 | 8.5a0-8.5a0 8.5a0 1 |
---|
1101 | 8.5a0-8.5a0 8.5b1 0 |
---|
1102 | 8.5a0-8.5a0 8.4 0 |
---|
1103 | 8.5b0-8.5b0 8.5a5 0 |
---|
1104 | 8.5b0-8.5b0 8.5b0 1 |
---|
1105 | 8.5b0-8.5b0 8.5.1 0 |
---|
1106 | 8.5-8.5 8.5a5 0 |
---|
1107 | 8.5-8.5 8.5b1 0 |
---|
1108 | 8.5-8.5 8.5 1 |
---|
1109 | 8.5-8.5 8.5.1 0 |
---|
1110 | 8.5.0-8.5.0 8.5a5 0 |
---|
1111 | 8.5.0-8.5.0 8.5b1 0 |
---|
1112 | 8.5.0-8.5.0 8.5.0 1 |
---|
1113 | 8.5.0-8.5.0 8.5.1 0 |
---|
1114 | 8.5.0-8.5.0 8.6a0 0 |
---|
1115 | 8.5.0-8.5.0 8.6b0 0 |
---|
1116 | 8.5.0-8.5.0 8.6.0 0 |
---|
1117 | 8.2 9 0 |
---|
1118 | 8.2- 9 1 |
---|
1119 | 8.2-8.5 9 0 |
---|
1120 | 8.2-9.1 9 1 |
---|
1121 | |
---|
1122 | 8.5-8.5 8.5b1 0 |
---|
1123 | 8.5a0-8.5 8.5b1 0 |
---|
1124 | 8.5a0-8.5.1 8.5b1 1 |
---|
1125 | |
---|
1126 | 8.5-8.5 8.5 1 |
---|
1127 | 8.5.0-8.5.0 8.5 1 |
---|
1128 | 8.5a0-8.5.0 8.5 0 |
---|
1129 | |
---|
1130 | } { |
---|
1131 | test package-vsatisfies-2.$n "package vsatisfies $provided $required" { |
---|
1132 | package vsatisfies $provided $required |
---|
1133 | } $satisfied |
---|
1134 | incr n |
---|
1135 | } |
---|
1136 | |
---|
1137 | test package-vsatisfies-3.0 "package vsatisfies multiple" { |
---|
1138 | # yes no |
---|
1139 | package vsatisfies 8.4 8.4 7.3 |
---|
1140 | } 1 |
---|
1141 | |
---|
1142 | test package-vsatisfies-3.1 "package vsatisfies multiple" { |
---|
1143 | # no yes |
---|
1144 | package vsatisfies 8.4 7.3 8.4 |
---|
1145 | } 1 |
---|
1146 | |
---|
1147 | test package-vsatisfies-3.2 "package vsatisfies multiple" { |
---|
1148 | # yes yes |
---|
1149 | package vsatisfies 8.4.2 8.4 8.4.1 |
---|
1150 | } 1 |
---|
1151 | |
---|
1152 | test package-vsatisfies-3.3 "package vsatisfies multiple" { |
---|
1153 | # no no |
---|
1154 | package vsatisfies 8.4 7.3 6.1 |
---|
1155 | } 0 |
---|
1156 | |
---|
1157 | |
---|
1158 | proc prefer {args} { |
---|
1159 | set ip [interp create] |
---|
1160 | lappend res [$ip eval {package prefer}] |
---|
1161 | foreach mode $args { |
---|
1162 | lappend res [$ip eval [list package prefer $mode]] |
---|
1163 | } |
---|
1164 | interp delete $ip |
---|
1165 | return $res |
---|
1166 | } |
---|
1167 | |
---|
1168 | test package-prefer-1.0 {default} { |
---|
1169 | prefer |
---|
1170 | } stable |
---|
1171 | |
---|
1172 | test package-prefer-1.1 {default} { |
---|
1173 | set ::env(TCL_PKG_PREFER_LATEST) stable ; # value not relevant! |
---|
1174 | set res [prefer] |
---|
1175 | unset ::env(TCL_PKG_PREFER_LATEST) |
---|
1176 | set res |
---|
1177 | } latest |
---|
1178 | |
---|
1179 | test package-prefer-2.0 {wrong\#args} { |
---|
1180 | catch {package prefer foo bar} msg |
---|
1181 | set msg |
---|
1182 | } {wrong # args: should be "package prefer ?latest|stable?"} |
---|
1183 | |
---|
1184 | test package-prefer-2.1 {bogus argument} { |
---|
1185 | catch {package prefer foo} msg |
---|
1186 | set msg |
---|
1187 | } {bad preference "foo": must be latest or stable} |
---|
1188 | |
---|
1189 | test package-prefer-3.0 {set, keep} { |
---|
1190 | package prefer stable |
---|
1191 | } stable |
---|
1192 | |
---|
1193 | test package-prefer-3.1 {set stable, keep} { |
---|
1194 | prefer stable |
---|
1195 | } {stable stable} |
---|
1196 | |
---|
1197 | test package-prefer-3.2 {set latest, change} { |
---|
1198 | prefer latest |
---|
1199 | } {stable latest} |
---|
1200 | |
---|
1201 | test package-prefer-3.3 {set latest, keep} { |
---|
1202 | prefer latest latest |
---|
1203 | } {stable latest latest} |
---|
1204 | |
---|
1205 | test package-prefer-3.4 {set stable, rejected} { |
---|
1206 | prefer latest stable |
---|
1207 | } {stable latest latest} |
---|
1208 | |
---|
1209 | rename prefer {} |
---|
1210 | |
---|
1211 | |
---|
1212 | set auto_path $oldPath |
---|
1213 | package unknown $oldPkgUnknown |
---|
1214 | concat |
---|
1215 | |
---|
1216 | cleanupTests |
---|
1217 | } |
---|
1218 | |
---|
1219 | # cleanup |
---|
1220 | interp delete $i |
---|
1221 | ::tcltest::cleanupTests |
---|
1222 | return |
---|