Fossil

Check-in [89f76a21]
Login

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

Overview
Comment:Work in progress on cleaning up home/repo handling in the test suite.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | testerCleanup
Files: files | file ages | folders
SHA1:89f76a21dda7490449e722f41988f18ba22c54ed
User & Date: mistachkin 2016-03-02 06:22:44
Context
2016-03-02
06:45
More work... check-in: 29f0328c user: mistachkin tags: testerCleanup
06:22
Work in progress on cleaning up home/repo handling in the test suite. check-in: 89f76a21 user: mistachkin tags: testerCleanup
02:10
Permit the TH1 hooks subsystem to check for the configuration without raising a 'fatal' error. check-in: b06cd631 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/merge5.test.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    protOut "  Got:\n    $result"
    test merge5-$testid 0
  } else {
    test merge5-$testid 1
  }    
}

catch {exec $::fossilexe info} res
if {![regexp {use --repository} $res]} {
  puts stderr "Cannot run this test within an open checkout"
  return
}
#
# Fossil will write data on $HOME, running 'fossil open' here.
# We need not to clutter the $HOME of the test caller.
set env(HOME) [pwd]

# Construct a test repository
#
exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
fossil rebuild m5.fossil
fossil open m5.fossil
fossil user default drh --user drh







|
<
<
<
<
<
<
<
<







34
35
36
37
38
39
40
41








42
43
44
45
46
47
48
    protOut "  Got:\n    $result"
    test merge5-$testid 0
  } else {
    test merge5-$testid 1
  }    
}

require_no_open_checkout; set_home_to_elsewhere









# Construct a test repository
#
exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
fossil rebuild m5.fossil
fossil open m5.fossil
fossil user default drh --user drh

Changes to test/merge_renames.test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# Tests for merging with renames
#
#

catch {exec $::fossilexe info} res
if {![regexp {use --repository} $res]} {
  puts stderr "Cannot run this test within an open checkout"
  return
}

######################################
#  Test 1                            #
#  Reported: Ticket [554f44ee74e3d]  #
######################################

repo_init





|
<
<
<
<







1
2
3
4
5
6




7
8
9
10
11
12
13
#
# Tests for merging with renames
#
#

require_no_open_checkout





######################################
#  Test 1                            #
#  Reported: Ticket [554f44ee74e3d]  #
######################################

repo_init

Changes to test/mv-rm.test.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#   http://www.hwaci.com/drh/
#
############################################################################
#
# MV / RM Commands
#

catch {exec $::fossilexe info} res
if {![regexp {use --repository} $res]} {
  puts stderr "Cannot run this test within an open checkout"
  return
}

########################################
# Setup: Add Files and Commit          #
########################################

set rootDir [file normalize [pwd]]








|
<
<
<
<







14
15
16
17
18
19
20
21




22
23
24
25
26
27
28
#   http://www.hwaci.com/drh/
#
############################################################################
#
# MV / RM Commands
#

require_no_open_checkout





########################################
# Setup: Add Files and Commit          #
########################################

set rootDir [file normalize [pwd]]

Changes to test/revert.test.

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    }
    test revert-$testid$key $passed
  }
  
  fossil undo
}

catch {exec $::fossilexe info} res
if {![regexp {use --repository} $res]} {
  puts stderr "Cannot run this test within an open checkout"
  return
}

repo_init

# Prepare first commit
#
write_file f1 "f1"
write_file f2 "f2"
write_file f3 "f3"







|
<
<
<
<
<







52
53
54
55
56
57
58
59





60
61
62
63
64
65
66
    }
    test revert-$testid$key $passed
  }
  
  fossil undo
}

require_no_open_checkout





repo_init

# Prepare first commit
#
write_file f1 "f1"
write_file f2 "f2"
write_file f3 "f3"

Changes to test/stash.test.

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
}

proc stash-test {testid stashArgs expectedStashOutput args} {
  fossil stash {*}$stashArgs
  return [test_result_state stash-$testid "stash $stashArgs" $expectedStashOutput {*}$args] 
}

