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.
Commit
bf62b1608c62eab08762f4dfa9fd789db6356948
Parent
f63576a79652366…
1 file changed
+23
+23
| --- test/set-manifest.test | ||
| +++ test/set-manifest.test | ||
| @@ -15,10 +15,16 @@ | ||
| 15 | 15 | # |
| 16 | 16 | ############################################################################ |
| 17 | 17 | # |
| 18 | 18 | # Test manifest setting |
| 19 | 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 | |
| 20 | 26 | |
| 21 | 27 | proc file_contains {fname match} { |
| 22 | 28 | set fp [open $fname r] |
| 23 | 29 | set contents [read $fp] |
| 24 | 30 | close $fp |
| @@ -53,10 +59,27 @@ | ||
| 53 | 59 | test "set-manifest-2-$v-n" {[llength $filelist] == 2} |
| 54 | 60 | foreach f $filelist { |
| 55 | 61 | test "set-manifest-2-$v-f-$f" {[file isfile $f]} |
| 56 | 62 | } |
| 57 | 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 | + | |
| 58 | 81 | |
| 59 | 82 | # Classic behavior: FALSE value removes manifest and manifest.uuid |
| 60 | 83 | set falses [list false off 0] |
| 61 | 84 | foreach v $falses { |
| 62 | 85 | fossil settings manifest $v |
| 63 | 86 |
| --- 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 |