Tk Library Source Code

View Ticket
Login
Ticket UUID: 3066026
Title: testutilities.tcl presumes tcltest loaded
Type: Bug Version: None
Submitter: lars_h Created on: 2010-09-14 15:16:54
Subsystem: Development Tools Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2010-09-16 03:05:07
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2010-09-15 20:05:07
Description:
From the definition and description of [testsNeedTcltest] in testutilities.tcl, it is clear that we want to allow for the case that the tcltest package has not yet been loaded; this procedure has a branch that does the necessary [package require].

However, on line 145 one finds the command

if {![package vsatisfies [package provide tcltest] 2.0]} {

which errors out in that case, since [package provide tcltest] then returns the empty string. 

Thus I get the following, if I try to source just a single .test file:

lars% tclsh
% source modules/math/math.test
expected version number but got ""
% set errorInfo
expected version number but got ""
    while executing
"package vsatisfies [package provide tcltest] 2.0"
    invoked from within
"if {![package vsatisfies [package provide tcltest] 2.0]} {
    # Tcltest 2.0+ provides a documented public API to define and
    # initialize a test c..."
    (file "modules/devtools/testutilities.tcl" line 145)
    invoked from within
"source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]"
    (file "modules/math/math.test" line 14)
    invoked from within
"source modules/math/math.test"
% 

Running tests using sak.tcl only seems to provide module granularity, and e.g. math is a rather large module.
User Comments: andreas_kupries added on 2010-09-16 03:05:07:

allow_comments - 1

Moved the tcltest
compatibility initialization into a procedure (InitializeTcltest)
which is called by testNeedsTcltest and a few other places to be
done only after we are sure that the tcltest package is present.

andreas_kupries added on 2010-09-14 23:49:58:
You can still use the environment variable TCLTEST_OPTIONS to provide additional settings to tcltest ...

TCLTEST_OPTIONS='-file math.test' ./sak.tcl ... might work.

An alternate solution would be to put the block 142-280 into a procedure, and call this procedure in "testNeedsTcltest" after we have established the tcltest package ... Oh, and lines 315-372 as well.