e05c25c1 |
1 | # Check functionality of dlog command (capturing of stdout) |
2 | |
3 | pload MODELING |
4 | |
5 | # activate logging |
6 | set status [dlog status] |
7 | dlog on |
8 | |
9 | # check that log does not fail at many executions |
10 | # note that this makes sense only if we do not run by test command with |
11 | # dlog already active, in which case puts is redefined |
12 | if { $status == off } { |
13 | for {set i 0} {$i < 10000} {incr i} { box b 1 1 1 } |
14 | dlog off |
15 | puts "Try puts to check that channel is not broken" |
16 | dlog on |
17 | } |
18 | |
19 | # check that logging works as expected |
20 | dlog reset |
21 | box b 1 1 1 |
22 | explode b f |
23 | if { $status == off } { |
24 | # this will get to log if executed using "test" command instead of testgrid, as it redefines puts |
25 | puts "output of puts -- should not be in the log" |
26 | } |
27 | dlog add "output of dlog add" |
28 | set log [dlog get] |
29 | set expected "box b 1 1 1 \nexplode b f \nb_1 b_2 b_3 b_4 b_5 b_6\noutput of dlog add\n" |
30 | if { $log != $expected } { |
31 | puts "Error: Logged text does not match expected" |
32 | puts "Value: \"$log\"" |
33 | puts "Expected: \"$expected\"" |
34 | } |
35 | |
36 | # return original state of logging |
37 | dlog $status |
38 | |
39 | puts "TEST COMPLETED" |