Fossil SCM
Clean up after a test fails, otherwise the directories it leaves makes the next test fail
Commit
098e61579f75d94b2674274f616e50632c0b2f4820659b5c1f572ef6c8249c68
Parent
bb353407c1b5ffb…
1 file changed
+12
-3
+12
-3
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -437,11 +437,13 @@ | ||
| 437 | 437 | test_report $name 0 "" [list "reason: $reason"] |
| 438 | 438 | uplevel 1 [list test_cleanup] |
| 439 | 439 | return -code return |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | -proc test_cleanup {} { | |
| 442 | +# Deletes the temporary repositories that test_setup made for the test | |
| 443 | +# file SCRIPTNAME, by default the file being sourced. | |
| 444 | +proc test_cleanup {{scriptName ""}} { | |
| 443 | 445 | if {$::KEEP} { |
| 444 | 446 | # To avoid errors with require_no_open_checkout, cd out of here. |
| 445 | 447 | if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd} |
| 446 | 448 | return |
| 447 | 449 | } |
| @@ -454,11 +456,13 @@ | ||
| 454 | 456 | error "Temporary repository path has wrong parent during cleanup." |
| 455 | 457 | } |
| 456 | 458 | if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd} |
| 457 | 459 | # First, attempt to delete the specific temporary repository directories |
| 458 | 460 | # for this test file. |
| 459 | - set scriptName [file tail [get_script_or_fail]] | |
| 461 | + if {$scriptName eq ""} { | |
| 462 | + set scriptName [file tail [get_script_or_fail]] | |
| 463 | + } | |
| 460 | 464 | foreach repoSeed $::tempRepoSeeds { |
| 461 | 465 | set repoPath [file join $::tempRepoPath $repoSeed $scriptName] |
| 462 | 466 | robust_delete $repoPath YES_DO_IT; # FORCE, arbitrary children. |
| 463 | 467 | set seedPath [file join $::tempRepoPath $repoSeed] |
| 464 | 468 | robust_delete $seedPath; # NO FORCE. |
| @@ -1150,11 +1154,16 @@ | ||
| 1150 | 1154 | foreach testfile $argv { |
| 1151 | 1155 | protOut "***** $testfile ******" |
| 1152 | 1156 | if { [catch {source $testdir/$testfile.test} testerror testopts] } { |
| 1153 | 1157 | test_report test-framework-$testfile 0 "" [list "error: $testerror"] |
| 1154 | 1158 | protOut "!!!!! $testfile: $testerror" |
| 1155 | - protOutDict $testopts" | |
| 1159 | + protOutDict $testopts | |
| 1160 | + # A test file that raises an error stops before its own test_cleanup, | |
| 1161 | + # and the directories it leaves make the next file's test_cleanup fail. | |
| 1162 | + if {[catch {test_cleanup $testfile.test} cleanuperror]} { | |
| 1163 | + protOut "!!!!! $testfile cleanup: $cleanuperror" | |
| 1164 | + } | |
| 1156 | 1165 | } else { |
| 1157 | 1166 | test test-framework-$testfile 1 |
| 1158 | 1167 | } |
| 1159 | 1168 | protOut "***** End of $testfile: [llength $bad_test] errors so far ******" |
| 1160 | 1169 | } |
| 1161 | 1170 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -437,11 +437,13 @@ | |
| 437 | test_report $name 0 "" [list "reason: $reason"] |
| 438 | uplevel 1 [list test_cleanup] |
| 439 | return -code return |
| 440 | } |
| 441 | |
| 442 | proc test_cleanup {} { |
| 443 | if {$::KEEP} { |
| 444 | # To avoid errors with require_no_open_checkout, cd out of here. |
| 445 | if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd} |
| 446 | return |
| 447 | } |
| @@ -454,11 +456,13 @@ | |
| 454 | error "Temporary repository path has wrong parent during cleanup." |
| 455 | } |
| 456 | if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd} |
| 457 | # First, attempt to delete the specific temporary repository directories |
| 458 | # for this test file. |
| 459 | set scriptName [file tail [get_script_or_fail]] |
| 460 | foreach repoSeed $::tempRepoSeeds { |
| 461 | set repoPath [file join $::tempRepoPath $repoSeed $scriptName] |
| 462 | robust_delete $repoPath YES_DO_IT; # FORCE, arbitrary children. |
| 463 | set seedPath [file join $::tempRepoPath $repoSeed] |
| 464 | robust_delete $seedPath; # NO FORCE. |
| @@ -1150,11 +1154,16 @@ | |
| 1150 | foreach testfile $argv { |
| 1151 | protOut "***** $testfile ******" |
| 1152 | if { [catch {source $testdir/$testfile.test} testerror testopts] } { |
| 1153 | test_report test-framework-$testfile 0 "" [list "error: $testerror"] |
| 1154 | protOut "!!!!! $testfile: $testerror" |
| 1155 | protOutDict $testopts" |
| 1156 | } else { |
| 1157 | test test-framework-$testfile 1 |
| 1158 | } |
| 1159 | protOut "***** End of $testfile: [llength $bad_test] errors so far ******" |
| 1160 | } |
| 1161 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -437,11 +437,13 @@ | |
| 437 | test_report $name 0 "" [list "reason: $reason"] |
| 438 | uplevel 1 [list test_cleanup] |
| 439 | return -code return |
| 440 | } |
| 441 | |
| 442 | # Deletes the temporary repositories that test_setup made for the test |
| 443 | # file SCRIPTNAME, by default the file being sourced. |
| 444 | proc test_cleanup {{scriptName ""}} { |
| 445 | if {$::KEEP} { |
| 446 | # To avoid errors with require_no_open_checkout, cd out of here. |
| 447 | if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd} |
| 448 | return |
| 449 | } |
| @@ -454,11 +456,13 @@ | |
| 456 | error "Temporary repository path has wrong parent during cleanup." |
| 457 | } |
| 458 | if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd} |
| 459 | # First, attempt to delete the specific temporary repository directories |
| 460 | # for this test file. |
| 461 | if {$scriptName eq ""} { |
| 462 | set scriptName [file tail [get_script_or_fail]] |
| 463 | } |
| 464 | foreach repoSeed $::tempRepoSeeds { |
| 465 | set repoPath [file join $::tempRepoPath $repoSeed $scriptName] |
| 466 | robust_delete $repoPath YES_DO_IT; # FORCE, arbitrary children. |
| 467 | set seedPath [file join $::tempRepoPath $repoSeed] |
| 468 | robust_delete $seedPath; # NO FORCE. |
| @@ -1150,11 +1154,16 @@ | |
| 1154 | foreach testfile $argv { |
| 1155 | protOut "***** $testfile ******" |
| 1156 | if { [catch {source $testdir/$testfile.test} testerror testopts] } { |
| 1157 | test_report test-framework-$testfile 0 "" [list "error: $testerror"] |
| 1158 | protOut "!!!!! $testfile: $testerror" |
| 1159 | protOutDict $testopts |
| 1160 | # A test file that raises an error stops before its own test_cleanup, |
| 1161 | # and the directories it leaves make the next file's test_cleanup fail. |
| 1162 | if {[catch {test_cleanup $testfile.test} cleanuperror]} { |
| 1163 | protOut "!!!!! $testfile cleanup: $cleanuperror" |
| 1164 | } |
| 1165 | } else { |
| 1166 | test test-framework-$testfile 1 |
| 1167 | } |
| 1168 | protOut "***** End of $testfile: [llength $bad_test] errors so far ******" |
| 1169 | } |
| 1170 |