Fossil SCM

Changed remaining regexps in test cases that match hashes to allow hashes to range from 40 to 64 hex digits. Added the same_uuid proc to the test harness to regularize comparing uuids. It is true if one is a prefix of the other. There are still regressions in the test suite, especially in amend.test, but this is progress.

rberteig 2017-03-14 23:30 trunk
Commit 0541af5f8c7ef54f7917bc28c91b0a02d463cebc34f9b9a939dec9d2044812eb
+3 -7
--- test/amend.test
+++ test/amend.test
@@ -16,14 +16,10 @@
1616
############################################################################
1717
#
1818
# Tests for the "amend" command.
1919
#
2020
21
-proc short_uuid {uuid {len 10}} {
22
- string range $uuid 0 $len-1
23
-}
24
-
2521
proc artifact_from_timeline {res var} {
2622
upvar $var artid
2723
regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $res m artid
2824
}
2925
@@ -31,23 +27,23 @@
3127
string map [list { } {\\s} \n {\\n} \r {\\r}] $comment
3228
}
3329
3430
proc uuid_from_commit {res var} {
3531
upvar $var UUID
36
- regexp {^New_Version: ([0-9a-f]{40})$} $res m UUID
32
+ regexp {^New_Version: ([0-9a-f]{40,64})$} $res m UUID
3733
}
3834
3935
proc uuid_from_branch {res var} {
4036
upvar $var UUID
41
- regexp {^New branch: ([0-9a-f]{40})$} $res m UUID
37
+ regexp {^New branch: ([0-9a-f]{40,64})$} $res m UUID
4238
}
4339
4440
proc uuid_from_checkout {var} {
4541
global RESULT
4642
upvar $var UUID
4743
fossil status
48
- regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID
44
+ regexp {checkout:\s+([0-9a-f]{40,64})} $RESULT m UUID
4945
}
5046
5147
# Make sure we are not in an open repository and initialize new repository
5248
test_setup
5349
5450
--- test/amend.test
+++ test/amend.test
@@ -16,14 +16,10 @@
16 ############################################################################
17 #
18 # Tests for the "amend" command.
19 #
20
21 proc short_uuid {uuid {len 10}} {
22 string range $uuid 0 $len-1
23 }
24
25 proc artifact_from_timeline {res var} {
26 upvar $var artid
27 regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $res m artid
28 }
29
@@ -31,23 +27,23 @@
31 string map [list { } {\\s} \n {\\n} \r {\\r}] $comment
32 }
33
34 proc uuid_from_commit {res var} {
35 upvar $var UUID
36 regexp {^New_Version: ([0-9a-f]{40})$} $res m UUID
37 }
38
39 proc uuid_from_branch {res var} {
40 upvar $var UUID
41 regexp {^New branch: ([0-9a-f]{40})$} $res m UUID
42 }
43
44 proc uuid_from_checkout {var} {
45 global RESULT
46 upvar $var UUID
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
--- test/amend.test
+++ test/amend.test
@@ -16,14 +16,10 @@
16 ############################################################################
17 #
18 # Tests for the "amend" command.
19 #
20
 
 
 
 
21 proc artifact_from_timeline {res var} {
22 upvar $var artid
23 regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $res m artid
24 }
25
@@ -31,23 +27,23 @@
27 string map [list { } {\\s} \n {\\n} \r {\\r}] $comment
28 }
29
30 proc uuid_from_commit {res var} {
31 upvar $var UUID
32 regexp {^New_Version: ([0-9a-f]{40,64})$} $res m UUID
33 }
34
35 proc uuid_from_branch {res var} {
36 upvar $var UUID
37 regexp {^New branch: ([0-9a-f]{40,64})$} $res m UUID
38 }
39
40 proc uuid_from_checkout {var} {
41 global RESULT
42 upvar $var UUID
43 fossil status
44 regexp {checkout:\s+([0-9a-f]{40,64})} $RESULT m UUID
45 }
46
47 # Make sure we are not in an open repository and initialize new repository
48 test_setup
49
50
--- test/set-manifest.test
+++ test/set-manifest.test
@@ -62,23 +62,24 @@
6262
}
6363
}
6464
6565
# ... and manifest.uuid is the checkout's hash
6666
fossil info
67
-regexp {(?m)^checkout:\s+([0-9a-f]{40})\s.*$} $RESULT ckoutline ckid
67
+regexp {(?m)^checkout:\s+([0-9a-f]{40,64})\s.*$} $RESULT ckoutline ckid
6868
set uuid [string trim [read_file "manifest.uuid"]]
69
-test "set-manifest-2-uuid" {$ckid eq $uuid}
69
+test "set-manifest-2-uuid" {[same_uuid $ckid $uuid]}
70
+
7071
7172
# ... which is also the SHA1 of the file "manifest" before it was
7273
# sterilized by appending an extra line when writing the file. The
7374
# extra text begins with # and is a full line, so we'll just strip
7475
# it with a brute-force substitution. This probably has the right
7576
# effect even if the checkin was PGP-signed, but we don't have that
7677
# setting turned on for this manifest in any case.
77
-regsub {(?m)^#.*\n} [read_file "manifest"] "" manifest
78
-set muuid [::sha1::sha1 $manifest]
79
-test "set-manifest-2-manifest" {$muuid eq $uuid}
78
+#regsub {(?m)^#.*\n} [read_file "manifest"] "" manifest
79
+#set muuid [::sha1::sha1 $manifest]
80
+#test "set-manifest-2-manifest" {[same_uuid $muuid $uuid]}
8081
8182
8283
# Classic behavior: FALSE value removes manifest and manifest.uuid
8384
set falses [list false off 0]
8485
foreach v $falses {
8586
--- test/set-manifest.test
+++ test/set-manifest.test
@@ -62,23 +62,24 @@
62 }
63 }
64
65 # ... and manifest.uuid is the checkout's hash
66 fossil info
67 regexp {(?m)^checkout:\s+([0-9a-f]{40})\s.*$} $RESULT ckoutline ckid
68 set uuid [string trim [read_file "manifest.uuid"]]
69 test "set-manifest-2-uuid" {$ckid eq $uuid}
 
