Replies: 3 comments
-
| I actually didn't know about -output! I took a look and it has very little use in the current testsuite. Is it useful enough to add? | 
Beta Was this translation helpful? Give feedback.
-
| Not essential, AFAIK. 
 Of course, it is possible to work around the absence of  | 
Beta Was this translation helpful? Give feedback.
-
| Thanks. I'll hold off adding support for -output for now, but I may come back to it | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The draft patch below adds -output and -errorOutput options to jimtcl tcltest.
It uses a custom
putscommand to capture output, but the customputsis only activated when either-outputor-errorOutputis specified in a test. For example, to capture stdout from a C/shell program, useputs [exec C-Program/shell-program]as the-bodyscript. If an error is expected,exec C-Programshould work (in-body). Similarly, output or error output (viaputs) from a tcl script can be tested. Sinceputsis customized in this patch when-outputor-errorOutputis specified, this renders tcltest.tcl unable to fully test standardputswhen writing tostdoutorstderr.It has been tested for the following testfile (and also using
make testin jimtcl, just to confirm it does not cause problems; itis not really exercised by
make testin jimtcl currently (because the tests do not check-outputor-errorOutputAFAIK):When there is an error, it prints the expected and actual values of -output and -errorOutput with
\t,\rand\nindicated visibly so as to make certain whitespace discrepancies more obvious. This is a potential improvement on the original tcltest suite. The output is also surrounded by braces, again in the interest of making whitespace discrepancies more obvious.It uses a UUID value to signify absence of -output or -errorOutput values, so that a null -output or -errorOutput string can be used to easily capture the actual output.
(For example, to capture the output of test1 below, use an empty -output string for matching, as indicated. Then the actual string can be copied from the tcltest output into -output, although any
\t,\ror\nhave to be converted into a tab or carriage return respectively, and any visible\ncharacters have to be deleted (but leave the actual newline):).
Patch is:
Beta Was this translation helpful? Give feedback.
All reactions