diff options
Diffstat (limited to 'tests/pkgMkIndex.test')
-rw-r--r-- | tests/pkgMkIndex.test | 79 |
1 files changed, 30 insertions, 49 deletions
diff --git a/tests/pkgMkIndex.test b/tests/pkgMkIndex.test index e49cf25..daad69b 100644 --- a/tests/pkgMkIndex.test +++ b/tests/pkgMkIndex.test @@ -8,30 +8,19 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: pkgMkIndex.test,v 1.6 1999/04/16 00:47:32 stanton Exp $ +# RCS: @(#) $Id: pkgMkIndex.test,v 1.7 1999/04/19 20:23:41 hershey Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] } -# temporarily copy the pkg and pkg1 dirs from testsDir to tmpDir -if {"$::tcltest::testsDir" != "$::tcltest::workingDir"} { - set origPkgDir [file join $::tcltest::testsDir pkg] - set newPkgDir [file join $::tcltest::workingDir pkg] - if {![catch {file copy $origPkgDir $newPkgDir}]} { - set removePkgDir 1 - } - if {![catch {file copy "${origPkgDir}1" "${newPkgDir}1"}]} { - set removePkg1Dir 1 - } -} +set fullPkgPath [file join $::tcltest::testsDir pkg] # 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 oldDir [pwd] -lappend auto_path [file join $::tcltest::workingDir pkg1] +lappend auto_path [file join $::tcltest::testsDir pkg1] namespace eval pkgtest { # Namespace for procs we can discard @@ -266,29 +255,29 @@ proc pkgtest::runIndex { args } { # changed on us test pkgMkIndex-1.1 {nothing matches pattern - current dir is the same} { - list [pkgtest::runIndex pkg nomatch.tcl] [pwd] + list [pkgtest::runIndex $fullPkgPath nomatch.tcl] [pwd] } [list {1 {no files matched glob pattern "nomatch.tcl"}} [pwd]] -cd $oldDir ;# 'cause 8.0.3 is left in the wrong place + test pkgMkIndex-2.1 {simple package} { - pkgtest::runIndex pkg simple.tcl + pkgtest::runIndex $fullPkgPath simple.tcl } {0 {{simple:1.0 {tclPkgSetup {simple.tcl source {::simple::lower ::simple::upper}}}}}} test pkgMkIndex-2.2 {simple package - use -direct} { - pkgtest::runIndex -direct pkg simple.tcl -} "0 {{simple:1.0 {source [file join pkg simple.tcl]}}}" + pkgtest::runIndex -direct $fullPkgPath simple.tcl +} "0 {{simple:1.0 {source [file join $fullPkgPath simple.tcl]}}}" test pkgMkIndex-3.1 {simple package with global symbols} { - pkgtest::runIndex pkg global.tcl + pkgtest::runIndex $fullPkgPath global.tcl } {0 {{global:1.0 {tclPkgSetup {global.tcl source {global_lower global_upper}}}}}} test pkgMkIndex-4.1 {split package} { - pkgtest::runIndex pkg pkg2_a.tcl pkg2_b.tcl + pkgtest::runIndex $fullPkgPath 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} { - pkgtest::runIndex -direct pkg pkg2_a.tcl pkg2_b.tcl -} "0 {{pkg2:1.0 {source [file join pkg pkg2_a.tcl] -source [file join pkg pkg2_b.tcl]}}}" + pkgtest::runIndex -direct $fullPkgPath pkg2_a.tcl pkg2_b.tcl +} "0 {{pkg2:1.0 {source [file join $fullPkgPath pkg2_a.tcl] +source [file join $fullPkgPath pkg2_b.tcl]}}}" # This will fail, with "direct1" procedures in the list of procedures # provided by std. @@ -297,36 +286,36 @@ source [file join pkg pkg2_b.tcl]}}}" # Both failures are caused by Tcl code executed in pkgIndex.tcl. test pkgMkIndex-5.1 {requires -direct package} { - pkgtest::runIndex pkg std.tcl + pkgtest::runIndex $fullPkgPath std.tcl } {0 {{std:1.0 {tclPkgSetup {std.tcl source {::std::p1 ::std::p2}}}}}} test pkgMkIndex-6.1 {pkg1 requires pkg3} { - pkgtest::runIndex pkg pkg1.tcl pkg3.tcl + pkgtest::runIndex $fullPkgPath 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} { - pkgtest::runIndex -direct pkg pkg1.tcl pkg3.tcl -} "0 {{pkg1:1.0 {source [file join pkg pkg1.tcl]}} {pkg3:1.0 {source [file join pkg pkg3.tcl]}}}" + pkgtest::runIndex -direct $fullPkgPath pkg1.tcl pkg3.tcl +} "0 {{pkg1:1.0 {source [file join $fullPkgPath pkg1.tcl]}} {pkg3:1.0 {source [file join $fullPkgPath pkg3.tcl]}}}" test pkgMkIndex-7.1 {pkg4 uses pkg3} { - pkgtest::runIndex pkg pkg4.tcl pkg3.tcl + pkgtest::runIndex $fullPkgPath 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} { - pkgtest::runIndex -direct pkg pkg4.tcl pkg3.tcl -} "0 {{pkg3:1.0 {source [file join pkg pkg3.tcl]}} {pkg4:1.0 {source [file join pkg pkg4.tcl]}}}" + pkgtest::runIndex -direct $fullPkgPath pkg4.tcl pkg3.tcl +} "0 {{pkg3:1.0 {source [file join $fullPkgPath pkg3.tcl]}} {pkg4:1.0 {source [file join $fullPkgPath pkg4.tcl]}}}" test pkgMkIndex-8.1 {pkg5 uses pkg2} { - pkgtest::runIndex pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl + pkgtest::runIndex $fullPkgPath 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} { - pkgtest::runIndex -direct pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl -} "0 {{pkg2:1.0 {source [file join pkg pkg2_a.tcl] -source [file join pkg pkg2_b.tcl]}} {pkg5:1.0 {source [file join pkg pkg5.tcl]}}}" + pkgtest::runIndex -direct $fullPkgPath pkg5.tcl pkg2_a.tcl pkg2_b.tcl +} "0 {{pkg2:1.0 {source [file join $fullPkgPath pkg2_a.tcl] +source [file join $fullPkgPath pkg2_b.tcl]}} {pkg5:1.0 {source [file join $fullPkgPath pkg5.tcl]}}}" test pkgMkIndex-9.1 {circular packages} { - pkgtest::runIndex pkg circ1.tcl circ2.tcl circ3.tcl + pkgtest::runIndex $fullPkgPath 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}}}}} # Some tests require the existence of one of the DLLs in the dltest directory @@ -336,30 +325,22 @@ set dll "[file tail $x]Required" set ::tcltest::testConfig($dll) [file exists $x] test pkgMkIndex-10.1 {package in DLL and script} $dll { - file copy -force $x pkg - pkgtest::runIndex pkg pkga[info sharedlibextension] pkga.tcl + file copy -force $x $fullPkgPath + pkgtest::runIndex $fullPkgPath pkga[info sharedlibextension] pkga.tcl } "0 {{Pkga:1.0 {tclPkgSetup {pkga[info sharedlibextension] load {pkga_eq pkga_quote}} {pkga.tcl source pkga_neq}}}}" test pkgMkIndex-10.2 {package in DLL hidden by -load} $dll { - pkgtest::runIndex -load Pkg* -- pkg pkga[info sharedlibextension] + pkgtest::runIndex -load Pkg* -- $fullPkgPath pkga[info sharedlibextension] } {0 {}} # Tolerate "namespace import" at the global scope test pkgMkIndex-11.1 {conflicting namespace imports} { - pkgtest::runIndex pkg import.tcl + pkgtest::runIndex $fullPkgPath import.tcl } {0 {{fubar:1.0 {tclPkgSetup {import.tcl source ::fubar::foo}}}}} # cleanup + namespace delete pkgtest -cd $::tcltest::workingDir -if {[info exists removePkgDir]} { - # strange error deleting the pkg dir only once--needs be done twice! - catch {file delete -force $newPkgDir} - catch {file delete -force $newPkgDir} -} -if {[info exists removePkg1Dir]} { - catch {file delete -force "${newPkgDir}1"} -} ::tcltest::cleanupTests return |