catch {exec $::fossilexe info} res
if {![regexp {use --repository} $res]} {
  puts stderr "Cannot run this test within an open checkout"
  return
}

repo_init

# Prepare first commit
#
write_file f1 "f1"
write_file f2 "f2"
write_file f3 "f3"







|
<
<
<
<
<







88
89
90
91
92
93
94
95





96
97
98
99
100
101
102
}

proc stash-test {testid stashArgs expectedStashOutput args} {
  fossil stash {*}$stashArgs
  return [test_result_state stash-$testid "stash $stashArgs" $expectedStashOutput {*}$args] 
}

require_no_open_checkout





repo_init

# Prepare first commit
#
write_file f1 "f1"
write_file f2 "f2"
write_file f3 "f3"

Changes to test/tester.tcl.

187
188
189
190
191
192
193
194
195
196
197
198
199



200




201









202
203

204




205
206









207
208
209
210
211
212
213
...
511
512
513
514
515
516
517









518
519
520
521
522
523
524
  set x [read_file $a]
  regsub -all { +\n} $x \n x
  set y [read_file $b]
  regsub -all { +\n} $y \n y
  return [expr {$x==$y}]
}

# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
  if {$::env(HOME) ne [pwd]} {
    catch {exec $::fossilexe info} res
    if {![regexp {use --repository} $res]} {



      error "In an open checkout: cannot initialize a new repository here."




    }









    # Fossil will write data on $FOSSIL_HOME, running 'fossil new' here.
    # We need not to clutter the $HOME of the test caller.

    #




    set ::env(FOSSIL_HOME) [pwd]
    set ::env(HOME) [pwd]









  }
  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
................................................................................

if {[catch {
  write_file [file join $tempPath temporary.txt] [clock seconds]
} error] != 0} {
  error "could not write file to directory \"$tempPath\",\
please set TEMP variable in environment: $error"
}










protInit $fossilexe
foreach testfile $argv {
  set dir [file root [file tail $testfile]]
  file delete -force $dir
  file mkdir $dir
  set origwd [pwd]







|
<
<
<
|
|
>
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
<
>
|
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>







187
188
189
190
191
192
193
194



195
196
197
198
199
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
...
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
  set x [read_file $a]
  regsub -all { +\n} $x \n x
  set y [read_file $b]
  regsub -all { +\n} $y \n y
  return [expr {$x==$y}]
}

