Fossil SCM

Print time elapsed in the test script.

danield 2026-11-19 14:43 UTC test-suite-new
Commit d0bbd8d6f77e1d565985331f467ed49ec4245534bb7e3c28415f086bab8a24b3
1 file changed +18 -1
+18 -1
--- test/tester.tcl
+++ test/tester.tcl
@@ -28,10 +28,11 @@
2828
2929
# Minimum Tcl is 8.6. auto.def should have found us a suitable Tcl
3030
# installation. Care is needed to keep compatible with both 8.6 and 9.0.
3131
package require Tcl 8.6-
3232
33
+set clock_start [clock milliseconds]
3334
set testfiledir [file normalize [file dirname [info script]]]
3435
set testrundir [pwd]
3536
set testdir [file normalize [file dirname $argv0]]
3637
set fossilexe [file normalize [lindex $argv 0]]
3738
set is_windows [expr {$::tcl_platform(platform) eq "windows"}]
@@ -92,10 +93,24 @@
9293
fconfigure $out -translation platform
9394
puts $out $msg
9495
close $out
9596
}
9697
}
98
+
99
+# print elapsed time
100
+proc printElapsedTime {{prependMsg "Time elapsed: "}} {
101
+ global clock_start
102
+ set clock_end [clock milliseconds]
103
+ set millis [expr {$clock_end - $clock_start}]
104
+ set h [expr {$millis / 3600000}]
105
+ set m [expr {($millis - (3600000 * $h)) / 60000}]
106
+ set s [expr {($millis - (3600000 * $h) - (60000 * $m)) / 1000.0}]
107
+ puts -nonewline $prependMsg
108
+ if {$h>0} {puts -nonewline $h "hours"}
109
+ if {$m>0} {puts -nonewline "$m mins"}
110
+ puts [format "%.3f secs" $s]
111
+}
97112
98113
# write a dict with just enough formatting
99114
# to make it human readable
100115
#
101116
proc protOutDict {dict {pattern *}} {
@@ -722,11 +737,11 @@
722737
protOut "test $name FAILED!" 1
723738
foreach line $detail {
724739
protOut " $line" 1
725740
}
726741
lappend bad_test $name
727
- if {$::HALT} {exit 1}
742
+ if {$::HALT} {printElapsedTime; exit 1}
728743
}
729744
}
730745
}
731746
732747
# Perform a test: test NAME passes if the expression EXPR, evaluated in
@@ -1094,7 +1109,9 @@
10941109
foreach s $skipped_tests {
10951110
protOut "***** [lindex $s 0]: [lindex $s 1]" 1
10961111
}
10971112
}
10981113
if {[llength $bad_test]>0} {
1114
+ printElapsedTime
10991115
exit 1
11001116
}
1117
+printElapsedTime
11011118
--- test/tester.tcl
+++ test/tester.tcl
@@ -28,10 +28,11 @@
28
29 # Minimum Tcl is 8.6. auto.def should have found us a suitable Tcl
30 # installation. Care is needed to keep compatible with both 8.6 and 9.0.
31 package require Tcl 8.6-
32
 
33 set testfiledir [file normalize [file dirname [info script]]]
34 set testrundir [pwd]
35 set testdir [file normalize [file dirname $argv0]]
36 set fossilexe [file normalize [lindex $argv 0]]
37 set is_windows [expr {$::tcl_platform(platform) eq "windows"}]
@@ -92,10 +93,24 @@
92 fconfigure $out -translation platform
93 puts $out $msg
94 close $out
95 }
96 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
98 # write a dict with just enough formatting
99 # to make it human readable
100 #
101 proc protOutDict {dict {pattern *}} {
@@ -722,11 +737,11 @@
722 protOut "test $name FAILED!" 1
723 foreach line $detail {
724 protOut " $line" 1
725 }
726 lappend bad_test $name
727 if {$::HALT} {exit 1}
728 }
729 }
730 }
731
732 # Perform a test: test NAME passes if the expression EXPR, evaluated in
@@ -1094,7 +1109,9 @@
1094 foreach s $skipped_tests {
1095 protOut "***** [lindex $s 0]: [lindex $s 1]" 1
1096 }
1097 }
1098 if {[llength $bad_test]>0} {
 
1099 exit 1
1100 }
 
1101
--- test/tester.tcl
+++ test/tester.tcl
@@ -28,10 +28,11 @@
28
29 # Minimum Tcl is 8.6. auto.def should have found us a suitable Tcl
30 # installation. Care is needed to keep compatible with both 8.6 and 9.0.
31 package require Tcl 8.6-
32
33 set clock_start [clock milliseconds]
34 set testfiledir [file normalize [file dirname [info script]]]
35 set testrundir [pwd]
36 set testdir [file normalize [file dirname $argv0]]
37 set fossilexe [file normalize [lindex $argv 0]]
38 set is_windows [expr {$::tcl_platform(platform) eq "windows"}]
@@ -92,10 +93,24 @@
93 fconfigure $out -translation platform
94 puts $out $msg
95 close $out
96 }
97 }
98
99 # print elapsed time
100 proc printElapsedTime {{prependMsg "Time elapsed: "}} {
101 global clock_start
102 set clock_end [clock milliseconds]
103 set millis [expr {$clock_end - $clock_start}]
104 set h [expr {$millis / 3600000}]
105 set m [expr {($millis - (3600000 * $h)) / 60000}]
106 set s [expr {($millis - (3600000 * $h) - (60000 * $m)) / 1000.0}]
107 puts -nonewline $prependMsg
108 if {$h>0} {puts -nonewline $h "hours"}
109 if {$m>0} {puts -nonewline "$m mins"}
110 puts [format "%.3f secs" $s]
111 }
112
113 # write a dict with just enough formatting
114 # to make it human readable
115 #
116 proc protOutDict {dict {pattern *}} {
@@ -722,11 +737,11 @@
737 protOut "test $name FAILED!" 1
738 foreach line $detail {
739 protOut " $line" 1
740 }
741 lappend bad_test $name
742 if {$::HALT} {printElapsedTime; exit 1}
743 }
744 }
745 }
746
747 # Perform a test: test NAME passes if the expression EXPR, evaluated in
@@ -1094,7 +1109,9 @@
1109 foreach s $skipped_tests {
1110 protOut "***** [lindex $s 0]: [lindex $s 1]" 1
1111 }
1112 }
1113 if {[llength $bad_test]>0} {
1114 printElapsedTime
1115 exit 1
1116 }
1117 printElapsedTime
1118

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button