Ticket UUID: | 495660 | |||
Title: | [{save|restore}State] useless/buggy | |||
Type: | Bug | Version: | obsolete: 8.4a4 | |
Submitter: | dgp | Created on: | 2001-12-20 23:14:32 | |
Subsystem: | 34. tcltest Package | Assigned To: | dgp | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2002-04-18 07:00:22 | |
Resolution: | Fixed | Closed By: | dgp | |
Closed on: | 2002-04-18 00:00:22 | |||
Description: |
[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]. | |||
User Comments: |
dgp added on 2002-04-18 07:00:22:
Logged In: YES user_id=80530 committed to HEAD (8.4a5) dgp added on 2002-04-17 06:22:55: File Added - 21328: ttstate.patch dgp added on 2002-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. dgp added on 2002-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. |
Attachments:
- ttstate.patch [download] added by dgp on 2002-04-17 06:22:55. [details]