Fossil SCM

Centralize early-return handling from the tests, always calling the test cleanup (which is harmless if not needed).

mistachkin 2016-03-03 18:49 testerCleanup
Commit b01a51f43ae0e9f4890ec78fae6c5384a55b4091
+2 -4
--- test/amend.test
+++ test/amend.test
@@ -55,20 +55,18 @@
5555
# Setup: Add file and commit #
5656
########################################
5757
5858
if {![uuid_from_checkout UUIDINIT]} {
5959
test amend-checkout-failure false
60
- test_cleanup
61
- return
60
+ test_cleanup_then_return
6261
}
6362
write_file datafile "data"
6463
fossil add datafile
6564
fossil commit -m "c1"
6665
if {![uuid_from_commit $RESULT UUID]} {
6766
test amend-setup-failure false
68
- test_cleanup
69
- return
67
+ test_cleanup_then_return
7068
}
7169
7270
########################################
7371
# Test: -branch #
7472
########################################
7573
--- test/amend.test
+++ test/amend.test
@@ -55,20 +55,18 @@
55 # Setup: Add file and commit #
56 ########################################
57
58 if {![uuid_from_checkout UUIDINIT]} {
59 test amend-checkout-failure false
60 test_cleanup
61 return
62 }
63 write_file datafile "data"
64 fossil add datafile
65 fossil commit -m "c1"
66 if {![uuid_from_commit $RESULT UUID]} {
67 test amend-setup-failure false
68 test_cleanup
69 return
70 }
71
72 ########################################
73 # Test: -branch #
74 ########################################
75
--- test/amend.test
+++ test/amend.test
@@ -55,20 +55,18 @@
55 # Setup: Add file and commit #
56 ########################################
57
58 if {![uuid_from_checkout UUIDINIT]} {
59 test amend-checkout-failure false
60 test_cleanup_then_return
 
61 }
62 write_file datafile "data"
63 fossil add datafile
64 fossil commit -m "c1"
65 if {![uuid_from_commit $RESULT UUID]} {
66 test amend-setup-failure false
67 test_cleanup_then_return
 
68 }
69
70 ########################################
71 # Test: -branch #
72 ########################################
73
+4 -2
--- test/json.test
+++ test/json.test
@@ -24,11 +24,12 @@
2424
# not configured. If that changes, these conditions might not prevent
2525
# the rest of this file from running.
2626
fossil test-th-eval "hasfeature json"
2727
2828
if {$::RESULT ne "1"} then {
29
- puts "Fossil was not compiled with JSON support."; return
29
+ puts "Fossil was not compiled with JSON support."
30
+ test_cleanup_then_return
3031
}
3132
3233
# We need a JSON parser to effectively test the JSON produced by
3334
# fossil. It looks like the one from tcllib is exactly what we need.
3435
# On ActiveTcl, add it with teacup. On other platforms, YMMV.
@@ -47,11 +48,12 @@
4748
4849
# and that the json itself smells ok and has the expected API error code in it
4950
fossil json -expectError
5051
set JR [json2dict $RESULT]
5152
if {$JR eq ""} {
52
- puts "Fossil was not compiled with JSON support (bad JSON)."; return
53
+ puts "Fossil was not compiled with JSON support (bad JSON)."
54
+ test_cleanup_then_return
5355
}
5456
test json-1 {[dict exists $JR resultCode]
5557
&& [dict get $JR resultCode] eq "FOSSIL-4102"}
5658
5759
# Use the CLI interface to execute a JSON command. Sets the global
5860
--- test/json.test
+++ test/json.test
@@ -24,11 +24,12 @@
24 # not configured. If that changes, these conditions might not prevent
25 # the rest of this file from running.
26 fossil test-th-eval "hasfeature json"
27
28 if {$::RESULT ne "1"} then {
29 puts "Fossil was not compiled with JSON support."; return
 
30 }
31
32 # We need a JSON parser to effectively test the JSON produced by
33 # fossil. It looks like the one from tcllib is exactly what we need.
34 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
@@ -47,11 +48,12 @@
47
48 # and that the json itself smells ok and has the expected API error code in it
49 fossil json -expectError
50 set JR [json2dict $RESULT]
51 if {$JR eq ""} {
52 puts "Fossil was not compiled with JSON support (bad JSON)."; return
 
53 }
54 test json-1 {[dict exists $JR resultCode]
55 && [dict get $JR resultCode] eq "FOSSIL-4102"}
56
57 # Use the CLI interface to execute a JSON command. Sets the global
58
--- test/json.test
+++ test/json.test
@@ -24,11 +24,12 @@
24 # not configured. If that changes, these conditions might not prevent
25 # the rest of this file from running.
26 fossil test-th-eval "hasfeature json"
27
28 if {$::RESULT ne "1"} then {
29 puts "Fossil was not compiled with JSON support."
30 test_cleanup_then_return
31 }
32
33 # We need a JSON parser to effectively test the JSON produced by
34 # fossil. It looks like the one from tcllib is exactly what we need.
35 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
@@ -47,11 +48,12 @@
48
49 # and that the json itself smells ok and has the expected API error code in it
50 fossil json -expectError
51 set JR [json2dict $RESULT]
52 if {$JR eq ""} {
53 puts "Fossil was not compiled with JSON support (bad JSON)."
54 test_cleanup_then_return
55 }
56 test json-1 {[dict exists $JR resultCode]
57 && [dict get $JR resultCode] eq "FOSSIL-4102"}
58
59 # Use the CLI interface to execute a JSON command. Sets the global
60
--- test/tester.tcl
+++ test/tester.tcl
@@ -231,10 +231,15 @@
231231
}
232232
after [expr {$try * 100}]
233233
}
234234
error "Could not delete \"$path\", error: $error"
235235
}
236
+
237
+proc test_cleanup_then_return {} {
238
+ uplevel 1 [list test_cleanup]
239
+ return -code return
240
+}
236241
237242
proc test_cleanup {} {
238243
if {![info exists ::tempRepoPath]} {return}
239244
if {![file exists $::tempRepoPath]} {return}
240245
if {![file isdirectory $::tempRepoPath]} {return}
241246
--- test/tester.tcl
+++ test/tester.tcl
@@ -231,10 +231,15 @@
231 }
232 after [expr {$try * 100}]
233 }
234 error "Could not delete \"$path\", error: $error"
235 }
 
 
 
 
 
