Re: want to redefine tcltest to add database updates




Thanks for the tip - I like it since it seems simple enough... But I
need more help...

In my simple tests to figure it all out, my dilemma is not knowing
whether a test passes or fails from the trace. I know I can easily
extract pre-test data that I need, but since test doesn't return a
code for pass/fail that trace recognizes, I think I'm stuck. It just
seems to print to the screen failures, or passing if verbose is
enabled. Any ideas on how to capture that info?

Here's my sample code:

proc cmdLeave {w x y z} {
puts "Leaving test() call"
puts "w = $w; x = $x; y = $y; z = $z"
}
trace add execution test leave "cmdLeave"

test test-2 {In-body compare} {
set a 2
return [expr $a == 2] ;# set to other number for failure case
} 1


RESULT ==>
Leaving test() call
w = test test-2 {In-body compare instead of relying on -result} {
set a 2
return [expr $a == 2]
} 1; x = 0; y = ; z = leave

As you can see, the result code (x) is 0 for both cases (pass/fail),
and the result(y) is empty for both also.

Thank you,
- David


On Mar 29, 8:49 am, Bryan Oakley <oak...@xxxxxxxxxxxxxxxxxxxx> wrote:
dwechsler wrote:
After recently learning that I can redefine any command, I was
thinking about redefining the test command from tcltest so it can
parse the initial description string and add it to a database. I'd
like it to also somehow look at the results of the tests to get pass/
fail status that I can also add.

If that's all that you want, you might consider simply adding an
execution trace on the test command. The way it works is this: every
time the test command runs, a proc of your choosing will get called. You
can choose for it to run either immediately before or immediately after
the test command runs. You'll be given the whole command line and other
useful bits depending on when your command is run.

http://www.tcl.tk/man/tcl8.4/TclCmd/trace.htm#M9

Arguably, that is a little less fraught with peril than redefining test,
though redefining test is a perfectly fine idea if you want more control.

--
Bryan Oakleyhttp://www.tclscripting.com


.