Fossil SCM

Added quick checks to verify that the manifest and manifest.uuid files have sensible content, at least for the initial empty checkin. This does require that an SHA1 module be installed for use by the test harness, which I am slightly surprised was not already needed by any other test case.

rberteig 2016-08-08 19:37 jan-manifest-tags
Commit bf62b1608c62eab08762f4dfa9fd789db6356948
1 file changed +23
--- test/set-manifest.test
+++ test/set-manifest.test
@@ -15,10 +15,16 @@
1515
#
1616
############################################################################
1717
#
1818
# Test manifest setting
1919
#
20
+
21
+# We need SHA1 to effectively test the manifest files produced by
22
+# fossil. It looks like the one from tcllib is exactly what we need.
23
+# On ActiveTcl, add it with teacup. On other platforms, YMMV.
24
+# teacup install sha1
25
+package require sha1
2026
2127
proc file_contains {fname match} {
2228
set fp [open $fname r]
2329
set contents [read $fp]
2430
close $fp
@@ -53,10 +59,27 @@
5359
test "set-manifest-2-$v-n" {[llength $filelist] == 2}
5460
foreach f $filelist {
5561
test "set-manifest-2-$v-f-$f" {[file isfile $f]}
5662
}
5763
}
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
+
5881
5982
# Classic behavior: FALSE value removes manifest and manifest.uuid
6083
set falses [list false off 0]
6184
foreach v $falses {
6285
fossil settings manifest $v
6386
--- test/set-manifest.test
+++ test/set-manifest.test
@@ -15,10 +15,16 @@
15 #
16 ############################################################################
17 #
18 # Test manifest setting
19 #
 
 
 
 
 
 
20
21 proc file_contains {fname match} {
22 set fp [open $fname r]
23 set contents [read $fp]
24 close $fp
@@ -53,10 +59,27 @@
53 test "set-manifest-2-$v-n" {[llength $filelist] == 2}
54 foreach f $filelist {
55 test "set-manifest-2-$v-f-$f" {[file isfile $f]}
56 }
57 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59 # Classic behavior: FALSE value removes manifest and manifest.uuid
60 set falses [list false off 0]
61 foreach v $falses {
62 fossil settings manifest $v
63
--- test/set-manifest.test
+++ test/set-manifest.test
@@ -15,10 +15,16 @@
15 #
16 ############################################################################
17 #
18 # Test manifest setting
19 #
20
21 # We need SHA1 to effectively test the manifest files produced by
22 # fossil. It looks like the one from tcllib is exactly what we need.
23 # On ActiveTcl, add it with teacup. On other platforms, YMMV.
24 # teacup install sha1
25 package require sha1
26
27 proc file_contains {fname match} {
28 set fp [open $fname r]
29 set contents [read $fp]
30 close $fp
@@ -53,10 +59,27 @@
59 test "set-manifest-2-$v-n" {[llength $filelist] == 2}
60 foreach f $filelist {
61 test "set-manifest-2-$v-f-$f" {[file isfile $f]}
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 fossil settings manifest $v
86

Keyboard Shortcuts

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