Fossil SCM

Clean up after a test fails, otherwise the directories it leaves makes the next test fail

danshearer 2026-11-11 08:42 UTC test-suite-new
Commit 098e61579f75d94b2674274f616e50632c0b2f4820659b5c1f572ef6c8249c68
1 file changed +12 -3
+12 -3
--- test/tester.tcl
+++ test/tester.tcl
@@ -437,11 +437,13 @@
437437
test_report $name 0 "" [list "reason: $reason"]
438438
uplevel 1 [list test_cleanup]
439439
return -code return
440440
}
441441
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 ""}} {
443445
if {$::KEEP} {
444446
# To avoid errors with require_no_open_checkout, cd out of here.
445447
if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd}
446448
return
447449
}
@@ -454,11 +456,13 @@
454456
error "Temporary repository path has wrong parent during cleanup."
455457
}
456458
if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd}
457459
# First, attempt to delete the specific temporary repository directories
458460
# 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
+ }
460464
foreach repoSeed $::tempRepoSeeds {
461465
set repoPath [file join $::tempRepoPath $repoSeed $scriptName]
462466
robust_delete $repoPath YES_DO_IT; # FORCE, arbitrary children.
463467
set seedPath [file join $::tempRepoPath $repoSeed]
464468
robust_delete $seedPath; # NO FORCE.
@@ -1150,11 +1154,16 @@
11501154
foreach testfile $argv {
11511155
protOut "***** $testfile ******"
11521156
if { [catch {source $testdir/$testfile.test} testerror testopts] } {
11531157
test_report test-framework-$testfile 0 "" [list "error: $testerror"]
11541158
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
+ }
11561165
} else {
11571166
test test-framework-$testfile 1
11581167
}
11591168
protOut "***** End of $testfile: [llength $bad_test] errors so far ******"
11601169
}
11611170
--- 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

Keyboard Shortcuts

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