The Problem After the cd command, the next command is almost always ls so we want to combine the two to automatically issuing the ls command right after the cd command. The Solution In bash, add the following line in either ~/.bash_profile or ~/.bashrc: If you are using csh or tcsh, add the following line […]
April 26, 2011
The Problem We want to organize tests in a hierarchy of directories and execute them in all at once. The Solution We can organize tests in sub directories of arbitrary depths, but in order for tcltest to include a directory, that directory must contain a file named all.tcl. In this example, we only create two […]
April 19, 2011
The Problem We want to test the result of a function, but don’t know the exact values The Solution In case where we only have a vague idea of what the result or output should look like, we can use the test command’s -match option. For example: Explanations: Lines 6-10: this is the same test […]
April 12, 2011
The Problem We want to test functions which might return an error. The Solution tcltest provides a way to test functions which might return an error: the -returnCodes flag. Before we go into details with the -returnCodes, let’s take a look at the behavior when a function returns an error: In line 1, we started […]
April 8, 2011
The Problem Not all functions return a value. Some of them produce output to the standard output (stdout) and we want to test that. The Solution We can capture the stdout for testing using the -output option to the test command. Furthermore, we can also use the -match option to deal with cases when we […]
April 7, 2011
The Problem Given a year and a month, I want to determine the last day of that month. For example, if the year is 2004 and the month is 2, then the last day is 29th because of leap year. The Solution Calculating the last day of a month is not hard, but complicated by […]
April 3, 2011
The Problem I want to be able to put constraints on tests such as: Platform constraints: For example, on the Unix platform, I don’t want to run Windows-specific tests. Known bugs: I want to temporarily disable valid tests that are failing until the developers fix the code. Crashed tests: I want to temporarily disabled tests […]
April 1, 2011
The Problem Sometimes I want to run just a subset of the tests. Some other times, I want to skip some specific tests. The Solution tcltest came with a configure command which customizes many aspects of the test invocation. Among those are the ability to include or exclude based on file names or test names. […]
April 26, 2011
0