Debian Codegraph @

tests/pkgMkIndex.test

raw
1 # This file contains tests for the pkg_mkIndex command.
2 # Note that the tests are limited to Tcl scripts only, there are no shared
3 # libraries against which to test.
4 #
5 # Sourcing this file into Tcl runs the tests and generates output for errors.
6 # No output means no errors were found.
7 #
8 # Copyright (c) 1998-1999 Scriptics Corporation.
9 # All rights reserved.
10
11 if {"::tcltest" ni [namespace children]} {
12 package require tcltest 2.5
13 namespace import -force ::tcltest::*
14 }
15
16 set fullPkgPath [makeDirectory pkg]
17
18 namespace eval pkgtest {
19 # Namespace for procs we can discard
20 }
21
22 # pkgtest::parseArgs --
23 #
24 # Parse an argument list.
25 #
26 # Arguments:
27 # <flags> (optional) arguments starting with a dash are collected as
28 # options to pkg_mkIndex and passed to pkg_mkIndex.
29 # dirPath the directory to index
30 # pattern0 pattern to index
31 # ... pattern to index
32 # patternN pattern to index
33 #
34 # Results:
35 # Returns a three element list:
36 # 0: the options
37 # 1: the directory to index
38 # 2: the patterns list
39
40 proc pkgtest::parseArgs { args } {
41 set options ""
42
43 set argc [llength $args]
44 for {set iarg 0} {$iarg < $argc} {incr iarg} {
45 set a [lindex $args $iarg]
46 if {[regexp {^-} $a]} {
47 lappend options $a
48 if {$a eq "-load"} {
49 incr iarg
50 lappend options [lindex $args $iarg]
51 }
52 } else {
53 break
54 }
55 }
56
57 set dirPath [lindex $args $iarg]
58 incr iarg
59 set patternList [lrange $args $iarg end]
60
61 return [list $options $dirPath $patternList]
62 }
63
64 # pkgtest::parseIndex --
65 #
66 # Loads a pkgIndex.tcl file, records all the calls to "package ifneeded".
67 #
68 # Arguments:
69 # filePath path to the pkgIndex.tcl file.
70 #
71 # Results:
72 # Returns a list, in "array set/get" format, where the keys are the package
73 # name and version (in the form "$name:$version"), and the values the rest
74 # of the command line.
75
76 proc pkgtest::parseIndex { filePath } {
77 # create a child interpreter, where we override "package ifneeded"
78
79 set child [interp create]
80 if {[catch {
81 $child eval {
82 rename package package_original
83 proc package { args } {
84 if {[lindex $args 0] eq "ifneeded"} {
85 set pkg [lindex $args 1]
86 set ver [lindex $args 2]
87 set ::PKGS($pkg:$ver) [lindex $args 3]
88 } else {
89 return [package_original {*}$args]
90 }
91 }
92 array set ::PKGS {}
93 }
94
95 set dir [file dirname $filePath]
96 $child eval {set curdir [pwd]}
97 $child eval [list cd $dir]
98 $child eval [list set dir $dir]
99 $child eval [list source [file tail $filePath]]
100 $child eval {cd $curdir}
101
102 # Create the list in sorted order, so that we don't get spurious
103 # errors because the order has changed.
104
105 array set P {}
106 foreach {k v} [$child eval {array get ::PKGS}] {
107 set P($k) $v
108 }
109
110 set PKGS ""
111 foreach k [lsort [array names P]] {
112 lappend PKGS $k $P($k)
113 }
114 } err opts]} {
115 set ei [dict get $opts -errorinfo]
116 set ec [dict get $opts -errorcode]
117
118 catch {interp delete $child}
119
120 error $ei $ec
121 }
122
123 interp delete $child
124
125 return $PKGS
126 }
127
128 # pkgtest::createIndex --
129 #
130 # Runs pkg_mkIndex for the given directory and set of patterns. This
131 # procedure deletes any pkgIndex.tcl file in the target directory, then runs
132 # pkg_mkIndex.
133 #
134 # Arguments:
135 # <flags> (optional) arguments starting with a dash are collected as
136 # options to pkg_mkIndex and passed to pkg_mkIndex.
137 # dirPath the directory to index
138 # pattern0 pattern to index
139 # ... pattern to index
140 # patternN pattern to index
141 #
142 # Results:
143 # Returns a two element list:
144 # 0: 1 if the procedure encountered an error, 0 otherwise.
145 # 1: the error result if element 0 was 1
146
147 proc pkgtest::createIndex { args } {
148 set parsed [parseArgs {*}$args]
149 set options [lindex $parsed 0]
150 set dirPath [lindex $parsed 1]
151 set patternList [lindex $parsed 2]
152
153 file mkdir $dirPath
154
155 if {[catch {
156 file delete [file join $dirPath pkgIndex.tcl]
157 pkg_mkIndex {*}$options $dirPath {*}$patternList
158 } err]} {
159 return [list 1 $err]
160 }
161
162 return [list 0 {}]
163 }
164
165 # makePkgList --
166 #
167 # Takes the output of a pkgtest::parseIndex call, filters it and returns a
168 # cleaned up list of packages and their actions.
169 #
170 # Arguments:
171 # inList output from a pkgtest::parseIndex.
172 #
173 # Results:
174 # Returns a list of two element lists:
175 # 0: the name:version
176 # 1: a list describing the package.
177 # For tclPkgSetup packages it consists of:
178 # 0: the keyword tclPkgSetup
179 # 1: the first file to source, with its exported procedures
180 # 2: the second file ...
181 # N: the N-1st file ...
182
183 proc makePkgList { inList } {
184 set pkgList ""
185
186 foreach {k v} $inList {
187 switch [lindex $v 0] {
188 tclPkgSetup {
189 set l tclPkgSetup
190 foreach s [lindex $v 4] {
191 lappend l $s
192 }
193 }
194 source {
195 set l $v
196 }
197 default {
198 error "can't handle $k $v"
199 }
200 }
201
202 lappend pkgList [list $k $l]
203 }
204
205 return $pkgList
206 }
207
208 # pkgtest::runIndex --
209 #
210 # Runs pkg_mkIndex, parses the generated index file.
211 #
212 # Arguments:
213 # <flags> (optional) arguments starting with a dash are collected as
214 # options to pkg_mkIndex and passed to pkg_mkIndex.
215 # dirPath the directory to index
216 # pattern0 pattern to index
217 # ... pattern to index
218 # patternN pattern to index
219 #
220 # Results:
221 # Returns a two element list:
222 # 0: 1 if the procedure encountered an error, 0 otherwise.
223 # 1: if no error, this is the parsed generated index file, in the format
224 # returned by pkgtest::parseIndex. If error, this is the error result.
225
226 proc pkgtest::runCreatedIndex {rv args} {
227 if {[lindex $rv 0] == 0} {
228 set parsed [parseArgs {*}$args]
229 set dirPath [lindex $parsed 1]
230 set idxFile [file join $dirPath pkgIndex.tcl]
231
232 if {[catch {
233 set result [list 0 [makePkgList [parseIndex $idxFile]]]
234 } err]} {
235 set result [list 1 $err]
236 }
237 file delete $idxFile
238 } else {
239 set result $rv
240 }
241
242 return $result
243 }
244 proc pkgtest::runIndex { args } {
245 set rv [createIndex {*}$args]
246 return [runCreatedIndex $rv {*}$args]
247 }
248
249 # If there is no match to the patterns, make sure the directory hasn't changed
250 # on us
251
252 test pkgMkIndex-1.1 {nothing matches pattern - current dir is the same} {
253 list [pkgtest::runIndex -lazy $fullPkgPath nomatch.tcl] [pwd]
254 } [list {1 {no files matched glob pattern "nomatch.tcl"}} [pwd]]
255
256 makeFile {
257 # This is a simple package, just to check basic functionality.
258 package provide simple 1.0
259 namespace eval simple {
260 namespace export lower upper
261 }
262 proc simple::lower { stg } {
263 return [string tolower $stg]
264 }
265 proc simple::upper { stg } {
266 return [string toupper $stg]
267 }
268 } [file join pkg simple.tcl]
269
270 test pkgMkIndex-2.1 {simple package} {
271 pkgtest::runIndex -lazy $fullPkgPath simple.tcl
272 } {0 {{simple:1.0 {tclPkgSetup {simple.tcl source {::simple::lower ::simple::upper}}}}}}
273
274 test pkgMkIndex-2.2 {simple package - use -direct} {
275 pkgtest::runIndex -direct $fullPkgPath simple.tcl
276 } "0 {{simple:1.0 {[list source [file join $fullPkgPath simple.tcl]]}}}"
277
278 test pkgMkIndex-2.3 {simple package - direct loading is default} {
279 pkgtest::runIndex $fullPkgPath simple.tcl
280 } "0 {{simple:1.0 {[list source [file join $fullPkgPath simple.tcl]]}}}"
281
282 test pkgMkIndex-2.4 {simple package - use -verbose} -body {
283 pkgtest::runIndex -verbose $fullPkgPath simple.tcl
284 } -result "0 {{simple:1.0 {[list source [file join $fullPkgPath simple.tcl]]}}}" \
285 -errorOutput {successful sourcing of simple.tcl
286 packages provided were {simple 1.0}
287 processed simple.tcl
288 }
289
290 removeFile [file join pkg simple.tcl]
291
292 makeFile {
293 # Contains global symbols, used to check that they don't have a leading ::
294 package provide global 1.0
295 proc global_lower { stg } {
296 return [string tolower $stg]
297 }
298 proc global_upper { stg } {
299 return [string toupper $stg]
300 }
301 } [file join pkg global.tcl]
302
303 test pkgMkIndex-3.1 {simple package with global symbols} {
304 pkgtest::runIndex -lazy $fullPkgPath global.tcl
305 } {0 {{global:1.0 {tclPkgSetup {global.tcl source {global_lower global_upper}}}}}}
306
307 removeFile [file join pkg global.tcl]
308
309 makeFile {
310 # This package is required by pkg1.
311 # This package is split into two files, to test packages that are split over
312 # multiple files.
313 package provide pkg2 1.0
314 namespace eval pkg2 {
315 namespace export p2-1
316 }
317 proc pkg2::p2-1 { num } {
318 return [expr {$num * 2}]
319 }
320 } [file join pkg pkg2_a.tcl]
321
322 makeFile {
323 # This package is required by pkg1.
324 # This package is split into two files, to test packages that are split over
325 # multiple files.
326 package provide pkg2 1.0
327 namespace eval pkg2 {
328 namespace export p2-2
329 }
330 proc pkg2::p2-2 { num } {
331 return [expr {$num * 3}]
332 }
333 } [file join pkg pkg2_b.tcl]
334
335 test pkgMkIndex-4.1 {split package} {
336 pkgtest::runIndex -lazy $fullPkgPath pkg2_a.tcl pkg2_b.tcl
337 } {0 {{pkg2:1.0 {tclPkgSetup {pkg2_a.tcl source ::pkg2::p2-1} {pkg2_b.tcl source ::pkg2::p2-2}}}}}
338
339 test pkgMkIndex-4.2 {split package - direct loading} {
340 pkgtest::runIndex -direct $fullPkgPath pkg2_a.tcl pkg2_b.tcl
341 } "0 {{pkg2:1.0 {[list source [file join $fullPkgPath pkg2_a.tcl]]
342 [list source [file join $fullPkgPath pkg2_b.tcl]]}}}"
343
344 # Add the direct1 directory to auto_path, so that the direct1 package can be
345 # found.
346 set direct1 [makeDirectory direct1]
347 lappend auto_path $direct1
348 makeFile {
349 # This is referenced by pkgIndex.tcl as a -direct script.
350 package provide direct1 1.0
351 namespace eval direct1 {
352 namespace export pd1 pd2
353 }
354 proc direct1::pd1 { stg } {
355 return [string tolower $stg]
356 }
357 proc direct1::pd2 { stg } {
358 return [string toupper $stg]
359 }
360 } [file join direct1 direct1.tcl]
361 pkg_mkIndex -direct $direct1 direct1.tcl
362
363 makeFile {
364 # Does a package require of direct1, whose pkgIndex.tcl entry is created
365 # above with option -direct. This tests that pkg_mkIndex can handle code
366 # that is sourced in pkgIndex.tcl files.
367 package require direct1
368 package provide std 1.0
369 namespace eval std {
370 namespace export p1 p2
371 }
372 proc std::p1 { stg } {
373 return [string tolower $stg]
374 }
375 proc std::p2 { stg } {
376 return [string toupper $stg]
377 }
378 } [file join pkg std.tcl]
379
380 test pkgMkIndex-5.1 {requires -direct package} {
381 pkgtest::runIndex -lazy $fullPkgPath std.tcl
382 } {0 {{std:1.0 {tclPkgSetup {std.tcl source {::std::p1 ::std::p2}}}}}}
383
384 removeFile [file join direct1 direct1.tcl]
385 file delete [file join $direct1 pkgIndex.tcl]
386 removeDirectory direct1
387 removeFile [file join pkg std.tcl]
388
389 makeFile {
390 # This package requires pkg3, but it does not use any of pkg3's procs in the
391 # code that is executed by the file (i.e. references to pkg3's procs are in
392 # the proc bodies only).
393 package require pkg3 1.0
394 package provide pkg1 1.0
395 namespace eval pkg1 {
396 namespace export p1-1 p1-2
397 }
398 proc pkg1::p1-1 { num } {
399 return [pkg3::p3-1 $num]
400 }
401 proc pkg1::p1-2 { num } {
402 return [pkg3::p3-2 $num]
403 }
404 } [file join pkg pkg1.tcl]
405
406 makeFile {
407 package provide pkg3 1.0
408 namespace eval pkg3 {
409 namespace export p3-1 p3-2
410 }
411 proc pkg3::p3-1 { num } {
412 return {[expr {$num * 2}]}
413 }
414 proc pkg3::p3-2 { num } {
415 return {[expr {$num * 3}]}
416 }
417 } [file join pkg pkg3.tcl]
418
419 test pkgMkIndex-6.1 {pkg1 requires pkg3} {
420 pkgtest::runIndex -lazy $fullPkgPath pkg1.tcl pkg3.tcl
421 } {0 {{pkg1:1.0 {tclPkgSetup {pkg1.tcl source {::pkg1::p1-1 ::pkg1::p1-2}}}} {pkg3:1.0 {tclPkgSetup {pkg3.tcl source {::pkg3::p3-1 ::pkg3::p3-2}}}}}}
422
423 test pkgMkIndex-6.2 {pkg1 requires pkg3 - use -direct} {
424 pkgtest::runIndex -direct $fullPkgPath pkg1.tcl pkg3.tcl
425 } "0 {{pkg1:1.0 {[list source [file join $fullPkgPath pkg1.tcl]]}} {pkg3:1.0 {[list source [file join $fullPkgPath pkg3.tcl]]}}}"
426
427 removeFile [file join pkg pkg1.tcl]
428
429 makeFile {
430 # This package requires pkg3, and it calls a pkg3 proc in the code that is
431 # executed by the file
432 package require pkg3 1.0
433 package provide pkg4 1.0
434 namespace eval pkg4 {
435 namespace export p4-1 p4-2
436 variable m2 [pkg3::p3-1 10]
437 }
438 proc pkg4::p4-1 { num } {
439 variable m2
440 return [expr {$m2 * $num}]
441 }
442 proc pkg4::p4-2 { num } {
443 return [pkg3::p3-2 $num]
444 }
445 } [file join pkg pkg4.tcl]
446
447 test pkgMkIndex-7.1 {pkg4 uses pkg3} {
448 pkgtest::runIndex -lazy $fullPkgPath pkg4.tcl pkg3.tcl
449 } {0 {{pkg3:1.0 {tclPkgSetup {pkg3.tcl source {::pkg3::p3-1 ::pkg3::p3-2}}}} {pkg4:1.0 {tclPkgSetup {pkg4.tcl source {::pkg4::p4-1 ::pkg4::p4-2}}}}}}
450
451 test pkgMkIndex-7.2 {pkg4 uses pkg3 - use -direct} {
452 pkgtest::runIndex -direct $fullPkgPath pkg4.tcl pkg3.tcl
453 } "0 {{pkg3:1.0 {[list source [file join $fullPkgPath pkg3.tcl]]}} {pkg4:1.0 {[list source [file join $fullPkgPath pkg4.tcl]]}}}"
454
455 removeFile [file join pkg pkg4.tcl]
456 removeFile [file join pkg pkg3.tcl]
457
458 makeFile {
459 # This package requires pkg2, and it calls a pkg2 proc in the code that is
460 # executed by the file. Pkg2 is a split package.
461 package require pkg2 1.0
462 package provide pkg5 1.0
463 namespace eval pkg5 {
464 namespace export p5-1 p5-2
465 variable m2 [pkg2::p2-1 10]
466 variable m3 [pkg2::p2-2 10]
467 }
468 proc pkg5::p5-1 { num } {
469 variable m2
470 return [expr {$m2 * $num}]
471 }
472 proc pkg5::p5-2 { num } {
473 variable m2
474 return [expr {$m2 * $num}]
475 }
476 } [file join pkg pkg5.tcl]
477
478 test pkgMkIndex-8.1 {pkg5 uses pkg2} {
479 pkgtest::runIndex -lazy $fullPkgPath pkg5.tcl pkg2_a.tcl pkg2_b.tcl
480 } {0 {{pkg2:1.0 {tclPkgSetup {pkg2_a.tcl source ::pkg2::p2-1} {pkg2_b.tcl source ::pkg2::p2-2}}} {pkg5:1.0 {tclPkgSetup {pkg5.tcl source {::pkg5::p5-1 ::pkg5::p5-2}}}}}}
481
482 test pkgMkIndex-8.2 {pkg5 uses pkg2 - use -direct} {
483 pkgtest::runIndex -direct $fullPkgPath pkg5.tcl pkg2_a.tcl pkg2_b.tcl
484 } "0 {{pkg2:1.0 {[list source [file join $fullPkgPath pkg2_a.tcl]]
485 [list source [file join $fullPkgPath pkg2_b.tcl]]}} {pkg5:1.0 {[list source [file join $fullPkgPath pkg5.tcl]]}}}"
486
487 removeFile [file join pkg pkg5.tcl]
488 removeFile [file join pkg pkg2_a.tcl]
489 removeFile [file join pkg pkg2_b.tcl]
490
491 makeFile {
492 # This package requires circ2, and circ2 requires circ3, which in turn
493 # requires circ1. In case of circularities, pkg_mkIndex should give up when
494 # it gets stuck.
495 package require circ2 1.0
496 package provide circ1 1.0
497 namespace eval circ1 {
498 namespace export c1-1 c1-2 c1-3 c1-4
499 }
500 proc circ1::c1-1 { num } {
501 return [circ2::c2-1 $num]
502 }
503 proc circ1::c1-2 { num } {
504 return [circ2::c2-2 $num]
505 }
506 proc circ1::c1-3 {} {
507 return 10
508 }
509 proc circ1::c1-4 {} {
510 return 20
511 }
512 } [file join pkg circ1.tcl]
513
514 makeFile {
515 # This package is required by circ1, and requires circ3. Circ3, in turn,
516 # requires circ1 to give us a circularity.
517 package require circ3 1.0
518 package provide circ2 1.0
519 namespace eval circ2 {
520 namespace export c2-1 c2-2
521 }
522 proc circ2::c2-1 { num } {
523 return [expr {$num * [circ3::c3-1]}]
524 }
525 proc circ2::c2-2 { num } {
526 return [expr {$num * [circ3::c3-2]}]
527 }
528 } [file join pkg circ2.tcl]
529
530 makeFile {
531 # This package is required by circ2, and in turn requires circ1. This closes
532 # the circularity.
533 package require circ1 1.0
534 package provide circ3 1.0
535 namespace eval circ3 {
536 namespace export c3-1 c3-4
537 }
538 proc circ3::c3-1 {} {
539 return [circ1::c1-3]
540 }
541 proc circ3::c3-2 {} {
542 return [circ1::c1-4]
543 }
544 } [file join pkg circ3.tcl]
545
546 test pkgMkIndex-9.1 {circular packages} {
547 pkgtest::runIndex -lazy $fullPkgPath circ1.tcl circ2.tcl circ3.tcl
548 } {0 {{circ1:1.0 {tclPkgSetup {circ1.tcl source {::circ1::c1-1 ::circ1::c1-2 ::circ1::c1-3 ::circ1::c1-4}}}} {circ2:1.0 {tclPkgSetup {circ2.tcl source {::circ2::c2-1 ::circ2::c2-2}}}} {circ3:1.0 {tclPkgSetup {circ3.tcl source ::circ3::c3-1}}}}}
549
550 removeFile [file join pkg circ1.tcl]
551 removeFile [file join pkg circ2.tcl]
552 removeFile [file join pkg circ3.tcl]
553
554 # Some tests require the existence of one of the DLLs in the dltest directory
555 set x [file join [file dirname [info nameofexecutable]] dltest \
556 pkga[info sharedlibextension]]
557 set dll "[file tail $x]Required"
558 testConstraint $dll [file exists $x]
559
560 if {[testConstraint $dll]} {
561 makeFile {
562 # This package provides pkga, which is also provided by a DLL.
563 package provide pkga 1.0
564 proc pkga_neq { x } {
565 return [expr {! [pkgq_eq $x]}]
566 }
567 } [file join pkg pkga.tcl]
568 file copy -force $x $fullPkgPath
569 }
570 testConstraint exec [llength [info commands ::exec]]
571
572 test pkgMkIndex-10.1 {package in DLL and script} [list exec $dll] {
573 # Do all [load]ing of shared libraries in another process, so we can
574 # delete the file and not get stuck because we're holding a reference to
575 # it.
576 set cmd [list pkg_mkIndex -lazy $fullPkgPath [file tail $x] pkga.tcl]
577 exec [interpreter] << $cmd
578 pkgtest::runCreatedIndex {0 {}} -lazy $fullPkgPath pkga[info sharedlibextension] pkga.tcl
579 } "0 {{pkga:1.0 {tclPkgSetup {pkga[info sharedlibextension] load {pkga_eq pkga_quote}} {pkga.tcl source pkga_neq}}}}"
580 test pkgMkIndex-10.2 {package in DLL hidden by -load} [list exec $dll] {
581 # Do all [load]ing of shared libraries in another process, so we can
582 # delete the file and not get stuck because we're holding a reference to
583 # it.
584 #
585 # This test depends on context from prior test, so repeat it.
586 set script \
587 "[list pkg_mkIndex -lazy $fullPkgPath [file tail $x] pkga.tcl]"
588 append script \n \
589 "[list pkg_mkIndex -lazy -load Pkg* $fullPkgPath [file tail $x]]"
590 exec [interpreter] << $script
591 pkgtest::runCreatedIndex {0 {}} -lazy -load Pkg* -- $fullPkgPath pkga[info sharedlibextension]
592 } {0 {}}
593
594 if {[testConstraint $dll]} {
595 file delete -force [file join $fullPkgPath [file tail $x]]
596 removeFile [file join pkg pkga.tcl]
597 }
598
599 # Tolerate "namespace import" at the global scope
600
601 makeFile {
602 package provide fubar 1.0
603 namespace eval ::fubar:: {
604 #
605 # export only public functions.
606 #
607 namespace export {[a-z]*}
608 }
609 proc ::fubar::foo {bar} {
610 puts "$bar"
611 return true
612 }
613 namespace import ::fubar::foo
614 } [file join pkg import.tcl]
615
616 test pkgMkIndex-11.1 {conflicting namespace imports} {
617 pkgtest::runIndex -lazy $fullPkgPath import.tcl
618 } {0 {{fubar:1.0 {tclPkgSetup {import.tcl source ::fubar::foo}}}}}
619
620 removeFile [file join pkg import.tcl]
621
622 # Verify that the auto load list generated is correct even when there is a
623 # proc name conflict between two namespaces (ie, ::foo::baz and ::bar::baz)
624
625 makeFile {
626 package provide football 1.0
627 namespace eval ::pro:: {
628 #
629 # export only public functions.
630 #
631 namespace export {[a-z]*}
632 }
633 namespace eval ::college:: {
634 #
635 # export only public functions.
636 #
637 namespace export {[a-z]*}
638 }
639 proc ::pro::team {} {
640 puts "go packers!"
641 return true
642 }
643 proc ::college::team {} {
644 puts "go badgers!"
645 return true
646 }
647 } [file join pkg samename.tcl]
648
649 test pkgMkIndex-12.1 {same name procs in different namespace} {
650 pkgtest::runIndex -lazy $fullPkgPath samename.tcl
651 } {0 {{football:1.0 {tclPkgSetup {samename.tcl source {::college::team ::pro::team}}}}}}
652
653 removeFile [file join pkg samename.tcl]
654
655 # Proc names with embedded spaces are properly listed (i.e. correct number of
656 # braces) in result
657 makeFile {
658 package provide spacename 1.0
659 proc {a b} {} {}
660 proc {c d} {} {}
661 } [file join pkg spacename.tcl]
662
663 test pkgMkIndex-13.1 {proc names with embedded spaces} {
664 pkgtest::runIndex -lazy $fullPkgPath spacename.tcl
665 } {0 {{spacename:1.0 {tclPkgSetup {spacename.tcl source {{a b} {c d}}}}}}}
666
667 removeFile [file join pkg spacename.tcl]
668
669 # Test the tcl::Pkg::CompareExtension helper function
670 test pkgMkIndex-14.1 {tcl::Pkg::CompareExtension} {unix} {
671 tcl::Pkg::CompareExtension foo.so .so
672 } 1
673 test pkgMkIndex-14.2 {tcl::Pkg::CompareExtension} {unix} {
674 tcl::Pkg::CompareExtension foo.so.bar .so
675 } 0
676 test pkgMkIndex-14.3 {tcl::Pkg::CompareExtension} {unix} {
677 tcl::Pkg::CompareExtension foo.so.1 .so
678 } 1
679 test pkgMkIndex-14.4 {tcl::Pkg::CompareExtension} {unix} {
680 tcl::Pkg::CompareExtension foo.so.1.2 .so
681 } 1
682 test pkgMkIndex-14.5 {tcl::Pkg::CompareExtension} {unix} {
683 tcl::Pkg::CompareExtension foo .so
684 } 0
685 test pkgMkIndex-14.6 {tcl::Pkg::CompareExtension} {unix} {
686 tcl::Pkg::CompareExtension foo.so.1.2.bar .so
687 } 0
688
689 # cleanup
690
691 removeDirectory pkg
692
693 namespace delete pkgtest
694 ::tcltest::cleanupTests
695 return
696
697 # Local Variables:
698 # mode: tcl
699 # fill-column: 78
700 # End: