Fossil

Check-in [cda4cc8b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Refactoring, fixes to the previous check-in, etc.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | testerCleanup
Files: files | file ages | folders
SHA1:cda4cc8b805bccc94f4880b5b88187af0a1fc181
User & Date: mistachkin 2016-03-02 07:13:37
Context
2016-03-02
07:31
Do not rely on 'clock seconds' (alone) being unique between 'repo_init' calls. Make temporary directory deletion more robust. Only save the current directory on the first 'repo_init' call per test. check-in: 004b3ffd user: mistachkin tags: testerCleanup
07:13
Refactoring, fixes to the previous check-in, etc. check-in: cda4cc8b user: mistachkin tags: testerCleanup
07:00
Attempt to make sure that multiple calls to 'repo_init' get properly cleaned up. check-in: c464935b user: mistachkin tags: testerCleanup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/tester.tcl.

221
222
223
224
225
226
227
228
229
230
231
232

233


234


235
236
237
238
239
240
241
242
243
...
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
  if {[string length $::tempPath] == 0 || \
      [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
    error "Temporary repository path has wrong parent during cleanup."
  }
  if {[info exists ::tempSavedPwd]} {
    cd $::tempSavedPwd; unset ::tempSavedPwd
  }
  # First, attempt to forcibly delete the specific temporary repository
  # directory.
  catch {file delete -force $::tempRepoPath}
  # Next, attempt to gracefully delete the temporary repository directories.
  foreach repoSeed $::tempRepoSeeds {

    catch {file delete [file join $::tempPath repo_[pid] $repoSeed]}


  }


  catch {file delete [file join $::tempPath repo_[pid]]}
  # Finally, attempt to gracefully delete the temporary home.
  if {$::tcl_platform(platform) eq "windows"} {
    catch {file delete [file join $::tempHomePath _fossil]}
  } else {
    catch {file delete [file join $::tempHomePath .fossil]}
  }
  catch {file delete $::tempHomePath}
}
................................................................................

#
# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
  set_home_to_elsewhere
  set repoSeed [string trim [clock seconds] -]

  lappend ::tempRepoSeeds $repoSeed
  set ::tempRepoPath [file join \
      $::tempPath repo_[pid] $repoSeed [file tail [get_script_or_fail]]]
  if {[catch {
    file mkdir $::tempRepoPath
  } error] != 0} {
    error "could not make directory \"$::tempRepoPath\",\
please set TEMP variable in environment: $error"
  }
  set ::tempSavedPwd [pwd]; cd $::tempRepoPath
  exec $::fossilexe new $filename
  exec $::fossilexe open $filename
  exec $::fossilexe set mtime-changes off
}

# This procedure only returns non-zero if the Tcl integration feature was
# enabled at compile-time and is now enabled at runtime.







|
|
|
<

>
|
>
>

>
>
|
|







 







>

|
|

|

|


|







221
222
223
224
225
226
227
228
229
230

231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
  if {[string length $::tempPath] == 0 || \
      [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
    error "Temporary repository path has wrong parent during cleanup."
  }
  if {[info exists ::tempSavedPwd]} {
    cd $::tempSavedPwd; unset ::tempSavedPwd
  }
  # First, attempt to delete the specific temporary repository directories
  # for this test file.
  set scriptName [file tail [get_script_or_fail]]

  foreach repoSeed $::tempRepoSeeds {
    set repoPath [file join $::tempRepoPath $repoSeed $scriptName]
    catch {file delete -force $repoPath}; # FORCE, arbitrary children.
    set seedPath [file join $::tempRepoPath $repoSeed]
    catch {file delete $seedPath}; # NO FORCE.
  }
  # Next, attempt to gracefully delete the temporary repository directory
  # for this process.
  catch {file delete $::tempRepoPath}
  # Finally, attempt to gracefully delete the temporary home directory.
  if {$::tcl_platform(platform) eq "windows"} {
    catch {file delete [file join $::tempHomePath _fossil]}
  } else {
    catch {file delete [file join $::tempHomePath .fossil]}
  }
  catch {file delete $::tempHomePath}
}
................................................................................

#
# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
  set_home_to_elsewhere
  set repoSeed [string trim [clock seconds] -]
  set ::tempRepoPath [file join $::tempPath repo_[pid]]
  lappend ::tempRepoSeeds $repoSeed
  set repoPath [file join \
      $::tempRepoPath $repoSeed [file tail [get_script_or_fail]]]
  if {[catch {
    file mkdir $repoPath
  } error] != 0} {
    error "could not make directory \"$repoPath\",\
please set TEMP variable in environment: $error"
  }
  set ::tempSavedPwd [pwd]; cd $repoPath
  exec $::fossilexe new $filename
  exec $::fossilexe open $filename
  exec $::fossilexe set mtime-changes off
}

# This procedure only returns non-zero if the Tcl integration feature was
# enabled at compile-time and is now enabled at runtime.