proc require_no_open_checkout {} {



  catch {exec $::fossilexe info} res
  if {![regexp {use --repository} $res]} {
    set projectName <unknown>
    set localRoot <unknown>
    regexp -line -- {^project-name: (.*)$} $res dummy projectName
    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
................................................................................

if {[catch {
  write_file [file join $tempPath temporary.txt] [clock seconds]
} error] != 0} {
  error "could not write file to directory \"$tempPath\",\
please set TEMP variable in environment: $error"
}

set tempHomePath [file join $tempPath home_[pid]]

if {[catch {
  file mkdir $tempHomePath
} error] != 0} {
  error "could not make directory \"$tempHomePath\",\
please set TEMP variable in environment: $error"
}

protInit $fossilexe
foreach testfile $argv {
  set dir [file root [file tail $testfile]]
  file delete -force $dir
  file mkdir $dir
  set origwd [pwd]

Changes to test/th1-docs.test.

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
############################################################################
#
# TH1 Docs
#

fossil test-th-eval "hasfeature th1Docs"

if {$::RESULT ne "1"} then {
  puts "Fossil was not compiled with TH1 docs support."; return
}

fossil test-th-eval "hasfeature tcl"

if {$::RESULT ne "1"} then {
  puts "Fossil was not compiled with Tcl support."; return
}

###############################################################################

set env(TH1_ENABLE_DOCS) 1; # TH1 docs must be enabled for this test.
set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
................................................................................

run_in_checkout {
  set data [fossil info]
}

regexp -line -- {^repository:   (.*)$} $data dummy repository

if {[string length $repository] == 0 || ![file exists $repository]} then {
  error "unable to locate repository"
}

set dataFileName [file join $::testdir th1-docs-input.txt]

###############################################################################








|





|







 







|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
############################################################################
#
# TH1 Docs
#

fossil test-th-eval "hasfeature th1Docs"

if {$::RESULT ne "1"} {
  puts "Fossil was not compiled with TH1 docs support."; return
}

fossil test-th-eval "hasfeature tcl"

if {$::RESULT ne "1"} {
  puts "Fossil was not compiled with Tcl support."; return
}

###############################################################################

set env(TH1_ENABLE_DOCS) 1; # TH1 docs must be enabled for this test.
set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
................................................................................

run_in_checkout {
  set data [fossil info]
}

regexp -line -- {^repository:   (.*)$} $data dummy repository

if {[string length $repository] == 0 || ![file exists $repository]} {
  error "unable to locate repository"
}

set dataFileName [file join $::testdir th1-docs-input.txt]

###############################################################################

Changes to test/th1-hooks.test.

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
############################################################################
#
# TH1 Hooks
#

fossil test-th-eval "hasfeature th1Hooks"

if {$::RESULT ne "1"} then {
  puts "Fossil was not compiled with TH1 hooks support."; return
}

###############################################################################

repo_init
write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
................................................................................
}

###############################################################################

set data [fossil info]
regexp -line -- {^repository:   (.*)$} $data dummy repository

if {[string length $repository] == 0 || ![file exists $repository]} then {
  error "unable to locate repository"
}

set dataFileName [file join $::testdir th1-hooks-input.txt]

###############################################################################








|







 







|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
############################################################################
#
# TH1 Hooks
#

fossil test-th-eval "hasfeature th1Hooks"

if {$::RESULT ne "1"} {
  puts "Fossil was not compiled with TH1 hooks support."; return
}

###############################################################################

repo_init
write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
................................................................................
}

###############################################################################

set data [fossil info]
regexp -line -- {^repository:   (.*)$} $data dummy repository

if {[string length $repository] == 0 || ![file exists $repository]} {
  error "unable to locate repository"
}

set dataFileName [file join $::testdir th1-hooks-input.txt]

###############################################################################

Changes to test/th1-repo.test.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#   Chris Drexler <ckolumbus@ac-drexler.de>
#
############################################################################
#
# TH1 tests that may modify the repository
#

catch {exec $::fossilexe info} res
if {![regexp {use --repository} $res]} {
  puts stderr "Cannot run this test within an open checkout"
  return
}

########################################
# Setup: Add Files and Commit          #
########################################

set rootDir [file normalize [pwd]]








|
<
<
<
<







17
18
19
20
21
22
23
24




25
26
27
28
29
30
31
#   Chris Drexler <ckolumbus@ac-drexler.de>
#
############################################################################
#
# TH1 tests that may modify the repository
#

require_no_open_checkout





########################################
# Setup: Add Files and Commit          #
########################################

set rootDir [file normalize [pwd]]

Changes to test/th1-tcl.test.

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

repo_init

###############################################################################

fossil test-th-eval "hasfeature tcl"

if {$::RESULT ne "1"} then {
  puts "Fossil was not compiled with Tcl support."; return
}

###############################################################################

set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.








|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

repo_init

###############################################################################

fossil test-th-eval "hasfeature tcl"

if {$::RESULT ne "1"} {
  puts "Fossil was not compiled with Tcl support."; return
}

###############################################################################

set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.

Changes to test/th1.test.

882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
###############################################################################

fossil test-th-eval "globalState vfs"
test th1-globalState-14 {[string length $RESULT] == 0}

###############################################################################

if {$tcl_platform(platform) eq "windows"} then {
  set altVfs win32-longpath
} else {
  set altVfs unix-dotfile
}

###############################################################################








|







882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
###############################################################################

fossil test-th-eval "globalState vfs"
test th1-globalState-14 {[string length $RESULT] == 0}

###############################################################################

if {$tcl_platform(platform) eq "windows"} {
  set altVfs win32-longpath
} else {
  set altVfs unix-dotfile
}

###############################################################################