Skip to content
Tcl Source Code History Of Ticket 3cff6841c6b8b7af
Login

History Of Ticket 3cff6841c6b8b7af

Artifacts Associated With Ticket 3cff6841c6b8b7af

  1. Ticket change [807dc5cfff] (rid 160001) by arjenmarkus on 2018-01-02 09:21:28:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. 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
      
    5. foundin initialized to: "2.4.0"
    6. is_private initialized to: "0"
    7. login: "arjenmarkus"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "b4dd46eb62d921721c0aeef91d8d6e06aaeb6646"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "arjenmarkus"
    14. subsystem initialized to: "34. tcltest Package"
    15. title initialized to: "Small bug regarding -body/-returnCodes"
    16. type initialized to: "Bug"
  2. Ticket change [95d810690d] (rid 160003) by dgp on 2018-01-02 12:56:34:

    1. 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.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  3. Ticket change [441b3b151c] (rid 160004) by dgp on 2018-01-02 13:02:16:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2458121.04324206"
    3. closer changed to: "dgp"
    4. 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.
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Invalid"
    8. status changed to: "Closed"