From 781eb759e73d151b78669389ed29fa20b45bf6ed Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 18 Jul 2003 21:15:11 +0000 Subject: * doc/tcltest.n: Restored the [Eval] proc to replace * library/tcltest/tcltest.tcl: the [::puts] command when either the -output or -error option for [test] is in use, in order to capture data written to the output or error channels for comparison against what is expected. This is easier to document and agrees better with most user expectations than the previous attempt to replace [puts] only in the caller's namespace. Documentation made more precise on the subject. [Bug 706359] --- ChangeLog | 33 +++++++++++++++++++++------------ doc/tcltest.n | 14 +++++++------- library/tcltest/tcltest.tcl | 22 ++++++---------------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 128d128..c9aeb74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,15 @@ 2003-07-18 Don Porter + * doc/tcltest.n: Restored the [Eval] proc to replace + * library/tcltest/tcltest.tcl: the [::puts] command when either the + -output or -error option for [test] is in use, in order to capture + data written to the output or error channels for comparison against + what is expected. This is easier to document and agrees better with + most user expectations than the previous attempt to replace [puts] + only in the caller's namespace. Documentation made more precise on + the subject. [Bug 706359] + * doc/AddErrInfo.3: Improved consistency of documentation * doc/CrtTrace.3: by using "null" everywhere to refer to * doc/Encoding.3: the character '\0', and using "NULL" @@ -232,13 +241,13 @@ 2003-06-23 Vince Darley * generic/tclFCmd.c: fix to bad error message when trying to - do 'file copy foo ""'. [Bug 756951] - * tests/fCmd.test: added two new tests for the bug. + do 'file copy foo ""'. [Bug 756951] + * tests/fCmd.test: added two new tests for the bug. * win/tclWinFile.c: * win/tclWin32Dll.c: recommitted some filesystem globbing - speed-ups, but disabled some on the older Win 95/98/ME where - they don't seem to work. + speed-ups, but disabled some on the older Win 95/98/ME where + they don't seem to work. * doc/FileSystem.3: documentation fix [Bug 720634] @@ -250,12 +259,12 @@ 2003-06-17 Vince Darley * win/makefile.vc: fixes to check-in below so compilation now - works again on Windows. + works again on Windows. * generic/tclCmdMZ.c: * tests/regexp.test: fixing of bugs related to regexp and regsub - matching of empty strings. Addition of a number of new tests. - [Bug 755335] + matching of empty strings. Addition of a number of new tests. + [Bug 755335] 2003-06-16 Andreas Kupries @@ -314,11 +323,11 @@ 2003-06-02 Vince Darley * win/tclWinFCmd.c: - * tests/fCmd.test: fix to [Bug #747575] in which a bad error - message is given when trying to rename a busy directory to - one with the same prefix, but not the same name. Added three - new tests. - + * tests/fCmd.test: fix to [Bug #747575] in which a bad error + message is given when trying to rename a busy directory to + one with the same prefix, but not the same name. Added three + new tests. + 2003-05-23 D. Richard Hipp * win/tclWinTime.c: Add tests to detect and avoid a division by zero diff --git a/doc/tcltest.n b/doc/tcltest.n index 23740dc..9f18320 100644 --- a/doc/tcltest.n +++ b/doc/tcltest.n @@ -8,7 +8,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: tcltest.n,v 1.40 2003/03/26 23:51:34 dgp Exp $ +'\" RCS: @(#) $Id: tcltest.n,v 1.41 2003/07/18 21:15:13 dgp Exp $ '\" .so man.macros .TH "tcltest" n 2.2 tcltest "Tcl Bundled Packages" @@ -476,7 +476,7 @@ an empty string. The \fB-output\fR attribute supplies the \fIexpectedValue\fR against which any output sent to \fBstdout\fR or [\fBoutputChannel\fR] during evaluation of the script(s) will be compared. Note that only output printed using -[\fBputs\fR] is used for comparison. If \fB-output\fR is not specified, +[\fB::puts\fR] is used for comparison. If \fB-output\fR is not specified, output sent to \fBstdout\fR and [\fBoutputChannel\fR] is not processed for comparison. .TP @@ -484,7 +484,7 @@ comparison. The \fB-errorOutput\fR attribute supplies the \fIexpectedValue\fR against which any output sent to \fBstderr\fR or [\fBerrorChannel\fR] during evaluation of the script(s) will be compared. Note that only output -printed using [\fBputs\fR] is used for comparison. If \fB-errorOutput\fR +printed using [\fB::puts\fR] is used for comparison. If \fB-errorOutput\fR is not specified, output sent to \fBstderr\fR and [\fBerrorChannel\fR] is not processed for comparison. .TP @@ -512,7 +512,7 @@ In default operation, a successful test produces no output. The output messages produced by [\fBtest\fR] are controlled by the [\fBconfigure -verbose\fR] option as described in \fBCONFIGURABLE OPTIONS\fR below. Any output produced by the test scripts themselves should be -produced using [\fBputs\fR] to [\fBoutputChannel\fR] or +produced using [\fB::puts\fR] to [\fBoutputChannel\fR] or [\fBerrorChannel\fR], so that users of the test suite may easily capture output with the [\fBconfigure -outfile\fR] and [\fBconfigure -errfile\fR] options, and so that the \fB-output\fR @@ -1050,13 +1050,13 @@ where 'm', 'n', 'o', and 'p' refer to tests that were run at the same test level as test level-1.1. .PP Implementation of output and error comparison in the test command -depends on usage of puts in your application code. Output is -intercepted by redefining the puts command while the defined test +depends on usage of ::puts in your application code. Output is +intercepted by redefining the ::puts command while the defined test script is being run. Errors thrown by C procedures or printed directly from C applications will not be caught by the test command. Therefore, usage of the \fB-output\fR and \fB-errorOuput\fR options to [\fBtest\fR] is useful only for pure Tcl applications -that use [\fBputs\fR] to produce output. +that use [\fB::puts\fR] to produce output. .SH KEYWORDS test, test harness, test suite diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index ca503a2..1d3a0b8 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -16,7 +16,7 @@ # Contributions from Don Porter, NIST, 2002. (not subject to US copyright) # All rights reserved. # -# RCS: @(#) $Id: tcltest.tcl,v 1.83 2003/07/16 14:31:06 dgp Exp $ +# RCS: @(#) $Id: tcltest.tcl,v 1.84 2003/07/18 21:15:13 dgp Exp $ package require Tcl 8.3 ;# uses [glob -directory] namespace eval tcltest { @@ -1605,26 +1605,16 @@ proc tcltest::Eval {script {ignoreOutput 1}} { if {!$ignoreOutput} { set outData {} set errData {} - set callerHasPuts [llength [uplevel 1 { - ::info commands [::namespace current]::puts - }]] - if {$callerHasPuts} { - uplevel 1 [list ::rename puts [namespace current]::Replace::Puts] - } else { - interp alias {} [namespace current]::Replace::Puts {} ::puts - } - uplevel 1 [list ::namespace import [namespace origin Replace::puts]] + rename ::puts [namespace current]::Replace::Puts + namespace eval :: \ + [list namespace import [namespace origin Replace::puts]] namespace import Replace::puts } set result [uplevel 1 $script] if {!$ignoreOutput} { namespace forget puts - uplevel 1 ::namespace forget puts - if {$callerHasPuts} { - uplevel 1 [list ::rename [namespace current]::Replace::Puts puts] - } else { - interp alias {} [namespace current]::Replace::Puts {} - } + namespace eval :: namespace forget puts + rename [namespace current]::Replace::Puts ::puts } return $result } -- cgit v0.12