Fossil SCM

Fix many outdated comments; refactor duplicated code; add new switch -knownBug for the case where the known bug is the fossil return code; Remove dead code and the unused -whatIf parameter

danshearer 2026-11-17 23:54 UTC test-suite-new
Commit 970df5d58b756cbafdbf1f311c45bd2be4f01f265fbe7308d9fb78005969fc04
1 file changed +50 -188
+50 -188
--- test/tester.tcl
+++ test/tester.tcl
@@ -51,56 +51,16 @@
5151
catch {exec $::fossilexe changes --changed} res
5252
set dirty_ckout [string length $res]
5353
5454
set argv [lrange $argv 1 end]
5555
56
-set i [lsearch $argv -keep]
57
-if {$i>=0} {
58
- set KEEP 1
59
- set argv [lreplace $argv $i $i]
60
-} else {
61
- set KEEP 0
62
-}
63
-
64
-set i [lsearch $argv -halt]
65
-if {$i>=0} {
66
- set HALT 1
67
- set argv [lreplace $argv $i $i]
68
-} else {
69
- set HALT 0
70
-}
71
-
72
-set i [lsearch $argv -prot]
73
-if {$i>=0} {
74
- set PROT 1
75
- set argv [lreplace $argv $i $i]
76
-} else {
77
- set PROT 0
78
-}
79
-
80
-set i [lsearch $argv -verbose]
81
-if {$i>=0} {
82
- set VERBOSE 1
83
- set argv [lreplace $argv $i $i]
84
-} else {
85
- set VERBOSE 0
86
-}
87
-
88
-set i [lsearch $argv -quiet]
89
-if {$i>=0} {
90
- set QUIET 1
91
- set argv [lreplace $argv $i $i]
92
-} else {
93
- set QUIET 0
94
-}
95
-
96
-set i [lsearch $argv -strict]
97
-if {$i>=0} {
98
- set STRICT 1
99
- set argv [lreplace $argv $i $i]
100
-} else {
101
- set STRICT 0
56
+foreach option {keep halt prot verbose quiet strict} {
57
+ set i [lsearch -exact $argv -$option]
58
+ set [string toupper $option] [expr {$i >= 0}]
59
+ if {$i >= 0} {
60
+ set argv [lreplace $argv $i $i]
61
+ }
10262
}
10363
10464
if {[llength $argv]==0} {
10565
foreach f [lsort [glob $testdir/*.test]] {
10666
set base [file root [file tail $f]]
@@ -160,11 +120,17 @@
160120
#
161121
# Consults the VERBOSE global variable to determine if
162122
# diagnostics should be emitted when no error is seen.
163123
# Sets the CODE and RESULT global variables for use in
164124
# test expressions, and the LASTCMD global variable to the
165
-# command, for the report of a failed test.
125
+# command, for the report of a failed test. CODE is 0 if the
126
+# command succeeded and did not write anything to standard error,
127
+# and 1 otherwise.
128
+#
129
+# A command that exits with the wrong status gets an ERROR line.
130
+# Where that status is a known bug, -knownBug among the arguments
131
+# limits the ERROR line to -strict runs.
166132
#
167133
proc fossil_maybe_answer {answer args} {
168134
global fossilexe
169135
set cmd $fossilexe
170136
set expectError 0
@@ -177,58 +143,48 @@
177143
set index [lsearch -exact $args -keepNewline]
178144
if {$index != -1} {
179145
set keepNewline 1
180146
set args [lreplace $args $index $index]
181147
}
182
- set whatIf 0
183
- set index [lsearch -exact $args -whatIf]
148
+ set knownBug 0
149
+ set index [lsearch -exact $args -knownBug]
184150
if {$index != -1} {
185
- set whatIf 1
151
+ set knownBug 1
186152
set args [lreplace $args $index $index]
187153
}
188154
foreach a $args {
189155
lappend cmd $a
190156
}
191
- protOut $cmd
157
+ protOut [list fossil {*}$args]
192158
193159
flush stdout
194
- if {$whatIf} {
195
- protOut [pwd]; protOut $answer
196
- set result WHAT-IF-MODE; set rc 42
197
- } else {
198
- if {[string length $answer] > 0} {
199
- protOut $answer
200
- set prompt_file [file join $::tempPath fossil_prompt_answer]
201
- write_file $prompt_file $answer\n
202
- set execCmd [list eval exec]
203
- if {$keepNewline} {lappend execCmd -keepnewline}
204
- lappend execCmd $cmd <$prompt_file
205
- set rc [catch $execCmd result]
206
- file delete $prompt_file
207
- } else {
208
- set execCmd [list eval exec]
209
- if {$keepNewline} {lappend execCmd -keepnewline}
210
- lappend execCmd $cmd
211
- set rc [catch $execCmd result]
212
- }
213
- }
160
+ set execCmd [list eval exec]
161
+ if {$keepNewline} {lappend execCmd -keepnewline}
162
+ lappend execCmd $cmd
163
+ set prompt_file [file join $::tempPath fossil_prompt_answer]
164
+ if {[string length $answer] > 0} {
165
+ protOut $answer
166
+ write_file $prompt_file $answer\n
167
+ lappend execCmd <$prompt_file
168
+ }
169
+ set rc [catch $execCmd result]
170
+ file delete $prompt_file
214171
set ab(str) {child process exited abnormally}
215172
set ab(len) [string length $ab(str)]
216173
set ab(off) [expr {$ab(len) - 1}]
217174
if {$rc && $expectError && \
218175
[string range $result end-$ab(off) end] eq $ab(str)} {
219176
set result [string range $result 0 end-$ab(len)]
220177
}
221178
global RESULT CODE LASTCMD
222
- set LASTCMD $cmd
179
+ set LASTCMD [list fossil {*}$args]
223180
set CODE $rc
224
- if {!$whatIf} {
225
- if {($rc && !$expectError) || (!$rc && $expectError)} {
226
- protOut "ERROR ($rc): $result" 1
227
- } elseif {$::VERBOSE} {
228
- protOut "RESULT ($rc): $result"
229
- }
181
+ set wrongStatus [expr {($rc != 0) != $expectError}]
182
+ if {$wrongStatus && (!$knownBug || $::STRICT)} {
183
+ protOut "ERROR ($rc): $result" 1
184
+ } elseif {$::VERBOSE} {
185
+ protOut "RESULT ($rc): $result"
230186
}
231187
set RESULT $result
232188
}
233189
234190
# Read a file into memory.
@@ -607,12 +563,12 @@
607563
# the tests inline with the rscript commands.
608564
#
609565
# Be sure to adhere to the requirements of run_in_checkout!
610566
proc test_block_in_checkout { name rscript {tscript ""} } {
611567
if {$::outside_fossil_repo || $::dirty_ckout} {
612
- set $::CODE 0
613
- set $::RESULT ""
568
+ set ::CODE 0
569
+ set ::RESULT ""
614570
} else {
615571
uplevel 1 [list run_in_checkout $rscript]
616572
if {[string length $tscript] == 0} {
617573
return ""
618574
} else {
@@ -624,13 +580,12 @@
624580
}
625581
}
626582
627583
# Single-test wrapper for the above.
628584
proc test_in_checkout { name rscript tscript } {
629
- return test_block_in_checkout name rscript {
630
- test $name $tscript
631
- }
585
+ uplevel 1 [list test_block_in_checkout $name $rscript \
586
+ [list test $name $tscript]]
632587
}
633588
634589
# Normalize file status lists (like those returned by 'fossil changes')
635590
# so they can be compared using simple string comparison
636591
#
@@ -691,28 +646,17 @@
691646
}
692647
693648
# Returns a usable temporary directory -OR- fails the testing process.
694649
#
695650
proc getTemporaryPath {} {
696
- #
697
- # NOTE: Build the list of "temporary directory" environment variables
698
- # to check, including all reasonable "cases" of the environment
699
- # variable names.
700
- #
701651
set names [list]
702652
703
- #
704
- # TODO: Add more here, if necessary.
705
- #
706653
foreach name [list FOSSIL_TEST_TEMP FOSSIL_TEMP TMPDIR TEMP TMP] {
707654
lappend names [string toupper $name] [string tolower $name] \
708655
[string totitle $name]
709656
}
710657
711
- #
712
- # NOTE: Check if we can use any of the environment variables.
713
- #
714658
foreach name $names {
715659
set value [getEnvironmentVariable $name]
716660
717661
if {[string length $value] > 0} {
718662
set value [file normalize $value]
@@ -721,87 +665,21 @@
721665
return $value
722666
}
723667
}
724668
}
725669
726
- #
727
- # NOTE: On non-Windows systems, fallback to /tmp if it is usable.
728
- #
729670
if {!$::is_windows} {
730671
set value /tmp
731672
732673
if {[file exists $value] && [file isdirectory $value]} {
733674
return $value
734675
}
735676
}
736677
737
- #
738
- # NOTE: There must be a usable temporary directory to continue testing.
739
- #
740678
error "Cannot find a usable temporary directory, testing halted."
741679
}
742680
743
-# Return the name of the versioned settings file containing the TH1
744
-# setup script.
745
-#
746
-proc getTh1SetupFileName {} {
747
- #
748
- # NOTE: This uses the "testdir" global variable provided by the
749
- # test suite; alternatively, the root of the source tree
750
- # could be obtained directly from Fossil.
751
- #
752
- return [file normalize [file join .fossil-settings th1-setup]]
753
-}
754
-
755
-# Return the saved name of the versioned settings file containing
756
-# the TH1 setup script.
757
-#
758
-proc getSavedTh1SetupFileName {} {
759
- return [appendArgs [getTh1SetupFileName] . [pid]]
760
-}
761
-
762
-# Sets the TH1 setup script to the one provided. Prior to calling
763
-# this, the [saveTh1SetupFile] procedure should be called in order to
764
-# preserve the existing TH1 setup script. Prior to completing the test,
765
-# the [restoreTh1SetupFile] procedure should be called to restore the
766
-# original TH1 setup script.
767
-#
768
-proc writeTh1SetupFile { data } {
769
- set fileName [getTh1SetupFileName]
770
- file mkdir [file dirname $fileName]
771
- return [write_file $fileName $data]
772
-}
773
-
774
-# Saves the TH1 setup script file by renaming it, based on the current
775
-# process ID.
776
-#
777
-proc saveTh1SetupFile {} {
778
- set oldFileName [getTh1SetupFileName]
779
- if {[file exists $oldFileName]} {
780
- set newFileName [getSavedTh1SetupFileName]
781
- catch {file delete $newFileName}
782
- file rename $oldFileName $newFileName
783
- }
784
-}
785
-
786
-# Restores the original TH1 setup script file by renaming it back, based
787
-# on the current process ID.
788
-#
789
-proc restoreTh1SetupFile {} {
790
- set oldFileName [getSavedTh1SetupFileName]
791
- set newFileName [getTh1SetupFileName]
792
- if {[file exists $oldFileName]} {
793
- catch {file delete $newFileName}
794
- file rename $oldFileName $newFileName
795
- } else {
796
- #
797
- # NOTE: There was no TH1 setup script file, delete the test one.
798
- #
799
- file delete $newFileName
800
- }
801
-}
802
-
803681
# Return VALUE as lines for the report of a failed test, after LABEL.
804682
# A value on one line is shown in double quotes. Each line of a value
805683
# on several lines is shown between "|" characters, so that leading and
806684
# trailing white space is visible.
807685
#
@@ -1027,29 +905,21 @@
1027905
error "fossil server did not report its port: $output"
1028906
}
1029907
return [list $pid $port $outFileName]
1030908
}
1031909
1032
-# This procedure stops a Fossil server instance that was previously started
1033
-# by the [test_start_server] procedure. The value of the "stop argument"
1034
-# will vary by platform as will the exact method used to stop the server.
1035
-# The fileName argument is the name of a temporary output file to delete.
910
+# Stops a Fossil server that test_start_server started. On Windows the
911
+# stop argument is the name of a file that must not exist yet; creating
912
+# it makes the server exit. Elsewhere it is the server's process ID.
913
+# FILENAME is a temporary output file to delete.
1036914
proc test_stop_server { stopArg pid fileName } {
1037915
if {$::is_windows} {
1038
- #
1039
- # NOTE: On Windows, the "stop argument" must be the name of a file
1040
- # that does NOT already exist.
1041
- #
1042916
if {[string length $stopArg] > 0 && \
1043917
![file exists $stopArg] && \
1044918
[catch {write_file $stopArg [clock seconds]}] == 0} {
1045919
while {1} {
1046920
if {[catch {
1047
- #
1048
- # NOTE: Using the TaskList utility requires Windows XP or
1049
- # later.
1050
- #
1051921
exec tasklist.exe /FI "PID eq $pid"
1052922
} result] != 0 || ![regexp -- " $pid " $result]} {
1053923
break
1054924
}
1055925
after 1000; # wait a bit...
@@ -1059,22 +929,14 @@
1059929
file delete $fileName
1060930
}
1061931
return true
1062932
}
1063933
} else {
1064
- #
1065
- # NOTE: On Unix, the "stop argument" must be an integer identifier
1066
- # that refers to an existing process.
1067
- #
1068934
if {[regexp {^(?:-)?\d+$} $stopArg] && \
1069935
[catch {exec kill -TERM $stopArg}] == 0} {
1070936
while {1} {
1071937
if {[catch {
1072
- #
1073
- # TODO: Is this portable to all the supported variants of
1074
- # Unix? It should be, it's POSIX.
1075
- #
1076938
exec ps -p $pid
1077939
} result] != 0 || ![regexp -- "(?:^$pid| $pid) " $result]} {
1078940
break
1079941
}
1080942
after 1000; # wait a bit...
@@ -1103,14 +965,12 @@
1103965
fossil http --in $inFileName --out $outFileName --ipaddr 127.0.0.1 \
1104966
$repository --localauth --th-trace -expectError
1105967
1106968
set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}]
1107969
1108
- if {1} {
1109
- catch {file delete $inFileName}
1110
- catch {file delete $outFileName}
1111
- }
970
+ catch {file delete $inFileName}
971
+ catch {file delete $outFileName}
1112972
1113973
return $result
1114974
}
1115975
1116976
# obtains and increments a "sequence number" for this test run.
@@ -1194,10 +1054,11 @@
11941054
please set TEMP variable in environment, error: $error"
11951055
}
11961056
11971057
11981058
protInit $fossilexe
1059
+protOut "***** Testing $fossilexe"
11991060
set ::tempKeepHome 1
12001061
12011062
# Start in tempHomePath to help avoid errors with require_no_open_checkout
12021063
set startPwd [pwd]
12031064
cd $tempHomePath
@@ -1229,15 +1090,16 @@
12291090
protOut "***** Final results: $nErr errors out of $test_count tests" 1
12301091
}
12311092
if {$nErr>0} {
12321093
protOut "***** Considered failures: $bad_test" 1
12331094
}
1234
-set nErr [llength $ignored_test]
1235
-if {$nErr>0 || !$::QUIET} {
1236
- protOut "***** Ignored results: $nErr ignored errors out of $test_count tests" 1
1095
+set nIgnored [llength $ignored_test]
1096
+if {$nIgnored>0 || !$::QUIET} {
1097
+ protOut "***** Ignored results: $nIgnored ignored errors out of\
1098
+ $test_count tests" 1
12371099
}
1238
-if {$nErr>0} {
1100
+if {$nIgnored>0} {
12391101
protOut "***** Ignored failures: $ignored_test" 1
12401102
}
12411103
set nSkipped [llength $skipped_tests]
12421104
if {$nSkipped>0} {
12431105
protOut "***** Skipped tests: [lmap s $skipped_tests {lindex $s 0}]" 1
12441106
--- test/tester.tcl
+++ test/tester.tcl
@@ -51,56 +51,16 @@
51 catch {exec $::fossilexe changes --changed} res
52 set dirty_ckout [string length $res]
53
54 set argv [lrange $argv 1 end]
55
56 set i [lsearch $argv -keep]
57 if {$i>=0} {
58 set KEEP 1
59 set argv [lreplace $argv $i $i]
60 } else {
61 set KEEP 0
62 }
63
64 set i [lsearch $argv -halt]
65 if {$i>=0} {
66 set HALT 1
67 set argv [lreplace $argv $i $i]
68 } else {
69 set HALT 0
70 }
71
72 set i [lsearch $argv -prot]
73 if {$i>=0} {
74 set PROT 1
75 set argv [lreplace $argv $i $i]
76 } else {
77 set PROT 0
78 }
79
80 set i [lsearch $argv -verbose]
81 if {$i>=0} {
82 set VERBOSE 1
83 set argv [lreplace $argv $i $i]
84 } else {
85 set VERBOSE 0
86 }
87
88 set i [lsearch $argv -quiet]
89 if {$i>=0} {
90 set QUIET 1
91 set argv [lreplace $argv $i $i]
92 } else {
93 set QUIET 0
94 }
95
96 set i [lsearch $argv -strict]
97 if {$i>=0} {
98 set STRICT 1
99 set argv [lreplace $argv $i $i]
100 } else {
101 set STRICT 0
102 }
103
104 if {[llength $argv]==0} {
105 foreach f [lsort [glob $testdir/*.test]] {
106 set base [file root [file tail $f]]
@@ -160,11 +120,17 @@
160 #
161 # Consults the VERBOSE global variable to determine if
162 # diagnostics should be emitted when no error is seen.
163 # Sets the CODE and RESULT global variables for use in
164 # test expressions, and the LASTCMD global variable to the
165 # command, for the report of a failed test.
 
 
 
 
 
 
166 #
167 proc fossil_maybe_answer {answer args} {
168 global fossilexe
169 set cmd $fossilexe
170 set expectError 0
@@ -177,58 +143,48 @@
177 set index [lsearch -exact $args -keepNewline]
178 if {$index != -1} {
179 set keepNewline 1
180 set args [lreplace $args $index $index]
181 }
182 set whatIf 0
183 set index [lsearch -exact $args -whatIf]
184 if {$index != -1} {
185 set whatIf 1
186 set args [lreplace $args $index $index]
187 }
188 foreach a $args {
189 lappend cmd $a
190 }
191 protOut $cmd
192
193 flush stdout
194 if {$whatIf} {
195 protOut [pwd]; protOut $answer
196 set result WHAT-IF-MODE; set rc 42
197 } else {
198 if {[string length $answer] > 0} {
199 protOut $answer
200 set prompt_file [file join $::tempPath fossil_prompt_answer]
201 write_file $prompt_file $answer\n
202 set execCmd [list eval exec]
203 if {$keepNewline} {lappend execCmd -keepnewline}
204 lappend execCmd $cmd <$prompt_file
205 set rc [catch $execCmd result]
206 file delete $prompt_file
207 } else {
208 set execCmd [list eval exec]
209 if {$keepNewline} {lappend execCmd -keepnewline}
210 lappend execCmd $cmd
211 set rc [catch $execCmd result]
212 }
213 }
214 set ab(str) {child process exited abnormally}
215 set ab(len) [string length $ab(str)]
216 set ab(off) [expr {$ab(len) - 1}]
217 if {$rc && $expectError && \
218 [string range $result end-$ab(off) end] eq $ab(str)} {
219 set result [string range $result 0 end-$ab(len)]
220 }
221 global RESULT CODE LASTCMD
222 set LASTCMD $cmd
223 set CODE $rc
224 if {!$whatIf} {
225 if {($rc && !$expectError) || (!$rc && $expectError)} {
226 protOut "ERROR ($rc): $result" 1
227 } elseif {$::VERBOSE} {
228 protOut "RESULT ($rc): $result"
229 }
230 }
231 set RESULT $result
232 }
233
234 # Read a file into memory.
@@ -607,12 +563,12 @@
607 # the tests inline with the rscript commands.
608 #
609 # Be sure to adhere to the requirements of run_in_checkout!
610 proc test_block_in_checkout { name rscript {tscript ""} } {
611 if {$::outside_fossil_repo || $::dirty_ckout} {
612 set $::CODE 0
613 set $::RESULT ""
614 } else {
615 uplevel 1 [list run_in_checkout $rscript]
616 if {[string length $tscript] == 0} {
617 return ""
618 } else {
@@ -624,13 +580,12 @@
624 }
625 }
626
627 # Single-test wrapper for the above.
628 proc test_in_checkout { name rscript tscript } {
629 return test_block_in_checkout name rscript {
630 test $name $tscript
631 }
632 }
633
634 # Normalize file status lists (like those returned by 'fossil changes')
635 # so they can be compared using simple string comparison
636 #
@@ -691,28 +646,17 @@
691 }
692
693 # Returns a usable temporary directory -OR- fails the testing process.
694 #
695 proc getTemporaryPath {} {
696 #
697 # NOTE: Build the list of "temporary directory" environment variables
698 # to check, including all reasonable "cases" of the environment
699 # variable names.
700 #
701 set names [list]
702
703 #
704 # TODO: Add more here, if necessary.
705 #
706 foreach name [list FOSSIL_TEST_TEMP FOSSIL_TEMP TMPDIR TEMP TMP] {
707 lappend names [string toupper $name] [string tolower $name] \
708 [string totitle $name]
709 }
710
711 #
712 # NOTE: Check if we can use any of the environment variables.
713 #
714 foreach name $names {
715 set value [getEnvironmentVariable $name]
716
717 if {[string length $value] > 0} {
718 set value [file normalize $value]
@@ -721,87 +665,21 @@
721 return $value
722 }
723 }
724 }
725
726 #
727 # NOTE: On non-Windows systems, fallback to /tmp if it is usable.
728 #
729 if {!$::is_windows} {
730 set value /tmp
731
732 if {[file exists $value] && [file isdirectory $value]} {
733 return $value
734 }
735 }
736
737 #
738 # NOTE: There must be a usable temporary directory to continue testing.
739 #
740 error "Cannot find a usable temporary directory, testing halted."
741 }
742
743 # Return the name of the versioned settings file containing the TH1
744 # setup script.
745 #
746 proc getTh1SetupFileName {} {
747 #
748 # NOTE: This uses the "testdir" global variable provided by the
749 # test suite; alternatively, the root of the source tree
750 # could be obtained directly from Fossil.
751 #
752 return [file normalize [file join .fossil-settings th1-setup]]
753 }
754
755 # Return the saved name of the versioned settings file containing
756 # the TH1 setup script.
757 #
758 proc getSavedTh1SetupFileName {} {
759 return [appendArgs [getTh1SetupFileName] . [pid]]
760 }
761
762 # Sets the TH1 setup script to the one provided. Prior to calling
763 # this, the [saveTh1SetupFile] procedure should be called in order to
764 # preserve the existing TH1 setup script. Prior to completing the test,
765 # the [restoreTh1SetupFile] procedure should be called to restore the
766 # original TH1 setup script.
767 #
768 proc writeTh1SetupFile { data } {
769 set fileName [getTh1SetupFileName]
770 file mkdir [file dirname $fileName]
771 return [write_file $fileName $data]
772 }
773
774 # Saves the TH1 setup script file by renaming it, based on the current
775 # process ID.
776 #
777 proc saveTh1SetupFile {} {
778 set oldFileName [getTh1SetupFileName]
779 if {[file exists $oldFileName]} {
780 set newFileName [getSavedTh1SetupFileName]
781 catch {file delete $newFileName}
782 file rename $oldFileName $newFileName
783 }
784 }
785
786 # Restores the original TH1 setup script file by renaming it back, based
787 # on the current process ID.
788 #
789 proc restoreTh1SetupFile {} {
790 set oldFileName [getSavedTh1SetupFileName]
791 set newFileName [getTh1SetupFileName]
792 if {[file exists $oldFileName]} {
793 catch {file delete $newFileName}
794 file rename $oldFileName $newFileName
795 } else {
796 #
797 # NOTE: There was no TH1 setup script file, delete the test one.
798 #
799 file delete $newFileName
800 }
801 }
802
803 # Return VALUE as lines for the report of a failed test, after LABEL.
804 # A value on one line is shown in double quotes. Each line of a value
805 # on several lines is shown between "|" characters, so that leading and
806 # trailing white space is visible.
807 #
@@ -1027,29 +905,21 @@
1027 error "fossil server did not report its port: $output"
1028 }
1029 return [list $pid $port $outFileName]
1030 }
1031
1032 # This procedure stops a Fossil server instance that was previously started
1033 # by the [test_start_server] procedure. The value of the "stop argument"
1034 # will vary by platform as will the exact method used to stop the server.
1035 # The fileName argument is the name of a temporary output file to delete.
1036 proc test_stop_server { stopArg pid fileName } {
1037 if {$::is_windows} {
1038 #
1039 # NOTE: On Windows, the "stop argument" must be the name of a file
1040 # that does NOT already exist.
1041 #
1042 if {[string length $stopArg] > 0 && \
1043 ![file exists $stopArg] && \
1044 [catch {write_file $stopArg [clock seconds]}] == 0} {
1045 while {1} {
1046 if {[catch {
1047 #
1048 # NOTE: Using the TaskList utility requires Windows XP or
1049 # later.
1050 #
1051 exec tasklist.exe /FI "PID eq $pid"
1052 } result] != 0 || ![regexp -- " $pid " $result]} {
1053 break
1054 }
1055 after 1000; # wait a bit...
@@ -1059,22 +929,14 @@
1059 file delete $fileName
1060 }
1061 return true
1062 }
1063 } else {
1064 #
1065 # NOTE: On Unix, the "stop argument" must be an integer identifier
1066 # that refers to an existing process.
1067 #
1068 if {[regexp {^(?:-)?\d+$} $stopArg] && \
1069 [catch {exec kill -TERM $stopArg}] == 0} {
1070 while {1} {
1071 if {[catch {
1072 #
1073 # TODO: Is this portable to all the supported variants of
1074 # Unix? It should be, it's POSIX.
1075 #
1076 exec ps -p $pid
1077 } result] != 0 || ![regexp -- "(?:^$pid| $pid) " $result]} {
1078 break
1079 }
1080 after 1000; # wait a bit...
@@ -1103,14 +965,12 @@
1103 fossil http --in $inFileName --out $outFileName --ipaddr 127.0.0.1 \
1104 $repository --localauth --th-trace -expectError
1105
1106 set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}]
1107
1108 if {1} {
1109 catch {file delete $inFileName}
1110 catch {file delete $outFileName}
1111 }
1112
1113 return $result
1114 }
1115
1116 # obtains and increments a "sequence number" for this test run.
@@ -1194,10 +1054,11 @@
1194 please set TEMP variable in environment, error: $error"
1195 }
1196
1197
1198 protInit $fossilexe
 
1199 set ::tempKeepHome 1
1200
1201 # Start in tempHomePath to help avoid errors with require_no_open_checkout
1202 set startPwd [pwd]
1203 cd $tempHomePath
@@ -1229,15 +1090,16 @@
1229 protOut "***** Final results: $nErr errors out of $test_count tests" 1
1230 }
1231 if {$nErr>0} {
1232 protOut "***** Considered failures: $bad_test" 1
1233 }
1234 set nErr [llength $ignored_test]
1235 if {$nErr>0 || !$::QUIET} {
1236 protOut "***** Ignored results: $nErr ignored errors out of $test_count tests" 1
 
1237 }
1238 if {$nErr>0} {
1239 protOut "***** Ignored failures: $ignored_test" 1
1240 }
1241 set nSkipped [llength $skipped_tests]
1242 if {$nSkipped>0} {
1243 protOut "***** Skipped tests: [lmap s $skipped_tests {lindex $s 0}]" 1
1244
--- test/tester.tcl
+++ test/tester.tcl
@@ -51,56 +51,16 @@
51 catch {exec $::fossilexe changes --changed} res
52 set dirty_ckout [string length $res]
53
54 set argv [lrange $argv 1 end]
55
56 foreach option {keep halt prot verbose quiet strict} {
57 set i [lsearch -exact $argv -$option]
58 set [string toupper $option] [expr {$i >= 0}]
59 if {$i >= 0} {
60 set argv [lreplace $argv $i $i]
61 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62 }
63
64 if {[llength $argv]==0} {
65 foreach f [lsort [glob $testdir/*.test]] {
66 set base [file root [file tail $f]]
@@ -160,11 +120,17 @@
120 #
121 # Consults the VERBOSE global variable to determine if
122 # diagnostics should be emitted when no error is seen.
123 # Sets the CODE and RESULT global variables for use in
124 # test expressions, and the LASTCMD global variable to the
125 # command, for the report of a failed test. CODE is 0 if the
126 # command succeeded and did not write anything to standard error,
127 # and 1 otherwise.
128 #
129 # A command that exits with the wrong status gets an ERROR line.
130 # Where that status is a known bug, -knownBug among the arguments
131 # limits the ERROR line to -strict runs.
132 #
133 proc fossil_maybe_answer {answer args} {
134 global fossilexe
135 set cmd $fossilexe
136 set expectError 0
@@ -177,58 +143,48 @@
143 set index [lsearch -exact $args -keepNewline]
144 if {$index != -1} {
145 set keepNewline 1
146 set args [lreplace $args $index $index]
147 }
148 set knownBug 0
149 set index [lsearch -exact $args -knownBug]
150 if {$index != -1} {
151 set knownBug 1
152 set args [lreplace $args $index $index]
153 }
154 foreach a $args {
155 lappend cmd $a
156 }
157 protOut [list fossil {*}$args]
158
159 flush stdout
160 set execCmd [list eval exec]
161 if {$keepNewline} {lappend execCmd -keepnewline}
162 lappend execCmd $cmd
163 set prompt_file [file join $::tempPath fossil_prompt_answer]
164 if {[string length $answer] > 0} {
165 protOut $answer
166 write_file $prompt_file $answer\n
167 lappend execCmd <$prompt_file
168 }
169 set rc [catch $execCmd result]
170 file delete $prompt_file
 
 
 
 
 
 
 
 
 
171 set ab(str) {child process exited abnormally}
172 set ab(len) [string length $ab(str)]
173 set ab(off) [expr {$ab(len) - 1}]
174 if {$rc && $expectError && \
175 [string range $result end-$ab(off) end] eq $ab(str)} {
176 set result [string range $result 0 end-$ab(len)]
177 }
178 global RESULT CODE LASTCMD
179 set LASTCMD [list fossil {*}$args]
180 set CODE $rc
181 set wrongStatus [expr {($rc != 0) != $expectError}]
182 if {$wrongStatus && (!$knownBug || $::STRICT)} {
183 protOut "ERROR ($rc): $result" 1
184 } elseif {$::VERBOSE} {
185 protOut "RESULT ($rc): $result"
 
186 }
187 set RESULT $result
188 }
189
190 # Read a file into memory.
@@ -607,12 +563,12 @@
563 # the tests inline with the rscript commands.
564 #
565 # Be sure to adhere to the requirements of run_in_checkout!
566 proc test_block_in_checkout { name rscript {tscript ""} } {
567 if {$::outside_fossil_repo || $::dirty_ckout} {
568 set ::CODE 0
569 set ::RESULT ""
570 } else {
571 uplevel 1 [list run_in_checkout $rscript]
572 if {[string length $tscript] == 0} {
573 return ""
574 } else {
@@ -624,13 +580,12 @@
580 }
581 }
582
583 # Single-test wrapper for the above.
584 proc test_in_checkout { name rscript tscript } {
585 uplevel 1 [list test_block_in_checkout $name $rscript \
586 [list test $name $tscript]]
 
587 }
588
589 # Normalize file status lists (like those returned by 'fossil changes')
590 # so they can be compared using simple string comparison
591 #
@@ -691,28 +646,17 @@
646 }
647
648 # Returns a usable temporary directory -OR- fails the testing process.
649 #
650 proc getTemporaryPath {} {
 
 
 
 
 
651 set names [list]
652
 
 
 
653 foreach name [list FOSSIL_TEST_TEMP FOSSIL_TEMP TMPDIR TEMP TMP] {
654 lappend names [string toupper $name] [string tolower $name] \
655 [string totitle $name]
656 }
657
 
 
 
658 foreach name $names {
659 set value [getEnvironmentVariable $name]
660
661 if {[string length $value] > 0} {
662 set value [file normalize $value]
@@ -721,87 +665,21 @@
665 return $value
666 }
667 }
668 }
669
 
 
 
670 if {!$::is_windows} {
671 set value /tmp
672
673 if {[file exists $value] && [file isdirectory $value]} {
674 return $value
675 }
676 }
677
 
 
 
678 error "Cannot find a usable temporary directory, testing halted."
679 }
680
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681 # Return VALUE as lines for the report of a failed test, after LABEL.
682 # A value on one line is shown in double quotes. Each line of a value
683 # on several lines is shown between "|" characters, so that leading and
684 # trailing white space is visible.
685 #
@@ -1027,29 +905,21 @@
905 error "fossil server did not report its port: $output"
906 }
907 return [list $pid $port $outFileName]
908 }
909
910 # Stops a Fossil server that test_start_server started. On Windows the
911 # stop argument is the name of a file that must not exist yet; creating
912 # it makes the server exit. Elsewhere it is the server's process ID.
913 # FILENAME is a temporary output file to delete.
914 proc test_stop_server { stopArg pid fileName } {
915 if {$::is_windows} {
 
 
 
 
916 if {[string length $stopArg] > 0 && \
917 ![file exists $stopArg] && \
918 [catch {write_file $stopArg [clock seconds]}] == 0} {
919 while {1} {
920 if {[catch {
 
 
 
 
921 exec tasklist.exe /FI "PID eq $pid"
922 } result] != 0 || ![regexp -- " $pid " $result]} {
923 break
924 }
925 after 1000; # wait a bit...
@@ -1059,22 +929,14 @@
929 file delete $fileName
930 }
931 return true
932 }
933 } else {
 
 
 
 
934 if {[regexp {^(?:-)?\d+$} $stopArg] && \
935 [catch {exec kill -TERM $stopArg}] == 0} {
936 while {1} {
937 if {[catch {
 
 
 
 
938 exec ps -p $pid
939 } result] != 0 || ![regexp -- "(?:^$pid| $pid) " $result]} {
940 break
941 }
942 after 1000; # wait a bit...
@@ -1103,14 +965,12 @@
965 fossil http --in $inFileName --out $outFileName --ipaddr 127.0.0.1 \
966 $repository --localauth --th-trace -expectError
967
968 set result [expr {[file exists $outFileName] ? [read_file $outFileName] : ""}]
969
970 catch {file delete $inFileName}
971 catch {file delete $outFileName}
 
 
972
973 return $result
974 }
975
976 # obtains and increments a "sequence number" for this test run.
@@ -1194,10 +1054,11 @@
1054 please set TEMP variable in environment, error: $error"
1055 }
1056
1057
1058 protInit $fossilexe
1059 protOut "***** Testing $fossilexe"
1060 set ::tempKeepHome 1
1061
1062 # Start in tempHomePath to help avoid errors with require_no_open_checkout
1063 set startPwd [pwd]
1064 cd $tempHomePath
@@ -1229,15 +1090,16 @@
1090 protOut "***** Final results: $nErr errors out of $test_count tests" 1
1091 }
1092 if {$nErr>0} {
1093 protOut "***** Considered failures: $bad_test" 1
1094 }
1095 set nIgnored [llength $ignored_test]
1096 if {$nIgnored>0 || !$::QUIET} {
1097 protOut "***** Ignored results: $nIgnored ignored errors out of\
1098 $test_count tests" 1
1099 }
1100 if {$nIgnored>0} {
1101 protOut "***** Ignored failures: $ignored_test" 1
1102 }
1103 set nSkipped [llength $skipped_tests]
1104 if {$nSkipped>0} {
1105 protOut "***** Skipped tests: [lmap s $skipped_tests {lindex $s 0}]" 1
1106

Keyboard Shortcuts

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