Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-04-18
07:00 • Closed ticket [495660ffff]: restore}State useless/buggy plus 7 other... artifact: e6ded7cfee user: dgp
2002-04-17
06:22 • Ticket [495660ffff]: 4 changes artifact: f93f6d85c8 user: dgp
06:22 • Add attachment ttstate.patch to ticket [495660ffff] artifact: ef9b65c310 user: dgp
06:22 • Ticket [495660ffff] restore}State useless/buggy status still Open wi... artifact: 6c47aa2175 user: dgp
2002-04-16
07:48 • Ticket [495660ffff]: 4 changes artifact: 05a5afcbe7 user: dgp
2002-03-23
06:06 • Ticket [495660ffff]: 1 change artifact: 123c8bb749 user: hobbs
2001-12-20
23:14 • New ticket [495660ffff]. artifact: e89b38472d user: dgp

[{save|restore}State] useless/buggy

Closed / Fixed495660ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-12-20 23:14:32
[saveState] records only the list of procedure
names and variable names in use, but not their
definitions, so there's really no "restore"
capability in [restore].

Also, [restoreState] only examines [info procs]
rather than [info commands], so new commands
are not cleaned up if they are not [proc]s.

Also, the history kept by [saveState] is only
one level deep, so a second call to [saveState]
destroys the saved information from the first call.
The saved state is actually stored in a Tcl list that
could easily manage a stack.

So, the whole deal looks pretty useless to me.

The actual bugs:

1) The documentation for [saveState] and [restoreState]
   suggests they are useful if a test file
   "creates or deletes global variables or procs".
   However, as noted above, there is no real restore
   capability, so these commands can do nothing to help
   out when procs or global variables are deleted.
   Well, [restoreState] could raise an error, but it
   doesn't.

2) The documentation refers to "global variables", but
   these routines operate in the frame of their
   callers, so they operate on global variables only
   if called from level #0.  They should use
   [info globals] instead of [info vars], to operate
   as documented.

With the features of tcltest 2.x, it seems to me
that each test should be managing its own setup and
cleanup with the -setup and -cleanup options anyway.
I'd suggest deprecating [{save|restore}state].
hobbs Ticket [495660ffff]: 1 change [History diff]2002-03-23 06:06:31
dgpplain2002-04-16 07:48:51
Logged In: YES 
user_id=80530

Note that {save|restore}State only pretend to
operate on procs and variables.  These are
also the things stored in namespaces.

It is simpler and more reliable for a test suite
to create and destroy a namespace for the commands
and variables it uses, than to attempt to call on
saveState and restoreState.
dgpplain2002-04-17 06:22:54
Logged In: YES 
user_id=80530

This patch removes documentation of [saveState] and
[restoreState] from tcltest 2.  The commands themselves
can stick around for the sake of compatibility support
for tcltest 1, but removing them from the documentation
effectively deprecates them so that new test suites will
not be encouraged to use these useless and buggy commands.
dgpplain2002-04-17 06:22:55
File Added - 21328: ttstate.patch
dgpplain2002-04-18 07:00:22
Logged In: YES 
user_id=80530

committed to HEAD (8.4a5)
Log in (anonymous is fine) to add a comment.

Attachments: