'\" '\" Copyright (c) 1990-1994 The Regents of the University of California '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. '\" Copyright (c) 1998-1999 Scriptics Corporation '\" Copyright (c) 2000 Ajuba Solutions '\" Contributions from Don Porter, NIST, 2002. (not subject to US copyright) '\" '\" 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.21 2002/06/28 19:22:55 dgp Exp $ '\" .so man.macros .TH "tcltest" n 2.1 tcltest "Tcl Bundled Packages" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME tcltest \- Test harness support code and utilities .SH SYNOPSIS .nf \fBpackage require tcltest ?2.1?\fR .sp \fBtcltest::test \fIname description ?option value ...?\fR \fBtcltest::test \fIname description constraints body result\fR \fBtcltest::test \fIname description optionList\fR .sp \fBtcltest::loadTestedCommands\fR \fBtcltest::makeDirectory \fIname ?directory?\fR \fBtcltest::removeDirectory \fIname ?directory?\fR \fBtcltest::makeFile \fIcontents name ?directory?\fR \fBtcltest::removeFile \fIname ?directory?\fR \fBtcltest::viewFile \fIname ?directory?\fR \fBtcltest::cleanupTests \fI?runningMultipleTests?\fR \fBtcltest::runAllTests\fR .sp .VS 2.1 \fBtcltest::configure\fR \fBtcltest::configure \fIoption\fR \fBtcltest::configure \fIoption value ?option value ...?\fR .VE \fBtcltest::testConstraint \fIconstraint ?value?\fR .VS 2.1 \fBtcltest::customMatch \fImode command\fR .VE \fBtcltest::outputChannel \fI?channelID?\fR \fBtcltest::errorChannel \fI?channelID?\fR \fBtcltest::interpreter \fI?interp?\fR .sp \fBtcltest::debug \fI?level?\fR \fBtcltest::errorFile \fI?filename?\fR \fBtcltest::limitConstraints \fI?boolean?\fR \fBtcltest::loadFile \fI?filename?\fR \fBtcltest::loadScript \fI?script?\fR \fBtcltest::match \fI?patternList?\fR \fBtcltest::matchDirectories \fI?patternList?\fR \fBtcltest::matchFiles \fI?patternList?\fR \fBtcltest::outputFile \fI?filename?\fR \fBtcltest::preserveCore \fI?level?\fR \fBtcltest::singleProcess \fI?boolean?\fR \fBtcltest::skip \fI?patternList?\fR \fBtcltest::skipDirectories \fI?patternList?\fR \fBtcltest::skipFiles \fI?patternList?\fR \fBtcltest::temporaryDirectory \fI?directory?\fR \fBtcltest::testsDirectory \fI?directory?\fR \fBtcltest::verbose \fI?level?\fR .sp \fBtcltest::bytestring \fIstring\fR \fBtcltest::normalizeMsg \fImsg\fR \fBtcltest::normalizePath \fIpathVar\fR \fBtcltest::workingDirectory \fI?dir?\fR .fi .BE .SH DESCRIPTION .PP The \fBtcltest\fR package provides several utility commands useful in the construction of test suites for code instrumented to be run by evaluation of Tcl commands. Notably the built-in commands of the Tcl library itself are tested by a test suite using the tcltest package. .PP All the commands provided by the \fBtcltest\fR package are defined in and exported from the \fB::tcltest\fR namespace, as indicated in the \fBSYNOPSIS\fR above. In the following sections, all commands will be described by their simple names, in the interest of brevity. .PP The central command of \fBtcltest\fR is [\fBtest\fR] that defines and runs a test. Testing with [\fBtest\fR] involves evaluation of a Tcl script and comparing the result to an expected result, as configured and controlled by a number of options. Several other commands provided by \fBtcltest\fR govern the configuration of [\fBtest\fR] and the collection of many [\fBtest\fR] commands into test suites. .PP See \fBCREATING TEST SUITES WITH TCLTEST\fR below for an extended example of how to use the commands of \fBtcltest\fR to produce test suites for your Tcl-enabled code. .SH COMMANDS .TP \fBtest\fR \fIname description ?option value ...?\fR Defines and possibly runs a test with the name \fIname\fR and description \fIdescription\fR. The name and description of a test are used in messages reported by [\fBtest\fR] during the test, as configured by the options of \fBtcltest\fR. The remaining \fIoption value\fR arguments to [\fBtest\fR] define the test, including the scripts to run, the conditions under which to run them, the expected result, and the means by which the expected and acutal results should be compared. See \fBTESTS\fR below for a complete description of the valid options and how they define a test. The [\fBtest\fR] command returns an empty string. .TP \fBtest\fR \fIname description constraints body result\fR This form of [\fBtest\fR] is provided to support test suites written for version 1 of the \fBtcltest\fR package, and also a simpler interface for a common usage. It is the same as [\fBtest\fR \fIname description\fB -constraints \fIconstraints\fB -body \fIbody\fB -result \fIresult\fR]. All other options to [\fBtest\fR] take their default values. .TP \fBtest\fR \fIname description optionList\fR This form of [\fBtest\fR] was provided to enable passing many options spanning several lines to [\fBtest\fR] as a single argument quoted by braces, rather than needing to backslash quote the newlines between arguments to [\fBtest\fR]. The \fIoptionList\fR argument is expected to be a list with an even number of elements representing \fIoption\fR and \fIvalue\fR arguments to pass to [\fBtest\fR]. However, these values are not passed directly, as in the alternate forms of [\fBswitch\fR]. Instead, this form makes an unfortunate attempt to overthrow Tcl's substitution rules by performing substitutions on some of these elements as an attempt to implement a "do what I mean" interpretation of a brace-enclosed ``block''. The result is nearly impossible to document clearly, and for that reason this form is not recommended. See \fBTESTS\fR below for better ways to reduce the need to backslash quote newlines when calling [\fBtest\fR]. If you insist on using this form, examine the source code of \fBtcltest\fR if you want to know the substitution details, or just enclose the third through last argument to [\fBtest\fR] in braces and hope for the best. .TP \fBloadTestedCommands\fR Evaluates the script specified by the [\fBconfigure -load\fR] or [\fBconfigure -loadfile\fR] configuration options in the caller's context. Returns the result of that script evaluation, including any error raised by the script. Use this command and the related confiugration options to provide the commands to be tested to the interpreter running the test suite. .TP \fBmakeFile\fR \fIcontents name ?directory?\fR Create a file that will be automatically be removed by [\fBcleanupTests\fR] at the end of a test file. This file is created relative to \fIdirectory\fR. If left unspecified, \fIdirectory\fR defaults to the directory specified by the \fB-tmpdir\fR option to [\fBconfigure\fR]. Returns the full path of the file created. Use this command to create any file required by a test with contents as needed. .TP \fBremoveFile\fR \fIname ?directory?\fR Force the file referenced by \fIname\fR to be removed. This file name should be relative to \fIdirectory\fR. If left unspecified, \fIdirectory\fR defaults to the directory specified by the \fB-tmpdir\fR option to [\fBconfigure\fR]. Returns an empty string. Use this command to delete files created by [\fBmakeFile\fR]. .TP \fBmakeDirectory\fR \fIname ?directory?\fR Create a directory named \fIname\fR that will automatically be removed by [\fBcleanupTests\fR] at the end of a test file. This directory is created relative to the directory specified by the \fB-tmpdir\fR option to [\fBconfigure\fR]. Returns the full path of the directory created. Use this command to create any directories that are required to exist by a test. .TP \fBremoveDirectory\fR \fIname\fR Force the directory referenced by \fIname\fR to be removed. This directory should be relative to \fIdirectory\fR. If left unspecified, \fIdirectory\fR defaults to the directory specified by the \fB-tmpdir\fR option to [\fBconfigure\fR]. Returns an empty string. Use this command to delete any directories created by [\fBmakeDirectory\fR]. .TP \fBviewFile\fR \fIfile ?directory?\fR Returns the contents of \fIfile\fR. This file name should be relative to \fIdirectory\fR. If left unspecified, \fIdirectory\fR defaults to the directory specified by the \fB-tmpdir\fR option to [\fBconfigure\fR]. Use this command as a convenient way to turn the contents of a file generated by a test into the result of that test for matching against an expected result. .TP \fBcleanupTests\fR \fI?calledFromAllFile?\fR This command should be called at the end of a test file. It prints statistics about the tests run and removes files that were created by [\fBmakeDirectory\fR] and [\fBmakeFile\fR]. Names of files and directories created outside of [\fBmakeFile\fR] and [\fBmakeDirectory\fR] and never deleted are printed to [\fBoutputChannel\fR]. This command also restores the original shell environment, as described by the ::env array. \fIcalledFromAllFile\fR should be specified as a true value if [\fBcleanupTests\fR] is called explicitly from an "all.tcl" file. Tcl files are generally used to run multiple tests. The [\fBcleanupTests\fR] command returns an empty string. For more details on how to run multiple tests, please see the section \fI"Running test files"\fR. .TP \fBrunAllTests\fR This command should be used in your 'all.tcl' file. It is used to loop over test files and directories, determining which test files to run and then running them. Note that this test calls [\fBcleanupTests\fR]; if using this proc in your 'all.tcl' file, you should not call [\fBcleanupTests\fR] explicitly in that file. See the sample 'all.tcl' file in the \fI"Examples"\fR section. .SH "CONFIGURATION COMMANDS" .TP \fBconfigure\fR Returns the list of configurable options supported by \fBtcltest\fR. See \fBCONFIGURABLE OPTIONS\fR below for the full list of options, their valid values, and their effect on \fBtcltest\fR operations. .TP \fBconfigure \fIoption\fR Returns the current value of the supported configurable option \fIoption\fR. Raises an error if \fIoption\fR is not a supported configurable option. .TP \fBconfigure \fIoption value ?option value ...?\fR Sets the value of each configurable option \fIoption\fR to the corresponding value \fIvalue\fR, in order. Raises an error if an \fIoption\fR is not a supported configurable option, or if \fIvalue\fR is not a valid value for the corresponding \fIoption\fR, or if a \fIvalue\fR is not provided. When an error is raised, the operation of [\fBconfigure\fR] is halted, and subsequent \fIoption value\fR arguments are not processed. .TP \fBcustomMatch \fImode script\fR Registers \fImode\fR as a new legal value of the \fB-match\fR option to [\fBtest\fR]. When the \fB-match \fImode\fR option is passed to [\fBtest\fR], the script \fIscript\fR will be evaluated to compare the actual result of evaluating the body of the test to the expected result. To perform the match, the \fIscript\fR is completed with two additional words, the expected result, and the actual result, and the completed script is evaluated in the global namespace. The completed script is expected to return a boolean value indicating whether or not the results match. The built-in matching modes of [\fBtest\fR] are \fBexact\fR, \fBglob\fR, and \fBregexp\fR. .TP \fBtestConstraint \fIconstraint ?boolean?\fR Sets or returns the boolean value associated with the named \fIconstraint\fR. See \fBTEST CONSTRAINTS\fR below for more information. .TP \fBinterpreter\fR \fI?executableName?\fR Sets or returns the name of the executable to be [\fBexec\fR]ed by [\fBrunAllTests\fR] to run each test file when [\fBconfigure -singleproc\fR] is false. The default value for [\fBinterpreter\fR] is the name of the currently running program as returned by [\fBinfo nameofexecutable\fR]. .TP \fBoutputChannel\fR \fI?channelID?\fR Sets or returns the output channel ID. This defaults to stdout. Any test that prints test related output should send that output to [\fBoutputChannel\fR] rather than letting that output default to stdout. .TP \fBerrorChannel\fR \fI?channelID?\fR Sets or returns the error channel ID. This defaults to stderr. Any test that prints error messages should send that output to [\fBerrorChannel\fR] rather than printing directly to stderr. .SH "SHORTCUT COMMANDS" .TP \fBdebug \fI?level?\fR Same as [\fBconfigure -debug \fI?level?\fR]. .TP \fBerrorFile \fI?filename?\fR Same as [\fBconfigure -errfile \fI?filename?\fR]. .TP \fBlimitConstraints \fI?boolean?\fR Same as [\fBconfigure -limitconstraints \fI?boolean?\fR]. .TP \fBloadFile \fI?filename?\fR Same as [\fBconfigure -loadfile \fI?filename?\fR]. .TP \fBloadScript \fI?script?\fR Same as [\fBconfigure -load \fI?script?\fR]. .TP \fBmatch \fI?patternList?\fR Same as [\fBconfigure -match \fI?patternList?\fR]. .TP \fBmatchDirectories \fI?patternList?\fR Same as [\fBconfigure -relateddir \fI?patternList?\fR]. .TP \fBmatchFiles \fI?patternList?\fR Same as [\fBconfigure -file \fI?patternList?\fR]. .TP \fBoutputFile \fI?filename?\fR Same as [\fBconfigure -outfile \fI?filename?\fR]. .TP \fBpreserveCore \fI?level?\fR Same as [\fBconfigure -preservecore \fI?level?\fR]. .TP \fBsingleProcess \fI?boolean?\fR Same as [\fBconfigure -singleproc \fI?boolean?\fR]. .TP \fBskip \fI?patternList?\fR Same as [\fBconfigure -skip \fI?patternList?\fR]. .TP \fBskipDirectories \fI?patternList?\fR Same as [\fBconfigure -asidefromdir \fI?patternList?\fR]. .TP \fBskipFiles \fI?patternList?\fR Same as [\fBconfigure -notfile \fI?patternList?\fR]. .TP \fBtemporaryDirectory \fI?directory?\fR Same as [\fBconfigure -tmpdir \fI?directory?\fR]. .TP \fBtestsDirectory \fI?directory?\fR Same as [\fBconfigure -testdir \fI?directory?\fR]. .TP \fBverbose \fI?level?\fR Same as [\fBconfigure -verbose \fI?level?\fR]. .SH "OTHER COMMANDS" .PP The remaining commands provided by \fBtcltest\fR have better alternatives provided by Tcl itself. They are retained to support existing test suites, but should be avoided in new code. .TP \fBworkingDirectory\fR \fI?directoryName?\fR Sets or returns the current working directory when the test suite is running. The default value for workingDirectory is the directory in which the test suite was launched. The Tcl commands [\fBcd\fR] and [\fBpwd\fR] are sufficient replacements. .TP \fBnormalizeMsg\fR \fImsg\fR Returns the result of removing the ``extra'' nelwines from \fImsg\fR, where ``extra'' is rather imprecise. Tcl offers plenty of string processing commands to modify strings as you wish, and [\fBcustomMatch\fR] allows flexible matching of actual and expected results. .TP \fBnormalizePath\fR \fIpathVar\fR Resolves symlinks in a path, thus creating a path without internal redirection. It is assumed that \fIpathVar\fR is absolute. \fIpathVar\fR is modified in place. The Tcl command [\fBfile normalize\fR] is a sufficient replacement. .TP \fBbytestring\fR \fIstring\fR Construct a string that consists of the requested sequence of bytes, as opposed to a string of properly formed UTF-8 characters using the value supplied in \fIstring\fR. This allows the tester to create denormalized or improperly formed strings to pass to C procedures that are supposed to accept strings with embedded NULL types and confirm that a string result has a certain pattern of bytes. This is exactly equivalent to the Tcl command [\fBencoding convertfrom identity\fR]. .SH TESTS The \fBtest\fR procedure runs a test script and prints an error message if the script's result does not match the expected result. Two syntaxes are provided for specifying the attributes of the tests. The first uses a separate argument for each of the attributes and values. The second form places all of the attributes and values together into a single argument; the argument must have proper list structure, with the elements of the list being the attributes and values. The second form makes it easy to construct multi-line scripts, since the braces around the whole list make it unnecessary to include a backslash at the end of each line. In the second form, no command or variable substitutions are performed on the attribute names. This makes the behavior of the second form different from the first form in some cases. .PP The first form for the \fBtest\fR command: .CS test \fIname\fR \fIdescription\fR ?-constraints \fIkeywordList|expression\fR ?-setup \fIsetupScript\fR? ?-body \fItestScript\fR? ?-cleanup \fIcleanupScript\fR? ?-result \fIexpectedAnswer\fR? ?-output \fIexpectedOutput\fR? ?-errorOutput \fIexpectedError\fR? ?-returnCodes \fIcodeList\fR? ?-match \fImode\fR? .CE .PP The second form for the \fBtest\fR command (adds brace grouping): .CS test \fIname\fR \fIdescription\fR { ?-constraints \fIkeywordList|expression\fR ?-setup \fIsetupScript\fR? ?-body \fItestScript\fR? ?-cleanup \fIcleanupScript\fR? ?-result \fIexpectedAnswer\fR? ?-output\fIexpectedOutput\fR? ?-errorOutput \fIexpectedError\fR? ?-returnCodes \fIcodeList\fR? ?-match \fImode\fR? } .CE The \fIname\fR argument should follow the pattern: .CS -. .CE For white-box (regression) tests, the target should be the name of the C function or Tcl procedure being tested. For black-box tests, the target should be the name of the feature being tested. Related tests should share a major number. .PP The \fIdescription\fR should be a short textual description of the test. It is generally used to help humans understand the purpose of the test. The name of a Tcl or C function being tested should be included in the description for regression tests. If the test case exists to reproduce a bug, include the bug ID in the description. .PP Valid attributes and associated values are: .TP \fB-constraints \fIkeywordList|expression\fR The optional \fIconstraints\fR attribute can be list of one or more keywords or an expression. If the \fIconstraints\fR value consists of keywords, each of these keywords being the name of a constraint defined by a call to \fItcltest::testConstraint\fR. If any of these elements is false or does not exist, the test is skipped. If the \fIconstraints\fR argument consists of an expression, that expression is evaluated. If the expression evaluates to true, then the test is run. Appropriate constraints should be added to any tests that should not always be run. See the "Test Constraints" section for a list of built-in constraints and information on how to add your own constraints. .TP \fB-setup \fIscript\fR The optional \fIsetup\fR attribute indicates a script that will be run before the script indicated by the \fIscript\fR attribute. If setup fails, the test will fail. .TP \fB-body \fIscript\fR The \fIbody\fR attribute indicates the script to run to carry out the test. It must return a result that can be checked for correctness. If left unspecified, the script value will be {}. .TP \fB-cleanup \fIscript\fR The optional \fIcleanup\fR attribute indicates a script that will be run after the script indicated by the \fIscript\fR attribute. If cleanup fails, the test will fail. .TP \fB-match \fImode\fR The \fImatch\fR attribute determines how expected answers supplied in \fIresult\fR, \fIoutput\fR, and \fIerrorOutput\fR are compared. Valid options for the value supplied are ``regexp'', ``glob'', ``exact'', and any value registered by a prior call to \fItcltest::customMatch\fR. If \fImatch\fR is not specified, the comparisons will be done in ``exact'' mode by default. .TP \fB-result \fIexpectedValue\fR The \fIresult\fR attribute supplies the comparison value with which the return value from script will be compared. If left unspecified, the default \fIexpectedValue\fR will be the empty list. .TP \fB-output \fIexpectedValue\fR The \fIoutput\fR attribute supplies the comparison value with which any output sent to stdout or tcltest::outputChannel during the script run will be compared. Note that only output printed using puts is used for comparison. If \fIoutput\fR is not specified, output sent to stdout and tcltest::outputChannel is not processed for comparison. .TP \fB-errorOutput \fIexpectedValue\fR The \fIerrorOutput\fR attribute supplies the comparison value with which any output sent to stderr or tcltest::errorChannel during the script run will be compared. Note that only output printed using puts is used for comparison. If \fIerrorOutput\fR is not specified, output sent to stderr and tcltest::errorChannel is not processed for comparison. .TP \fB-returnCodes \fIexpectedCodeList\fR The optional \fIreturnCodes\fR attribute indicates which return codes from the script supplied with the \fIscript\fR attribute are correct. Default values for \fIexpectedCodeList\fR are 0 (normal return) and 2 (return exception). Symbolic values \fInormal\fR (0), \fIerror\fR (1), \fIreturn\fR (2), \fIbreak\fR (3), and \fIcontinue\fR (4) can be used in the \fIexpectedCodeList\fR list. .PP To pass, a test must successfully execute its setup, script, and cleanup code. The return code of the test and its return values must match expected values, and if specified, output and error data from the test must match expected output and error values. If all of these conditions are not met, then the test fails. .SH "TEST CONSTRAINTS" Constraints are used to determine whether or not a test should be skipped. If a test is constrained by ``unixOnly'', then it will only be run if the value of the constraint is true. Several constraints are defined in the \fBtcltest\fR package. To add constraints, you can call \fBtcltest::testConstraint\fR with the appropriate arguments in your own test file. .PP The following is a list of constraints defined in the \fBtcltest\fR package: .TP \fIsingleTestInterp\fR test can only be run if all test files are sourced into a single interpreter .TP \fIunix\fR test can only be run on any UNIX platform .TP \fIwin\fR test can only be run on any Windows platform .TP \fInt\fR test can only be run on any Windows NT platform .TP \fI95\fR test can only be run on any Windows 95 platform .TP \fI98\fR test can only be run on any Windows 98 platform .TP \fImac\fR test can only be run on any Mac platform .TP \fIunixOrWin\fR test can only be run on a UNIX or Windows platform .TP \fImacOrWin\fR test can only be run on a Mac or Windows platform .TP \fImacOrUnix\fR test can only be run on a Mac or UNIX platform .TP \fItempNotWin\fR test can not be run on Windows. This flag is used to temporarily disable a test. .TP \fItempNotMac\fR test can not be run on a Mac. This flag is used to temporarily disable a test. .TP \fIunixCrash\fR test crashes if it's run on UNIX. This flag is used to temporarily disable a test. .TP \fIwinCrash\fR test crashes if it's run on Windows. This flag is used to temporarily disable a test. .TP \fImacCrash\fR test crashes if it's run on a Mac. This flag is used to temporarily disable a test. .TP \fIemptyTest\fR test is empty, and so not worth running, but it remains as a place-holder for a test to be written in the future. This constraint always causes tests to be skipped. .TP \fIknownBug\fR test is known to fail and the bug is not yet fixed. This constraint always causes tests to be skipped unless the user specifies otherwise. See the "Introduction" section for more details. .TP \fInonPortable\fR test can only be run in the master Tcl/Tk development environment. Some tests are inherently non-portable because they depend on things like word length, file system configuration, window manager, etc. These tests are only run in the main Tcl development directory where the configuration is well known. This constraint always causes tests to be skipped unless the user specifies otherwise. .TP \fIuserInteraction\fR test requires interaction from the user. This constraint always causes tests to be skipped unless the user specifies otherwise. .TP \fIinteractive\fR test can only be run in if the interpreter is in interactive mode (when the global tcl_interactive variable is set to 1). .TP \fInonBlockFiles\fR test can only be run if platform supports setting files into nonblocking mode .TP \fIasyncPipeClose\fR test can only be run if platform supports async flush and async close on a pipe .TP \fIunixExecs\fR test can only be run if this machine has Unix-style commands \fBcat\fR, \fBecho\fR, \fBsh\fR, \fBwc\fR, \fBrm\fR, \fBsleep\fR, \fBfgrep\fR, \fBps\fR, \fBchmod\fR, and \fBmkdir\fR available .TP \fIhasIsoLocale\fR test can only be run if can switch to an ISO locale .TP \fIroot\fR test can only run if Unix user is root .TP \fInotRoot\fR test can only run if Unix user is not root .TP \fIeformat\fR test can only run if app has a working version of sprintf with respect to the "e" format of floating-point numbers. .TP \fIstdio\fR test can only be run if the current app can be spawned via a pipe .SH "CONFIGURABLE OPTIONS" .TP \fBsingleProcess\fR \fI?value?\fR Sets or returns a boolean indicating whether test files should be sourced into the current interpreter by runAllTests or run in their own processes. If \fIvalue\fR is true (1), tests are sourced into the current interpreter. If \fIvalue\fR is false (0), tests are run in the interpreter specified in tcltest::interpreter. The default value for tcltest::singleProcess is false. .TP \fBdebug\fR \fI?level?\fR Sets or returns the current debug level. The debug level determines how much tcltest package debugging information is printed to stdout. The default debug level is 0. Levels are defined as: .RS .IP 0 Do not display any debug information. .IP 1 Display information regarding whether a test is skipped because it doesn't match any of the tests that were specified using -match or tcltest::match (userSpecifiedNonMatch) or matches any of the tests specified by -skip or tcltest::skip (userSpecifiedSkip). .IP 2 Display the flag array parsed by the command line processor, the contents of the ::env array, and all user-defined variables that exist in the current namespace as they are used. .IP 3 Display information regarding what individual procs in the test harness are doing. .RE .TP \fBverbose\fR \fI?levelList?\fR Sets or returns the current verbosity level. The default verbosity level is "body". See the "Test output" section for a more detailed explanation of this option. Levels are defined as: .RS .IP body Display the body of failed tests .IP pass Print output when a test passes .IP skip Print output when a test is skipped .IP start Print output whenever a test starts .IP error Print errorInfo and errorCode, if they exist, when a test return code does not match its expected return code .RE .TP \fBtcltest::preserveCore\fR \fI?level?\fR Sets or returns the current core preservation level. This level determines how stringent checks for core files are. The default core preservation level is 0. Levels are defined as: .RS .IP 0 No checking - do not check for core files at the end of each test command, but do check for them whenever tcltest::cleanupTests is called from tcltest::runAllTests. .IP 1 Check for core files at the end of each test command and whenever tcltest::cleanupTests is called from tcltest::runAllTests. .IP 2 Check for core files at the end of all test commands and whenever tcltest::cleanupTests is called from all.tcl. Save any core files produced in tcltest::temporaryDirectory. .RE .TP \fBtcltest::limitConstraints \fI?value?\fR Sets or returns a boolean indicating whether testing is being limited to the list of constraints specified by the \fB-constraints\fR command line option. If \fIvalue\fR is true, only those tests with constraints present in the list specified in the \fB-constraints\fR command line option. .TP \fBtcltest::temporaryDirectory\fR \fI?directoryName?\fR Sets or returns the output directory for temporary files created by tcltest::makeFile and tcltest::makeDirectory. This defaults to the directory returned by \fItcltest::workingDirectory\fR. .TP \fBtcltest::testsDirectory\fR \fI?directoryName?\fR Sets or returns the directory where the tests reside. This defaults to the directory returned by \fItcltest::workingDirectory\fR if the script cannot determine where the \fItests\fR directory is located. This variable should be explicitly set if tests are being run from an all.tcl file. .TP \fBtcltest::match\fR \fI?globPatternList?\fR Sets or returns the glob pattern list that determines which tests should be run. Only tests which match one of the glob patterns in \fIglobPatternList\fR are run by the test harness. The default value for \fIglobPatternList\fR is '*'. .TP \fBtcltest::matchFiles\fR \fI?globPatternList?\fR Sets or returns the glob pattern list that determines which test files should be run. Only test files which match one of the glob patterns in \fIglobPatternList\fR are run by the test harness. The default value for \fIglobPatternList\fR is '*.test'. .TP \fBtcltest::matchDirectories\fR \fI?globPatternList?\fR Sets or returns the glob pattern list that determines which test subdirectories of the current test directory should be run. Only test subdirectories which match one of the glob patterns in \fIglobPatternList\fR are run by the test harness. The default value for \fIglobPatternList\fR is '*'. .TP \fBtcltest::skip\fR \fI?globPatternList?\fR Sets or returns the glob pattern list that determines which tests (of those matched by tcltest::match) should be skipped. The default value for \fIglobPatternList\fR is {}. .TP \fBtcltest::skipFiles\fR \fI?globPatternList?\fR Sets or returns the glob pattern list that determines which test files (of those matched by tcltest::matchFiles) should be skipped. The default value for \fIglobPatternList\fR is {}. .TP \fBtcltest::skipDirectories\fR \fI?globPatternList?\fR Sets or returns the glob pattern list that determines which test subdirectories (of those matched by tcltest::matchDirectories) should be skipped. The default value for \fIglobPatternList\fR is {}. .TP \fBtcltest::loadScript\fR \fI?script?\fR Sets or returns the script executed by \fBloadTestedCommands\fR. .TP \fBtcltest::loadFile\fR \fI?filename?\fR Sets ore returns the file name associated with the script executed \fBloadTestedCommands\fR. If setting \fIfilename\fR, this proc will open the file and call \fItcltest::loadScript\fR with the content. .TP \fBtcltest::outputFile\fR \fI?filename?\fR Sets or returns the file name corresponding to the output file. This defaults to stdout. This proc calls outputChannel to set the output file channel. Any test that prints test related output should send that output to \fItcltest::outputChannel\fR rather than letting that output default to stdout. .TP \fBtcltest::errorFile\fR \fI?filename?\fR Sets or returns the file name corresponding to the error file. This defaults to stderr. This proc calls errorChannel to set the error file channel. Any test that prints test related error output should send that output to \fItcltest::errorChannel\fR or \fItcltest::outputChannel\fR rather than letting that output default to stdout. .SH "CREATING TEST SUITES WITH TCLTEST" .SH "RUNNING TEST FILES" Use the following command to run a test file that uses package tcltest: .CS ?