diff options
author | escoffon <escoffon> | 1998-10-17 00:21:39 (GMT) |
---|---|---|
committer | escoffon <escoffon> | 1998-10-17 00:21:39 (GMT) |
commit | 0d09c361456f377474244ee597e06a8ab8105de3 (patch) | |
tree | e3d33d876884b1d446bc420c01d572efe535939f | |
parent | 0d1101d7ed7ac7f7a09b67d881c3883fb3f16f2b (diff) | |
download | tcl-0d09c361456f377474244ee597e06a8ab8105de3.zip tcl-0d09c361456f377474244ee597e06a8ab8105de3.tar.gz tcl-0d09c361456f377474244ee597e06a8ab8105de3.tar.bz2 |
Added the pkg_mkIndex test suite
-rw-r--r-- | tests/pkg/circ1.tcl | 34 | ||||
-rw-r--r-- | tests/pkg/circ2.tcl | 25 | ||||
-rw-r--r-- | tests/pkg/circ3.tcl | 25 | ||||
-rw-r--r-- | tests/pkg/global.tcl | 19 | ||||
-rw-r--r-- | tests/pkg/pkg1.tcl | 26 | ||||
-rw-r--r-- | tests/pkg/pkg2_a.tcl | 22 | ||||
-rw-r--r-- | tests/pkg/pkg2_b.tcl | 22 | ||||
-rw-r--r-- | tests/pkg/pkg3.tcl | 22 | ||||
-rw-r--r-- | tests/pkg/pkg4.tcl | 27 | ||||
-rw-r--r-- | tests/pkg/pkg5.tcl | 30 | ||||
-rw-r--r-- | tests/pkg/simple.tcl | 23 | ||||
-rw-r--r-- | tests/pkg/std.tcl | 28 | ||||
-rw-r--r-- | tests/pkg1/direct1.tcl | 23 | ||||
-rw-r--r-- | tests/pkg1/pkgIndex.tcl | 11 | ||||
-rw-r--r-- | tests/pkgMkIndex.test | 402 |
15 files changed, 739 insertions, 0 deletions
diff --git a/tests/pkg/circ1.tcl b/tests/pkg/circ1.tcl new file mode 100644 index 0000000..3616621 --- /dev/null +++ b/tests/pkg/circ1.tcl @@ -0,0 +1,34 @@ +# circ1.tcl -- +# +# Test package for pkg_mkIndex. This package requires circ2, and circ2 +# requires circ3, which in turn requires circ1. +# In case of cirularities, pkg_mkIndex should give up when it gets stuck. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: circ1.tcl,v 1.1 1998/10/17 00:21:39 escoffon Exp $ + +package require circ2 1.0 + +package provide circ1 1.0 + +namespace eval circ1 { + namespace export c1-1 c1-2 c1-3 c1-4 +} + +proc circ1::c1-1 { num } { + return [circ2::c2-1 $num] +} + +proc circ1::c1-2 { num } { + return [circ2::c2-2 $num] +} + +proc circ1::c1-3 {} { + return 10 +} + +proc circ1::c1-4 {} { + return 20 +} diff --git a/tests/pkg/circ2.tcl b/tests/pkg/circ2.tcl new file mode 100644 index 0000000..66a20a3 --- /dev/null +++ b/tests/pkg/circ2.tcl @@ -0,0 +1,25 @@ +# circ2.tcl -- +# +# Test package for pkg_mkIndex. This package is required by circ1, and +# requires circ3. Circ3, in turn, requires circ1 to give us a circularity. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: circ2.tcl,v 1.1 1998/10/17 00:21:39 escoffon Exp $ + +package require circ3 1.0 + +package provide circ2 1.0 + +namespace eval circ2 { + namespace export c2-1 c2-2 +} + +proc circ2::c2-1 { num } { + return [expr $num * [circ3::c3-1]] +} + +proc circ2::c2-2 { num } { + return [expr $num * [circ3::c3-2]] +} diff --git a/tests/pkg/circ3.tcl b/tests/pkg/circ3.tcl new file mode 100644 index 0000000..ddcb691 --- /dev/null +++ b/tests/pkg/circ3.tcl @@ -0,0 +1,25 @@ +# circ3.tcl -- +# +# Test package for pkg_mkIndex. This package is required by circ2, and in +# turn requires circ1. This closes the circularity. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: circ3.tcl,v 1.1 1998/10/17 00:21:40 escoffon Exp $ + +package require circ1 1.0 + +package provide circ3 1.0 + +namespace eval circ3 { + namespace export c3-1 c3-4 +} + +proc circ3::c3-1 {} { + return [circ1::c1-3] +} + +proc circ3::c3-2 {} { + return [circ1::c1-4] +} diff --git a/tests/pkg/global.tcl b/tests/pkg/global.tcl new file mode 100644 index 0000000..38925c5 --- /dev/null +++ b/tests/pkg/global.tcl @@ -0,0 +1,19 @@ +# global.tcl -- +# +# Test package for pkg_mkIndex. +# Contains global symbols, used to check that they don't have a leading :: +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: global.tcl,v 1.1 1998/10/17 00:21:40 escoffon Exp $ + +package provide global 1.0 + +proc global_lower { stg } { + return [string tolower $stg] +} + +proc global_upper { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg/pkg1.tcl b/tests/pkg/pkg1.tcl new file mode 100644 index 0000000..e2cf960 --- /dev/null +++ b/tests/pkg/pkg1.tcl @@ -0,0 +1,26 @@ +# pkg1.tcl -- +# +# Test package for pkg_mkIndex. This package requires pkg3, but it does +# not use any of pkg3's procs in the code that is executed by the file +# (i.e. references to pkg3's procs are in the proc bodies only). +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg1.tcl,v 1.1 1998/10/17 00:21:40 escoffon Exp $ + +package require pkg3 1.0 + +package provide pkg1 1.0 + +namespace eval pkg1 { + namespace export p1-1 p1-2 +} + +proc pkg1::p1-1 { num } { + return [pkg3::p3-1 $num] +} + +proc pkg1::p1-2 { num } { + return [pkg3::p3-2 $num] +} diff --git a/tests/pkg/pkg2_a.tcl b/tests/pkg/pkg2_a.tcl new file mode 100644 index 0000000..85e16c4 --- /dev/null +++ b/tests/pkg/pkg2_a.tcl @@ -0,0 +1,22 @@ +# pkg2_a.tcl -- +# +# Test package for pkg_mkIndex. This package is required by pkg1. +# This package is split into two files, to test packages that are split +# over multiple files. +# +# Copyright (c) 2998 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# SCCS: %Z% %M% %I% %E% %U% + +package provide pkg2 1.0 + +namespace eval pkg2 { + namespace export p2-1 +} + +proc pkg2::p2-1 { num } { + return [expr $num * 2] +} diff --git a/tests/pkg/pkg2_b.tcl b/tests/pkg/pkg2_b.tcl new file mode 100644 index 0000000..15fb1a8 --- /dev/null +++ b/tests/pkg/pkg2_b.tcl @@ -0,0 +1,22 @@ +# pkg2_b.tcl -- +# +# Test package for pkg_mkIndex. This package is required by pkg1. +# This package is split into two files, to test packages that are split +# over multiple files. +# +# Copyright (c) 2998 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# SCCS: %Z% %M% %I% %E% %U% + +package provide pkg2 1.0 + +namespace eval pkg2 { + namespace export p2-2 +} + +proc pkg2::p2-2 { num } { + return [expr $num * 3] +} diff --git a/tests/pkg/pkg3.tcl b/tests/pkg/pkg3.tcl new file mode 100644 index 0000000..fd769c4 --- /dev/null +++ b/tests/pkg/pkg3.tcl @@ -0,0 +1,22 @@ +# pkg3.tcl -- +# +# Test package for pkg_mkIndex. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg3.tcl,v 1.1 1998/10/17 00:21:42 escoffon Exp $ + +package provide pkg3 1.0 + +namespace eval pkg3 { + namespace export p3-1 p3-2 +} + +proc pkg3::p3-1 { num } { + return {[expr $num * 2]} +} + +proc pkg3::p3-2 { num } { + return {[expr $num * 3]} +} diff --git a/tests/pkg/pkg4.tcl b/tests/pkg/pkg4.tcl new file mode 100644 index 0000000..ccb9291 --- /dev/null +++ b/tests/pkg/pkg4.tcl @@ -0,0 +1,27 @@ +# pkg4.tcl -- +# +# Test package for pkg_mkIndex. This package requires pkg3, and it calls +# a pkg3 proc in the code that is executed by the file +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg4.tcl,v 1.1 1998/10/17 00:21:42 escoffon Exp $ + +package require pkg3 1.0 + +package provide pkg4 1.0 + +namespace eval pkg4 { + namespace export p4-1 p4-2 + variable m2 [pkg3::p3-1 10] +} + +proc pkg4::p4-1 { num } { + variable m2 + return [expr {$m2 * $num}] +} + +proc pkg4::p4-2 { num } { + return [pkg3::p3-2 $num] +} diff --git a/tests/pkg/pkg5.tcl b/tests/pkg/pkg5.tcl new file mode 100644 index 0000000..5e25e6d --- /dev/null +++ b/tests/pkg/pkg5.tcl @@ -0,0 +1,30 @@ +# pkg5.tcl -- +# +# Test package for pkg_mkIndex. This package requires pkg2, and it calls +# a pkg2 proc in the code that is executed by the file. +# Pkg2 is a split package. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg5.tcl,v 1.1 1998/10/17 00:21:42 escoffon Exp $ + +package require pkg2 1.0 + +package provide pkg5 1.0 + +namespace eval pkg5 { + namespace export p5-1 p5-2 + variable m2 [pkg2::p2-1 10] + variable m3 [pkg2::p2-2 10] +} + +proc pkg5::p5-1 { num } { + variable m2 + return [expr {$m2 * $num}] +} + +proc pkg5::p5-2 { num } { + variable m2 + return [expr {$m2 * $num}] +} diff --git a/tests/pkg/simple.tcl b/tests/pkg/simple.tcl new file mode 100644 index 0000000..a2cf121 --- /dev/null +++ b/tests/pkg/simple.tcl @@ -0,0 +1,23 @@ +# simple.tcl -- +# +# Test package for pkg_mkIndex. This is a simple package, just to check +# basic functionality. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: simple.tcl,v 1.1 1998/10/17 00:21:43 escoffon Exp $ + +package provide simple 1.0 + +namespace eval simple { + namespace export lower upper +} + +proc simple::lower { stg } { + return [string tolower $stg] +} + +proc simple::upper { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg/std.tcl b/tests/pkg/std.tcl new file mode 100644 index 0000000..48c4048 --- /dev/null +++ b/tests/pkg/std.tcl @@ -0,0 +1,28 @@ +# std.tcl -- +# +# Test package for pkg_mkIndex. +# Does a package require of direct1, whose pkgIndex.tcl entry (in pkg1) +# should be a -direct entry. +# This tests that pkg_mkIndex can handle code that is sourced in pkgIndex.tcl +# files. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: std.tcl,v 1.1 1998/10/17 00:21:43 escoffon Exp $ + +package require direct1 + +package provide std 1.0 + +namespace eval std { + namespace export p1 p2 +} + +proc std::p1 { stg } { + return [string tolower $stg] +} + +proc std::p2 { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg1/direct1.tcl b/tests/pkg1/direct1.tcl new file mode 100644 index 0000000..cc10330 --- /dev/null +++ b/tests/pkg1/direct1.tcl @@ -0,0 +1,23 @@ +# std.tcl -- +# +# Test support package for pkg_mkIndex. +# This is referenced by pkgIndex.tcl as a -direct script. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: direct1.tcl,v 1.1 1998/10/17 00:21:44 escoffon Exp $ + +package provide direct1 1.0 + +namespace eval direct1 { + namespace export pd1 pd2 +} + +proc direct1::pd1 { stg } { + return [string tolower $stg] +} + +proc direct1::pd2 { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg1/pkgIndex.tcl b/tests/pkg1/pkgIndex.tcl new file mode 100644 index 0000000..5dc1d5e --- /dev/null +++ b/tests/pkg1/pkgIndex.tcl @@ -0,0 +1,11 @@ +# Tcl package index file, version 1.1 +# This file is generated by the "pkg_mkIndex -direct" command +# and sourced either when an application starts up or +# by a "package unknown" script. It invokes the +# "package ifneeded" command to set up package-related +# information so that packages will be loaded automatically +# in response to "package require" commands. When this +# script is sourced, the variable $dir must contain the +# full path name of this file's directory. + +package ifneeded direct1 1.0 [list source [file join $dir direct1.tcl]] diff --git a/tests/pkgMkIndex.test b/tests/pkgMkIndex.test new file mode 100644 index 0000000..f30c8ea --- /dev/null +++ b/tests/pkgMkIndex.test @@ -0,0 +1,402 @@ +# This file contains tests for the pkg_mkIndex command. +# Note that the tests are limited to Tcl scripts only, there are no shared +# libraries against which to test. +# +# Sourcing this file into Tcl runs the tests and generates output for +# errors. No output means no errors were found. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkgMkIndex.test,v 1.1 1998/10/17 00:21:39 escoffon Exp $ + +if {[string compare test [info procs test]] == 1} then {source defs} + +# Add the pkg1 directory to auto_path, so that its packages can be found. +# packages in pkg1 are used to test indexing of packages in pkg. +# Make sure that the path to pkg1 is absolute. + +set scriptDir [file dirname [info script]] +if {[string compare [file pathtype $scriptDir] relative] == 0} { + set oldDir [pwd] + catch { + cd [file join [pwd] $scriptDir] + set scriptDir [pwd] + } + cd $oldDir +} +lappend auto_path [file join $scriptDir pkg1] + +# pkgproc -- +# +# Wraps around proc, saves the name of the procedure in procList, so that +# the procedure can be undefined at the end. +# +# Arguments: +# procName procedure name +# argList arguments list +# body procedure body +# +# Results: +# Returns the return value of proc + +proc pkgproc { procName argList body } { + set result [proc $procName $argList $body] + + lappend ::procList $procName + + return $result +} + +set ::procList pkgproc + +set ::pkgDriverCount 0 + +# parseArgs -- +# +# Parse an argument list. +# +# Arguments: +# <flags> (optional) arguments starting with a dash are collected +# as options to pkg_mkIndex and passed to pkg_mkIndex. +# dirPath the directory to index +# pattern0 pattern to index +# ... pattern to index +# patternN pattern to index +# +# Results: +# Returns a three element list: +# 0: the options +# 1: the directory to index +# 2: the patterns list + +pkgproc parseArgs { args } { + set options "" + + set argc [llength $args] + for {set iarg 0} {$iarg < $argc} {incr iarg} { + set a [lindex $args $iarg] + if {[regexp {^-} $a]} { + lappend options $a + } else { + break + } + } + + set dirPath [lindex $args $iarg] + incr iarg + set patternList [lrange $args $iarg end] + + return [list $options $dirPath $patternList] +} + +# parsePkgIndex -- +# +# Loads a pkgIndex.tcl file, records all the calls to "package ifneeded". +# +# Arguments: +# filePath path to the pkgIndex.tcl file. +# +# Results: +# Returns a list, in "array set/get" format, where the keys are the package +# name and version (in the form "$name:$version"), and the values the rest +# of the command line. + +pkgproc parsePkgIndex { filePath } { + # create a slave interpreter, where we override "package ifneeded" + + set slave [interp create] + if {[catch { + $slave eval { + rename package package_original + proc package { args } { + if {[string compare [lindex $args 0] ifneeded] == 0} { + set pkg [lindex $args 1] + set ver [lindex $args 2] + set ::PKGS($pkg:$ver) [lindex $args 3] + } else { + return [eval package_original $args] + } + } + array set ::PKGS {} + } + + set dir [file dirname $filePath] + $slave eval {set curdir [pwd]} + $slave eval [list cd $dir] + $slave eval [list set dir $dir] + $slave eval [list source [file tail $filePath]] + $slave eval {cd $curdir} + + # Create the list in sorted order, so that we don't get spurious + # errors because the order has changed. + + array set P {} + foreach {k v} [$slave eval {array get ::PKGS}] { + set P($k) $v + } + + set PKGS "" + foreach k [lsort [array names P]] { + lappend PKGS $k $P($k) + } + } err]} { + set ei $::errorInfo + set ec $::errorCode + + catch {interp delete $slave} + + error $ei $ec + } + + interp delete $slave + + return $PKGS +} + +# createIndex -- +# +# Runs pkg_mkIndex for the given directory and set of patterns. +# This procedure deletes any pkgIndex.tcl file in the target directory, +# then runs pkg_mkIndex. +# +# Arguments: +# <flags> (optional) arguments starting with a dash are collected +# as options to pkg_mkIndex and passed to pkg_mkIndex. +# dirPath the directory to index +# pattern0 pattern to index +# ... pattern to index +# patternN pattern to index +# +# Results: +# Returns a two element list: +# 0: 1 if the procedure encountered an error, 0 otherwise. +# 1: the error result if element 0 was 1 + +pkgproc createIndex { args } { + set parsed [eval parseArgs $args] + set options [lindex $parsed 0] + set dirPath [lindex $parsed 1] + set patternList [lindex $parsed 2] + + if {[catch { + file delete [file join $dirPath pkgIndex.tcl] + eval pkg_mkIndex $options $dirPath $patternList + } err]} { + return [list 1 $err] + } + + return [list 0 {}] +} + +# makePkgList -- +# +# Takes the output of a parsePkgIndex call, filters it and returns a +# cleaned up list of packages and their actions. +# +# Arguments: +# inList output from a parsePkgIndex. +# +# Results: +# Returns a list of two element lists: +# 0: the name:version +# 1: a list describing the package. +# For tclPkgSetup packages it consists of: +# 0: the keyword tclPkgSetup +# 1: the first file to source, with its exported procedures +# 2: the second file ... +# N: the N-1st file ... + +pkgproc makePkgList { inList } { + set pkgList "" + + foreach {k v} $inList { + switch [lindex $v 0] { + tclPkgSetup { + set l tclPkgSetup + foreach s [lindex $v 4] { + lappend l $s + } + } + + source { + set l $v + } + + default { + error "can't handle $k $v" + } + } + + lappend pkgList [list $k $l] + } + + return $pkgList +} + +# runIndex -- +# +# Runs pkg_mkIndex, parses the generated index file. +# +# Arguments: +# <flags> (optional) arguments starting with a dash are collected +# as options to pkg_mkIndex and passed to pkg_mkIndex. +# dirPath the directory to index +# pattern0 pattern to index +# ... pattern to index +# patternN pattern to index +# +# Results: +# Returns a two element list: +# 0: 1 if the procedure encountered an error, 0 otherwise. +# 1: if no error, this is the parsed generated index file, in the format +# returned by parsePkgIndex. +# If error, this is the error result. + +pkgproc runIndex { args } { + set rv [eval createIndex $args] + if {[lindex $rv 0] == 0} { + set parsed [eval parseArgs $args] + set dirPath [lindex $parsed 1] + set idxFile [file join $dirPath pkgIndex.tcl] + + if {[catch { + set result [list 0 [makePkgList [parsePkgIndex $idxFile]]] + } err]} { + set result [list 1 $err] + } + file delete $idxFile + } else { + set result $rv + } + + return $result +} + +# If there is no match to the patterns, make sure the directory hasn't +# changed on us + +test pkgMkIndex-1.1 {nothing matches pattern - current dir is the same} { + list [runIndex pkg nomatch.tcl] [pwd] +} [list {1 {no files matched glob pattern "nomatch.tcl"}} [pwd]] + +test pkgMkIndex-2.1 {simple package} { + runIndex pkg simple.tcl +} {0 {{simple:1.0 {tclPkgSetup {simple.tcl source {::simple::lower ::simple::upper}}}}}} + +test pkgMkIndex-2.2 {simple package - use -direct} { + runIndex -direct pkg simple.tcl +} {0 {{simple:1.0 {source pkg/simple.tcl}}}} + +test pkgMkIndex-3.1 {simple package with global symbols} { + runIndex pkg global.tcl +} {0 {{global:1.0 {tclPkgSetup {global.tcl source {global_lower global_upper}}}}}} + +test pkgMkIndex-4.1 {split package} { + runIndex pkg pkg2_a.tcl pkg2_b.tcl +} {0 {{pkg2:1.0 {tclPkgSetup {pkg2_a.tcl source ::pkg2::p2-1} {pkg2_b.tcl source ::pkg2::p2-2}}}}} + +test pkgMkIndex-4.2 {split package - direct loading} { + runIndex -direct pkg pkg2_a.tcl pkg2_b.tcl +} {0 {{pkg2:1.0 {source pkg/pkg2_a.tcl +source pkg/pkg2_b.tcl}}}} + +# This will fail, with "direct1" procedures in the list of procedures +# provided by std. +# It may also fail, if tclblend is in the auto_path, with an additional +# command "loadJava" which comes from the tclblend pkgIndex.tcl file. +# Both failures are caused by Tcl code executed in pkgIndex.tcl. + +test pkgMkIndex-5.1 {requires -direct package} { + runIndex pkg std.tcl +} {0 {{std:1.0 {tclPkgSetup {std.tcl source {::std::p1 ::std::p2}}}}}} + +test pkgMkIndex-5.2 {requires -direct package - use -nopkgrequire} { + runIndex -nopkgrequire pkg std.tcl +} {0 {{std:1.0 {tclPkgSetup {std.tcl source {::std::p1 ::std::p2}}}}}} + +test pkgMkIndex-6.1 {pkg1 requires pkg3} { + runIndex pkg pkg1.tcl pkg3.tcl +} {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}}}}}} + +test pkgMkIndex-6.2 {pkg1 requires pkg3 - use -direct} { + runIndex -direct pkg pkg1.tcl pkg3.tcl +} {0 {{pkg1:1.0 {source pkg/pkg1.tcl}} {pkg3:1.0 {source pkg/pkg3.tcl}}}} + +test pkgMkIndex-6.3 {pkg1 requires pkg3 - use -nopkgrequire} { + runIndex -nopkgrequire pkg pkg1.tcl pkg3.tcl +} {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}}}}}} + +test pkgMkIndex-6.4 {pkg1 requires pkg3 - use -direct -nopkgrequire} { + runIndex -direct -nopkgrequire pkg pkg1.tcl pkg3.tcl +} {0 {{pkg1:1.0 {source pkg/pkg1.tcl}} {pkg3:1.0 {source pkg/pkg3.tcl}}}} + +test pkgMkIndex-7.1 {pkg4 uses pkg3} { + runIndex pkg pkg4.tcl pkg3.tcl +} {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}}}}}} + +test pkgMkIndex-7.2 {pkg4 uses pkg3 - use -direct} { + runIndex -direct pkg pkg4.tcl pkg3.tcl +} {0 {{pkg3:1.0 {source pkg/pkg3.tcl}} {pkg4:1.0 {source pkg/pkg4.tcl}}}} + +# Should pkg_mkIndex throw an error if not all packages are indexed? +# Currently it doesn't, and that's why there is a "success". +# The error marker was set at 1 so that the fail tests as a reminder to +# look at pkg_mkIndex behaviour on errors like these + +test pkgMkIndex-7.3 {pkg4 uses pkg3 - use -nopkgrequire} { + runIndex -nopkgrequire pkg pkg4.tcl pkg3.tcl +} {1 {{pkg3:1.0 {tclPkgSetup {pkg3.tcl source {::pkg3::p3-1 ::pkg3::p3-2}}}}}} + +test pkgMkIndex-7.4 {pkg4 uses pkg3 - use -direct -nopkgrequire} { + runIndex -direct -nopkgrequire pkg pkg4.tcl pkg3.tcl +} {1 {{pkg3:1.0 {source pkg/pkg3.tcl}}}} + +test pkgMkIndex-8.1 {pkg5 uses pkg2} { + runIndex pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl +} {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}}}}}} + +test pkgMkIndex-8.2 {pkg5 uses pkg2 - use -direct} { + runIndex -direct pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl +} {0 {{pkg2:1.0 {source pkg/pkg2_a.tcl +source pkg/pkg2_b.tcl}} {pkg5:1.0 {source pkg/pkg5.tcl}}}} + +# Should pkg_mkIndex throw an error if not all packages are indexed? +# Currently it doesn't, and that's why there is a "success". +# The error marker was set at 1 so that the fail tests as a reminder to +# look at pkg_mkIndex behaviour on errors like these + +test pkgMkIndex-8.3 {pkg5 uses pkg2 - use -nopkgrequire} { + runIndex -nopkgrequire pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl +} {1 {{pkg2:1.0 {tclPkgSetup {pkg2_a.tcl source ::pkg2::p2-1} {pkg2_b.tcl source ::pkg2::p2-2}}}}} + +test pkgMkIndex-8.4 {pkg5 uses pkg2 - use -direct -nopkgrequire} { + runIndex -direct -nopkgrequire pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl +} {1 {{pkg2:1.0 {source pkg/pkg2_a.tcl +source pkg/pkg2_b.tcl}}}} + +# Should pkg_mkIndex throw an error if not all packages are indexed? +# Currently it doesn't, and that's why there is a "success". +# The error marker was set at 1 so that the fail tests as a reminder to +# look at pkg_mkIndex behaviour on errors like these + +test pkgMkIndex-9.1 {circular packages} { + runIndex pkg circ1.tcl circ2.tcl circ3.tcl +} {1 {}} + +test pkgMkIndex-9.2 {circular packages - use -nopkgrequire} { + runIndex -nopkgrequire pkg circ1.tcl circ2.tcl circ3.tcl +} {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}}}}} + +# +# cleanup +# + +file delete [file join pkg pkgIndex.tcl] + +foreach p $::procList { + rename $p {} +} + +unset ::procList +unset ::pkgDriverCount |