1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
# all.tcl --
#
# This file contains a top-level script to run all of the Tcl
# tests. Execute it by invoking "tclsh all.test" in this directory.
#
# To test a subset of the modules, invoke it by 'tclsh all.test -modules "<module list>"'
#
# Copyright (c) 1998-2000 by Ajuba Solutions.
# All rights reserved.
#
# RCS: @(#) $Id: all.tcl,v 1.7 2009/12/08 21:00:51 andreas_kupries Exp $
catch {wm withdraw .}
set old_auto_path $auto_path
if {[lsearch [namespace children] ::tcltest] == -1} {
namespace eval ::tcltest {}
proc ::tcltest::processCmdLineArgsAddFlagsHook {} {
return [list -modules]
}
proc ::tcltest::processCmdLineArgsHook {argv} {
array set foo $argv
catch {set ::modules $foo(-modules)}
}
proc ::tcltest::cleanupTestsHook {{c {}}} {
if { [string equal $c ""] } {
# Ignore calls in the master.
return
}
# When called from a slave copy the information found in the
# slave to here and update our own data.
# Get total/pass/skip/fail counts
array set foo [$c eval {array get ::tcltest::numTests}]
foreach index {Total Passed Skipped Failed} {
incr ::tcltest::numTests($index) $foo($index)
}
incr ::tcltest::numTestFiles
# Append the list of failFiles if necessary
set f [$c eval {
set ff $::tcltest::failFiles
if {($::tcltest::currentFailure) && \
([lsearch -exact $ff $testFileName] == -1)} {
set res [file join $::tcllibModule $testFileName]
} else {
set res ""
}
set res
}] ; # {}
if { ![string equal $f ""] } {
lappend ::tcltest::failFiles $f
}
# Get the "skipped because" information
unset foo
array set foo [$c eval {array get ::tcltest::skippedBecause}]
foreach constraint [array names foo] {
if { ![info exists ::tcltest::skippedBecause($constraint)] } {
set ::tcltest::skippedBecause($constraint) $foo($constraint)
} else {
incr ::tcltest::skippedBecause($constraint) $foo($constraint)
}
}
# Clean out the state in the slave
$c eval {
foreach index {Total Passed Skipped Failed} {
set ::tcltest::numTests($index) 0
}
set ::tcltest::failFiles {}
foreach constraint [array names ::tcltest::skippedBecause] {
unset ::tcltest::skippedBecause($constraint)
}
}
}
package require tcltest
namespace import ::tcltest::*
}
set ::tcltest::testSingleFile false
set ::tcltest::testsDirectory [file dirname \
[file dirname [file dirname [info script]]]]
# We need to ensure that the testsDirectory is absolute
if {[catch {::tcltest::normalizePath ::tcltest::testsDirectory}]} {
# The version of tcltest we have here does not support
# 'normalizePath', so we have to do this on our own.
set oldpwd [pwd]
catch {cd $::tcltest::testsDirectory}
set ::tcltest::testsDirectory [pwd]
cd $oldpwd
}
set root $::tcltest::testsDirectory
proc Note {k v} {
puts stdout [list @@ $k $v]
flush stdout
return
}
proc Now {} {return [clock seconds]}
puts stdout ""
Note Host [info hostname]
Note Platform $tcl_platform(os)-$tcl_platform(osVersion)-$tcl_platform(machine)
Note CWD $::tcltest::testsDirectory
Note Shell [info nameofexecutable]
Note Tcl [info patchlevel]
# Host => Platform | Identity of the Test environment.
# Shell => Tcl |
# CWD | Identity of the Tcllib under test.
if {[llength $::tcltest::skip]} {Note SkipTests $::tcltest::skip}
if {[llength $::tcltest::match]} {Note MatchTests $::tcltest::match}
if {[llength $::tcltest::skipFiles]} {Note SkipFiles $::tcltest::skipFiles}
if {[llength $::tcltest::matchFiles]} {Note MatchFiles $::tcltest::matchFiles}
set auto_path $old_auto_path
set auto_path [linsert $auto_path 0 [file join $root modules]]
set old_apath $auto_path
##
## Take default action if the modules are not specified
##
if {![info exists modules]} then {
foreach module [glob [file join $root modules]/*/*.test] {
set tmp([lindex [file split $module] end-1]) 1
}
set modules [lsort -dict [array names tmp]]
unset tmp
}
Note Start [Now]
foreach module $modules {
set ::tcltest::testsDirectory [file join $root modules $module]
if { ![file isdirectory $::tcltest::testsDirectory] } {
puts stdout "unknown module $module"
}
set auto_path $old_apath
set auto_path [linsert $auto_path 0 $::tcltest::testsDirectory]
# For each module, make a slave interp and source that module's
# tests into the slave. This isolates the test suites from one
# another.
Note Module [file tail $module]
set c [interp create]
interp alias $c pSet {} set
interp alias $c Note {} Note
$c eval {
# import the auto_path from the parent interp,
# so "package require" works
set ::auto_path [pSet ::auto_path]
set ::argv0 [pSet ::argv0]
set ::tcllibModule [pSet module]
# The next command allows the execution of 'tk' constrained
# tests, if Tk is present (for example when this code is run
# run by 'wish').
# Under wish 8.2/8.3 we have to explicitly load Tk into the
# slave, the package management is not able to.
if {![package vsatisfies [package provide Tcl] 8.4]} {
catch {
load {} Tk
wm withdraw .
}
} else {
catch {
package require Tk
wm withdraw .
}
}
package require tcltest
# Re-import, the loading of an older tcltest package reset it
# to the standard set of paths.
set ::auto_path [pSet ::auto_path]
namespace import ::tcltest::*
set ::tcltest::testSingleFile false
set ::tcltest::testsDirectory [pSet ::tcltest::testsDirectory]
# configure not present in tcltest 1.x
if {[catch {::tcltest::configure -verbose {
body skip start error pass usec line
}}]} {
# ^ body skip start error pass usec line
set ::tcltest::verbose psb ;# pass skip body
}
}
interp alias \
$c ::tcltest::cleanupTestsHook \
{} ::tcltest::cleanupTestsHook $c
# source each of the specified tests
foreach file [lsort [::tcltest::getMatchingFiles]] {
set tail [file tail $file]
Note Testsuite [string map [list "$root/" ""] $file]
Note StartFile [Now]
$c eval {
if {[catch {source [pSet file]} msg]} {
puts stdout "@+"
puts stdout @|[join [split $errorInfo \n] "\n@|"]
puts stdout "@-"
}
}
Note EndFile [Now]
}
interp delete $c
puts stdout ""
}
# cleanup
Note End [Now]
::tcltest::cleanupTests 1
# FRINK: nocheck
# Use of 'exit' ensures proper termination of the test system when
# driven by a 'wish' instead of a 'tclsh'. Otherwise 'wish' would
# enter its regular event loop and no tests would complete.
exit
|