Fossil SCM

Modify 'th1' test file to run most of its tests outside of the Fossil source checkout using a new test suite infrastructure procedure.

mistachkin 2016-01-09 19:14 trunk
Commit 7b9b5807f48f9e53b06d800ac488f78d351d3e9d
2 files changed +18 +17 -6
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,10 +21,11 @@
2121
#
2222
# Where ../test/tester.tcl is the name of this file and ../bld/fossil
2323
# is the name of the executable to be tested.
2424
#
2525
26
+set testfiledir [file dirname [info script]]
2627
set testrundir [pwd]
2728
set testdir [file normalize [file dir $argv0]]
2829
set fossilexe [file normalize [lindex $argv 0]]
2930
set argv [lrange $argv 1 end]
3031
@@ -188,10 +189,27 @@
188189
exec $::fossilexe new $filename
189190
exec $::fossilexe open $filename
190191
exec $::fossilexe clean -f
191192
exec $::fossilexe set mtime-changes off
192193
}
194
+
195
+# This (rarely used) procedure is designed to run a test within the Fossil
196
+# source checkout (e.g. one that does NOT modify any state), while saving
197
+# and restoring the current directory (e.g. one used when running a test
198
+# file outside of the Fossil source checkout). Please do NOT use this
199
+# procedure unless you are absolutely sure it does not modify the state of
200
+# the repository or source checkout in any way.
201
+#
202
+proc run_in_checkout { script {dir ""} } {
203
+ if {[string length $dir] == 0} {set dir $::testfiledir}
204
+ set savedPwd [pwd]; cd $dir
205
+ set code [catch {
206
+ uplevel 1 $script
207
+ } result]
208
+ cd $savedPwd; unset savedPwd
209
+ return -code $code $result
210
+}
193211
194212
# Normalize file status lists (like those returned by 'fossil changes')
195213
# so they can be compared using simple string comparison
196214
#
197215
proc normalize_status_list {list} {
198216
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,10 +21,11 @@
21 #
22 # Where ../test/tester.tcl is the name of this file and ../bld/fossil
23 # is the name of the executable to be tested.
24 #
25
 
26 set testrundir [pwd]
27 set testdir [file normalize [file dir $argv0]]
28 set fossilexe [file normalize [lindex $argv 0]]
29 set argv [lrange $argv 1 end]
30
@@ -188,10 +189,27 @@
188 exec $::fossilexe new $filename
189 exec $::fossilexe open $filename
190 exec $::fossilexe clean -f
191 exec $::fossilexe set mtime-changes off
192 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
194 # Normalize file status lists (like those returned by 'fossil changes')
195 # so they can be compared using simple string comparison
196 #
197 proc normalize_status_list {list} {
198
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,10 +21,11 @@
21 #
22 # Where ../test/tester.tcl is the name of this file and ../bld/fossil
23 # is the name of the executable to be tested.
24 #
25
26 set testfiledir [file dirname [info script]]
27 set testrundir [pwd]
28 set testdir [file normalize [file dir $argv0]]
29 set fossilexe [file normalize [lindex $argv 0]]
30 set argv [lrange $argv 1 end]
31
@@ -188,10 +189,27 @@
189 exec $::fossilexe new $filename
190 exec $::fossilexe open $filename
191 exec $::fossilexe clean -f
192 exec $::fossilexe set mtime-changes off
193 }
194
195 # This (rarely used) procedure is designed to run a test within the Fossil
196 # source checkout (e.g. one that does NOT modify any state), while saving
197 # and restoring the current directory (e.g. one used when running a test
198 # file outside of the Fossil source checkout). Please do NOT use this
199 # procedure unless you are absolutely sure it does not modify the state of
200 # the repository or source checkout in any way.
201 #
202 proc run_in_checkout { script {dir ""} } {
203 if {[string length $dir] == 0} {set dir $::testfiledir}
204 set savedPwd [pwd]; cd $dir
205 set code [catch {
206 uplevel 1 $script
207 } result]
208 cd $savedPwd; unset savedPwd
209 return -code $code $result
210 }
211
212 # Normalize file status lists (like those returned by 'fossil changes')
213 # so they can be compared using simple string comparison
214 #
215 proc normalize_status_list {list} {
216
+17 -6
--- test/th1.test
+++ test/th1.test
@@ -16,11 +16,11 @@
1616
############################################################################
1717
#
1818
# TH1 Commands
1919
#
2020
21
-set dir [file dirname [info script]]
21
+set dir [file dirname [info script]]; repo_init
2222
2323
###############################################################################
2424
2525
fossil test-th-eval --open-config "setting th1-hooks"
2626
set th1Hooks [expr {$RESULT eq "1"}]
@@ -639,11 +639,14 @@
639639
fossil test-th-eval "styleHeader {Page Title Here}"
640640
test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
641641
642642
###############################################################################
643643
644
-fossil test-th-eval --open-config "styleHeader {Page Title Here}"
644
+run_in_checkout {
645
+ fossil test-th-eval --open-config "styleHeader {Page Title Here}"
646
+}
647
+
645648
test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]}
646649
647650
###############################################################################
648651
649652
fossil test-th-eval "styleFooter"
@@ -722,11 +725,14 @@
722725
fossil test-th-eval "artifact tip"
723726
test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}}
724727
725728
###############################################################################
726729
727
-fossil test-th-eval --open-config "artifact tip"
730
+run_in_checkout {
731
+ fossil test-th-eval --open-config "artifact tip"
732
+}
733
+
728734
test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]}
729735
730736
###############################################################################
731737
732738
fossil test-th-eval "artifact 0000000000"
@@ -742,11 +748,14 @@
742748
fossil test-th-eval "artifact tip test/th1.test"
743749
test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}}
744750
745751
###############################################################################
746752
747
-fossil test-th-eval --open-config "artifact tip test/th1.test"
753
+run_in_checkout {
754
+ fossil test-th-eval --open-config "artifact tip test/th1.test"
755
+}
756
+
748757
test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]}
749758
750759
###############################################################################
751760
752761
fossil test-th-eval "artifact 0000000000 test/th1.test"
@@ -1260,10 +1269,12 @@
12601269
12611270
#
12621271
# TODO: Modify the result of this test if the source file (i.e.
12631272
# "ajax/cgi-bin/fossil-json.cgi.example") changes.
12641273
#
1265
-fossil test-th-eval --open-config \
1266
- {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]}
1274
+run_in_checkout {
1275
+ fossil test-th-eval --open-config \
1276
+ {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]}
1277
+}
12671278
12681279
test th1-encode64-3 {$RESULT eq \
12691280
"IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="}
12701281
--- test/th1.test
+++ test/th1.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # TH1 Commands
19 #
20
21 set dir [file dirname [info script]]
22
23 ###############################################################################
24
25 fossil test-th-eval --open-config "setting th1-hooks"
26 set th1Hooks [expr {$RESULT eq "1"}]
@@ -639,11 +639,14 @@
639 fossil test-th-eval "styleHeader {Page Title Here}"
640 test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
641
642 ###############################################################################
643
644 fossil test-th-eval --open-config "styleHeader {Page Title Here}"
 
 
 
