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.
-
The draft patch below adds -output and -errorOutput options to jimtcl tcltest.
It uses a custom
puts
command to capture output, but the customputs
is only activated when either-output
or-errorOutput
is specified in a test. For example, to capture stdout from a C/shell program, useputs [exec C-Program/shell-program]
as the-body
script. If an error is expected,exec C-Program
should work (in-body
). Similarly, output or error output (viaputs
) from a tcl script can be tested. Sinceputs
is customized in this patch when-output
or-errorOutput
is specified, this renders tcltest.tcl unable to fully test standardputs
when writing tostdout
orstderr
.It has been tested for the following testfile (and also using
make test
in jimtcl, just to confirm it does not cause problems; itis not really exercised by
make test
in jimtcl currently (because the tests do not check-output
or-errorOutput
AFAIK):When there is an error, it prints the expected and actual values of -output and -errorOutput with
\t
,\r
and\n
indicated 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
,\r
or\n
have to be converted into a tab or carriage return respectively, and any visible\n
characters have to be deleted (but leave the actual newline):).
Patch is:
Beta Was this translation helpful? Give feedback.
All reactions