Fossil SCM
Centralize early-return handling from the tests, always calling the test cleanup (which is harmless if not needed).
Commit
b01a51f43ae0e9f4890ec78fae6c5384a55b4091
Parent
314e9b35663d36c…
6 files changed
+2
-4
+4
-2
+5
+6
-2
+5
-1
+2
-1
+2
-4
| --- test/amend.test | ||
| +++ test/amend.test | ||
| @@ -55,20 +55,18 @@ | ||
| 55 | 55 | # Setup: Add file and commit # |
| 56 | 56 | ######################################## |
| 57 | 57 | |
| 58 | 58 | if {![uuid_from_checkout UUIDINIT]} { |
| 59 | 59 | test amend-checkout-failure false |
| 60 | - test_cleanup | |
| 61 | - return | |
| 60 | + test_cleanup_then_return | |
| 62 | 61 | } |
| 63 | 62 | write_file datafile "data" |
| 64 | 63 | fossil add datafile |
| 65 | 64 | fossil commit -m "c1" |
| 66 | 65 | if {![uuid_from_commit $RESULT UUID]} { |
| 67 | 66 | test amend-setup-failure false |
| 68 | - test_cleanup | |
| 69 | - return | |
| 67 | + test_cleanup_then_return | |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | 70 | ######################################## |
| 73 | 71 | # Test: -branch # |
| 74 | 72 | ######################################## |
| 75 | 73 |
| --- 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 @@ | ||
| 24 | 24 | # not configured. If that changes, these conditions might not prevent |
| 25 | 25 | # the rest of this file from running. |
| 26 | 26 | fossil test-th-eval "hasfeature json" |
| 27 | 27 | |
| 28 | 28 | 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 | |
| 30 | 31 | } |
| 31 | 32 | |
| 32 | 33 | # We need a JSON parser to effectively test the JSON produced by |
| 33 | 34 | # fossil. It looks like the one from tcllib is exactly what we need. |
| 34 | 35 | # On ActiveTcl, add it with teacup. On other platforms, YMMV. |
| @@ -47,11 +48,12 @@ | ||
| 47 | 48 | |
| 48 | 49 | # and that the json itself smells ok and has the expected API error code in it |
| 49 | 50 | fossil json -expectError |
| 50 | 51 | set JR [json2dict $RESULT] |
| 51 | 52 | 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 | |
| 53 | 55 | } |
| 54 | 56 | test json-1 {[dict exists $JR resultCode] |
| 55 | 57 | && [dict get $JR resultCode] eq "FOSSIL-4102"} |
| 56 | 58 | |
| 57 | 59 | # Use the CLI interface to execute a JSON command. Sets the global |
| 58 | 60 |
| --- 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 |
+5
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -231,10 +231,15 @@ | ||
| 231 | 231 | } |
| 232 | 232 | after [expr {$try * 100}] |
| 233 | 233 | } |
| 234 | 234 | error "Could not delete \"$path\", error: $error" |
| 235 | 235 | } |
| 236 | + | |
| 237 | +proc test_cleanup_then_return {} { | |
| 238 | + uplevel 1 [list test_cleanup] | |
| 239 | + return -code return | |
| 240 | +} | |
| 236 | 241 | |
| 237 | 242 | proc test_cleanup {} { |
| 238 | 243 | if {![info exists ::tempRepoPath]} {return} |
| 239 | 244 | if {![file exists $::tempRepoPath]} {return} |
| 240 | 245 | if {![file isdirectory $::tempRepoPath]} {return} |
| 241 | 246 |
| --- 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 |
+6
-2
| --- test/th1-docs.test | ||
| +++ test/th1-docs.test | ||
| @@ -19,18 +19,22 @@ | ||
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | fossil test-th-eval "hasfeature th1Docs" |
| 22 | 22 | |
| 23 | 23 | 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 | |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | fossil test-th-eval "hasfeature tcl" |
| 28 | 29 | |
| 29 | 30 | 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 | |
| 31 | 33 | } |
| 34 | + | |
| 35 | +############################################################################### | |
| 32 | 36 | |
| 33 | 37 | test_setup "" |
| 34 | 38 | |
| 35 | 39 | ############################################################################### |
| 36 | 40 | |
| 37 | 41 |
| --- 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 |
+5
-1
| --- test/th1-hooks.test | ||
| +++ test/th1-hooks.test | ||
| @@ -19,16 +19,20 @@ | ||
| 19 | 19 | # |
| 20 | 20 | |
| 21 | 21 | fossil test-th-eval "hasfeature th1Hooks" |
| 22 | 22 | |
| 23 | 23 | 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 | |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | ############################################################################### |
| 28 | 29 | |
| 29 | 30 | test_setup |
| 31 | + | |
| 32 | +############################################################################### | |
| 33 | + | |
| 30 | 34 | write_file f1 "f1"; fossil add f1; fossil commit -m "c1" |
| 31 | 35 | |
| 32 | 36 | ############################################################################### |
| 33 | 37 | |
| 34 | 38 | set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test. |
| 35 | 39 |
| --- 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 |
+2
-1
| --- test/th1-tcl.test | ||
| +++ test/th1-tcl.test | ||
| @@ -23,11 +23,12 @@ | ||
| 23 | 23 | ############################################################################### |
| 24 | 24 | |
| 25 | 25 | fossil test-th-eval "hasfeature tcl" |
| 26 | 26 | |
| 27 | 27 | 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 | |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | ############################################################################### |
| 32 | 33 | |
| 33 | 34 | test_setup |
| 34 | 35 |
| --- 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 |