645 test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]}
646
647 ###############################################################################
648
649 fossil test-th-eval "styleFooter"
@@ -722,11 +725,14 @@
722 fossil test-th-eval "artifact tip"
723 test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}}
724
725 ###############################################################################
726
727 fossil test-th-eval --open-config "artifact tip"
 
 
 
728 test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]}
729
730 ###############################################################################
731
732 fossil test-th-eval "artifact 0000000000"
@@ -742,11 +748,14 @@
742 fossil test-th-eval "artifact tip test/th1.test"
743 test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}}
744
745 ###############################################################################
746
747 fossil test-th-eval --open-config "artifact tip test/th1.test"
 
 
 
748 test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]}
749
750 ###############################################################################
751
752 fossil test-th-eval "artifact 0000000000 test/th1.test"
@@ -1260,10 +1269,12 @@
1260
1261 #
1262 # TODO: Modify the result of this test if the source file (i.e.
1263 # "ajax/cgi-bin/fossil-json.cgi.example") changes.
1264 #
1265 fossil test-th-eval --open-config \
1266 {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]}
 
 
1267
1268 test th1-encode64-3 {$RESULT eq \
1269 "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="}
1270
--- test/th1.test
+++ test/th1.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # TH1 Commands
19 #
20
21 set dir [file dirname [info script]]; repo_init
22
23 ###############################################################################
24
25 fossil test-th-eval --open-config "setting th1-hooks"
26 set th1Hooks [expr {$RESULT eq "1"}]
@@ -639,11 +639,14 @@
639 fossil test-th-eval "styleHeader {Page Title Here}"
640 test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
641
642 ###############################################################################
643
644 run_in_checkout {
645 fossil test-th-eval --open-config "styleHeader {Page Title Here}"
646 }
647
648 test th1-header-2 {[regexp -- {<title>Fossil: Page Title Here</title>} $RESULT]}
649
650 ###############################################################################
651
652 fossil test-th-eval "styleFooter"
@@ -722,11 +725,14 @@
725 fossil test-th-eval "artifact tip"
726 test th1-artifact-2 {$RESULT eq {TH_ERROR: repository unavailable}}
727
728 ###############################################################################
729
730 run_in_checkout {
731 fossil test-th-eval --open-config "artifact tip"
732 }
733
734 test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40}} $RESULT]}
735
736 ###############################################################################
737
738 fossil test-th-eval "artifact 0000000000"
@@ -742,11 +748,14 @@
748 fossil test-th-eval "artifact tip test/th1.test"
749 test th1-artifact-6 {$RESULT eq {TH_ERROR: repository unavailable}}
750
751 ###############################################################################
752
753 run_in_checkout {
754 fossil test-th-eval --open-config "artifact tip test/th1.test"
755 }
756
757 test th1-artifact-7 {[regexp -- {th1-artifact-7} $RESULT]}
758
759 ###############################################################################
760
761 fossil test-th-eval "artifact 0000000000 test/th1.test"
@@ -1260,10 +1269,12 @@
1269
1270 #
1271 # TODO: Modify the result of this test if the source file (i.e.
1272 # "ajax/cgi-bin/fossil-json.cgi.example") changes.
1273 #
1274 run_in_checkout {
1275 fossil test-th-eval --open-config \
1276 {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]}
1277 }
1278
1279 test th1-encode64-3 {$RESULT eq \
1280 "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="}
1281

Keyboard Shortcuts

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