|
2018-01-02
| ||
| 13:02 | • Closed ticket [3cff6841c6]: Small bug regarding -body/-returnCodes plus 7 ot... artifact: 441b3b151c user: dgp | |
| 12:56 | • Ticket [3cff6841c6]: 3 changes artifact: 95d810690d user: dgp | |
| 09:21 | • New ticket [3cff6841c6]. artifact: 807dc5cfff user: arjenmarkus | |
Small bug regarding -body/-returnCodes
Closed / Invalid3cff6841c6b8b7af6f3d15dec74b626f557024abCreated 9 years agoUpdated 9 years ago
Descriptionplain2018-01-02 09:21:28
I am trying to use the -returnCodes option to test that a command is returning proper error codes if it is invoked with incorrect arguments. However, if I use -returnCodes, I cannot use -body to indicate the script.
Here is a small script that illustrates the issue:
# chktest.tcl --
# Check a strange phenomenon with tcltest
#
set version [package require tcltest]
puts "Version tcltest: $version"
namespace import ::tcltest::*
test returncode-1.0 "Return an error code" {
return -code 1 "Error"
} -returnCodes 1
test returncode-1.1 "Return an error code" -body {
return -code 1 "Error"
} -returnCodes 1
The first test will succeed, whereas the second does not:
Version tcltest: 2.4.0
==== returncode-1.1 Return an error code FAILED
==== Contents of test case:
return -code 1 "Error"
---- Test generated return exception; Return code was: 2
---- Return code should have been one of: 1
==== returncode-1.1 FAILED
dgpplain2018-01-02 12:56:34
$ tclsh chktest.tcl -verbose bpste
Version tcltest: 2.4.1
++++ returncode-1.0 SKIPPED:
return -code 1 "Error"
---- returncode-1.1 start
==== returncode-1.1 Return an error code FAILED
==== Contents of test case:
return -code 1 "Error"
---- Test generated return exception; Return code was: 2
---- Return code should have been one of: 1
==== returncode-1.1 FAILED
The first test does not pass. It is skipped because
the constraint 'return -code 1 "Error"' is not met.
dgpplain2018-01-02 13:02:16
The second test is behaving properly. The body return -code error "Error" generates the return code 2, TCL_RETURN. You told the test to expect the code 1, TCL_ERROR. The test properly informs you the test body did not behave as it was told to expect.
Log in (anonymous is fine) to add a comment.