Artifacts Associated With Ticket 3cff6841c6b8b7af
Ticket change [807dc5cfff] (rid 160001) by arjenmarkus on 2018-01-02 09:21:28:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
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 - foundin initialized to: "2.4.0"
- is_private initialized to: "0"
- login: "arjenmarkus"
- priority initialized to: "5 Medium"
- private_contact initialized to: "b4dd46eb62d921721c0aeef91d8d6e06aaeb6646"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "arjenmarkus"
- subsystem initialized to: "34. tcltest Package"
- title initialized to: "Small bug regarding -body/-returnCodes"
- type initialized to: "Bug"
Ticket change [95d810690d] (rid 160003) by dgp on 2018-01-02 12:56:34:
- icomment:
$ 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. - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [441b3b151c] (rid 160004) by dgp on 2018-01-02 13:02:16:
- assignee changed to: "dgp"
- closedate changed to: "2458121.04324206"
- closer changed to: "dgp"
- icomment:
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.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"