236
237 proc test_cleanup {} {
238 if {![info exists ::tempRepoPath]} {return}
239 if {![file exists $::tempRepoPath]} {return}
240 if {![file isdirectory $::tempRepoPath]} {return}
241
--- test/tester.tcl
+++ test/tester.tcl
@@ -231,10 +231,15 @@
231 }
232 after [expr {$try * 100}]
233 }
234 error "Could not delete \"$path\", error: $error"
235 }
236
237 proc test_cleanup_then_return {} {
238 uplevel 1 [list test_cleanup]
239 return -code return
240 }
241
242 proc test_cleanup {} {
243 if {![info exists ::tempRepoPath]} {return}
244 if {![file exists $::tempRepoPath]} {return}
245 if {![file isdirectory $::tempRepoPath]} {return}
246
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -19,18 +19,22 @@
1919
#
2020
2121
fossil test-th-eval "hasfeature th1Docs"
2222
2323
if {$::RESULT ne "1"} {
24
- puts "Fossil was not compiled with TH1 docs support."; return
24
+ puts "Fossil was not compiled with TH1 docs support."
25
+ test_cleanup_then_return
2526
}
2627
2728
fossil test-th-eval "hasfeature tcl"
2829
2930
if {$::RESULT ne "1"} {
30
- puts "Fossil was not compiled with Tcl support."; return
31
+ puts "Fossil was not compiled with Tcl support."
32
+ test_cleanup_then_return
3133
}
34
+
35
+###############################################################################
3236
3337
test_setup ""
3438
3539
###############################################################################
3640
3741
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -19,18 +19,22 @@
19 #
20
21 fossil test-th-eval "hasfeature th1Docs"
22
23 if {$::RESULT ne "1"} {
24 puts "Fossil was not compiled with TH1 docs support."; return
 
25 }
26
27 fossil test-th-eval "hasfeature tcl"
28
29 if {$::RESULT ne "1"} {
30 puts "Fossil was not compiled with Tcl support."; return
 
31 }
 
 
32
33 test_setup ""
34
35 ###############################################################################
36
37
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -19,18 +19,22 @@
19 #
20
21 fossil test-th-eval "hasfeature th1Docs"
22
23 if {$::RESULT ne "1"} {
24 puts "Fossil was not compiled with TH1 docs support."
25 test_cleanup_then_return
26 }
27
28 fossil test-th-eval "hasfeature tcl"
29
30 if {$::RESULT ne "1"} {
31 puts "Fossil was not compiled with Tcl support."
32 test_cleanup_then_return
33 }
34
35 ###############################################################################
36
37 test_setup ""
38
39 ###############################################################################
40
41
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -19,16 +19,20 @@
1919
#
2020
2121
fossil test-th-eval "hasfeature th1Hooks"
2222
2323
if {$::RESULT ne "1"} {
24
- puts "Fossil was not compiled with TH1 hooks support."; return
24
+ puts "Fossil was not compiled with TH1 hooks support."
25
+ test_cleanup_then_return
2526
}
2627
2728
###############################################################################
2829
2930
test_setup
31
+
32
+###############################################################################
33
+
3034
write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
3135
3236
###############################################################################
3337
3438
set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
3539
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -19,16 +19,20 @@
19 #
20
21 fossil test-th-eval "hasfeature th1Hooks"
22
23 if {$::RESULT ne "1"} {
24 puts "Fossil was not compiled with TH1 hooks support."; return
 
25 }
26
27 ###############################################################################
28
29 test_setup
 
 
 
30 write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
31
32 ###############################################################################
33
34 set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
35
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -19,16 +19,20 @@
19 #
20
21 fossil test-th-eval "hasfeature th1Hooks"
22
23 if {$::RESULT ne "1"} {
24 puts "Fossil was not compiled with TH1 hooks support."
25 test_cleanup_then_return
26 }
27
28 ###############################################################################
29
30 test_setup
31
32 ###############################################################################
33
34 write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
35
36 ###############################################################################
37
38 set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
39
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -23,11 +23,12 @@
2323
###############################################################################
2424
2525
fossil test-th-eval "hasfeature tcl"
2626
2727
if {$::RESULT ne "1"} {
28
- puts "Fossil was not compiled with Tcl support."; return
28
+ puts "Fossil was not compiled with Tcl support."
29
+ test_cleanup_then_return
2930
}
3031
3132
###############################################################################
3233
3334
test_setup
3435
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -23,11 +23,12 @@
23 ###############################################################################
24
25 fossil test-th-eval "hasfeature tcl"
26
27 if {$::RESULT ne "1"} {
28 puts "Fossil was not compiled with Tcl support."; return
 
29 }
30
31 ###############################################################################
32
33 test_setup
34
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -23,11 +23,12 @@
23 ###############################################################################
24
25 fossil test-th-eval "hasfeature tcl"
26
27 if {$::RESULT ne "1"} {
28 puts "Fossil was not compiled with Tcl support."
29 test_cleanup_then_return
30 }
31
32 ###############################################################################
33
34 test_setup
35

Keyboard Shortcuts

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