Fossil SCM

Work in progress on cleaning up home/repo handling in the test suite.

mistachkin 2016-03-02 06:22 trunk
Commit 89f76a21dda7490449e722f41988f18ba22c54ed
--- test/merge5.test
+++ test/merge5.test
@@ -36,19 +36,11 @@
3636
} else {
3737
test merge5-$testid 1
3838
}
3939
}
4040
41
-catch {exec $::fossilexe info} res
42
-if {![regexp {use --repository} $res]} {
43
- puts stderr "Cannot run this test within an open checkout"
44
- return
45
-}
46
-#
47
-# Fossil will write data on $HOME, running 'fossil open' here.
48
-# We need not to clutter the $HOME of the test caller.
49
-set env(HOME) [pwd]
41
+require_no_open_checkout; set_home_to_elsewhere
5042
5143
# Construct a test repository
5244
#
5345
exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
5446
fossil rebuild m5.fossil
5547
--- test/merge5.test
+++ test/merge5.test
@@ -36,19 +36,11 @@
36 } else {
37 test merge5-$testid 1
38 }
39 }
40
41 catch {exec $::fossilexe info} res
42 if {![regexp {use --repository} $res]} {
43 puts stderr "Cannot run this test within an open checkout"
44 return
45 }
46 #
47 # Fossil will write data on $HOME, running 'fossil open' here.
48 # We need not to clutter the $HOME of the test caller.
49 set env(HOME) [pwd]
50
51 # Construct a test repository
52 #
53 exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
54 fossil rebuild m5.fossil
55
--- test/merge5.test
+++ test/merge5.test
@@ -36,19 +36,11 @@
36 } else {
37 test merge5-$testid 1
38 }
39 }
40
41 require_no_open_checkout; set_home_to_elsewhere
 
 
 
 
 
 
 
 
42
43 # Construct a test repository
44 #
45 exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
46 fossil rebuild m5.fossil
47
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -1,15 +1,11 @@
11
#
22
# Tests for merging with renames
33
#
44
#
55
6
-catch {exec $::fossilexe info} res
7
-if {![regexp {use --repository} $res]} {
8
- puts stderr "Cannot run this test within an open checkout"
9
- return
10
-}
6
+require_no_open_checkout
117
128
######################################
139
# Test 1 #
1410
# Reported: Ticket [554f44ee74e3d] #
1511
######################################
1612
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -1,15 +1,11 @@
1 #
2 # Tests for merging with renames
3 #
4 #
5
6 catch {exec $::fossilexe info} res
7 if {![regexp {use --repository} $res]} {
8 puts stderr "Cannot run this test within an open checkout"
9 return
10 }
11
12 ######################################
13 # Test 1 #
14 # Reported: Ticket [554f44ee74e3d] #
15 ######################################
16
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -1,15 +1,11 @@
1 #
2 # Tests for merging with renames
3 #
4 #
5
6 require_no_open_checkout
 
 
 
 
7
8 ######################################
9 # Test 1 #
10 # Reported: Ticket [554f44ee74e3d] #
11 ######################################
12
+1 -5
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -16,15 +16,11 @@
1616
############################################################################
1717
#
1818
# MV / RM Commands
1919
#
2020
21
-catch {exec $::fossilexe info} res
22
-if {![regexp {use --repository} $res]} {
23
- puts stderr "Cannot run this test within an open checkout"
24
- return
25
-}
21
+require_no_open_checkout
2622
2723
########################################
2824
# Setup: Add Files and Commit #
2925
########################################
3026
3127
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -16,15 +16,11 @@
16 ############################################################################
17 #
18 # MV / RM Commands
19 #
20
21 catch {exec $::fossilexe info} res
22 if {![regexp {use --repository} $res]} {
23 puts stderr "Cannot run this test within an open checkout"
24 return
25 }
26
27 ########################################
28 # Setup: Add Files and Commit #
29 ########################################
30
31
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -16,15 +16,11 @@
16 ############################################################################
17 #
18 # MV / RM Commands
19 #
20
21 require_no_open_checkout
 
 
 
 
22
23 ########################################
24 # Setup: Add Files and Commit #
25 ########################################
26
27
--- test/revert.test
+++ test/revert.test
@@ -54,16 +54,11 @@
5454
}
5555
5656
fossil undo
5757
}
5858
59
-catch {exec $::fossilexe info} res
60
-if {![regexp {use --repository} $res]} {
61
- puts stderr "Cannot run this test within an open checkout"
62
- return
63
-}
64
-
59
+require_no_open_checkout
6560
repo_init
6661
6762
# Prepare first commit
6863
#
6964
write_file f1 "f1"
7065
--- test/revert.test
+++ test/revert.test
@@ -54,16 +54,11 @@
54 }
55
56 fossil undo
57 }
58
59 catch {exec $::fossilexe info} res
60 if {![regexp {use --repository} $res]} {
61 puts stderr "Cannot run this test within an open checkout"
62 return
63 }
64
65 repo_init
66
67 # Prepare first commit
68 #
69 write_file f1 "f1"
70
--- test/revert.test
+++ test/revert.test
@@ -54,16 +54,11 @@
54 }
55
56 fossil undo
57 }
58
59 require_no_open_checkout
 
 
 
 
 
