Previous: Compression and Encryption, Up: The ARTE RTA Test Files


5.4 The TCL test script

TCL is a powerful language, at least for the requirements of ARTE. The following examples show the basic functionality of the ARTE Core without needeing any extra Plugin to extend the TCL interpreter's default dictionary.

  1. The following script will just set the title of the Test (to be shown in the results report), print a debug message in the output ARTE log, and make the test fail (with the ARTE-builtin fail command).

              
              #test1.tcl
              
              # Set test title...
              settitle "Dummy test which will always fail"
              
              # Print a debug message...
              debug "And show log..."
              
              # And force the test to fail
              fail "Message shown if failed"
              
    

  2. If a given test doesn't have any managed failure point, it will pass, as the one shown here:

              
              #test2.tcl
              
              # Set test title...
              settitle "Dummy test which will always pass"
              
              # Print a debug message...
              debug "More logs..."
              
    

  3. The following script uses two other ARTE-builtin commands: failifdifferent and failifequal, which compare two given strings.

              
              #test3.tcl
              
              # Set test title...
              settitle "Dummy test which will also fail comparing strings"
              
              # Print a debug message...
              debug "And show another log here..."
              
              # Compare two strings and fail if they are different (they will
              #  be the same here)
              failifdifferent "str" "str" "Message shown if failed"
              
              # Compare two strings and fail if they are equal (they will
              #  be different here)
              failifequal "str" "nostr" "Message shown if failed"
              
              # Compare two strings and fail if they are different (they will
              #  be different here, so this will be the failure point)
              failifdifferent "str" "nostr" "Message shown if failed"
              
    

As the interpreter is a complete TCL interpreter, plus some customized commands, you can use whatever TCL allows you. TCL can treat outputs from commands as strings, and using the built-in failifdifferent or failifequal commands, you can control wether a test correctly passed or not.

Also, when your test has multiple places where it may fail (like ‘test3.tcl’), you can always add an extra last string to the command, which will be included in the reports generated by ARTE, to know the exact failure point.

If, for whatever reason, you need another new magic command to be built in the TCL interpreter of ARTE, you can easily implement it creating a new plugin and exporting the new ‘PLUGIN Dictionary’ (see Exporting the plugin dictionary)