Fossil SCM

Robustify the cleanup process.

mistachkin 2016-03-02 06:58 UTC testerCleanup
Commit ee5214b7edc79518b663c0ed852b05a50c0ca544
1 file changed +18 -5
+18 -5
--- test/tester.tcl
+++ test/tester.tcl
@@ -220,14 +220,26 @@
220220
set tempPathEnd [expr {[string length $::tempPath] - 1}]
221221
if {[string length $::tempPath] == 0 || \
222222
[string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
223223
error "Temporary repository path has wrong parent during cleanup."
224224
}
225
- catch {file delete -force $::tempRepoPath}
226225
if {[info exists ::tempSavedPwd]} {
227226
cd $::tempSavedPwd; unset ::tempSavedPwd
228227
}
228
+ # First, attempt to forcibly delete the specific temporary repository
229
+ # directory.
230
+ catch {file delete -force $::tempRepoPath}
231
+ # Next, attempt to gracefully delete the temporary repository directories.
232
+ catch {file delete [file join $::tempPath repo_[pid] $::tempRepoSeed]}
233
+ catch {file delete [file join $::tempPath repo_[pid]]}
234
+ # Finally, attempt to gracefully delete the temporary home.
235
+ if {$::tcl_platform(platform) eq "windows"} {
236
+ catch {file delete [file join $::tempHomePath _fossil]}
237
+ } else {
238
+ catch {file delete [file join $::tempHomePath .fossil]}
239
+ }
240
+ catch {file delete $::tempHomePath}
229241
}
230242
231243
proc is_home_elsewhere {} {
232244
return [expr {[info exists ::env(FOSSIL_HOME)] && \
233245
$::env(FOSSIL_HOME) eq $::tempHomePath}]
@@ -245,13 +257,13 @@
245257
#
246258
# Create and open a new Fossil repository and clean the checkout
247259
#
248260
proc repo_init {{filename ".rep.fossil"}} {
249261
set_home_to_elsewhere
262
+ set ::tempRepoSeed [string trim [clock seconds] -]
250263
set ::tempRepoPath [file join \
251
- $::tempPath repo_[pid] [string trim [clock seconds] -] \
252
- [file tail [get_script_or_fail]]]
264
+ $::tempPath repo_[pid] $::tempRepoSeed [file tail [get_script_or_fail]]]
253265
if {[catch {
254266
file mkdir $::tempRepoPath
255267
} error] != 0} {
256268
error "could not make directory \"$::tempRepoPath\",\
257269
please set TEMP variable in environment: $error"
@@ -557,13 +569,14 @@
557569
}
558570
559571
set tempPath [file normalize $tempPath]
560572
561573
if {[catch {
562
- write_file [file join $tempPath temporary.txt] [clock seconds]
574
+ set tempFile [file join $tempPath temporary.txt]
575
+ write_file $tempFile [clock seconds]; file delete $tempFile
563576
} error] != 0} {
564
- error "could not write file to directory \"$tempPath\",\
577
+ error "could not write file \"$tempFile\" in directory \"$tempPath\",\
565578
please set TEMP variable in environment: $error"
566579
}
567580
568581
set tempHomePath [file join $tempPath home_[pid]]
569582
570583
--- test/tester.tcl
+++ test/tester.tcl
@@ -220,14 +220,26 @@
220 set tempPathEnd [expr {[string length $::tempPath] - 1}]
221 if {[string length $::tempPath] == 0 || \
222 [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
223 error "Temporary repository path has wrong parent during cleanup."
224 }
225 catch {file delete -force $::tempRepoPath}
226 if {[info exists ::tempSavedPwd]} {
227 cd $::tempSavedPwd; unset ::tempSavedPwd
228 }
 
 
 
 
 
 
 
 
 
 
 
 
 
229 }
230
231 proc is_home_elsewhere {} {
232 return [expr {[info exists ::env(FOSSIL_HOME)] && \
233 $::env(FOSSIL_HOME) eq $::tempHomePath}]
@@ -245,13 +257,13 @@
245 #
246 # Create and open a new Fossil repository and clean the checkout
247 #
248 proc repo_init {{filename ".rep.fossil"}} {
249 set_home_to_elsewhere
 
250 set ::tempRepoPath [file join \
251 $::tempPath repo_[pid] [string trim [clock seconds] -] \
252 [file tail [get_script_or_fail]]]
253 if {[catch {
254 file mkdir $::tempRepoPath
255 } error] != 0} {
256 error "could not make directory \"$::tempRepoPath\",\
257 please set TEMP variable in environment: $error"
@@ -557,13 +569,14 @@
557 }
558
559 set tempPath [file normalize $tempPath]
560
561 if {[catch {
562 write_file [file join $tempPath temporary.txt] [clock seconds]
 
563 } error] != 0} {
564 error "could not write file to directory \"$tempPath\",\
565 please set TEMP variable in environment: $error"
566 }
567
568 set tempHomePath [file join $tempPath home_[pid]]
569
570
--- test/tester.tcl
+++ test/tester.tcl
@@ -220,14 +220,26 @@
220 set tempPathEnd [expr {[string length $::tempPath] - 1}]
221 if {[string length $::tempPath] == 0 || \
222 [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
223 error "Temporary repository path has wrong parent during cleanup."
224 }
 
225 if {[info exists ::tempSavedPwd]} {
226 cd $::tempSavedPwd; unset ::tempSavedPwd
227 }
228 # First, attempt to forcibly delete the specific temporary repository
229 # directory.
230 catch {file delete -force $::tempRepoPath}
231 # Next, attempt to gracefully delete the temporary repository directories.
232 catch {file delete [file join $::tempPath repo_[pid] $::tempRepoSeed]}
233 catch {file delete [file join $::tempPath repo_[pid]]}
234 # Finally, attempt to gracefully delete the temporary home.
235 if {$::tcl_platform(platform) eq "windows"} {
236 catch {file delete [file join $::tempHomePath _fossil]}
237 } else {
238 catch {file delete [file join $::tempHomePath .fossil]}
239 }
240 catch {file delete $::tempHomePath}
241 }
242
243 proc is_home_elsewhere {} {
244 return [expr {[info exists ::env(FOSSIL_HOME)] && \
245 $::env(FOSSIL_HOME) eq $::tempHomePath}]
@@ -245,13 +257,13 @@
257 #
258 # Create and open a new Fossil repository and clean the checkout
259 #
260 proc repo_init {{filename ".rep.fossil"}} {
261 set_home_to_elsewhere
262 set ::tempRepoSeed [string trim [clock seconds] -]
263 set ::tempRepoPath [file join \
264 $::tempPath repo_[pid] $::tempRepoSeed [file tail [get_script_or_fail]]]
 
265 if {[catch {
266 file mkdir $::tempRepoPath
267 } error] != 0} {
268 error "could not make directory \"$::tempRepoPath\",\
269 please set TEMP variable in environment: $error"
@@ -557,13 +569,14 @@
569 }
570
571 set tempPath [file normalize $tempPath]
572
573 if {[catch {
574 set tempFile [file join $tempPath temporary.txt]
575 write_file $tempFile [clock seconds]; file delete $tempFile
576 } error] != 0} {
577 error "could not write file \"$tempFile\" in directory \"$tempPath\",\
578 please set TEMP variable in environment: $error"
579 }
580
581 set tempHomePath [file join $tempPath home_[pid]]
582
583

Keyboard Shortcuts

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