Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2014-06-23
12:50 • Ticket [2f9df4c4fa] tcltest - request to move -cleanup script execution until af... artifact: 3cb1e21ad0 user: jan.nijtmans
12:40 • Ticket [2f9df4c4fa]: 5 changes artifact: bfc6957273 user: jan.nijtmans
11:55 • Ticket [2f9df4c4fa]: 5 changes artifact: 784e966029 user: dgp
2014-06-22
16:28 • Closed ticket [2f9df4c4fa]. artifact: af6856ecb5 user: jan.nijtmans
16:17
ticket [2f9df4c4fa]: tcltest - request to move -cleanup script execution until after -output compare... check-in: 6c7cb5d46a user: jan.nijtmans tags: trunk
16:15
ticket [2f9df4c4fa]: tcltest - request to move -cleanup script execution until after -output compare... check-in: 1a1cb1c7d7 user: jan.nijtmans tags: core-8-5-branch
01:56 • Ticket [2f9df4c4fa] tcltest - request to move -cleanup script execution until af... artifact: 0a72a31a1a user: anonymous
2014-06-20
20:25 • Ticket [2f9df4c4fa]: 5 changes artifact: 9aac871873 user: jan.nijtmans
20:21
ticket [2f9df4c4fa]: tcltest - request to move -cleanup script execution until after -output compare check-in: a61197b82c user: jan.nijtmans tags: bug-2f9df4c4fa
2014-06-19
03:32 • New ticket [2f9df4c4fa] tcltest - request to move -cleanup script execution unti... artifact: f184ba45e4 user: anonymous

tcltest - request to move -cleanup script execution until after -output compare

Closed / Fixed2f9df4c4faf342320cdc05066ef43bf0f4ca5b59Created 12 years agoUpdated 12 years ago
Descriptionplain2014-06-19 03:32:09
I've been trying to create a customMatch in tcltest that allows me to specify the output results via the -output switch that uses data generated by the -body portion of the test.

So, the -output switch in such a scenario would look something like:

-output {$myVariableDefinedIntheBodySection}

and the customMatch is equally straightforward with:

tcltest::customMatch exactSubst exactSubst
proc exactSubst { expected actual } {
  set expectedSubst "subst {$expected}"
  set expectedSubst [uplevel 1 $expectedSubst]
  return [tcltest::CompareStrings $actual $expectedSubst exact]
}

so, I just make the customMatch perform the required variable substitution in the -output value.

To use it I use -match exactSubst as expected.

All is well *except* in the -cleanup section of test, I naturally unset the variable myVariableDefinedIntheBodySection.  The odd thing is that tclTest::test runs the -cleanup script *before* it performs the -output, -errorOutput comparisons.  This, of course, thwarts my attempt to use the variable in the -output switch.

This example is a little contrived and in my real case I really want to delete the variable so it doesn't pollute the next test which uses the same variable (in a slightly different way).

So, the request is to move the execution of -cleanup until after the output, errorOutput and result comparisons in tcltest::test.  It's a bit odd that it's in its current location in the code so that makes me think that it's intentional.  So I'm curious to know if it can be done safely.

Regardless, love tcltest and been using it for years.  Thank you for your efforts.  :-)

best regards,

Mark
Referenced by3
  • 6c7cb5d46aticket [2f9df4c4fa]: tcltest - request to move -cleanup script execution until after -output compare. tcltest -> version 2.3.8 check-in2014-06-22 16:17:12
  • 1a1cb1c7d7ticket [2f9df4c4fa]: tcltest - request to move -cleanup script execution until after -output compare tcltest -> version 2.3.8 check-in2014-06-22 16:15:43
  • a61197b82cticket [2f9df4c4fa]: tcltest - request to move -cleanup script execution until after -output compare check-in2014-06-20 20:21:50
jan.nijtmanswiki2014-06-20 20:25:28

I think that the -cleanup code should be able to clean up everything, even a custom match function. It appears that no test results are affected, so this should be harmless. Is your suggestion this: [a61197b82c]?.

Thanks!

anonymoushtml2014-06-22 01:56:27

Looks good. I think the ability to build expectedValue output and errorOutput from test body material is a great addition to tcltest's capability. Thank you!

jan.nijtmanswiki2014-06-22 16:28:55

Committed to core-8-5-branch [1a1cb1c7d7] and trunk [6c7cb5d46a]

dgpplain2014-06-23 11:55:41
New test failure on trunk:

execute.test
Test file error: invalid -preservecore value "": expected integer but got ""
    while executing
"Configure -preservecore"
    (procedure "preserveCore" line 5)
    invoked from within
"preserveCore"
    (procedure "test" line 1)
    invoked from within
"test execute-6.5 {TclCompEvalObj: bytecode epoch validation} -body {
    set script { llength {} }
    set result {}
    lappend result [if 1 $script]..."
    (file "/local/tmp/dgp/fossil/tcl-only/tests/execute.test" line 607)
jan.nijtmansplain2014-06-23 12:40:08
Yes, I can reproduce this on trunk, but on on core-8-5-branch. Investigation mode on.....
jan.nijtmansplain2014-06-23 12:50:02
Fixed on core-8-5-branch and trunk now. Thanks!
Log in (anonymous is fine) to add a comment.