60 repo_init
61
62 # Prepare first commit
63 #
64 write_file f1 "f1"
65
+1 -6
--- test/stash.test
+++ test/stash.test
@@ -90,16 +90,11 @@
9090
proc stash-test {testid stashArgs expectedStashOutput args} {
9191
fossil stash {*}$stashArgs
9292
return [test_result_state stash-$testid "stash $stashArgs" $expectedStashOutput {*}$args]
9393
}
9494
95
-catch {exec $::fossilexe info} res
96
-if {![regexp {use --repository} $res]} {
97
- puts stderr "Cannot run this test within an open checkout"
98
- return
99
-}
100
-
95
+require_no_open_checkout
10196
repo_init
10297
10398
# Prepare first commit
10499
#
105100
write_file f1 "f1"
106101
--- test/stash.test
+++ test/stash.test
@@ -90,16 +90,11 @@
90 proc stash-test {testid stashArgs expectedStashOutput args} {
91 fossil stash {*}$stashArgs
92 return [test_result_state stash-$testid "stash $stashArgs" $expectedStashOutput {*}$args]
93 }
94
95 catch {exec $::fossilexe info} res
96 if {![regexp {use --repository} $res]} {
97 puts stderr "Cannot run this test within an open checkout"
98 return
99 }
100
101 repo_init
102
103 # Prepare first commit
104 #
105 write_file f1 "f1"
106
--- test/stash.test
+++ test/stash.test
@@ -90,16 +90,11 @@
90 proc stash-test {testid stashArgs expectedStashOutput args} {
91 fossil stash {*}$stashArgs
92 return [test_result_state stash-$testid "stash $stashArgs" $expectedStashOutput {*}$args]
93 }
94
95 require_no_open_checkout
 
 
 
 
 
