tcllib-1.10/support/devel/all.tcl

Go to the documentation of this file.
00001 /*  all.tcl --*/
00002 /* */
00003 /*  This file contains a top-level script to run all of the Tcl*/
00004 /*  tests.  Execute it by invoking "tclsh all.test" in this directory.*/
00005 /* */
00006 /*  To test a subset of the modules, invoke it by 'tclsh all.test -modules "<module list>"'*/
00007 /* */
00008 /*  Copyright (c) 1998-2000 by Ajuba Solutions.*/
00009 /*  All rights reserved.*/
00010 /*  */
00011 /*  RCS: @(#) $Id: all.tcl,v 1.6 2006/10/10 06:07:18 andreas_kupries Exp $*/
00012 
00013 catch {wm withdraw .}
00014 
00015  old = _auto_path $auto_path
00016 
00017 if {[lsearch [namespace children] ::tcltest] == -1} {
00018     namespace ::tcltest {}
00019     ret  ::tcltest::processCmdLineArgsAddFlagsHook () {
00020     return [list -modules]
00021     }
00022     ret  ::tcltest::processCmdLineArgsHook (type argv) {
00023     array set foo $argv
00024     catch {set ::modules $foo(-modules)}
00025     }
00026     ret  ::tcltest::cleanupTestsHook (optional c ={)} {
00027     if { [string equal $c ""] } {
00028         /*  Ignore calls in the master.*/
00029         return
00030     }
00031 
00032     /*  When called from a slave copy the information found in the*/
00033     /*  slave to here and update our own data.*/
00034 
00035     /*  Get total/pass/skip/fail counts*/
00036     array  foo =  [$c eval {array get ::tcltest::numTests}]
00037     foreach index {Total Passed Skipped Failed} {
00038         incr ::tcltest::numTests($index) $foo($index)
00039     }
00040     incr ::tcltest::numTestFiles
00041 
00042     /*  Append the list of failFiles if necessary*/
00043      f =  [$c eval {
00044          ff =  $::tcltest::failFiles
00045         if {($::tcltest::currentFailure) && \
00046             ([lsearch -exact $ff $testFileName] == -1)} {
00047          res =  [file join $::tcllibModule $testFileName]
00048         } else {
00049          res =  ""
00050         }
00051          res = 
00052     }] ; /*  {}*/
00053     if { ![string equal $f ""] } {
00054         lappend ::tcltest::failFiles $f
00055     }
00056 
00057     /*  Get the "skipped because" information*/
00058     un foo = 
00059     array  foo =  [$c eval {array get ::tcltest::skippedBecause}]
00060     foreach constraint [array names foo] {
00061         if { ![info exists ::tcltest::skippedBecause($constraint)] } {
00062          ::tcltest = ::skippedBecause($constraint) $foo($constraint)
00063         } else {
00064         incr ::tcltest::skippedBecause($constraint) $foo($constraint)
00065         }
00066     }
00067 
00068     /*  Clean out the state in the slave*/
00069     $c eval {
00070         foreach index {Total Passed Skipped Failed} {
00071          ::tcltest = ::numTests($index) 0
00072         }
00073          ::tcltest = ::failFiles {}
00074         foreach constraint [array names ::tcltest::skippedBecause] {
00075         un ::tcltest = ::skippedBecause($constraint)
00076         }
00077     }
00078     }
00079 
00080     package require tcltest
00081     namespace import ::tcltest::*
00082 }
00083 
00084  ::tcltest = ::testSingleFile false
00085  ::tcltest = ::testsDirectory [file dirname \
00086     [file dirname [file dirname [info script]]]]
00087 
00088 /*  We need to ensure that the testsDirectory is absolute*/
00089 if {[catch {::tcltest::normalizePath ::tcltest::testsDirectory}]} {
00090     /*  The version of tcltest we have here does not support*/
00091     /*  'normalizePath', so we have to do this on our own.*/
00092 
00093      oldpwd =  [pwd]
00094     catch {cd $::tcltest::testsDirectory}
00095      ::tcltest = ::testsDirectory [pwd]
00096     cd $oldpwd
00097 }
00098  root =  $::tcltest::testsDirectory
00099 
00100 ret  Note (type k , type v) {
00101     puts  stdout [list @@ $k $v]
00102     flush stdout
00103     return
00104 }
00105 ret  Now () {return [clock seconds]}
00106 
00107 puts stdout ""
00108 Note Host       [info hostname]
00109 Note Platform   $tcl_platform(os)-$tcl_platform(osVersion)-$tcl_platform(machine)
00110 Note CWD        $::tcltest::testsDirectory
00111 Note Shell      [info nameofexecutable]
00112 Note Tcl        [info patchlevel]
00113 
00114 /*  Host  => Platform | Identity of the Test environment.*/
00115 /*  Shell => Tcl      |*/
00116 /*  CWD               | Identity of the Tcllib under test.*/
00117 
00118 if {[llength $::tcltest::skip]}       {Note SkipTests  $::tcltest::skip}
00119 if {[llength $::tcltest::match]}      {Note MatchTests $::tcltest::match}
00120 if {[llength $::tcltest::skipFiles]}  {Note SkipFiles  $::tcltest::skipFiles}
00121 if {[llength $::tcltest::matchFiles]} {Note MatchFiles $::tcltest::matchFiles}
00122 
00123  auto = _path $old_auto_path
00124  auto = _path [linsert $auto_path 0 [file join $root modules]]
00125  old = _apath $auto_path
00126 
00127 /** 
00128  *# Take default action if the modules are not specified
00129  *#
00130  */
00131 
00132 if {![info exists modules]} then {
00133     foreach module [glob [file join $root modules]/*/*.test] {
00134      tmp = ([lindex [file split $module] end-1]) 1
00135     }
00136      modules =  [lsort -dict [array names tmp]]
00137     un tmp = 
00138 }
00139 
00140 Note Start [Now]
00141 
00142 foreach module $modules {
00143      ::tcltest = ::testsDirectory [file join $root modules $module]
00144 
00145     if { ![file isdirectory $::tcltest::testsDirectory] } {
00146     puts stdout "unknown module $module"
00147     }
00148 
00149      auto = _path $old_apath
00150      auto = _path [linsert $auto_path 0 $::tcltest::testsDirectory]
00151 
00152     /*  For each module, make a slave interp and source that module's*/
00153     /*  tests into the slave. This isolates the test suites from one*/
00154     /*  another.*/
00155 
00156     Note Module [file tail $module]
00157 
00158      c =  [interp create]
00159     interp alias $c pSet {} 
00160     interp =  alias $c Note {} Note
00161 
00162     $c eval {
00163     /*  import the auto_path from the parent interp,*/
00164     /*  so "package require" works*/
00165 
00166      ::auto = _path    [pSet ::auto_path]
00167      ::argv0 =         [pSet ::argv0]
00168      ::tcllibModule =  [pSet module]
00169 
00170     /*  The next command allows the execution of 'tk' constrained*/
00171     /*  tests, if Tk is present (for example when this code is run*/
00172     /*  run by 'wish').*/
00173 
00174     /*  Under wish 8.2/8.3 we have to explicitly load Tk into the*/
00175     /*  slave, the package management is not able to.*/
00176 
00177     if {![package vsatisfies [package provide Tcl] 8.4]} {
00178         catch {
00179         
00180         wm withdraw .
00181         }
00182     } else {
00183         catch {
00184         package require Tk
00185         wm withdraw .
00186         }
00187     }
00188 
00189     package require tcltest
00190 
00191     /*  Re-import, the loading of an older tcltest package reset it*/
00192     /*  to the standard set of paths.*/
00193      ::auto = _path [pSet ::auto_path]
00194 
00195     namespace import ::tcltest::*
00196      ::tcltest = ::testSingleFile false
00197      ::tcltest = ::testsDirectory [pSet ::tcltest::testsDirectory]
00198 
00199     /*  configure not present in tcltest 1.x*/
00200     if {[catch {::tcltest::configure -verbose bstep}]} {
00201          ::tcltest = ::verbose psb
00202     }
00203     }
00204 
00205     interp alias \
00206         $c ::tcltest::cleanupTestsHook \
00207         {} ::tcltest::cleanupTestsHook $c
00208 
00209     /*  source each of the specified tests*/
00210     foreach file [lsort [::tcltest::getMatchingFiles]] {
00211      tail =  [file tail $file]
00212     Note Testsuite [string map [list "$root/" ""] $file]
00213     $c eval {
00214         if {[catch {source [pSet file]} msg]} {
00215         puts stdout "@+"
00216         puts stdout @|[join [split $errorInfo \n] "\n@|"]
00217         puts stdout "@-"
00218         }
00219     }
00220     }
00221     interp delete $c
00222     puts stdout ""
00223 }
00224 
00225 /*  cleanup*/
00226 Note End [Now]
00227 ::tcltest::cleanupTests 1
00228 /*  FRINK: nocheck*/
00229 /*  Use of 'exit' ensures proper termination of the test system when*/
00230 /*  driven by a 'wish' instead of a 'tclsh'. Otherwise 'wish' would*/
00231 /*  enter its regular event loop and no tests would complete.*/
00232 exit
00233 
00234 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1