Tcl Source Code

View Ticket
Login
Ticket UUID: 2820402
Title: Add command to load tcltest in subinterpreter
Type: Patch Created on: 2009-07-12 15:25:19
Submitter: dkf Assigned to: dgp
Subsystem: 34. tcltest Package Severity: Minor
Priority: 6 Last modified: 2016-08-20 16:47:25
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: None
Description:
It would be really nice if there was a command that loaded tcltest into a child interpreter and set up the links in it so that summary information in the child interp gets reported as part of the overall test run. This would reduce the amount of output produced by Tcl test runs (specifically init.test and pkg.test). I add here some code I've been experimenting with to do this (not as a patch unfortunately, but still...):

proc tcltest::ReportedFromSlave 
interp alias $childInterp tcltest::ReportToMaster {} apply {
    {total passed skipped failed because newfiles}
    {
        variable numTests
        variable skippedBecause
        variable createdNewFiles
        incr numTests(Total)   $total
        incr numTests(Passed)  $passed
        incr numTests(Skipped) $skipped
        incr numTests(Failed)  $failed
        foreach {constraint count} $because {
            incr skippedBecause($constraint) $count
        }
        foreach {testfile created} $newfiles {
            lappend createdNewFiles($testfile) {*}$created
        }
        return
    }
    ::tcltest
}
interp eval $i {
    proc tcltest::cleanupTestsHook {} {
        variable numTests
        variable skippedBecause
        variable createdNewFiles
        variable testSingleFile
        ReportToMaster $numTests(Total) $numTests(Passed) \
            $numTests(Skipped) $numTests(Failed) \
            [array get skippedBecause] [array get createdNewFiles]
        set testSingleFile false
    }
}