200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
set projectName [string trim $projectName]
regexp -line -- {^local-root: (.*)$} $res dummy localRoot
set localRoot [string trim $localRoot]
error "Detected an open checkout of project \"$projectName\",\
rooted at \"$localRoot\", testing halted"
}
}
proc is_home_elsewhere {} {
return [expr {[info exists ::env(FOSSIL_HOME)] && \
$::env(FOSSIL_HOME) eq $::tempHomePath}]
}
proc set_home_to_elsewhere {} {
#
# Fossil will write data on $HOME (or $FOSSIL_HOME). We need not
# to clutter the real $HOME (or $FOSSIL_HOME) of the test caller.
#
if {[is_home_elsewhere]} {
protOut "***** FOSSIL_HOME is already elsewhere"
return
}
set ::env(FOSSIL_HOME) $::tempHomePath
}
#
# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
if {![is_home_elsewhere]} {
require_no_open_checkout
set_home_to_elsewhere
}
catch {exec $::fossilexe close -f}
file delete $filename
exec $::fossilexe new $filename
exec $::fossilexe open $filename
exec $::fossilexe clean -f
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.
proc is_tcl_usable_by_fossil {} {
fossil test-th-eval "hasfeature tcl"
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
|
>
>
>
>
>
>
>
>
<
<
>
<
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
set projectName [string trim $projectName]
regexp -line -- {^local-root: (.*)$} $res dummy localRoot
set localRoot [string trim $localRoot]
error "Detected an open checkout of project \"$projectName\",\
rooted at \"$localRoot\", testing halted"
}
}
proc get_script_or_fail {} {
set fileName [file normalize [info script]]
if {[string length $fileName] == 0 || ![file exists $fileName]} {
error "Failed to obtain the file name of the test being run."
}
return $fileName
}
proc test_cleanup {} {
if {![info exists ::tempRepoPath]} {return}
if {![file exists $::tempRepoPath]} {return}
if {![file isdirectory $::tempRepoPath]} {return}
set tempPathEnd [expr {[string length $::tempPath] - 1}]
if {[string length $::tempPath] == 0 || \
[string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
error "Temporary repository path has wrong parent during cleanup."
}
catch {file delete -force $::tempRepoPath}
if {[info exists ::tempSavedPwd]} {
cd $::tempSavedPwd; unset ::tempSavedPwd
}
}
proc is_home_elsewhere {} {
return [expr {[info exists ::env(FOSSIL_HOME)] && \
$::env(FOSSIL_HOME) eq $::tempHomePath}]
}
proc set_home_to_elsewhere {} {
#
# Fossil will write data on $HOME (or $FOSSIL_HOME). We need not
# to clutter the real $HOME (or $FOSSIL_HOME) of the test caller.
#
if {[is_home_elsewhere]} {return}
set ::env(FOSSIL_HOME) $::tempHomePath
}
#
# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
set_home_to_elsewhere
set ::tempRepoPath [file join \
$tempPath repo_[pid] [string trim [clock seconds] -] \
[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.
proc is_tcl_usable_by_fossil {} {
fossil test-th-eval "hasfeature tcl"
|