96 repo_init
97
98 # Prepare first commit
99 #
100 write_file f1 "f1"
101
+44 -10
--- test/tester.tcl
+++ test/tester.tcl
@@ -189,23 +189,48 @@
189189
set y [read_file $b]
190190
regsub -all { +\n} $y \n y
191191
return [expr {$x==$y}]
192192
}
193193
194
+proc require_no_open_checkout {} {
195
+ catch {exec $::fossilexe info} res
196
+ if {![regexp {use --repository} $res]} {
197
+ set projectName <unknown>
198
+ set localRoot <unknown>
199
+ regexp -line -- {^project-name: (.*)$} $res dummy projectName
200
+ set projectName [string trim $projectName]
201
+ regexp -line -- {^local-root: (.*)$} $res dummy localRoot
202
+ set localRoot [string trim $localRoot]
203
+ error "Detected an open checkout of project \"$projectName\",\
204
+rooted at \"$localRoot\", testing halted"
205
+ }
206
+}
207
+
208
+proc is_home_elsewhere {} {
209
+ return [expr {[info exists ::env(FOSSIL_HOME)] && \
210
+ $::env(FOSSIL_HOME) eq $::tempHomePath}]
211
+}
212
+
213
+proc set_home_to_elsewhere {} {
214
+ #
215
+ # Fossil will write data on $HOME (or $FOSSIL_HOME). We need not
216
+ # to clutter the real $HOME (or $FOSSIL_HOME) of the test caller.
217
+ #
218
+ if {[is_home_elsewhere]} {
219
+ protOut "***** FOSSIL_HOME is already elsewhere"
220
+ return
221
+ }
222
+ set ::env(FOSSIL_HOME) $::tempHomePath
223
+}
224
+
225
+#
194226
# Create and open a new Fossil repository and clean the checkout
195227
#
196228
proc repo_init {{filename ".rep.fossil"}} {
197
- if {$::env(HOME) ne [pwd]} {
198
- catch {exec $::fossilexe info} res
199
- if {![regexp {use --repository} $res]} {
200
- error "In an open checkout: cannot initialize a new repository here."
201
- }
202
- # Fossil will write data on $FOSSIL_HOME, running 'fossil new' here.
203
- # We need not to clutter the $HOME of the test caller.
204
- #
205
- set ::env(FOSSIL_HOME) [pwd]
206
- set ::env(HOME) [pwd]
229
+ if {![is_home_elsewhere]} {
230
+ require_no_open_checkout
231
+ set_home_to_elsewhere
207232
}
208233
catch {exec $::fossilexe close -f}
209234
file delete $filename
210235
exec $::fossilexe new $filename
211236
exec $::fossilexe open $filename
@@ -513,10 +538,19 @@
513538
write_file [file join $tempPath temporary.txt] [clock seconds]
514539
} error] != 0} {
515540
error "could not write file to directory \"$tempPath\",\
516541
please set TEMP variable in environment: $error"
517542
}
543
+
544
+set tempHomePath [file join $tempPath home_[pid]]
545
+
546
+if {[catch {
547
+ file mkdir $tempHomePath
548
+} error] != 0} {
549
+ error "could not make directory \"$tempHomePath\",\
550
+please set TEMP variable in environment: $error"
551
+}
518552
519553
protInit $fossilexe
520554
foreach testfile $argv {
521555
set dir [file root [file tail $testfile]]
522556
file delete -force $dir
523557
--- test/tester.tcl
+++ test/tester.tcl
@@ -189,23 +189,48 @@
189 set y [read_file $b]
190 regsub -all { +\n} $y \n y
191 return [expr {$x==$y}]
192 }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194 # Create and open a new Fossil repository and clean the checkout
195 #
196 proc repo_init {{filename ".rep.fossil"}} {
197 if {$::env(HOME) ne [pwd]} {
198 catch {exec $::fossilexe info} res
199 if {![regexp {use --repository} $res]} {
200 error "In an open checkout: cannot initialize a new repository here."
201 }
202 # Fossil will write data on $FOSSIL_HOME, running 'fossil new' here.
203 # We need not to clutter the $HOME of the test caller.
204 #
205 set ::env(FOSSIL_HOME) [pwd]
206 set ::env(HOME) [pwd]
207 }
208 catch {exec $::fossilexe close -f}
209 file delete $filename
210 exec $::fossilexe new $filename
211 exec $::fossilexe open $filename
@@ -513,10 +538,19 @@
513 write_file [file join $tempPath temporary.txt] [clock seconds]
514 } error] != 0} {
515 error "could not write file to directory \"$tempPath\",\
516 please set TEMP variable in environment: $error"
517 }
 
 
 
 
 
 
 
 
 
