Fossil SCM

Cleanup, modularize, and robustify all test setup and cleanup.

mistachkin 2016-03-08 19:37 trunk merge
Commit fa5922169348382d82571233252606a77f6f2234
+14 -4
--- src/main.mk
+++ src/main.mk
@@ -459,15 +459,25 @@
459459
$(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
460460
461461
$(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
462462
$(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
463463
464
-# WARNING. DANGER. Running the test suite modifies the repository the
465
-# build is done from, i.e. the checkout belongs to. Do not sync/push
466
-# the repository after running the tests.
464
+# Run the test suite.
465
+# Other flags that can be included in TESTFLAGS are:
466
+#
467
+# -halt Stop testing after the first failed test
468
+# -keep Keep the temporary workspace for debugging
469
+# -prot Write a detailed log of the tests to the file ./prot
470
+# -verbose Include even more details in the output
471
+# -quiet Hide most output from the terminal
472
+# -strict Treat known bugs as failures
473
+#
474
+# TESTFLAGS can also include names of specific test files to limit
475
+# the run to just those test cases.
476
+#
467477
test: $(OBJDIR) $(APPNAME)
468
- $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
478
+ $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) -quiet $(TESTFLAGS)
469479
470480
$(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
471481
$(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
472482
473483
# Setup the options used to compile the included SQLite library.
474484
--- src/main.mk
+++ src/main.mk
@@ -459,15 +459,25 @@
459 $(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
460
461 $(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
462 $(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
463
464 # WARNING. DANGER. Running the test suite modifies the repository the
465 # build is done from, i.e. the checkout belongs to. Do not sync/push
466 # the repository after running the tests.
 
 
 
 
 
 
 
 
 
 
467 test: $(OBJDIR) $(APPNAME)
468 $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
469
470 $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
471 $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
472
473 # Setup the options used to compile the included SQLite library.
474
--- src/main.mk
+++ src/main.mk
@@ -459,15 +459,25 @@
459 $(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
460
461 $(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
462 $(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
463
464 # Run the test suite.
465 # Other flags that can be included in TESTFLAGS are:
466 #
467 # -halt Stop testing after the first failed test
468 # -keep Keep the temporary workspace for debugging
469 # -prot Write a detailed log of the tests to the file ./prot
470 # -verbose Include even more details in the output
471 # -quiet Hide most output from the terminal
472 # -strict Treat known bugs as failures
473 #
474 # TESTFLAGS can also include names of specific test files to limit
475 # the run to just those test cases.
476 #
477 test: $(OBJDIR) $(APPNAME)
478 $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) -quiet $(TESTFLAGS)
479
480 $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
481 $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
482
483 # Setup the options used to compile the included SQLite library.
484
+14 -4
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -303,15 +303,25 @@
303303
$(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
304304
305305
$(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
306306
$(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
307307
308
-# WARNING. DANGER. Running the test suite modifies the repository the
309
-# build is done from, i.e. the checkout belongs to. Do not sync/push
310
-# the repository after running the tests.
308
+# Run the test suite.
309
+# Other flags that can be included in TESTFLAGS are:
310
+#
311
+# -halt Stop testing after the first failed test
312
+# -keep Keep the temporary workspace for debugging
313
+# -prot Write a detailed log of the tests to the file ./prot
314
+# -verbose Include even more details in the output
315
+# -quiet Hide most output from the terminal
316
+# -strict Treat known bugs as failures
317
+#
318
+# TESTFLAGS can also include names of specific test files to limit
319
+# the run to just those test cases.
320
+#
311321
test: $(OBJDIR) $(APPNAME)
312
- $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
322
+ $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) -quiet $(TESTFLAGS)
313323
314324
$(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
315325
$(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
316326
$(SRCDIR)/../manifest \
317327
$(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
318328
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -303,15 +303,25 @@
303 $(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
304
305 $(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
306 $(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
307
308 # WARNING. DANGER. Running the test suite modifies the repository the
309 # build is done from, i.e. the checkout belongs to. Do not sync/push
310 # the repository after running the tests.
 
 
 
 
 
 
 
 
 
 
311 test: $(OBJDIR) $(APPNAME)
312 $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
313
314 $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
315 $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
316 $(SRCDIR)/../manifest \
317 $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
318
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -303,15 +303,25 @@
303 $(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
304
305 $(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
306 $(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
307
308 # Run the test suite.
309 # Other flags that can be included in TESTFLAGS are:
310 #
311 # -halt Stop testing after the first failed test
312 # -keep Keep the temporary workspace for debugging
313 # -prot Write a detailed log of the tests to the file ./prot
314 # -verbose Include even more details in the output
315 # -quiet Hide most output from the terminal
316 # -strict Treat known bugs as failures
317 #
318 # TESTFLAGS can also include names of specific test files to limit
319 # the run to just those test cases.
320 #
321 test: $(OBJDIR) $(APPNAME)
322 $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) -quiet $(TESTFLAGS)
323
324 $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
325 $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
326 $(SRCDIR)/../manifest \
327 $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
328
+7 -3
--- test/amend.test
+++ test/amend.test
@@ -47,26 +47,26 @@
4747
fossil status
4848
regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID
4949
}
5050
5151
# Make sure we are not in an open repository and initialize new repository
52
-repo_init
52
+test_setup
5353
5454
########################################
5555
# Setup: Add file and commit #
5656
########################################
5757
5858
if {![uuid_from_checkout UUIDINIT]} {
5959
test amend-checkout-failure false
60
- return
60
+ test_cleanup_then_return
6161
}
6262
write_file datafile "data"
6363
fossil add datafile
6464
fossil commit -m "c1"
6565
if {![uuid_from_commit $RESULT UUID]} {
6666
test amend-setup-failure false
67
- return
67
+ test_cleanup_then_return
6868
}
6969
7070
########################################
7171
# Test: -branch #
7272
########################################
@@ -401,5 +401,9 @@
401401
########################################
402402
# Test: NULL UUID #
403403
########################################
404404
fossil amend {} -close -expectError
405405
test amend-null-uuid {$CODE && [string first "no such check-in" $RESULT] != -1}
406
+
407
+###############################################################################
408
+
409
+test_cleanup
406410
--- test/amend.test
+++ test/amend.test
@@ -47,26 +47,26 @@
47 fossil status
48 regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID
49 }
50
51 # Make sure we are not in an open repository and initialize new repository
52 repo_init
53
54 ########################################
55 # Setup: Add file and commit #
56 ########################################
57
58 if {![uuid_from_checkout UUIDINIT]} {
59 test amend-checkout-failure false
60 return
61 }
62 write_file datafile "data"
63 fossil add datafile
64 fossil commit -m "c1"
65 if {![uuid_from_commit $RESULT UUID]} {
66 test amend-setup-failure false
67 return
68 }
69
70 ########################################
71 # Test: -branch #
72 ########################################
@@ -401,5 +401,9 @@
401 ########################################
402 # Test: NULL UUID #
403 ########################################
404 fossil amend {} -close -expectError
405 test amend-null-uuid {$CODE && [string first "no such check-in" $RESULT] != -1}
 
 
 
 
406
--- test/amend.test
+++ test/amend.test
@@ -47,26 +47,26 @@
47 fossil status
48 regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID
49 }
50
51 # Make sure we are not in an open repository and initialize new repository
52 test_setup
53
54 ########################################
55 # Setup: Add file and commit #
56 ########################################
57
58 if {![uuid_from_checkout UUIDINIT]} {
59 test amend-checkout-failure false
60 test_cleanup_then_return
61 }
62 write_file datafile "data"
63 fossil add datafile
64 fossil commit -m "c1"
65 if {![uuid_from_commit $RESULT UUID]} {
66 test amend-setup-failure false
67 test_cleanup_then_return
68 }
69
70 ########################################
71 # Test: -branch #
72 ########################################
@@ -401,5 +401,9 @@
401 ########################################
402 # Test: NULL UUID #
403 ########################################
404 fossil amend {} -close -expectError
405 test amend-null-uuid {$CODE && [string first "no such check-in" $RESULT] != -1}
406
407 ###############################################################################
408
409 test_cleanup
410
+5 -1
--- test/clean.test
+++ test/clean.test
@@ -16,11 +16,11 @@
1616
############################################################################
1717
#
1818
# Tests of the "clean" command, including the ability to undo it.
1919
#
2020
21
-repo_init
21
+test_setup
2222
2323
###############################################################################
2424
2525
fossil extra
2626
test clean-0 {[normalize_result] eq {}}
@@ -185,5 +185,9 @@
185185
186186
###############################################################################
187187
188188
fossil extra
189189
test clean-31 {[normalize_result] eq {}}
190
+
191
+###############################################################################
192
+
193
+test_cleanup
190194
--- test/clean.test
+++ test/clean.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # Tests of the "clean" command, including the ability to undo it.
19 #
20
21 repo_init
22
23 ###############################################################################
24
25 fossil extra
26 test clean-0 {[normalize_result] eq {}}
@@ -185,5 +185,9 @@
185
186 ###############################################################################
187
188 fossil extra
189 test clean-31 {[normalize_result] eq {}}
 
 
 
 
190
--- test/clean.test
+++ test/clean.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # Tests of the "clean" command, including the ability to undo it.
19 #
20
21 test_setup
22
23 ###############################################################################
24
25 fossil extra
26 test clean-0 {[normalize_result] eq {}}
@@ -185,5 +185,9 @@
185
186 ###############################################################################
187
188 fossil extra
189 test clean-31 {[normalize_result] eq {}}
190
191 ###############################################################################
192
193 test_cleanup
194
--- test/cmdline.test
+++ test/cmdline.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Test command line parsing
1919
#
20
+
21
+test_setup ""
2022
2123
proc cmd-line {testname args} {
2224
set i 1
2325
foreach {cmdline result} $args {
2426
fossil test-echo $cmdline
@@ -26,5 +28,9 @@
2628
incr i
2729
}
2830
}
2931
cmd-line 100 abc abc a\"bc a\"bc \"abc\" \"abc\"
3032
cmd-line 101 * * *.* *.*
33
+
34
+###############################################################################
35
+
36
+test_cleanup
3137
--- test/cmdline.test
+++ test/cmdline.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test command line parsing
19 #
 
 
20
21 proc cmd-line {testname args} {
22 set i 1
23 foreach {cmdline result} $args {
24 fossil test-echo $cmdline
@@ -26,5 +28,9 @@
26 incr i
27 }
28 }
29 cmd-line 100 abc abc a\"bc a\"bc \"abc\" \"abc\"
30 cmd-line 101 * * *.* *.*
 
 
 
 
31
--- test/cmdline.test
+++ test/cmdline.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test command line parsing
19 #
20
21 test_setup ""
22
23 proc cmd-line {testname args} {
24 set i 1
25 foreach {cmdline result} $args {
26 fossil test-echo $cmdline
@@ -26,5 +28,9 @@
28 incr i
29 }
30 }
31 cmd-line 100 abc abc a\"bc a\"bc \"abc\" \"abc\"
32 cmd-line 101 * * *.* *.*
33
34 ###############################################################################
35
36 test_cleanup
37
--- test/comment.test
+++ test/comment.test
@@ -16,10 +16,14 @@
1616
############################################################################
1717
#
1818
# Test comment formatting and printing.
1919
#
2020
21
+test_setup ""
22
+
23
+###############################################################################
24
+
2125
fossil test-comment-format "" ""
2226
test comment-1 {$RESULT eq "\n(1 lines output)"}
2327
2428
###############################################################################
2529
@@ -314,5 +318,9 @@
314318
315319
###############################################################################
316320
317321
fossil test-comment-format --width 81 --indent 9 --decode --trimcrlf --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig
318322
test comment-60 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"}
323
+
324
+###############################################################################
325
+
326
+test_cleanup
319327
--- test/comment.test
+++ test/comment.test
@@ -16,10 +16,14 @@
16 ############################################################################
17 #
18 # Test comment formatting and printing.
19 #
20
 
 
 
 
21 fossil test-comment-format "" ""
22 test comment-1 {$RESULT eq "\n(1 lines output)"}
23
24 ###############################################################################
25
@@ -314,5 +318,9 @@
314
315 ###############################################################################
316
317 fossil test-comment-format --width 81 --indent 9 --decode --trimcrlf --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig
318 test comment-60 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"}
 
 
 
 
319
--- test/comment.test
+++ test/comment.test
@@ -16,10 +16,14 @@
16 ############################################################################
17 #
18 # Test comment formatting and printing.
19 #
20
21 test_setup ""
22
23 ###############################################################################
24
25 fossil test-comment-format "" ""
26 test comment-1 {$RESULT eq "\n(1 lines output)"}
27
28 ###############################################################################
29
@@ -314,5 +318,9 @@
318
319 ###############################################################################
320
321 fossil test-comment-format --width 81 --indent 9 --decode --trimcrlf --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig
322 test comment-60 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"}
323
324 ###############################################################################
325
326 test_cleanup
327
--- test/contains-selector.test
+++ test/contains-selector.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Test containsSelector() function in src/style.c
1919
#
20
+
21
+test_setup ""
2022
2123
proc contains-selector {testId css selectorResultMap} {
2224
set css [string trim $css]
2325
set filename [file join $::tempPath compare-selector.css]
2426
set fh [open $filename w]
@@ -45,5 +47,9 @@
4547
.d 0
4648
{.c.d} 0
4749
{.c .d} 1
4850
.e 1
4951
}
52
+
53
+###############################################################################
54
+
55
+test_cleanup
5056
--- test/contains-selector.test
+++ test/contains-selector.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test containsSelector() function in src/style.c
19 #
 
 
20
21 proc contains-selector {testId css selectorResultMap} {
22 set css [string trim $css]
23 set filename [file join $::tempPath compare-selector.css]
24 set fh [open $filename w]
@@ -45,5 +47,9 @@
45 .d 0
46 {.c.d} 0
47 {.c .d} 1
48 .e 1
49 }
 
 
 
 
50
--- test/contains-selector.test
+++ test/contains-selector.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test containsSelector() function in src/style.c
19 #
20
21 test_setup ""
22
23 proc contains-selector {testId css selectorResultMap} {
24 set css [string trim $css]
25 set filename [file join $::tempPath compare-selector.css]
26 set fh [open $filename w]
@@ -45,5 +47,9 @@
47 .d 0
48 {.c.d} 0
49 {.c .d} 1
50 .e 1
51 }
52
53 ###############################################################################
54
55 test_cleanup
56
--- test/delta1.test
+++ test/delta1.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Tests of the delta mechanism.
1919
#
20
+
21
+test_setup ""
2022
2123
# Use test script files as the basis for this test.
2224
#
2325
# For each test, copy the file intact to "./t1". Make
2426
# some random changes in "./t2". Then call test-delta on the
@@ -41,5 +43,9 @@
4143
write_file t2 [random_changes $f1 1 1 0 0.4]
4244
fossil test-delta t1 t2
4345
test delta-$base-$i-3 {$RESULT=="ok"}
4446
}
4547
}
48
+
49
+###############################################################################
50
+
51
+test_cleanup
4652
--- test/delta1.test
+++ test/delta1.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the delta mechanism.
19 #
 
 
20
21 # Use test script files as the basis for this test.
22 #
23 # For each test, copy the file intact to "./t1". Make
24 # some random changes in "./t2". Then call test-delta on the
@@ -41,5 +43,9 @@
41 write_file t2 [random_changes $f1 1 1 0 0.4]
42 fossil test-delta t1 t2
43 test delta-$base-$i-3 {$RESULT=="ok"}
44 }
45 }
 
 
 
 
46
--- test/delta1.test
+++ test/delta1.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the delta mechanism.
19 #
20
21 test_setup ""
22
23 # Use test script files as the basis for this test.
24 #
25 # For each test, copy the file intact to "./t1". Make
26 # some random changes in "./t2". Then call test-delta on the
@@ -41,5 +43,9 @@
43 write_file t2 [random_changes $f1 1 1 0 0.4]
44 fossil test-delta t1 t2
45 test delta-$base-$i-3 {$RESULT=="ok"}
46 }
47 }
48
49 ###############################################################################
50
51 test_cleanup
52
+5 -1
--- test/file1.test
+++ test/file1.test
@@ -16,11 +16,11 @@
1616
############################################################################
1717
#
1818
# File utilities
1919
#
2020
21
-repo_init
21
+test_setup
2222
2323
proc simplify-name {testname args} {
2424
set i 1
2525
foreach {path result} $args {
2626
fossil test-simplify-name $path
@@ -96,5 +96,9 @@
9696
9797
catch {file delete test1/test2}
9898
catch {file delete test1}
9999
100100
if {[info exists savedPwd]} {cd $savedPwd; unset savedPwd}
101
+
102
+###############################################################################
103
+
104
+test_cleanup
101105
--- test/file1.test
+++ test/file1.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # File utilities
19 #
20
21 repo_init
22
23 proc simplify-name {testname args} {
24 set i 1
25 foreach {path result} $args {
26 fossil test-simplify-name $path
@@ -96,5 +96,9 @@
96
97 catch {file delete test1/test2}
98 catch {file delete test1}
99
100 if {[info exists savedPwd]} {cd $savedPwd; unset savedPwd}
 
 
 
 
101
--- test/file1.test
+++ test/file1.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # File utilities
19 #
20
21 test_setup
22
23 proc simplify-name {testname args} {
24 set i 1
25 foreach {path result} $args {
26 fossil test-simplify-name $path
@@ -96,5 +96,9 @@
96
97 catch {file delete test1/test2}
98 catch {file delete test1}
99
100 if {[info exists savedPwd]} {cd $savedPwd; unset savedPwd}
101
102 ###############################################################################
103
104 test_cleanup
105
--- test/glob.test
+++ test/glob.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Test glob pattern parsing
1919
#
20
+
21
+test_setup ""
2022
2123
proc glob-parse {testname args} {
2224
set i 1
2325
foreach {pattern string result} $args {
2426
fossil test-glob $pattern $string
@@ -180,5 +182,9 @@
180182
glob-parse 119 "'o*,two three,four'" "one,two three,four" \
181183
[string map [list \r\n \n] \
182184
{SQL expression: (x GLOB 'o*,two three,four')
183185
pattern[0] = [o*,two three,four]
184186
1 one,two three,four}]
187
+
188
+###############################################################################
189
+
190
+test_cleanup
185191
--- test/glob.test
+++ test/glob.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test glob pattern parsing
19 #
 
 
20
21 proc glob-parse {testname args} {
22 set i 1
23 foreach {pattern string result} $args {
24 fossil test-glob $pattern $string
@@ -180,5 +182,9 @@
180 glob-parse 119 "'o*,two three,four'" "one,two three,four" \
181 [string map [list \r\n \n] \
182 {SQL expression: (x GLOB 'o*,two three,four')
183 pattern[0] = [o*,two three,four]
184 1 one,two three,four}]
 
 
 
 
185
--- test/glob.test
+++ test/glob.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test glob pattern parsing
19 #
20
21 test_setup ""
22
23 proc glob-parse {testname args} {
24 set i 1
25 foreach {pattern string result} $args {
26 fossil test-glob $pattern $string
@@ -180,5 +182,9 @@
182 glob-parse 119 "'o*,two three,four'" "one,two three,four" \
183 [string map [list \r\n \n] \
184 {SQL expression: (x GLOB 'o*,two three,four')
185 pattern[0] = [o*,two three,four]
186 1 one,two three,four}]
187
188 ###############################################################################
189
190 test_cleanup
191
+10 -4
--- test/json.test
+++ test/json.test
@@ -24,11 +24,12 @@
2424
# not configured. If that changes, these conditions might not prevent
2525
# the rest of this file from running.
2626
fossil test-th-eval "hasfeature json"
2727
2828
if {$::RESULT ne "1"} then {
29
- puts "Fossil was not compiled with JSON support."; return
29
+ puts "Fossil was not compiled with JSON support."
30
+ test_cleanup_then_return
3031
}
3132
3233
# We need a JSON parser to effectively test the JSON produced by
3334
# fossil. It looks like the one from tcllib is exactly what we need.
3435
# On ActiveTcl, add it with teacup. On other platforms, YMMV.
@@ -47,11 +48,12 @@
4748
4849
# and that the json itself smells ok and has the expected API error code in it
4950
fossil json -expectError
5051
set JR [json2dict $RESULT]
5152
if {$JR eq ""} {
52
- puts "Fossil was not compiled with JSON support (bad JSON)."; return
53
+ puts "Fossil was not compiled with JSON support (bad JSON)."
54
+ test_cleanup_then_return
5355
}
5456
test json-1 {[dict exists $JR resultCode]
5557
&& [dict get $JR resultCode] eq "FOSSIL-4102"}
5658
5759
# Use the CLI interface to execute a JSON command. Sets the global
@@ -163,11 +165,11 @@
163165
}
164166
165167
#### VERSION AKA HAI
166168
167169
# The JSON API generally assumes we have a respository, so let it have one.
168
-repo_init
170
+test_setup
169171
170172
# Check for basic envelope fields in the result with an error
171173
fossil_json -expectError
172174
test_json_envelope json-enverr [concat resultCode fossil timestamp \
173175
resultText command procTimeUs procTimeMs] {}
@@ -666,11 +668,11 @@
666668
# is not writable" error comes back as HTML. i don't know if the
667669
# error happens before we have made the determination that the app is
668670
# in JSON mode or if the error handling is incorrectly not
669671
# recognizing JSON mode.
670672
#
671
-#repo_init x.fossil
673
+#test_setup x.fossil
672674
#catch {exec chmod 444 .rep.fossil}; # Unix. What about Win?
673675
fossil_http_json /json/timeline/checkin $U1Cookie
674676
test json-ROrepo-1-1 {$CODE == 0}
675677
test json-ROrepo-1-2 {[regexp {\}\s*$} $RESULT]}
676678
test json-ROrepo-1-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]}
@@ -845,5 +847,9 @@
845847
# Fossil repository db file is not valid.
846848
write_file nope.fossil {
847849
This is not a fossil repo. It ought to be a SQLite db with a well-known schema,
848850
but it is actually just a block of text.
849851
}
852
+
853
+###############################################################################
854
+
855
+test_cleanup
850856
--- test/json.test
+++ test/json.test
@@ -24,11 +24,12 @@
24 # not configured. If that changes, these conditions might not prevent
25 # the rest of this file from running.
26 fossil test-th-eval "hasfeature json"
27
28 if {$::RESULT ne "1"} then {
29 puts "Fossil was not compiled with JSON support."; return
 
30 }
31
32 # We need a JSON parser to effectively test the JSON produced by
33 # fossil. It looks like the one from tcllib is exactly what we need.
34 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
@@ -47,11 +48,12 @@
47
48 # and that the json itself smells ok and has the expected API error code in it
49 fossil json -expectError
50 set JR [json2dict $RESULT]
51 if {$JR eq ""} {
52 puts "Fossil was not compiled with JSON support (bad JSON)."; return
 
53 }
54 test json-1 {[dict exists $JR resultCode]
55 && [dict get $JR resultCode] eq "FOSSIL-4102"}
56
57 # Use the CLI interface to execute a JSON command. Sets the global
@@ -163,11 +165,11 @@
163 }
164
165 #### VERSION AKA HAI
166
167 # The JSON API generally assumes we have a respository, so let it have one.
168 repo_init
169
170 # Check for basic envelope fields in the result with an error
171 fossil_json -expectError
172 test_json_envelope json-enverr [concat resultCode fossil timestamp \
173 resultText command procTimeUs procTimeMs] {}
@@ -666,11 +668,11 @@
666 # is not writable" error comes back as HTML. i don't know if the
667 # error happens before we have made the determination that the app is
668 # in JSON mode or if the error handling is incorrectly not
669 # recognizing JSON mode.
670 #
671 #repo_init x.fossil
672 #catch {exec chmod 444 .rep.fossil}; # Unix. What about Win?
673 fossil_http_json /json/timeline/checkin $U1Cookie
674 test json-ROrepo-1-1 {$CODE == 0}
675 test json-ROrepo-1-2 {[regexp {\}\s*$} $RESULT]}
676 test json-ROrepo-1-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]}
@@ -845,5 +847,9 @@
845 # Fossil repository db file is not valid.
846 write_file nope.fossil {
847 This is not a fossil repo. It ought to be a SQLite db with a well-known schema,
848 but it is actually just a block of text.
849 }
 
 
 
 
850
--- test/json.test
+++ test/json.test
@@ -24,11 +24,12 @@
24 # not configured. If that changes, these conditions might not prevent
25 # the rest of this file from running.
26 fossil test-th-eval "hasfeature json"
27
28 if {$::RESULT ne "1"} then {
29 puts "Fossil was not compiled with JSON support."
30 test_cleanup_then_return
31 }
32
33 # We need a JSON parser to effectively test the JSON produced by
34 # fossil. It looks like the one from tcllib is exactly what we need.
35 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
@@ -47,11 +48,12 @@
48
49 # and that the json itself smells ok and has the expected API error code in it
50 fossil json -expectError
51 set JR [json2dict $RESULT]
52 if {$JR eq ""} {
53 puts "Fossil was not compiled with JSON support (bad JSON)."
54 test_cleanup_then_return
55 }
56 test json-1 {[dict exists $JR resultCode]
57 && [dict get $JR resultCode] eq "FOSSIL-4102"}
58
59 # Use the CLI interface to execute a JSON command. Sets the global
@@ -163,11 +165,11 @@
165 }
166
167 #### VERSION AKA HAI
168
169 # The JSON API generally assumes we have a respository, so let it have one.
170 test_setup
171
172 # Check for basic envelope fields in the result with an error
173 fossil_json -expectError
174 test_json_envelope json-enverr [concat resultCode fossil timestamp \
175 resultText command procTimeUs procTimeMs] {}
@@ -666,11 +668,11 @@
668 # is not writable" error comes back as HTML. i don't know if the
669 # error happens before we have made the determination that the app is
670 # in JSON mode or if the error handling is incorrectly not
671 # recognizing JSON mode.
672 #
673 #test_setup x.fossil
674 #catch {exec chmod 444 .rep.fossil}; # Unix. What about Win?
675 fossil_http_json /json/timeline/checkin $U1Cookie
676 test json-ROrepo-1-1 {$CODE == 0}
677 test json-ROrepo-1-2 {[regexp {\}\s*$} $RESULT]}
678 test json-ROrepo-1-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]}
@@ -845,5 +847,9 @@
847 # Fossil repository db file is not valid.
848 write_file nope.fossil {
849 This is not a fossil repo. It ought to be a SQLite db with a well-known schema,
850 but it is actually just a block of text.
851 }
852
853 ###############################################################################
854
855 test_cleanup
856
--- test/merge1.test
+++ test/merge1.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Tests of the 3-way merge
1919
#
20
+
21
+test_setup ""
2022
2123
write_file_indented t1 {
2224
111 - This is line one of the demo program - 1111
2325
222 - The second line program line in code - 2222
2426
333 - This is a test of the merging algohm - 3333
@@ -398,5 +400,9 @@
398400
STUV
399401
XYZ.
400402
}
401403
fossil 3-way-merge t1 t2 t3 a23
402404
test merge1-7.2 {[same_file t23 a23]}
405
+
406
+###############################################################################
407
+
408
+test_cleanup
403409
--- test/merge1.test
+++ test/merge1.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the 3-way merge
19 #
 
 
20
21 write_file_indented t1 {
22 111 - This is line one of the demo program - 1111
23 222 - The second line program line in code - 2222
24 333 - This is a test of the merging algohm - 3333
@@ -398,5 +400,9 @@
398 STUV
399 XYZ.
400 }
401 fossil 3-way-merge t1 t2 t3 a23
402 test merge1-7.2 {[same_file t23 a23]}
 
 
 
 
403
--- test/merge1.test
+++ test/merge1.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the 3-way merge
19 #
20
21 test_setup ""
22
23 write_file_indented t1 {
24 111 - This is line one of the demo program - 1111
25 222 - The second line program line in code - 2222
26 333 - This is a test of the merging algohm - 3333
@@ -398,5 +400,9 @@
400 STUV
401 XYZ.
402 }
403 fossil 3-way-merge t1 t2 t3 a23
404 test merge1-7.2 {[same_file t23 a23]}
405
406 ###############################################################################
407
408 test_cleanup
409
--- test/merge2.test
+++ test/merge2.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Tests of the delta mechanism.
1919
#
20
+
21
+test_setup ""
2022
2123
set filelist [glob $testdir/*]
2224
foreach f $filelist {
2325
if {[file isdir $f]} continue
2426
set base [file root [file tail $f]]
@@ -38,5 +40,9 @@
3840
test merge-$base-$i-23 {[same_file a23 t23]}
3941
fossil 3-way-merge t1 t3 t2 a32
4042
test merge-$base-$i-32 {[same_file a32 t32]}
4143
}
4244
}
45
+
46
+###############################################################################
47
+
48
+test_cleanup
4349
--- test/merge2.test
+++ test/merge2.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the delta mechanism.
19 #
 
 
20
21 set filelist [glob $testdir/*]
22 foreach f $filelist {
23 if {[file isdir $f]} continue
24 set base [file root [file tail $f]]
@@ -38,5 +40,9 @@
38 test merge-$base-$i-23 {[same_file a23 t23]}
39 fossil 3-way-merge t1 t3 t2 a32
40 test merge-$base-$i-32 {[same_file a32 t32]}
41 }
42 }
 
 
 
 
43
--- test/merge2.test
+++ test/merge2.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the delta mechanism.
19 #
20
21 test_setup ""
22
23 set filelist [glob $testdir/*]
24 foreach f $filelist {
25 if {[file isdir $f]} continue
26 set base [file root [file tail $f]]
@@ -38,5 +40,9 @@
40 test merge-$base-$i-23 {[same_file a23 t23]}
41 fossil 3-way-merge t1 t3 t2 a32
42 test merge-$base-$i-32 {[same_file a32 t32]}
43 }
44 }
45
46 ###############################################################################
47
48 test_cleanup
49
--- test/merge3.test
+++ test/merge3.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Tests of the 3-way merge
1919
#
20
+
21
+test_setup ""
2022
2123
proc merge-test {testid basis v1 v2 result} {
2224
write_file t1 [join [string trim $basis] \n]\n
2325
write_file t2 [join [string trim $v1] \n]\n
2426
write_file t3 [join [string trim $v2] \n]\n
@@ -633,5 +635,9 @@
633635
} {
634636
1 2 3 4 5 7 8 9b
635637
} {
636638
1 2 3 4 5 7 8 MINE: 9b a b c d e COM: 9 YOURS: 9b END
637639
}
640
+
641
+###############################################################################
642
+
643
+test_cleanup
638644
--- test/merge3.test
+++ test/merge3.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the 3-way merge
19 #
 
 
20
21 proc merge-test {testid basis v1 v2 result} {
22 write_file t1 [join [string trim $basis] \n]\n
23 write_file t2 [join [string trim $v1] \n]\n
24 write_file t3 [join [string trim $v2] \n]\n
@@ -633,5 +635,9 @@
633 } {
634 1 2 3 4 5 7 8 9b
635 } {
636 1 2 3 4 5 7 8 MINE: 9b a b c d e COM: 9 YOURS: 9b END
637 }
 
 
 
 
638
--- test/merge3.test
+++ test/merge3.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the 3-way merge
19 #
20
21 test_setup ""
22
23 proc merge-test {testid basis v1 v2 result} {
24 write_file t1 [join [string trim $basis] \n]\n
25 write_file t2 [join [string trim $v1] \n]\n
26 write_file t3 [join [string trim $v2] \n]\n
@@ -633,5 +635,9 @@
635 } {
636 1 2 3 4 5 7 8 9b
637 } {
638 1 2 3 4 5 7 8 MINE: 9b a b c d e COM: 9 YOURS: 9b END
639 }
640
641 ###############################################################################
642
643 test_cleanup
644
--- test/merge4.test
+++ test/merge4.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Tests of the 3-way merge
1919
#
20
+
21
+test_setup ""
2022
2123
proc merge-test {testid basis v1 v2 result1 result2} {
2224
write_file t1 [join [string trim $basis] \n]\n
2325
write_file t2 [join [string trim $v1] \n]\n
2426
write_file t3 [join [string trim $v2] \n]\n
@@ -93,5 +95,9 @@
9395
} {
9496
2b 3b 4c 5c 6c 7b 8b
9597
} {
9698
2b 3b 4c 5c 6c 7b 8b
9799
}
100
+
101
+###############################################################################
102
+
103
+test_cleanup
98104
--- test/merge4.test
+++ test/merge4.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the 3-way merge
19 #
 
 
20
21 proc merge-test {testid basis v1 v2 result1 result2} {
22 write_file t1 [join [string trim $basis] \n]\n
23 write_file t2 [join [string trim $v1] \n]\n
24 write_file t3 [join [string trim $v2] \n]\n
@@ -93,5 +95,9 @@
93 } {
94 2b 3b 4c 5c 6c 7b 8b
95 } {
96 2b 3b 4c 5c 6c 7b 8b
97 }
 
 
 
 
98
--- test/merge4.test
+++ test/merge4.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Tests of the 3-way merge
19 #
20
21 test_setup ""
22
23 proc merge-test {testid basis v1 v2 result1 result2} {
24 write_file t1 [join [string trim $basis] \n]\n
25 write_file t2 [join [string trim $v1] \n]\n
26 write_file t3 [join [string trim $v2] \n]\n
@@ -93,5 +95,9 @@
95 } {
96 2b 3b 4c 5c 6c 7b 8b
97 } {
98 2b 3b 4c 5c 6c 7b 8b
99 }
100
101 ###############################################################################
102
103 test_cleanup
104
--- 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; test_setup ""
5042
5143
# Construct a test repository
5244
#
5345
exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
5446
fossil rebuild m5.fossil
@@ -309,5 +301,9 @@
309301
checkout-test 142 {
310302
7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt
311303
98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt
312304
e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt
313305
}
306
+
307
+###############################################################################
308
+
309
+test_cleanup
314310
--- 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
@@ -309,5 +301,9 @@
309 checkout-test 142 {
310 7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt
311 98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt
312 e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt
313 }
 
 
 
 
314
--- 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; test_setup ""
 
 
 
 
 
 
 
 
42
43 # Construct a test repository
44 #
45 exec $::fossilexe sqlite3 --no-repository m5.fossil <$testdir/${testfile}_repo.sql
46 fossil rebuild m5.fossil
@@ -309,5 +301,9 @@
301 checkout-test 142 {
302 7eaf64a2c9141277b4c24259c7766d6a77047af7 one.txt
303 98e47f99bb9fed4fdcd407f553615ca7f15a38a2 three.txt
304 e58c5da3e6007d0e30600ea31611813093ad180f two-rename.txt
305 }
306
307 ###############################################################################
308
309 test_cleanup
310
--- test/merge6.test
+++ test/merge6.test
@@ -20,11 +20,11 @@
2020
2121
####################################################################
2222
# TEST 1: Handle multiple merges each with one or more ADDED files #
2323
####################################################################
2424
25
-repo_init
25
+test_setup
2626
fossil ls
2727
2828
test merge_multi-0 {[normalize_result] eq {}}
2929
3030
write_file f1 "f1 line"
@@ -63,5 +63,9 @@
6363
6464
test merge_multi-4 {[normalize_result] eq {f1
6565
f2
6666
f3
6767
f4}} knownBug
68
+
69
+###############################################################################
70
+
71
+test_cleanup
6872
--- test/merge6.test
+++ test/merge6.test
@@ -20,11 +20,11 @@
20
21 ####################################################################
22 # TEST 1: Handle multiple merges each with one or more ADDED files #
23 ####################################################################
24
25 repo_init
26 fossil ls
27
28 test merge_multi-0 {[normalize_result] eq {}}
29
30 write_file f1 "f1 line"
@@ -63,5 +63,9 @@
63
64 test merge_multi-4 {[normalize_result] eq {f1
65 f2
66 f3
67 f4}} knownBug
 
 
 
 
68
--- test/merge6.test
+++ test/merge6.test
@@ -20,11 +20,11 @@
20
21 ####################################################################
22 # TEST 1: Handle multiple merges each with one or more ADDED files #
23 ####################################################################
24
25 test_setup
26 fossil ls
27
28 test merge_multi-0 {[normalize_result] eq {}}
29
30 write_file f1 "f1 line"
@@ -63,5 +63,9 @@
63
64 test merge_multi-4 {[normalize_result] eq {f1
65 f2
66 f3
67 f4}} knownBug
68
69 ###############################################################################
70
71 test_cleanup
72
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -1,22 +1,18 @@
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
17
-repo_init
13
+test_setup
1814
1915
write_file f1 "line"
2016
fossil add f1
2117
fossil commit -m "c1"
2218
fossil tag add pivot current
@@ -70,11 +66,11 @@
7066
######################################
7167
# Test 2 #
7268
# Reported: Ticket [74413366fe5067] #
7369
######################################
7470
75
-repo_init
71
+test_setup
7672
7773
write_file f1 "line"
7874
fossil add f1
7975
fossil commit -m "base file"
8076
fossil tag add pivot current
@@ -118,11 +114,11 @@
118114
######################################
119115
# Test 3 #
120116
# Reported: Ticket [30b28cf351] #
121117
######################################
122118
123
-repo_init
119
+test_setup
124120
125121
write_file f1 "line"
126122
fossil add f1
127123
fossil commit -m "base file"
128124
fossil tag add pivot current
@@ -173,11 +169,11 @@
173169
######################################
174170
# Test 5 #
175171
# Handle Rename/Add via Merge #
176172
######################################
177173
178
-repo_init
174
+test_setup
179175
180176
write_file f1 "old f1 line"
181177
fossil add f1
182178
fossil commit -m "base file"
183179
@@ -207,5 +203,9 @@
207203
# Tests for troubles not specifically linked with renames but that I'd like to
208204
# write:
209205
# [c26c63eb1b] - 'merge --backout' does not handle conflicts properly
210206
# [953031915f] - Lack of warning when overwriting extra files
211207
# [4df5f38f1e] - Troubles merging a file delete with a file change
208
+
209
+###############################################################################
210
+
211
+test_cleanup
212212
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -1,22 +1,18 @@
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
17 repo_init
18
19 write_file f1 "line"
20 fossil add f1
21 fossil commit -m "c1"
22 fossil tag add pivot current
@@ -70,11 +66,11 @@
70 ######################################
71 # Test 2 #
72 # Reported: Ticket [74413366fe5067] #
73 ######################################
74
75 repo_init
76
77 write_file f1 "line"
78 fossil add f1
79 fossil commit -m "base file"
80 fossil tag add pivot current
@@ -118,11 +114,11 @@
118 ######################################
119 # Test 3 #
120 # Reported: Ticket [30b28cf351] #
121 ######################################
122
123 repo_init
124
125 write_file f1 "line"
126 fossil add f1
127 fossil commit -m "base file"
128 fossil tag add pivot current
@@ -173,11 +169,11 @@
173 ######################################
174 # Test 5 #
175 # Handle Rename/Add via Merge #
176 ######################################
177
178 repo_init
179
180 write_file f1 "old f1 line"
181 fossil add f1
182 fossil commit -m "base file"
183
@@ -207,5 +203,9 @@
207 # Tests for troubles not specifically linked with renames but that I'd like to
208 # write:
209 # [c26c63eb1b] - 'merge --backout' does not handle conflicts properly
210 # [953031915f] - Lack of warning when overwriting extra files
211 # [4df5f38f1e] - Troubles merging a file delete with a file change
 
 
 
 
212
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -1,22 +1,18 @@
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
13 test_setup
14
15 write_file f1 "line"
16 fossil add f1
17 fossil commit -m "c1"
18 fossil tag add pivot current
@@ -70,11 +66,11 @@
66 ######################################
67 # Test 2 #
68 # Reported: Ticket [74413366fe5067] #
69 ######################################
70
71 test_setup
72
73 write_file f1 "line"
74 fossil add f1
75 fossil commit -m "base file"
76 fossil tag add pivot current
@@ -118,11 +114,11 @@
114 ######################################
115 # Test 3 #
116 # Reported: Ticket [30b28cf351] #
117 ######################################
118
119 test_setup
120
121 write_file f1 "line"
122 fossil add f1
123 fossil commit -m "base file"
124 fossil tag add pivot current
@@ -173,11 +169,11 @@
169 ######################################
170 # Test 5 #
171 # Handle Rename/Add via Merge #
172 ######################################
173
174 test_setup
175
176 write_file f1 "old f1 line"
177 fossil add f1
178 fossil commit -m "base file"
179
@@ -207,5 +203,9 @@
203 # Tests for troubles not specifically linked with renames but that I'd like to
204 # write:
205 # [c26c63eb1b] - 'merge --backout' does not handle conflicts properly
206 # [953031915f] - Lack of warning when overwriting extra files
207 # [4df5f38f1e] - Troubles merging a file delete with a file change
208
209 ###############################################################################
210
211 test_cleanup
212
+6 -8
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -16,28 +16,22 @@
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
31
-set rootDir [file normalize [pwd]]
27
+test_setup; set rootDir [file normalize [pwd]]
3228
3329
set undoMsg "\n \"fossil undo\" is\
3430
available to undo changes to the\
3531
working checkout."
3632
37
-repo_init
38
-
3933
write_file f1 "f1"
4034
write_file f2 "f2"
4135
write_file f3 "f3"
4236
write_file f4 "f4"
4337
write_file f5 "f5"
@@ -387,5 +381,9 @@
387381
test rm-hard-absolute-6 {
388382
[normalize_result] eq "REVERT f8${undoMsg}"
389383
}
390384
391385
cd $rootDir
386
+
387
+###############################################################################
388
+
389
+test_cleanup
392390
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -16,28 +16,22 @@
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 set rootDir [file normalize [pwd]]
32
33 set undoMsg "\n \"fossil undo\" is\
34 available to undo changes to the\
35 working checkout."
36
37 repo_init
38
39 write_file f1 "f1"
40 write_file f2 "f2"
41 write_file f3 "f3"
42 write_file f4 "f4"
43 write_file f5 "f5"
@@ -387,5 +381,9 @@
387 test rm-hard-absolute-6 {
388 [normalize_result] eq "REVERT f8${undoMsg}"
389 }
390
391 cd $rootDir
 
 
 
 
392
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -16,28 +16,22 @@
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_setup; set rootDir [file normalize [pwd]]
28
29 set undoMsg "\n \"fossil undo\" is\
30 available to undo changes to the\
31 working checkout."
32
 
 
33 write_file f1 "f1"
34 write_file f2 "f2"
35 write_file f3 "f3"
36 write_file f4 "f4"
37 write_file f5 "f5"
@@ -387,5 +381,9 @@
381 test rm-hard-absolute-6 {
382 [normalize_result] eq "REVERT f8${undoMsg}"
383 }
384
385 cd $rootDir
386
387 ###############################################################################
388
389 test_cleanup
390
--- test/revert.test
+++ test/revert.test
@@ -54,17 +54,12 @@
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
-
65
-repo_init
59
+require_no_open_checkout
60
+test_setup
6661
6762
# Prepare first commit
6863
#
6964
write_file f1 "f1"
7065
write_file f2 "f2"
@@ -162,11 +157,11 @@
162157
163158
164159
# Test reverting the combination of a renamed file and an added file that
165160
# uses the renamed file's original filename.
166161
#
167
-repo_init
162
+test_setup
168163
write_file f1 "f1"
169164
fossil add f1
170165
fossil commit -m "add f1"
171166
172167
write_file f1n "f1n"
@@ -180,11 +175,11 @@
180175
} -exists {f1} -notexists {f1n}
181176
182177
183178
# Test reverting a rename in the repo but not completed in the file
184179
# system
185
-repo_init
180
+test_setup
186181
write_file f1 "f1"
187182
fossil add f1
188183
fossil commit -m "add f1"
189184
fossil mv --soft f1 f1new
190185
test 3-mv-1 {[file exists f1]}
@@ -191,5 +186,9 @@
191186
test 3-mv-2 {![file exists f1new]}
192187
revert-test 3-1 {} {
193188
REVERT f1
194189
DELETE f1new
195190
} -exists {f1} -notexists {f1n}
191
+
192
+###############################################################################
193
+
194
+test_cleanup
196195
--- test/revert.test
+++ test/revert.test
@@ -54,17 +54,12 @@
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 write_file f2 "f2"
@@ -162,11 +157,11 @@
162
163
164 # Test reverting the combination of a renamed file and an added file that
165 # uses the renamed file's original filename.
166 #
167 repo_init
168 write_file f1 "f1"
169 fossil add f1
170 fossil commit -m "add f1"
171
172 write_file f1n "f1n"
@@ -180,11 +175,11 @@
180 } -exists {f1} -notexists {f1n}
181
182
183 # Test reverting a rename in the repo but not completed in the file
184 # system
185 repo_init
186 write_file f1 "f1"
187 fossil add f1
188 fossil commit -m "add f1"
189 fossil mv --soft f1 f1new
190 test 3-mv-1 {[file exists f1]}
@@ -191,5 +186,9 @@
191 test 3-mv-2 {![file exists f1new]}
192 revert-test 3-1 {} {
193 REVERT f1
194 DELETE f1new
195 } -exists {f1} -notexists {f1n}
 
 
 
 
196
--- test/revert.test
+++ test/revert.test
@@ -54,17 +54,12 @@
54 }
55
56 fossil undo
57 }
58
59 require_no_open_checkout
60 test_setup
 
 
 
 
 
61
62 # Prepare first commit
63 #
64 write_file f1 "f1"
65 write_file f2 "f2"
@@ -162,11 +157,11 @@
157
158
159 # Test reverting the combination of a renamed file and an added file that
160 # uses the renamed file's original filename.
161 #
162 test_setup
163 write_file f1 "f1"
164 fossil add f1
165 fossil commit -m "add f1"
166
167 write_file f1n "f1n"
@@ -180,11 +175,11 @@
175 } -exists {f1} -notexists {f1n}
176
177
178 # Test reverting a rename in the repo but not completed in the file
179 # system
180 test_setup
181 write_file f1 "f1"
182 fossil add f1
183 fossil commit -m "add f1"
184 fossil mv --soft f1 f1new
185 test 3-mv-1 {[file exists f1]}
@@ -191,5 +186,9 @@
186 test 3-mv-2 {![file exists f1new]}
187 revert-test 3-1 {} {
188 REVERT f1
189 DELETE f1new
190 } -exists {f1} -notexists {f1n}
191
192 ###############################################################################
193
194 test_cleanup
195
+15 -16
--- test/stash.test
+++ test/stash.test
@@ -90,17 +90,12 @@
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
-
101
-repo_init
95
+require_no_open_checkout
96
+test_setup
10297
10398
# Prepare first commit
10499
#
105100
write_file f1 "f1"
106101
write_file f2 "f2"
@@ -231,11 +226,11 @@
231226
# uses the renamed file's original filename. I expect to see the same
232227
# behavior as fossil revert: calmly back out both the rename and the
233228
# add, and presumably stash the content of the added file before it
234229
# is replaced by the revert.
235230
#
236
-repo_init
231
+test_setup
237232
write_file f1 "f1"
238233
fossil add f1
239234
fossil commit -m "add f1"
240235
241236
write_file f1n "f1n"
@@ -254,11 +249,11 @@
254249
255250
# Test stashing a newly added (but never committed) file. As with
256251
# fossil revert, fossil stash save unmanages the new file, but
257252
# leaves the copy present on disk. This is undocumented, but
258253
# probably sensible.
259
-repo_init
254
+test_setup
260255
write_file f1 "f1"
261256
write_file f2 "f2"
262257
fossil add f1 f2
263258
fossil commit -m "baseline"
264259
@@ -288,21 +283,21 @@
288283
289284
290285
# Test stashing a rename of one file with at least one file
291286
# unchanged. This should stash (and revert) just the rename
292287
# operation. Instead it also stores and touches the unchanged file.
293
-repo_init
288
+test_setup
294289
write_file f1 "f1"
295290
write_file f2 "f2"
296291
fossil add f1 f2
297292
fossil commit -m "baseline"
298293
299294
fossil mv --hard f2 f2n
300
-test_result_state stash-3-4-mv "mv --hard f2 f2n" {
295
+test_result_state stash-3-2-mv "mv --hard f2 f2n" [concat {
301296
RENAME f2 f2n
302
- MOVED_FILE f2
303
-} -changes {
297
+ MOVED_FILE} [file normalize f2] {
298
+}] -changes {
304299
RENAMED f2n
305300
} -addremove {
306301
} -exists {f1 f2n} -notexists {f2}
307302
308303
stash-test 3-2 {save -m f2n} {
@@ -325,11 +320,11 @@
325320
326321
327322
########
328323
# fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
329324
330
-repo_init
325
+test_setup
331326
write_file f1 "f1"
332327
write_file f2 "f2"
333328
write_file f3 "f3"
334329
fossil add f1 f2 f3
335330
fossil commit -m "c1" --tag c1
@@ -362,11 +357,11 @@
362357
DELETED f1
363358
EDITED f2
364359
} -addremove {
365360
} -exists {f0 f2 f3} -notexists {f1}
366361
fossil stash diff
367
-test stash-4-2-diff-CODE {!$::CODE} ;# knownBug
362
+test stash-4-2-diff-CODE {!$::CODE} knownBug
368363
fossil stash show
369364
test stash-4-2-show-1 {[regexp {DELETE f1} $RESULT]}
370365
test stash-4-2-show-2 {[regexp {CHANGED f2} $RESULT]}
371366
test stash-4-2-show-3 {[regexp {ADDED f0} $RESULT]}
372367
@@ -381,11 +376,11 @@
381376
EDITED f2
382377
RENAMED f3n
383378
} -addremove {
384379
} -exists {f0 f2 f3n} -notexists {f1 f3}
385380
fossil stash diff
386
-test stash-4-3-diff-CODE {!$::CODE} ;# knownBug
381
+test stash-4-3-diff-CODE {!$::CODE} knownBug
387382
fossil stash show
388383
test stash-4-3-show-1 {[regexp {DELETE f1} $RESULT]}
389384
test stash-4-3-show-2 {[regexp {CHANGED f2} $RESULT]}
390385
test stash-4-3-show-2 {[regexp {CHANGED f3n} $RESULT]}
391386
test stash-4-3-show-3 {[regexp {ADDED f0} $RESULT]}
@@ -394,5 +389,9 @@
394389
# fossil stash goto ?STASHID?
395390
# fossil stash rm|drop ?STASHID? ?-a|--all?
396391
397392
#fossil checkout --force c1
398393
#fossil clean
394
+
395
+###############################################################################
396
+
397
+test_cleanup
399398
--- test/stash.test
+++ test/stash.test
@@ -90,17 +90,12 @@
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 write_file f2 "f2"
@@ -231,11 +226,11 @@
231 # uses the renamed file's original filename. I expect to see the same
232 # behavior as fossil revert: calmly back out both the rename and the
233 # add, and presumably stash the content of the added file before it
234 # is replaced by the revert.
235 #
236 repo_init
237 write_file f1 "f1"
238 fossil add f1
239 fossil commit -m "add f1"
240
241 write_file f1n "f1n"
@@ -254,11 +249,11 @@
254
255 # Test stashing a newly added (but never committed) file. As with
256 # fossil revert, fossil stash save unmanages the new file, but
257 # leaves the copy present on disk. This is undocumented, but
258 # probably sensible.
259 repo_init
260 write_file f1 "f1"
261 write_file f2 "f2"
262 fossil add f1 f2
263 fossil commit -m "baseline"
264
@@ -288,21 +283,21 @@
288
289
290 # Test stashing a rename of one file with at least one file
291 # unchanged. This should stash (and revert) just the rename
292 # operation. Instead it also stores and touches the unchanged file.
293 repo_init
294 write_file f1 "f1"
295 write_file f2 "f2"
296 fossil add f1 f2
297 fossil commit -m "baseline"
298
299 fossil mv --hard f2 f2n
300 test_result_state stash-3-4-mv "mv --hard f2 f2n" {
301 RENAME f2 f2n
302 MOVED_FILE f2
303 } -changes {
304 RENAMED f2n
305 } -addremove {
306 } -exists {f1 f2n} -notexists {f2}
307
308 stash-test 3-2 {save -m f2n} {
@@ -325,11 +320,11 @@
325
326
327 ########
328 # fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
329
330 repo_init
331 write_file f1 "f1"
332 write_file f2 "f2"
333 write_file f3 "f3"
334 fossil add f1 f2 f3
335 fossil commit -m "c1" --tag c1
@@ -362,11 +357,11 @@
362 DELETED f1
363 EDITED f2
364 } -addremove {
365 } -exists {f0 f2 f3} -notexists {f1}
366 fossil stash diff
367 test stash-4-2-diff-CODE {!$::CODE} ;# knownBug
368 fossil stash show
369 test stash-4-2-show-1 {[regexp {DELETE f1} $RESULT]}
370 test stash-4-2-show-2 {[regexp {CHANGED f2} $RESULT]}
371 test stash-4-2-show-3 {[regexp {ADDED f0} $RESULT]}
372
@@ -381,11 +376,11 @@
381 EDITED f2
382 RENAMED f3n
383 } -addremove {
384 } -exists {f0 f2 f3n} -notexists {f1 f3}
385 fossil stash diff
386 test stash-4-3-diff-CODE {!$::CODE} ;# knownBug
387 fossil stash show
388 test stash-4-3-show-1 {[regexp {DELETE f1} $RESULT]}
389 test stash-4-3-show-2 {[regexp {CHANGED f2} $RESULT]}
390 test stash-4-3-show-2 {[regexp {CHANGED f3n} $RESULT]}
391 test stash-4-3-show-3 {[regexp {ADDED f0} $RESULT]}
@@ -394,5 +389,9 @@
394 # fossil stash goto ?STASHID?
395 # fossil stash rm|drop ?STASHID? ?-a|--all?
396
397 #fossil checkout --force c1
398 #fossil clean
 
 
 
 
399
--- test/stash.test
+++ test/stash.test
@@ -90,17 +90,12 @@
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 test_setup
 
 
 
 
 
97
98 # Prepare first commit
99 #
100 write_file f1 "f1"
101 write_file f2 "f2"
@@ -231,11 +226,11 @@
226 # uses the renamed file's original filename. I expect to see the same
227 # behavior as fossil revert: calmly back out both the rename and the
228 # add, and presumably stash the content of the added file before it
229 # is replaced by the revert.
230 #
231 test_setup
232 write_file f1 "f1"
233 fossil add f1
234 fossil commit -m "add f1"
235
236 write_file f1n "f1n"
@@ -254,11 +249,11 @@
249
250 # Test stashing a newly added (but never committed) file. As with
251 # fossil revert, fossil stash save unmanages the new file, but
252 # leaves the copy present on disk. This is undocumented, but
253 # probably sensible.
254 test_setup
255 write_file f1 "f1"
256 write_file f2 "f2"
257 fossil add f1 f2
258 fossil commit -m "baseline"
259
@@ -288,21 +283,21 @@
283
284
285 # Test stashing a rename of one file with at least one file
286 # unchanged. This should stash (and revert) just the rename
287 # operation. Instead it also stores and touches the unchanged file.
288 test_setup
289 write_file f1 "f1"
290 write_file f2 "f2"
291 fossil add f1 f2
292 fossil commit -m "baseline"
293
294 fossil mv --hard f2 f2n
295 test_result_state stash-3-2-mv "mv --hard f2 f2n" [concat {
296 RENAME f2 f2n
297 MOVED_FILE} [file normalize f2] {
298 }] -changes {
299 RENAMED f2n
300 } -addremove {
301 } -exists {f1 f2n} -notexists {f2}
302
303 stash-test 3-2 {save -m f2n} {
@@ -325,11 +320,11 @@
320
321
322 ########
323 # fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
324
325 test_setup
326 write_file f1 "f1"
327 write_file f2 "f2"
328 write_file f3 "f3"
329 fossil add f1 f2 f3
330 fossil commit -m "c1" --tag c1
@@ -362,11 +357,11 @@
357 DELETED f1
358 EDITED f2
359 } -addremove {
360 } -exists {f0 f2 f3} -notexists {f1}
361 fossil stash diff
362 test stash-4-2-diff-CODE {!$::CODE} knownBug
363 fossil stash show
364 test stash-4-2-show-1 {[regexp {DELETE f1} $RESULT]}
365 test stash-4-2-show-2 {[regexp {CHANGED f2} $RESULT]}
366 test stash-4-2-show-3 {[regexp {ADDED f0} $RESULT]}
367
@@ -381,11 +376,11 @@
376 EDITED f2
377 RENAMED f3n
378 } -addremove {
379 } -exists {f0 f2 f3n} -notexists {f1 f3}
380 fossil stash diff
381 test stash-4-3-diff-CODE {!$::CODE} knownBug
382 fossil stash show
383 test stash-4-3-show-1 {[regexp {DELETE f1} $RESULT]}
384 test stash-4-3-show-2 {[regexp {CHANGED f2} $RESULT]}
385 test stash-4-3-show-2 {[regexp {CHANGED f3n} $RESULT]}
386 test stash-4-3-show-3 {[regexp {ADDED f0} $RESULT]}
@@ -394,5 +389,9 @@
389 # fossil stash goto ?STASHID?
390 # fossil stash rm|drop ?STASHID? ?-a|--all?
391
392 #fossil checkout --force c1
393 #fossil clean
394
395 ###############################################################################
396
397 test_cleanup
398
+202 -30
--- test/tester.tcl
+++ test/tester.tcl
@@ -32,10 +32,18 @@
3232
[string length [file extension $fossilexe]] == 0} {
3333
append fossilexe .exe
3434
}
3535
3636
set argv [lrange $argv 1 end]
37
+
38
+set i [lsearch $argv -keep]
39
+if {$i>=0} {
40
+ set KEEP 1
41
+ set argv [lreplace $argv $i $i]
42
+} else {
43
+ set KEEP 0
44
+}
3745
3846
set i [lsearch $argv -halt]
3947
if {$i>=0} {
4048
set HALT 1
4149
set argv [lreplace $argv $i $i]
@@ -189,30 +197,134 @@
189197
set y [read_file $b]
190198
regsub -all { +\n} $y \n y
191199
return [expr {$x==$y}]
192200
}
193201
202
+proc require_no_open_checkout {} {
203
+ if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
204
+ $::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
205
+ return
206
+ }
207
+ catch {exec $::fossilexe info} res
208
+ if {![regexp {use --repository} $res]} {
209
+ set projectName <unknown>
210
+ set localRoot <unknown>
211
+ regexp -line -- {^project-name: (.*)$} $res dummy projectName
212
+ set projectName [string trim $projectName]
213
+ regexp -line -- {^local-root: (.*)$} $res dummy localRoot
214
+ set localRoot [string trim $localRoot]
215
+ error "Detected an open checkout of project \"$projectName\",\
216
+rooted at \"$localRoot\", testing halted."
217
+ }
218
+}
219
+
220
+proc get_script_or_fail {} {
221
+ set fileName [file normalize [info script]]
222
+ if {[string length $fileName] == 0 || ![file exists $fileName]} {
223
+ error "Failed to obtain the file name of the test being run."
224
+ }
225
+ return $fileName
226
+}
227
+
228
+proc robust_delete { path {force ""} } {
229
+ set error "unknown error"
230
+ for {set try 0} {$try < 10} {incr try} {
231
+ if {$force eq "YES_DO_IT"} {
232
+ if {[catch {file delete -force $path} error] == 0} {
233
+ return
234
+ }
235
+ } else {
236
+ if {[catch {file delete $path} error] == 0} {
237
+ return
238
+ }
239
+ }
240
+ after [expr {$try * 100}]
241
+ }
242
+ error "Could not delete \"$path\", error: $error"
243
+}
244
+
245
+proc test_cleanup_then_return {} {
246
+ uplevel 1 [list test_cleanup]
247
+ return -code return
248
+}
249
+
250
+proc test_cleanup {} {
251
+ if {$::KEEP} {return}; # All cleanup disabled?
252
+ if {![info exists ::tempRepoPath]} {return}
253
+ if {![file exists $::tempRepoPath]} {return}
254
+ if {![file isdirectory $::tempRepoPath]} {return}
255
+ set tempPathEnd [expr {[string length $::tempPath] - 1}]
256
+ if {[string length $::tempPath] == 0 || \
257
+ [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
258
+ error "Temporary repository path has wrong parent during cleanup."
259
+ }
260
+ if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd}
261
+ # First, attempt to delete the specific temporary repository directories
262
+ # for this test file.
263
+ set scriptName [file tail [get_script_or_fail]]
264
+ foreach repoSeed $::tempRepoSeeds {
265
+ set repoPath [file join $::tempRepoPath $repoSeed $scriptName]
266
+ robust_delete $repoPath YES_DO_IT; # FORCE, arbitrary children.
267
+ set seedPath [file join $::tempRepoPath $repoSeed]
268
+ robust_delete $seedPath; # NO FORCE.
269
+ }
270
+ # Next, attempt to gracefully delete the temporary repository directory
271
+ # for this process.
272
+ robust_delete $::tempRepoPath
273
+ # Finally, attempt to gracefully delete the temporary home directory,
274
+ # unless forbidden by external forces.
275
+ if {![info exists ::tempKeepHome]} {delete_temporary_home}
276
+}
277
+
278
+proc delete_temporary_home {} {
279
+ if {$::KEEP} {return}; # All cleanup disabled?
280
+ if {$::tcl_platform(platform) eq "windows"} {
281
+ robust_delete [file join $::tempHomePath _fossil]
282
+ } else {
283
+ robust_delete [file join $::tempHomePath .fossil]
284
+ }
285
+ robust_delete $::tempHomePath
286
+}
287
+
288
+proc is_home_elsewhere {} {
289
+ return [expr {[info exists ::env(FOSSIL_HOME)] && \
290
+ $::env(FOSSIL_HOME) eq $::tempHomePath}]
291
+}
292
+
293
+proc set_home_to_elsewhere {} {
294
+ #
295
+ # Fossil will write data on $HOME (or $FOSSIL_HOME). We need not
296
+ # to clutter the real $HOME (or $FOSSIL_HOME) of the test caller.
297
+ #
298
+ if {[is_home_elsewhere]} {return}
299
+ set ::env(FOSSIL_HOME) $::tempHomePath
300
+}
301
+
302
+#
194303
# Create and open a new Fossil repository and clean the checkout
195304
#
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
212
- exec $::fossilexe clean -f
213
- exec $::fossilexe set mtime-changes off
305
+proc test_setup {{filename ".rep.fossil"}} {
306
+ set_home_to_elsewhere
307
+ if {![info exists ::tempRepoPath]} {
308
+ set ::tempRepoPath [file join $::tempPath repo_[pid]]
309
+ }
310
+ set repoSeed [appendArgs [string trim [clock seconds] -] _ [getSeqNo]]
311
+ lappend ::tempRepoSeeds $repoSeed
312
+ set repoPath [file join \
313
+ $::tempRepoPath $repoSeed [file tail [get_script_or_fail]]]
314
+ if {[catch {
315
+ file mkdir $repoPath
316
+ } error] != 0} {
317
+ error "Could not make directory \"$repoPath\",\
318
+please set TEMP variable in environment, error: $error"
319
+ }
320
+ if {![info exists ::tempSavedPwd]} {set ::tempSavedPwd [pwd]}; cd $repoPath
321
+ if {[string length $filename] > 0} {
322
+ exec $::fossilexe new $filename
323
+ exec $::fossilexe open $filename
324
+ exec $::fossilexe set mtime-changes off
325
+ }
214326
}
215327
216328
# This procedure only returns non-zero if the Tcl integration feature was
217329
# enabled at compile-time and is now enabled at runtime.
218330
proc is_tcl_usable_by_fossil {} {
@@ -284,10 +396,67 @@
284396
# Append all arguments into a single value and then returns it.
285397
#
286398
proc appendArgs {args} {
287399
eval append result $args
288400
}
401
+
402
+# Returns the value of the specified environment variable -OR- any empty
403
+# string if it does not exist.
404
+#
405
+proc getEnvironmentVariable { name } {
406
+ return [expr {[info exists ::env($name)] ? $::env($name) : ""}]
407
+}
408
+
409
+# Returns a usable temporary directory -OR- fails the testing process.
410
+#
411
+proc getTemporaryPath {} {
412
+ #
413
+ # NOTE: Build the list of "temporary directory" environment variables
414
+ # to check, including all reasonable "cases" of the environment
415
+ # variable names.
416
+ #
417
+ set names [list]
418
+
419
+ #
420
+ # TODO: Add more here, if necessary.
421
+ #
422
+ foreach name [list FOSSIL_TEST_TEMP FOSSIL_TEMP TEMP TMP] {
423
+ lappend names [string toupper $name] [string tolower $name] \
424
+ [string totitle $name]
425
+ }
426
+
427
+ #
428
+ # NOTE: Check if we can use any of the environment variables.
429
+ #
430
+ foreach name $names {
431
+ set value [getEnvironmentVariable $name]
432
+
433
+ if {[string length $value] > 0} then {
434
+ set value [file normalize $value]
435
+
436
+ if {[file exists $value] && [file isdirectory $value]} then {
437
+ return $value
438
+ }
439
+ }
440
+ }
441
+
442
+ #
443
+ # NOTE: On non-Windows systems, fallback to /tmp if it is usable.
444
+ #
445
+ if {$::tcl_platform(platform) ne "windows"} {
446
+ set value /tmp
447
+
448
+ if {[file exists $value] && [file isdirectory $value]} then {
449
+ return $value
450
+ }
451
+ }
452
+
453
+ #
454
+ # NOTE: There must be a usable temporary directory to continue testing.
455
+ #
456
+ error "Cannot find a usable temporary directory, testing halted."
457
+}
289458
290459
# Return the name of the versioned settings file containing the TH1
291460
# setup script.
292461
#
293462
proc getTh1SetupFileName {} {
@@ -498,38 +667,41 @@
498667
# returns the third to last line of the normalized result.
499668
proc third_to_last_data_line {} {
500669
return [lindex [split [normalize_result] \n] end-2]
501670
}
502671
503
-set tempPath [expr {[info exists env(TEMP)] ? \
504
- $env(TEMP) : [file dirname [info script]]}]
672
+set tempPath [getTemporaryPath]
505673
506674
if {$tcl_platform(platform) eq "windows"} {
507675
set tempPath [string map [list \\ /] $tempPath]
508676
}
509677
510
-set tempPath [file normalize $tempPath]
678
+if {[catch {
679
+ set tempFile [file join $tempPath temporary.txt]
680
+ write_file $tempFile [clock seconds]; file delete $tempFile
681
+} error] != 0} {
682
+ error "Could not write file \"$tempFile\" in directory \"$tempPath\",\
683
+please set TEMP variable in environment, error: $error"
684
+}
685
+
686
+set tempHomePath [file join $tempPath home_[pid]]
511687
512688
if {[catch {
513
- write_file [file join $tempPath temporary.txt] [clock seconds]
689
+ file mkdir $tempHomePath
514690
} error] != 0} {
515
- error "could not write file to directory \"$tempPath\",\
516
-please set TEMP variable in environment: $error"
691
+ error "Could not make directory \"$tempHomePath\",\
692
+please set TEMP variable in environment, error: $error"
517693
}
518694
519695
protInit $fossilexe
696
+set ::tempKeepHome 1
520697
foreach testfile $argv {
521
- set dir [file root [file tail $testfile]]
522
- file delete -force $dir
523
- file mkdir $dir
524
- set origwd [pwd]
525
- cd $dir
526698
protOut "***** $testfile ******"
527699
source $testdir/$testfile.test
528700
protOut "***** End of $testfile: [llength $bad_test] errors so far ******"
529
- cd $origwd
530701
}
702
+unset ::tempKeepHome; delete_temporary_home
531703
set nErr [llength $bad_test]
532704
if {$nErr>0 || !$::QUIET} {
533705
protOut "***** Final results: $nErr errors out of $test_count tests" 1
534706
}
535707
if {$nErr>0} {
536708
--- test/tester.tcl
+++ test/tester.tcl
@@ -32,10 +32,18 @@
32 [string length [file extension $fossilexe]] == 0} {
33 append fossilexe .exe
34 }
35
36 set argv [lrange $argv 1 end]
 
 
 
 
 
 
 
 
37
38 set i [lsearch $argv -halt]
39 if {$i>=0} {
40 set HALT 1
41 set argv [lreplace $argv $i $i]
@@ -189,30 +197,134 @@
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
212 exec $::fossilexe clean -f
213 exec $::fossilexe set mtime-changes off
 
 
 
214 }
215
216 # This procedure only returns non-zero if the Tcl integration feature was
217 # enabled at compile-time and is now enabled at runtime.
218 proc is_tcl_usable_by_fossil {} {
@@ -284,10 +396,67 @@
284 # Append all arguments into a single value and then returns it.
285 #
286 proc appendArgs {args} {
287 eval append result $args
288 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
290 # Return the name of the versioned settings file containing the TH1
291 # setup script.
292 #
293 proc getTh1SetupFileName {} {
@@ -498,38 +667,41 @@
498 # returns the third to last line of the normalized result.
499 proc third_to_last_data_line {} {
500 return [lindex [split [normalize_result] \n] end-2]
501 }
502
503 set tempPath [expr {[info exists env(TEMP)] ? \
504 $env(TEMP) : [file dirname [info script]]}]
505
506 if {$tcl_platform(platform) eq "windows"} {
507 set tempPath [string map [list \\ /] $tempPath]
508 }
509
510 set tempPath [file normalize $tempPath]
 
 
 
 
 
 
 
 
511
512 if {[catch {
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 file mkdir $dir
524 set origwd [pwd]
525 cd $dir
526 protOut "***** $testfile ******"
527 source $testdir/$testfile.test
528 protOut "***** End of $testfile: [llength $bad_test] errors so far ******"
529 cd $origwd
530 }
 
531 set nErr [llength $bad_test]
532 if {$nErr>0 || !$::QUIET} {
533 protOut "***** Final results: $nErr errors out of $test_count tests" 1
534 }
535 if {$nErr>0} {
536
--- test/tester.tcl
+++ test/tester.tcl
@@ -32,10 +32,18 @@
32 [string length [file extension $fossilexe]] == 0} {
33 append fossilexe .exe
34 }
35
36 set argv [lrange $argv 1 end]
37
38 set i [lsearch $argv -keep]
39 if {$i>=0} {
40 set KEEP 1
41 set argv [lreplace $argv $i $i]
42 } else {
43 set KEEP 0
44 }
45
46 set i [lsearch $argv -halt]
47 if {$i>=0} {
48 set HALT 1
49 set argv [lreplace $argv $i $i]
@@ -189,30 +197,134 @@
197 set y [read_file $b]
198 regsub -all { +\n} $y \n y
199 return [expr {$x==$y}]
200 }
201
202 proc require_no_open_checkout {} {
203 if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
204 $::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
205 return
206 }
207 catch {exec $::fossilexe info} res
208 if {![regexp {use --repository} $res]} {
209 set projectName <unknown>
210 set localRoot <unknown>
211 regexp -line -- {^project-name: (.*)$} $res dummy projectName
212 set projectName [string trim $projectName]
213 regexp -line -- {^local-root: (.*)$} $res dummy localRoot
214 set localRoot [string trim $localRoot]
215 error "Detected an open checkout of project \"$projectName\",\
216 rooted at \"$localRoot\", testing halted."
217 }
218 }
219
220 proc get_script_or_fail {} {
221 set fileName [file normalize [info script]]
222 if {[string length $fileName] == 0 || ![file exists $fileName]} {
223 error "Failed to obtain the file name of the test being run."
224 }
225 return $fileName
226 }
227
228 proc robust_delete { path {force ""} } {
229 set error "unknown error"
230 for {set try 0} {$try < 10} {incr try} {
231 if {$force eq "YES_DO_IT"} {
232 if {[catch {file delete -force $path} error] == 0} {
233 return
234 }
235 } else {
236 if {[catch {file delete $path} error] == 0} {
237 return
238 }
239 }
240 after [expr {$try * 100}]
241 }
242 error "Could not delete \"$path\", error: $error"
243 }
244
245 proc test_cleanup_then_return {} {
246 uplevel 1 [list test_cleanup]
247 return -code return
248 }
249
250 proc test_cleanup {} {
251 if {$::KEEP} {return}; # All cleanup disabled?
252 if {![info exists ::tempRepoPath]} {return}
253 if {![file exists $::tempRepoPath]} {return}
254 if {![file isdirectory $::tempRepoPath]} {return}
255 set tempPathEnd [expr {[string length $::tempPath] - 1}]
256 if {[string length $::tempPath] == 0 || \
257 [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
258 error "Temporary repository path has wrong parent during cleanup."
259 }
260 if {[info exists ::tempSavedPwd]} {cd $::tempSavedPwd; unset ::tempSavedPwd}
261 # First, attempt to delete the specific temporary repository directories
262 # for this test file.
263 set scriptName [file tail [get_script_or_fail]]
264 foreach repoSeed $::tempRepoSeeds {
265 set repoPath [file join $::tempRepoPath $repoSeed $scriptName]
266 robust_delete $repoPath YES_DO_IT; # FORCE, arbitrary children.
267 set seedPath [file join $::tempRepoPath $repoSeed]
268 robust_delete $seedPath; # NO FORCE.
269 }
270 # Next, attempt to gracefully delete the temporary repository directory
271 # for this process.
272 robust_delete $::tempRepoPath
273 # Finally, attempt to gracefully delete the temporary home directory,
274 # unless forbidden by external forces.
275 if {![info exists ::tempKeepHome]} {delete_temporary_home}
276 }
277
278 proc delete_temporary_home {} {
279 if {$::KEEP} {return}; # All cleanup disabled?
280 if {$::tcl_platform(platform) eq "windows"} {
281 robust_delete [file join $::tempHomePath _fossil]
282 } else {
283 robust_delete [file join $::tempHomePath .fossil]
284 }
285 robust_delete $::tempHomePath
286 }
287
288 proc is_home_elsewhere {} {
289 return [expr {[info exists ::env(FOSSIL_HOME)] && \
290 $::env(FOSSIL_HOME) eq $::tempHomePath}]
291 }
292
293 proc set_home_to_elsewhere {} {
294 #
295 # Fossil will write data on $HOME (or $FOSSIL_HOME). We need not
296 # to clutter the real $HOME (or $FOSSIL_HOME) of the test caller.
297 #
298 if {[is_home_elsewhere]} {return}
299 set ::env(FOSSIL_HOME) $::tempHomePath
300 }
301
302 #
303 # Create and open a new Fossil repository and clean the checkout
304 #
305 proc test_setup {{filename ".rep.fossil"}} {
306 set_home_to_elsewhere
307 if {![info exists ::tempRepoPath]} {
308 set ::tempRepoPath [file join $::tempPath repo_[pid]]
309 }
310 set repoSeed [appendArgs [string trim [clock seconds] -] _ [getSeqNo]]
311 lappend ::tempRepoSeeds $repoSeed
312 set repoPath [file join \
313 $::tempRepoPath $repoSeed [file tail [get_script_or_fail]]]
314 if {[catch {
315 file mkdir $repoPath
316 } error] != 0} {
317 error "Could not make directory \"$repoPath\",\
318 please set TEMP variable in environment, error: $error"
319 }
320 if {![info exists ::tempSavedPwd]} {set ::tempSavedPwd [pwd]}; cd $repoPath
321 if {[string length $filename] > 0} {
322 exec $::fossilexe new $filename
323 exec $::fossilexe open $filename
324 exec $::fossilexe set mtime-changes off
325 }
326 }
327
328 # This procedure only returns non-zero if the Tcl integration feature was
329 # enabled at compile-time and is now enabled at runtime.
330 proc is_tcl_usable_by_fossil {} {
@@ -284,10 +396,67 @@
396 # Append all arguments into a single value and then returns it.
397 #
398 proc appendArgs {args} {
399 eval append result $args
400 }
401
402 # Returns the value of the specified environment variable -OR- any empty
403 # string if it does not exist.
404 #
405 proc getEnvironmentVariable { name } {
406 return [expr {[info exists ::env($name)] ? $::env($name) : ""}]
407 }
408
409 # Returns a usable temporary directory -OR- fails the testing process.
410 #
411 proc getTemporaryPath {} {
412 #
413 # NOTE: Build the list of "temporary directory" environment variables
414 # to check, including all reasonable "cases" of the environment
415 # variable names.
416 #
417 set names [list]
418
419 #
420 # TODO: Add more here, if necessary.
421 #
422 foreach name [list FOSSIL_TEST_TEMP FOSSIL_TEMP TEMP TMP] {
423 lappend names [string toupper $name] [string tolower $name] \
424 [string totitle $name]
425 }
426
427 #
428 # NOTE: Check if we can use any of the environment variables.
429 #
430 foreach name $names {
431 set value [getEnvironmentVariable $name]
432
433 if {[string length $value] > 0} then {
434 set value [file normalize $value]
435
436 if {[file exists $value] && [file isdirectory $value]} then {
437 return $value
438 }
439 }
440 }
441
442 #
443 # NOTE: On non-Windows systems, fallback to /tmp if it is usable.
444 #
445 if {$::tcl_platform(platform) ne "windows"} {
446 set value /tmp
447
448 if {[file exists $value] && [file isdirectory $value]} then {
449 return $value
450 }
451 }
452
453 #
454 # NOTE: There must be a usable temporary directory to continue testing.
455 #
456 error "Cannot find a usable temporary directory, testing halted."
457 }
458
459 # Return the name of the versioned settings file containing the TH1
460 # setup script.
461 #
462 proc getTh1SetupFileName {} {
@@ -498,38 +667,41 @@
667 # returns the third to last line of the normalized result.
668 proc third_to_last_data_line {} {
669 return [lindex [split [normalize_result] \n] end-2]
670 }
671
672 set tempPath [getTemporaryPath]
 
673
674 if {$tcl_platform(platform) eq "windows"} {
675 set tempPath [string map [list \\ /] $tempPath]
676 }
677
678 if {[catch {
679 set tempFile [file join $tempPath temporary.txt]
680 write_file $tempFile [clock seconds]; file delete $tempFile
681 } error] != 0} {
682 error "Could not write file \"$tempFile\" in directory \"$tempPath\",\
683 please set TEMP variable in environment, error: $error"
684 }
685
686 set tempHomePath [file join $tempPath home_[pid]]
687
688 if {[catch {
689 file mkdir $tempHomePath
690 } error] != 0} {
691 error "Could not make directory \"$tempHomePath\",\
692 please set TEMP variable in environment, error: $error"
693 }
694
695 protInit $fossilexe
696 set ::tempKeepHome 1
697 foreach testfile $argv {
 
 
 
 
 
698 protOut "***** $testfile ******"
699 source $testdir/$testfile.test
700 protOut "***** End of $testfile: [llength $bad_test] errors so far ******"
 
701 }
702 unset ::tempKeepHome; delete_temporary_home
703 set nErr [llength $bad_test]
704 if {$nErr>0 || !$::QUIET} {
705 protOut "***** Final results: $nErr errors out of $test_count tests" 1
706 }
707 if {$nErr>0} {
708
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -18,19 +18,25 @@
1818
# TH1 Docs
1919
#
2020
2121
fossil test-th-eval "hasfeature th1Docs"
2222
23
-if {$::RESULT ne "1"} then {
24
- puts "Fossil was not compiled with TH1 docs support."; return
23
+if {$::RESULT ne "1"} {
24
+ puts "Fossil was not compiled with TH1 docs support."
25
+ test_cleanup_then_return
2526
}
2627
2728
fossil test-th-eval "hasfeature tcl"
2829
29
-if {$::RESULT ne "1"} then {
30
- puts "Fossil was not compiled with Tcl support."; return
30
+if {$::RESULT ne "1"} {
31
+ puts "Fossil was not compiled with Tcl support."
32
+ test_cleanup_then_return
3133
}
34
+
35
+###############################################################################
36
+
37
+test_setup ""
3238
3339
###############################################################################
3440
3541
set env(TH1_ENABLE_DOCS) 1; # TH1 docs must be enabled for this test.
3642
set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
@@ -41,11 +47,11 @@
4147
set data [fossil info]
4248
}
4349
4450
regexp -line -- {^repository: (.*)$} $data dummy repository
4551
46
-if {[string length $repository] == 0 || ![file exists $repository]} then {
52
+if {[string length $repository] == 0 || ![file exists $repository]} {
4753
error "unable to locate repository"
4854
}
4955
5056
set dataFileName [file join $::testdir th1-docs-input.txt]
5157
@@ -57,5 +63,9 @@
5763
}
5864
5965
test th1-docs-1a {[regexp {<title>Fossil: test/fileStat.th1</title>} $RESULT]}
6066
test th1-docs-1b {[regexp {>\[[0-9a-f]{40}\]<} $RESULT]}
6167
test th1-docs-1c {[regexp { contains \d+ files\.} $RESULT]}
68
+
69
+###############################################################################
70
+
71
+test_cleanup
6272
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -18,19 +18,25 @@
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
35 set env(TH1_ENABLE_DOCS) 1; # TH1 docs must be enabled for this test.
36 set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
@@ -41,11 +47,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
@@ -57,5 +63,9 @@
57 }
58
59 test th1-docs-1a {[regexp {<title>Fossil: test/fileStat.th1</title>} $RESULT]}
60 test th1-docs-1b {[regexp {>\[[0-9a-f]{40}\]<} $RESULT]}
61 test th1-docs-1c {[regexp { contains \d+ files\.} $RESULT]}
 
 
 
 
62
--- test/th1-docs.test
+++ test/th1-docs.test
@@ -18,19 +18,25 @@
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."
25 test_cleanup_then_return
26 }
27
28 fossil test-th-eval "hasfeature tcl"
29
30 if {$::RESULT ne "1"} {
31 puts "Fossil was not compiled with Tcl support."
32 test_cleanup_then_return
33 }
34
35 ###############################################################################
36
37 test_setup ""
38
39 ###############################################################################
40
41 set env(TH1_ENABLE_DOCS) 1; # TH1 docs must be enabled for this test.
42 set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
@@ -41,11 +47,11 @@
47 set data [fossil info]
48 }
49
50 regexp -line -- {^repository: (.*)$} $data dummy repository
51
52 if {[string length $repository] == 0 || ![file exists $repository]} {
53 error "unable to locate repository"
54 }
55
56 set dataFileName [file join $::testdir th1-docs-input.txt]
57
@@ -57,5 +63,9 @@
63 }
64
65 test th1-docs-1a {[regexp {<title>Fossil: test/fileStat.th1</title>} $RESULT]}
66 test th1-docs-1b {[regexp {>\[[0-9a-f]{40}\]<} $RESULT]}
67 test th1-docs-1c {[regexp { contains \d+ files\.} $RESULT]}
68
69 ###############################################################################
70
71 test_cleanup
72
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -18,17 +18,21 @@
1818
# TH1 Hooks
1919
#
2020
2121
fossil test-th-eval "hasfeature th1Hooks"
2222
23
-if {$::RESULT ne "1"} then {
24
- puts "Fossil was not compiled with TH1 hooks support."; return
23
+if {$::RESULT ne "1"} {
24
+ puts "Fossil was not compiled with TH1 hooks support."
25
+ test_cleanup_then_return
2526
}
2627
2728
###############################################################################
2829
29
-repo_init
30
+test_setup
31
+
32
+###############################################################################
33
+
3034
write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
3135
3236
###############################################################################
3337
3438
set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
@@ -106,11 +110,11 @@
106110
###############################################################################
107111
108112
set data [fossil info]
109113
regexp -line -- {^repository: (.*)$} $data dummy repository
110114
111
-if {[string length $repository] == 0 || ![file exists $repository]} then {
115
+if {[string length $repository] == 0 || ![file exists $repository]} {
112116
error "unable to locate repository"
113117
}
114118
115119
set dataFileName [file join $::testdir th1-hooks-input.txt]
116120
@@ -195,5 +199,9 @@
195199
{<h1><b>command_hook http webpage_hook test1 webpage_notify test1</b></h1>}}
196200
197201
###############################################################################
198202
199203
restoreTh1SetupFile
204
+
205
+###############################################################################
206
+
207
+test_cleanup
200208
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -18,17 +18,21 @@
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
29 repo_init
 
 
 
30 write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
31
32 ###############################################################################
33
34 set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
@@ -106,11 +110,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
@@ -195,5 +199,9 @@
195 {<h1><b>command_hook http webpage_hook test1 webpage_notify test1</b></h1>}}
196
197 ###############################################################################
198
199 restoreTh1SetupFile
 
 
 
 
200
--- test/th1-hooks.test
+++ test/th1-hooks.test
@@ -18,17 +18,21 @@
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."
25 test_cleanup_then_return
26 }
27
28 ###############################################################################
29
30 test_setup
31
32 ###############################################################################
33
34 write_file f1 "f1"; fossil add f1; fossil commit -m "c1"
35
36 ###############################################################################
37
38 set env(TH1_ENABLE_HOOKS) 1; # TH1 hooks must be enabled for this test.
@@ -106,11 +110,11 @@
110 ###############################################################################
111
112 set data [fossil info]
113 regexp -line -- {^repository: (.*)$} $data dummy repository
114
115 if {[string length $repository] == 0 || ![file exists $repository]} {
116 error "unable to locate repository"
117 }
118
119 set dataFileName [file join $::testdir th1-hooks-input.txt]
120
@@ -195,5 +199,9 @@
199 {<h1><b>command_hook http webpage_hook test1 webpage_notify test1</b></h1>}}
200
201 ###############################################################################
202
203 restoreTh1SetupFile
204
205 ###############################################################################
206
207 test_cleanup
208
--- test/th1-repo.test
+++ test/th1-repo.test
@@ -19,23 +19,17 @@
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
34
-set rootDir [file normalize [pwd]]
35
-
36
-repo_init
30
+test_setup; set rootDir [file normalize [pwd]]
3731
3832
write_file f1.md "f1"
3933
write_file f2.md "f2"
4034
write_file f3.txt "f3"
4135
write_file f4.md "f4"
@@ -86,5 +80,9 @@
8680
test th1-dir-3.8 {[lindex [lindex $RESULT 2] 1] == 2}
8781
test th1-dir-3.9 {[regexp -- $dateTime [lindex [lindex $RESULT 2] 2]]}
8882
test th1-dir-3.10 {[lindex [lindex $RESULT 3] 0] eq "subdirC/f10.md"}
8983
test th1-dir-3.11 {[lindex [lindex $RESULT 3] 1] == 3}
9084
test th1-dir-3.12 {[regexp -- $dateTime [lindex [lindex $RESULT 3] 2]]}
85
+
86
+###############################################################################
87
+
88
+test_cleanup
9189
--- test/th1-repo.test
+++ test/th1-repo.test
@@ -19,23 +19,17 @@
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 set rootDir [file normalize [pwd]]
35
36 repo_init
37
38 write_file f1.md "f1"
39 write_file f2.md "f2"
40 write_file f3.txt "f3"
41 write_file f4.md "f4"
@@ -86,5 +80,9 @@
86 test th1-dir-3.8 {[lindex [lindex $RESULT 2] 1] == 2}
87 test th1-dir-3.9 {[regexp -- $dateTime [lindex [lindex $RESULT 2] 2]]}
88 test th1-dir-3.10 {[lindex [lindex $RESULT 3] 0] eq "subdirC/f10.md"}
89 test th1-dir-3.11 {[lindex [lindex $RESULT 3] 1] == 3}
90 test th1-dir-3.12 {[regexp -- $dateTime [lindex [lindex $RESULT 3] 2]]}
 
 
 
 
91
--- test/th1-repo.test
+++ test/th1-repo.test
@@ -19,23 +19,17 @@
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_setup; set rootDir [file normalize [pwd]]
 
 
31
32 write_file f1.md "f1"
33 write_file f2.md "f2"
34 write_file f3.txt "f3"
35 write_file f4.md "f4"
@@ -86,5 +80,9 @@
80 test th1-dir-3.8 {[lindex [lindex $RESULT 2] 1] == 2}
81 test th1-dir-3.9 {[regexp -- $dateTime [lindex [lindex $RESULT 2] 2]]}
82 test th1-dir-3.10 {[lindex [lindex $RESULT 3] 0] eq "subdirC/f10.md"}
83 test th1-dir-3.11 {[lindex [lindex $RESULT 3] 1] == 3}
84 test th1-dir-3.12 {[regexp -- $dateTime [lindex [lindex $RESULT 3] 2]]}
85
86 ###############################################################################
87
88 test_cleanup
89
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -20,19 +20,20 @@
2020
2121
set dir [file dirname [info script]]
2222
2323
###############################################################################
2424
25
-repo_init
26
-
27
-###############################################################################
28
-
2925
fossil test-th-eval "hasfeature tcl"
3026
31
-if {$::RESULT ne "1"} then {
32
- puts "Fossil was not compiled with Tcl support."; return
27
+if {$::RESULT ne "1"} {
28
+ puts "Fossil was not compiled with Tcl support."
29
+ test_cleanup_then_return
3330
}
31
+
32
+###############################################################################
33
+
34
+test_setup
3435
3536
###############################################################################
3637
3738
set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
3839
@@ -173,5 +174,9 @@
173174
174175
###############################################################################
175176
176177
fossil test-th-eval "tclMakeSafe; tclEval set x 2; tclEval info vars x"
177178
test th1-tcl-17 {[normalize_result] eq {x}}
179
+
180
+###############################################################################
181
+
182
+test_cleanup
178183
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -20,19 +20,20 @@
20
21 set dir [file dirname [info script]]
22
23 ###############################################################################
24
25 repo_init
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 set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
38
@@ -173,5 +174,9 @@
173
174 ###############################################################################
175
176 fossil test-th-eval "tclMakeSafe; tclEval set x 2; tclEval info vars x"
177 test th1-tcl-17 {[normalize_result] eq {x}}
 
 
 
 
178
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -20,19 +20,20 @@
20
21 set dir [file dirname [info script]]
22
23 ###############################################################################
24
 
 
 
 
25 fossil test-th-eval "hasfeature tcl"
26
27 if {$::RESULT ne "1"} {
28 puts "Fossil was not compiled with Tcl support."
29 test_cleanup_then_return
30 }
31
32 ###############################################################################
33
34 test_setup
35
36 ###############################################################################
37
38 set env(TH1_ENABLE_TCL) 1; # Tcl integration must be enabled for this test.
39
@@ -173,5 +174,9 @@
174
175 ###############################################################################
176
177 fossil test-th-eval "tclMakeSafe; tclEval set x 2; tclEval info vars x"
178 test th1-tcl-17 {[normalize_result] eq {x}}
179
180 ###############################################################################
181
182 test_cleanup
183
+6 -2
--- test/th1.test
+++ test/th1.test
@@ -16,11 +16,11 @@
1616
############################################################################
1717
#
1818
# TH1 Commands
1919
#
2020
21
-set dir [file dirname [info script]]; repo_init
21
+set dir [file dirname [info script]]; test_setup
2222
2323
###############################################################################
2424
2525
set th1Tcl [is_tcl_usable_by_fossil]
2626
set th1Hooks [are_th1_hooks_usable_by_fossil]
@@ -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
@@ -1451,5 +1451,9 @@
14511451
}
14521452
14531453
fossil test-th-source $th1FileName
14541454
test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
14551455
file delete $th1FileName
1456
+
1457
+###############################################################################
1458
+
1459
+test_cleanup
14561460
--- test/th1.test
+++ test/th1.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # TH1 Commands
19 #
20
21 set dir [file dirname [info script]]; repo_init
22
23 ###############################################################################
24
25 set th1Tcl [is_tcl_usable_by_fossil]
26 set th1Hooks [are_th1_hooks_usable_by_fossil]
@@ -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
@@ -1451,5 +1451,9 @@
1451 }
1452
1453 fossil test-th-source $th1FileName
1454 test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455 file delete $th1FileName
 
 
 
 
1456
--- test/th1.test
+++ test/th1.test
@@ -16,11 +16,11 @@
16 ############################################################################
17 #
18 # TH1 Commands
19 #
20
21 set dir [file dirname [info script]]; test_setup
22
23 ###############################################################################
24
25 set th1Tcl [is_tcl_usable_by_fossil]
26 set th1Hooks [are_th1_hooks_usable_by_fossil]
@@ -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
@@ -1451,5 +1451,9 @@
1451 }
1452
1453 fossil test-th-source $th1FileName
1454 test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
1455 file delete $th1FileName
1456
1457 ###############################################################################
1458
1459 test_cleanup
1460
--- test/utf.test
+++ test/utf.test
@@ -15,10 +15,12 @@
1515
#
1616
############################################################################
1717
#
1818
# Test UTF-8/UTF-16 detection
1919
#
20
+
21
+test_setup ""
2022
2123
proc swap_byte_order {str} {
2224
set result ""
2325
for {set i 0} {$i < [string length $str]} {incr i} {
2426
set c [scan [string index $str $i] %c]
@@ -23490,5 +23492,9 @@
2349023492
Has flag LOOK_SHORT: no}
2349123493
2349223494
############################ END GENERATED SECTION ############################
2349323495
2349423496
deleteTestFiles $tempPath 100
23497
+
23498
+###############################################################################
23499
+
23500
+test_cleanup
2349523501
--- test/utf.test
+++ test/utf.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test UTF-8/UTF-16 detection
19 #
 
 
20
21 proc swap_byte_order {str} {
22 set result ""
23 for {set i 0} {$i < [string length $str]} {incr i} {
24 set c [scan [string index $str $i] %c]
@@ -23490,5 +23492,9 @@
23490 Has flag LOOK_SHORT: no}
23491
23492 ############################ END GENERATED SECTION ############################
23493
23494 deleteTestFiles $tempPath 100
 
 
 
 
23495
--- test/utf.test
+++ test/utf.test
@@ -15,10 +15,12 @@
15 #
16 ############################################################################
17 #
18 # Test UTF-8/UTF-16 detection
19 #
20
21 test_setup ""
22
23 proc swap_byte_order {str} {
24 set result ""
25 for {set i 0} {$i < [string length $str]} {incr i} {
26 set c [scan [string index $str $i] %c]
@@ -23490,5 +23492,9 @@
23492 Has flag LOOK_SHORT: no}
23493
23494 ############################ END GENERATED SECTION ############################
23495
23496 deleteTestFiles $tempPath 100
23497
23498 ###############################################################################
23499
23500 test_cleanup
23501

Keyboard Shortcuts

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