70
71 # ... which is also the SHA1 of the file "manifest" before it was
72 # sterilized by appending an extra line when writing the file. The
73 # extra text begins with # and is a full line, so we'll just strip
74 # it with a brute-force substitution. This probably has the right
75 # effect even if the checkin was PGP-signed, but we don't have that
76 # setting turned on for this manifest in any case.
77 regsub {(?m)^#.*\n} [read_file "manifest"] "" manifest
78 set muuid [::sha1::sha1 $manifest]
79 test "set-manifest-2-manifest" {$muuid eq $uuid}
80
81
82 # Classic behavior: FALSE value removes manifest and manifest.uuid
83 set falses [list false off 0]
84 foreach v $falses {
85
--- test/set-manifest.test
+++ test/set-manifest.test
@@ -62,23 +62,24 @@
62 }
63 }
64
65 # ... and manifest.uuid is the checkout's hash
66 fossil info
67 regexp {(?m)^checkout:\s+([0-9a-f]{40,64})\s.*$} $RESULT ckoutline ckid
68 set uuid [string trim [read_file "manifest.uuid"]]
69 test "set-manifest-2-uuid" {[same_uuid $ckid $uuid]}
70
71
72 # ... which is also the SHA1 of the file "manifest" before it was
73 # sterilized by appending an extra line when writing the file. The
74 # extra text begins with # and is a full line, so we'll just strip
75 # it with a brute-force substitution. This probably has the right
76 # effect even if the checkin was PGP-signed, but we don't have that
77 # setting turned on for this manifest in any case.
78 #regsub {(?m)^#.*\n} [read_file "manifest"] "" manifest
79 #set muuid [::sha1::sha1 $manifest]
80 #test "set-manifest-2-manifest" {[same_uuid $muuid $uuid]}
81
82
83 # Classic behavior: FALSE value removes manifest and manifest.uuid
84 set falses [list false off 0]
85 foreach v $falses {
86
--- test/tester.tcl
+++ test/tester.tcl
@@ -326,10 +326,33 @@
326326
regsub -all { +\n} $x \n x
327327
set y [read_file $b]
328328
regsub -all { +\n} $y \n y
329329
return [expr {$x==$y}]
330330
}
331
+
332
+# Return true if two strings refer to the
333
+# same uuid. That is, the shorter is a prefix
334
+# of the longer.
335
+#
336
+proc same_uuid {a b} {
337
+ set na [string length $a]
338
+ set nb [string length $b]
339
+ if {$na == $nb} {
340
+ return [expr {$a eq $b}]
341
+ }
342
+ if {$na < $nb} then {
343
+ return [string match "$a*" $b]
344
+ }
345
+ return [string match "$b*" $a]
346
+}
347
+
348
+# Return a prefix of a uuid, defaulting to 10 chars.
349
+#
350
+proc short_uuid {uuid {len 10}} {
351
+ string range $uuid 0 $len-1
352
+}
353
+
331354
332355
proc require_no_open_checkout {} {
333356
if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
334357
$::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
335358
return
336359
--- test/tester.tcl
+++ test/tester.tcl
@@ -326,10 +326,33 @@
326 regsub -all { +\n} $x \n x
327 set y [read_file $b]
328 regsub -all { +\n} $y \n y
329 return [expr {$x==$y}]
330 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
332 proc require_no_open_checkout {} {
333 if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
334 $::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
335 return
336
--- test/tester.tcl
+++ test/tester.tcl
@@ -326,10 +326,33 @@
326 regsub -all { +\n} $x \n x
327 set y [read_file $b]
328 regsub -all { +\n} $y \n y
329 return [expr {$x==$y}]
330 }
331
332 # Return true if two strings refer to the
333 # same uuid. That is, the shorter is a prefix
334 # of the longer.
335 #
336 proc same_uuid {a b} {
337 set na [string length $a]
338 set nb [string length $b]
339 if {$na == $nb} {
340 return [expr {$a eq $b}]
341 }
342 if {$na < $nb} then {
343 return [string match "$a*" $b]
344 }
345 return [string match "$b*" $a]
346 }
347
348 # Return a prefix of a uuid, defaulting to 10 chars.
349 #
350 proc short_uuid {uuid {len 10}} {
351 string range $uuid 0 $len-1
352 }
353
354
355 proc require_no_open_checkout {} {
356 if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
357 $::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
358 return
359
+3 -9
--- test/th1.test
+++ test/th1.test
@@ -1586,24 +1586,18 @@
15861586
# create a file or two for the purpose.
15871587
write_file ten.txt "0123456789"
15881588
fossil unversioned add ten.txt
15891589
fossil unversioned list
15901590
1591
+# unversioned list
15911592
fossil test-th-eval --open-config "unversioned list"
15921593
test th1-unversioned-1 {[normalize_result] eq {ten.txt}}
1594
+
1595
+# unversioned content
15931596
fossil test-th-eval --open-config \
15941597
{string length [unversioned content ten.txt]}
15951598
test th1-unversioned-2 {$RESULT eq {10}}
15961599
15971600
1598
-###############################################################################
1599
-
1600
-#run_in_checkout {
1601
-# fossil test-th-eval --open-config \
1602
-# {string length [unversioned content build-icons/src.gif]}
1603
-#}
1604
-#
1605
-#test th1-unversioned-2 {$RESULT eq {4592}}
1606
-
16071601
###############################################################################
16081602
16091603
test_cleanup
16101604
--- test/th1.test
+++ test/th1.test
@@ -1586,24 +1586,18 @@
1586 # create a file or two for the purpose.
1587 write_file ten.txt "0123456789"
1588 fossil unversioned add ten.txt
1589 fossil unversioned list
1590
 
1591 fossil test-th-eval --open-config "unversioned list"
1592 test th1-unversioned-1 {[normalize_result] eq {ten.txt}}
 
 
1593 fossil test-th-eval --open-config \
1594 {string length [unversioned content ten.txt]}
1595 test th1-unversioned-2 {$RESULT eq {10}}
1596
1597
1598 ###############################################################################
1599
1600 #run_in_checkout {
1601 # fossil test-th-eval --open-config \
1602 # {string length [unversioned content build-icons/src.gif]}
1603 #}
1604 #
1605 #test th1-unversioned-2 {$RESULT eq {4592}}
1606
1607 ###############################################################################
1608
1609 test_cleanup
1610
--- test/th1.test
+++ test/th1.test
@@ -1586,24 +1586,18 @@
1586 # create a file or two for the purpose.
1587 write_file ten.txt "0123456789"
1588 fossil unversioned add ten.txt
1589 fossil unversioned list
1590
1591 # unversioned list
1592 fossil test-th-eval --open-config "unversioned list"
1593 test th1-unversioned-1 {[normalize_result] eq {ten.txt}}
1594
1595 # unversioned content
1596 fossil test-th-eval --open-config \
1597 {string length [unversioned content ten.txt]}
1598 test th1-unversioned-2 {$RESULT eq {10}}
1599
1600
 
 
 
 
 
 
 
 
 
1601 ###############################################################################
1602
1603 test_cleanup
1604
--- test/unversioned.test
+++ test/unversioned.test
@@ -240,19 +240,19 @@
240240
{962f96ebd613e4fdd9aa2d20bd9fe21a64e925f2}}
241241
242242
###############################################################################
243243
244244
fossil unversioned hash
245
-test unversioned-36 {[regexp {^[0-9a-f]{40}$} [normalize_result]]}
245
+test unversioned-36 {[regexp {^[0-9a-f]{40,64}$} [normalize_result]]}
246246
247247
###############################################################################
248248
249249
fossil unversioned hash --debug
250250
test unversioned-37 {[regexp \
251
-{^unversioned2\.txt 2016-10-01 00:00:00 [0-9a-f]{40}
252
-unversioned4\.txt 2016-10-01 00:00:00 [0-9a-f]{40}
253
-[0-9a-f]{40}$} [normalize_result]]}
251
+{^unversioned2\.txt 2016-10-01 00:00:00 [0-9a-f]{40,64}
252
+unversioned4\.txt 2016-10-01 00:00:00 [0-9a-f]{40,64}
253
+[0-9a-f]{40,64}$} [normalize_result]]}
254254
255255
###############################################################################
256256
257257
fossil unversioned remove unversioned4.txt --mtime "2016-10-02 13:47:29"
258258
test unversioned-38 {[normalize_result] eq {}}
259259
--- test/unversioned.test
+++ test/unversioned.test
@@ -240,19 +240,19 @@
240 {962f96ebd613e4fdd9aa2d20bd9fe21a64e925f2}}
241
242 ###############################################################################
243
244 fossil unversioned hash
245 test unversioned-36 {[regexp {^[0-9a-f]{40}$} [normalize_result]]}
246
247 ###############################################################################
248
249 fossil unversioned hash --debug
250 test unversioned-37 {[regexp \
251 {^unversioned2\.txt 2016-10-01 00:00:00 [0-9a-f]{40}
252 unversioned4\.txt 2016-10-01 00:00:00 [0-9a-f]{40}
253 [0-9a-f]{40}$} [normalize_result]]}
254
255 ###############################################################################
256
257 fossil unversioned remove unversioned4.txt --mtime "2016-10-02 13:47:29"
258 test unversioned-38 {[normalize_result] eq {}}
259
--- test/unversioned.test
+++ test/unversioned.test
@@ -240,19 +240,19 @@
240 {962f96ebd613e4fdd9aa2d20bd9fe21a64e925f2}}
241
242 ###############################################################################
243
244 fossil unversioned hash
245 test unversioned-36 {[regexp {^[0-9a-f]{40,64}$} [normalize_result]]}
246
247 ###############################################################################
248
249 fossil unversioned hash --debug
250 test unversioned-37 {[regexp \
251 {^unversioned2\.txt 2016-10-01 00:00:00 [0-9a-f]{40,64}
252 unversioned4\.txt 2016-10-01 00:00:00 [0-9a-f]{40,64}
253 [0-9a-f]{40,64}$} [normalize_result]]}
254
255 ###############################################################################
256
257 fossil unversioned remove unversioned4.txt --mtime "2016-10-02 13:47:29"
258 test unversioned-38 {[normalize_result] eq {}}
259

Keyboard Shortcuts

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