518
519 protInit $fossilexe
520 foreach testfile $argv {
521 set dir [file root [file tail $testfile]]
522 file delete -force $dir
523
--- test/tester.tcl
+++ test/tester.tcl
@@ -189,23 +189,48 @@
189 set y [read_file $b]
190 regsub -all { +\n} $y \n y
191 return [expr {$x==$y}]
192 }
193
194 proc require_no_open_checkout {} {
195 catch {exec $::fossilexe info} res
196 if {![regexp {use --repository} $res]} {
197 set projectName <unknown>
198 set localRoot <unknown>
199 regexp -line -- {^project-name: (.*)$} $res dummy projectName
200 set projectName [string trim $projectName]
201 regexp -line -- {^local-root: (.*)$} $res dummy localRoot
202 set localRoot [string trim $localRoot]
203 error "Detected an open checkout of project \"$projectName\",\
204 rooted at \"$localRoot\", testing halted"
205 }
206 }
207
208 proc is_home_elsewhere {} {
209 return [expr {[info exists ::env(FOSSIL_HOME)] && \
210 $::env(FOSSIL_HOME) eq $::tempHomePath}]
211 }
212
213 proc set_home_to_elsewhere {} {
214 #
215 # Fossil will write data on $HOME (or $FOSSIL_HOME). We need not
216 # to clutter the real $HOME (or $FOSSIL_HOME) of the test caller.
217 #
218 if {[is_home_elsewhere]} {
219 protOut "***** FOSSIL_HOME is already elsewhere"
220 return
221 }
222 set ::env(FOSSIL_HOME) $::tempHomePath
223 }
224
225 #
226 # Create and open a new Fossil repository and clean the checkout
227 #
228 proc repo_init {{filename ".rep.fossil"}} {
229 if {![is_home_elsewhere]} {
230 require_no_open_checkout
231 set_home_to_elsewhere
 
 
 
 
 
 
 
232 }
233 catch {exec $::fossilexe close -f}
234 file delete $filename
235 exec $::fossilexe new $filename
236 exec $::fossilexe open $filename
@@ -513,10 +538,19 @@
538 write_file [file join $tempPath temporary.txt] [clock seconds]
539 } error] != 0} {
540 error "could not write file to directory \"$tempPath\",\
541 please set TEMP variable in environment: $error"
542 }
543
544 set tempHomePath [file join $tempPath home_[pid]]
545
546 if {[catch {
547 file mkdir $tempHomePath
548 } error] != 0} {
549 error "could not make directory \"$tempHomePath\",\
550 please set TEMP variable in environment: $error"
551 }
552
553 protInit $fossilexe
554 foreach testfile $argv {
555 set dir [file root [file tail $testfile]]
556 file delete -force $dir
557
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -18,17 +18,17 @@
1818
# TH1 Docs
1919
#
2020
2121
fossil test-th-eval "hasfeature th1Docs"
2222
23
-if {$::RESULT ne "1"} then {
23
+if {$::RESULT ne "1"} {
2424
puts "Fossil was not compiled with TH1 docs support."; return
2525
}
2626
2727
fossil test-th-eval "hasfeature tcl"
2828
29
-if {$::RESULT ne "1"} then {
29
+if {$::RESULT ne "1"} {
3030
puts "Fossil was not compiled with Tcl support."; return
3131
}
3232
3333
###############################################################################
3434
@@ -41,11 +41,11 @@
4141
set data [fossil info]
4242
}
4343
4444
regexp -line -- {^repository: (.*)$} $data dummy repository
4545
46
-if {[string length $repository] == 0 || ![file exists $repository]} then {
46
+if {[string length $repository] == 0 || ![file exists $repository]} {
4747
error "unable to locate repository"
4848
}
4949
5050
set dataFileName [file join $::testdir th1-docs-input.txt]
5151
5252
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -18,17 +18,17 @@
18 # TH1 Docs
19 #
20
21 fossil test-th-eval "hasfeature th1Docs"
22
23 if {$::RESULT ne "1"} then {
24 puts "Fossil was not compiled with TH1 docs support."; return
25 }
26
27 fossil test-th-eval "hasfeature tcl"
28
29 if {$::RESULT ne "1"} then {
30 puts "Fossil was not compiled with Tcl support."; return
31 }
32
33 ###############################################################################
34
@@ -41,11 +41,11 @@
41 set data [fossil info]
42 }
43
44 regexp -line -- {^repository: (.*)$} $data dummy repository
45
46 if {[string length $repository] == 0 || ![file exists $repository]} then {
47 error "unable to locate repository"
48 }
49
50 set dataFileName [file join $::testdir th1-docs-input.txt]
51
52
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -18,17 +18,17 @@
18 # TH1 Docs
19 #
20
21 fossil test-th-eval "hasfeature th1Docs"
22
23 if {$::RESULT ne "1"} {
24 puts "Fossil was not compiled with TH1 docs support."; return
25 }
26
27 fossil test-th-eval "hasfeature tcl"
28
29 if {$::RESULT ne "1"} {
30 puts "Fossil was not compiled with Tcl support."; return
31 }
32
33 ###############################################################################
34
@@ -41,11 +41,11 @@
41 set data [fossil info]
42 }
43
44 regexp -line -- {^repository: (.*)$} $data dummy repository
45
46 if {[string length $repository] == 0 || ![file exists $repository]} {
47 error "unable to locate repository"
48 }
49
50 set dataFileName [file join $::testdir th1-docs-input.txt]
51
52
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -18,11 +18,11 @@
1818
# TH1 Hooks
1919
#
2020
2121
fossil test-th-eval "hasfeature th1Hooks"
2222
23
-if {$::RESULT ne "1"} then {
23
+if {$::RESULT ne "1"} {
2424
puts "Fossil was not compiled with TH1 hooks support."; return
2525
}
2626
2727
###############################################################################
2828
@@ -106,11 +106,11 @@
106106
###############################################################################
107107
108108
set data [fossil info]
109109
regexp -line -- {^repository: (.*)$} $data dummy repository
110110
111
-if {[string length $repository] == 0 || ![file exists $repository]} then {
111
+if {[string length $repository] == 0 || ![file exists $repository]} {
112112
error "unable to locate repository"
113113
}
114114
115115
set dataFileName [file join $::testdir th1-hooks-input.txt]
116116
117117
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -18,11 +18,11 @@
18 # TH1 Hooks
19 #
20
21 fossil test-th-eval "hasfeature th1Hooks"
22
23 if {$::RESULT ne "1"} then {
24 puts "Fossil was not compiled with TH1 hooks support."; return
25 }
26
27 ###############################################################################
28
@@ -106,11 +106,11 @@
106 ###############################################################################
107
108 set data [fossil info]
109 regexp -line -- {^repository: (.*)$} $data dummy repository
110
111 if {[string length $repository] == 0 || ![file exists $repository]} then {
112 error "unable to locate repository"
113 }
114
115 set dataFileName [file join $::testdir th1-hooks-input.txt]
116
117
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -18,11 +18,11 @@
18 # TH1 Hooks
19 #
20
21 fossil test-th-eval "hasfeature th1Hooks"
22
23 if {$::RESULT ne "1"} {
24 puts "Fossil was not compiled with TH1 hooks support."; return
25 }
26
27 ###############################################################################
28
@@ -106,11 +106,11 @@
106 ###############################################################################
107
108 set data [fossil info]
109 regexp -line -- {^repository: (.*)$} $data dummy repository
110
111 if {[string length $repository] == 0 || ![file exists $repository]} {
112 error "unable to locate repository"
113 }
114
115 set dataFileName [file join $::testdir th1-hooks-input.txt]
116
117
--- test/th1-repo.test
+++ test/th1-repo.test
@@ -19,15 +19,11 @@
1919
############################################################################
2020
#
2121
# TH1 tests that may modify the repository
2222
#
2323
24
-catch {exec $::fossilexe info} res
25
-if {![regexp {use --repository} $res]} {
26
- puts stderr "Cannot run this test within an open checkout"
27
- return
28
-}
24
+require_no_open_checkout
2925
3026
########################################
3127
# Setup: Add Files and Commit #
3228
########################################
3329
3430
--- test/th1-repo.test
+++ test/th1-repo.test
@@ -19,15 +19,11 @@
19 ############################################################################
20 #
21 # TH1 tests that may modify the repository
22 #
23
24 catch {exec $::fossilexe info} res
25 if {![regexp {use --repository} $res]} {
26 puts stderr "Cannot run this test within an open checkout"
27 return
28 }
29
30 ########################################
31 # Setup: Add Files and Commit #
32 ########################################
33
34
--- test/th1-repo.test
+++ test/th1-repo.test
@@ -19,15 +19,11 @@
19 ############################################################################
20 #
21 # TH1 tests that may modify the repository
22 #
23
24 require_no_open_checkout
 
 
 
 
25
26 ########################################
27 # Setup: Add Files and Commit #
28 ########################################
29
30
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -26,11 +26,11 @@
2626
2727
###############################################################################
2828
2929
fossil test-th-eval "hasfeature tcl"
3030
31
-if {$::RESULT ne "1"} then {
31
+if {$::RESULT ne "1"} {
3232
puts "Fossil was not compiled with Tcl support."; return
3333
}
3434
3535
###############################################################################
3636
3737
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -26,11 +26,11 @@
26
27 ###############################################################################
28
29 fossil test-th-eval "hasfeature tcl"
30
31 if {$::RESULT ne "1"} then {
32 puts "Fossil was not compiled with Tcl support."; return
33 }
34
35 ###############################################################################
36
37
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -26,11 +26,11 @@
26
27 ###############################################################################
28
29 fossil test-th-eval "hasfeature tcl"
30
31 if {$::RESULT ne "1"} {
32 puts "Fossil was not compiled with Tcl support."; return
33 }
34
35 ###############################################################################
36
37
+1 -1
--- test/th1.test
+++ test/th1.test
@@ -884,11 +884,11 @@
884884
fossil test-th-eval "globalState vfs"
885885
test th1-globalState-14 {[string length $RESULT] == 0}
886886
887887
###############################################################################
888888
889
-if {$tcl_platform(platform) eq "windows"} then {
889
+if {$tcl_platform(platform) eq "windows"} {
890890
set altVfs win32-longpath
891891
} else {
892892
set altVfs unix-dotfile
893893
}
894894
895895
--- test/th1.test
+++ test/th1.test
@@ -884,11 +884,11 @@
884 fossil test-th-eval "globalState vfs"
885 test th1-globalState-14 {[string length $RESULT] == 0}
886
887 ###############################################################################
888
889 if {$tcl_platform(platform) eq "windows"} then {
890 set altVfs win32-longpath
891 } else {
892 set altVfs unix-dotfile
893 }
894
895
--- test/th1.test
+++ test/th1.test
@@ -884,11 +884,11 @@
884 fossil test-th-eval "globalState vfs"
885 test th1-globalState-14 {[string length $RESULT] == 0}
886
887 ###############################################################################
888
889 if {$tcl_platform(platform) eq "windows"} {
890 set altVfs win32-longpath
891 } else {
892 set altVfs unix-dotfile
893 }
894
895

Keyboard Shortcuts

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