Fossil SCM
Add additional tests and helper procedures and isolate some tests more.
Commit
892e523f7cb5052077534df3f4899c8bcb4fec6d
Parent
5c9a0fa7cf212fa…
1 file changed
+121
-44
+121
-44
| --- test/amend.test | ||
| +++ test/amend.test | ||
| @@ -17,38 +17,58 @@ | ||
| 17 | 17 | |
| 18 | 18 | proc uuid_from_commit {res var} { |
| 19 | 19 | upvar $var UUID |
| 20 | 20 | regexp {^New_Version: ([0-9a-f]{40})$} $res m UUID |
| 21 | 21 | } |
| 22 | + | |
| 23 | +proc uuid_from_branch {res var} { | |
| 24 | + upvar $var UUID | |
| 25 | + regexp {^New branch: ([0-9a-f]{40})$} $res m UUID | |
| 26 | +} | |
| 27 | + | |
| 28 | +proc uuid_from_checkout {var} { | |
| 29 | + global RESULT | |
| 30 | + upvar $var UUID | |
| 31 | + fossil status | |
| 32 | + regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID | |
| 33 | +} | |
| 22 | 34 | |
| 23 | 35 | # Make sure we are not in an open repository and initialize new repository |
| 24 | 36 | repo_init |
| 25 | 37 | |
| 26 | 38 | ######################################## |
| 27 | 39 | # Setup: Add file and commit # |
| 28 | 40 | ######################################## |
| 29 | -write_file datafile "data" | |
| 30 | 41 | |
| 42 | +if {![uuid_from_checkout UUIDINIT]} { | |
| 43 | + test amend-checkout-failure false | |
| 44 | + return | |
| 45 | +} | |
| 46 | +write_file datafile "data" | |
| 31 | 47 | fossil add datafile |
| 32 | 48 | fossil commit -m "c1" |
| 33 | -write_file datafile "data.file" | |
| 34 | -fossil commit -m "c2" | |
| 35 | 49 | if {![uuid_from_commit $RESULT UUID]} { |
| 36 | 50 | test amend-setup-failure false |
| 37 | 51 | return |
| 38 | 52 | } |
| 39 | 53 | |
| 40 | 54 | ######################################## |
| 41 | 55 | # Test: -branch # |
| 42 | 56 | ######################################## |
| 43 | -fossil amend $UUID -branch amended-branch | |
| 57 | +set UUIDB UUIDB | |
| 58 | +write_file datafile "data.file" | |
| 59 | +fossil commit -m "c2" | |
| 60 | +if {![uuid_from_commit $RESULT UUIDB]} { | |
| 61 | + test amend-branch.setup false | |
| 62 | +} | |
| 63 | +fossil amend $UUIDB -branch amended-branch | |
| 44 | 64 | test amend-branch-1.1 {[regexp {tags:\s+amended-branch} $RESULT]} |
| 45 | 65 | fossil branch ls |
| 46 | 66 | test amend-branch-1.2 {[string first "* amended-branch" $RESULT] != -1} |
| 47 | 67 | fossil tag list |
| 48 | 68 | test amend-branch-1.3 {[string first amended-branch $RESULT] != -1} |
| 49 | -fossil tag list --raw $UUID | |
| 69 | +fossil tag list --raw $UUIDB | |
| 50 | 70 | test amend-branch-1.4 {[string first "branch=amended-branch" $RESULT] != -1} |
| 51 | 71 | test amend-branch-1.5 {[string first "sym-amended-branch" $RESULT] != -1} |
| 52 | 72 | fossil timeline -n 1 |
| 53 | 73 | test amend-branch-1.6 {[string match {*Move*to*branch*amended-branch*} $RESULT]} |
| 54 | 74 | |
| @@ -71,48 +91,89 @@ | ||
| 71 | 91 | 1234 1234 |
| 72 | 92 | 123456 #123456 |
| 73 | 93 | } { |
| 74 | 94 | incr tc |
| 75 | 95 | fossil amend $UUID -bgcolor $color |
| 76 | - test amend-bgcolor-$tc.1 {[string match "*uuid:*$UUID*" $RESULT]} | |
| 96 | + test amend-bgcolor-1.$tc.a {[string match "*uuid:*$UUID*" $RESULT]} | |
| 77 | 97 | fossil tag list --raw $UUID |
| 78 | - test amend-bgcolor-$tc.2 {[string first "bgcolor=$result" $RESULT] != -1} | |
| 98 | + test amend-bgcolor-1.$tc.b {[string first "bgcolor=$result" $RESULT] != -1} | |
| 79 | 99 | fossil timeline -n 1 |
| 80 | - test amend-bgcolor-$tc.3 { | |
| 100 | + test amend-bgcolor-1.$tc.c { | |
| 81 | 101 | [string match "*Change*background*color*to*\"$result\"*" $RESULT] |
| 82 | 102 | } |
| 83 | 103 | if {[artifact_from_timeline $RESULT artid]} { |
| 84 | 104 | fossil artifact $artid |
| 85 | - test amend-bgcolor-$tc.4 { | |
| 105 | + test amend-bgcolor-1.$tc.d { | |
| 86 | 106 | [string match "*T +bgcolor $UUID $result*" $RESULT] |
| 87 | 107 | } |
| 88 | 108 | } else { |
| 89 | 109 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 90 | - test amend-bgcolor-$tc.4 false | |
| 110 | + test amend-bgcolor-1.$tc.d false | |
| 91 | 111 | } |
| 112 | +} | |
| 113 | +fossil amend $UUID -bgcolor {} | |
| 114 | +test amend-bgcolor-2.1 {[string match "*uuid:*$UUID*" $RESULT]} | |
| 115 | +fossil tag list --raw $UUID | |
| 116 | +test amend-bgcolor-2.2 { | |
| 117 | + [string first "bgcolor=" $RESULT] == -1 && | |
| 118 | + [string first "bgcolor" $RESULT] != -1 | |
| 119 | +} | |
| 120 | +fossil timeline -n 1 | |
| 121 | +test amend-bgcolor-2.3 {[string match "*Cancel*background*color.*" $RESULT]} | |
| 122 | +if {[artifact_from_timeline $RESULT artid]} { | |
| 123 | + fossil artifact $artid | |
| 124 | + test amend-bgcolor-2.4 {[string match "*T -bgcolor $UUID*" $RESULT]} | |
| 125 | +} else { | |
| 126 | + if {$VERBOSE} { protOut "No artifact found in timeline output" } | |
| 127 | + test amend-bgcolor-2.4 false | |
| 92 | 128 | } |
| 93 | 129 | |
| 94 | 130 | ######################################## |
| 95 | 131 | # Test: -branchcolor # |
| 96 | 132 | ######################################## |
| 97 | -fossil amend $UUID -branchcolor yellow | |
| 98 | -test amend-branchcolor-1.1 {[string match "*uuid:*$UUID*" $RESULT]} | |
| 99 | -fossil tag ls --raw $UUID | |
| 133 | +set UUID2 UUID2 | |
| 134 | +fossil branch new brclr $UUID | |
| 135 | +if {![uuid_from_branch $RESULT UUID2]} { | |
| 136 | + test amend-branchcolor.setup false | |
| 137 | +} | |
| 138 | +fossil update $UUID2 | |
| 139 | +fossil amend $UUID2 -branchcolor yellow | |
| 140 | +test amend-branchcolor-1.1 {[string match "*uuid:*$UUID2*" $RESULT]} | |
| 141 | +fossil tag ls --raw $UUID2 | |
| 100 | 142 | test amend-branchcolor-1.2 {[string first "bgcolor=yellow" $RESULT] != -1} |
| 101 | 143 | fossil timeline -n 1 |
| 102 | 144 | test amend-branchcolor-1.3 { |
| 103 | 145 | [string match {*Change*branch*background*color*to*"yellow".*} $RESULT] |
| 104 | 146 | } |
| 105 | 147 | if {[regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $RESULT m artid]} { |
| 106 | 148 | fossil artifact $artid |
| 107 | 149 | test amend-branchcolor-1.4 { |
| 108 | - [string match "*T \*bgcolor $UUID yellow*" $RESULT] | |
| 150 | + [string match "*T \*bgcolor $UUID2 yellow*" $RESULT] | |
| 109 | 151 | } |
| 110 | 152 | } else { |
| 111 | 153 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 112 | 154 | test amend-branchcolor-1.4 false |
| 113 | 155 | } |
| 156 | + | |
| 157 | +set UUIDN UUIDN | |
| 158 | +write_file datafile "brclr" | |
| 159 | +fossil commit -m "brclr" | |
| 160 | +if {![uuid_from_commit $RESULT UUIDN]} { | |
| 161 | + test amend-branchcolor-propagating.setup false | |
| 162 | +} | |
| 163 | +write_file datafile "bc1" | |
| 164 | +fossil commit -m "mc1" | |
| 165 | +write_file datafile "bc2" | |
| 166 | +fossil commit -m "mc2" | |
| 167 | +fossil amend $UUIDN -branchcolor deadbe | |
| 168 | +test amend-branchcolor-2.1 {[string match "*uuid:*$UUIDN*" $RESULT]} | |
| 169 | +fossil tag ls --raw current | |
| 170 | +test amend-branchcolor-2.2 {[string first "bgcolor=#deadbe" $RESULT] != -1} | |
| 171 | +fossil timeline -n 1 | |
| 172 | +test amend-branchcolor-2.3 { | |
| 173 | + [string match {*Change*branch*background*color*to*"#deadbe".*} $RESULT] | |
| 174 | +} | |
| 114 | 175 | |
| 115 | 176 | ######################################## |
| 116 | 177 | # Test: -author # |
| 117 | 178 | ######################################## |
| 118 | 179 | fossil amend $UUID -author author-test |
| @@ -127,13 +188,13 @@ | ||
| 127 | 188 | ######################################## |
| 128 | 189 | set timestamp [clock scan yesterday] |
| 129 | 190 | set date [clock format $timestamp -format "%Y-%m-%d" -gmt 1] |
| 130 | 191 | set time [clock format $timestamp -format "%H:%M:%S" -gmt 1] |
| 131 | 192 | set datetime "$date $time" |
| 132 | -fossil amend $UUID -date $datetime | |
| 133 | -test amend-date-1.1 {[string match "*uuid:*$UUID*$datetime*" $RESULT]} | |
| 134 | -fossil tag ls --raw $UUID | |
| 193 | +fossil amend $UUIDINIT -date $datetime | |
| 194 | +test amend-date-1.1 {[string match "*uuid:*$UUIDINIT*$datetime*" $RESULT]} | |
| 195 | +fossil tag ls --raw $UUIDINIT | |
| 135 | 196 | test amend-date-1.2 {[string first "date=$datetime" $RESULT] != -1} |
| 136 | 197 | fossil timeline -n 1 |
| 137 | 198 | test amend-date-1.3 {[string match "*Timestamp*$date*$time*" $RESULT]} |
| 138 | 199 | set badformats { |
| 139 | 200 | "%+" |
| @@ -144,60 +205,76 @@ | ||
| 144 | 205 | } |
| 145 | 206 | set sc 0 |
| 146 | 207 | foreach badformat $badformats { |
| 147 | 208 | incr sc |
| 148 | 209 | set datetime [clock format $timestamp -format $badformat -gmt 1] |
| 149 | - fossil amend $UUID -date $datetime | |
| 210 | + fossil amend $UUIDINIT -date $datetime | |
| 150 | 211 | test amend-date-2.$sc {[string first "YYYY-MM-DD HH:MM:SS" $RESULT] != -1} |
| 151 | 212 | } |
| 152 | 213 | |
| 153 | 214 | ######################################## |
| 154 | 215 | # Test: -hide # |
| 155 | 216 | ######################################## |
| 156 | -fossil amend $UUID -hide | |
| 157 | -test amend-hide-1.1 {[string match "*uuid:*$UUID*" $RESULT]} | |
| 158 | -fossil tag ls --raw $UUID | |
| 217 | +set UUIDH UUIDH | |
| 218 | +fossil revert | |
| 219 | +fossil update trunk | |
| 220 | +fossil branch new tohide current | |
| 221 | +if {![uuid_from_branch $RESULT UUIDH]} { | |
| 222 | + test amend-hide-setup false | |
| 223 | +} | |
| 224 | +fossil amend $UUIDH -hide | |
| 225 | +test amend-hide-1.1 {[string match "*uuid:*$UUIDH*" $RESULT]} | |
| 226 | +fossil tag ls --raw $UUIDH | |
| 159 | 227 | test amend-hide-1.2 {[string first "hidden" $RESULT] != -1} |
| 160 | 228 | fossil timeline -n 1 |
| 161 | 229 | test amend-hide-1.3 {[string match {*Add*propagating*"hidden".*} $RESULT]} |
| 162 | 230 | |
| 163 | 231 | ######################################## |
| 164 | 232 | # Test: -close # |
| 165 | 233 | ######################################## |
| 166 | -fossil amend $UUID -close | |
| 167 | -test amend-close-1.1 {[string match "*uuid:*$UUID*" $RESULT]} | |
| 168 | -fossil tag ls --raw $UUID | |
| 234 | +set UUIDC UUIDC | |
| 235 | +fossil branch new cllf $UUID | |
| 236 | +if {![uuid_from_branch $RESULT UUIDC]} { | |
| 237 | + test amend-close.setup false | |
| 238 | +} | |
| 239 | +fossil update $UUIDC | |
| 240 | +fossil amend $UUIDC -close | |
| 241 | +test amend-close-1.1.a {[string match "*uuid:*$UUIDC*" $RESULT]} | |
| 242 | +test amend-close-1.1.b { | |
| 243 | + [string match "*comment:*Create*new*branch*named*\"cllf\"*" $RESULT] | |
| 244 | +} | |
| 245 | +fossil tag ls --raw $UUIDC | |
| 169 | 246 | test amend-close-1.2 {[string first "closed" $RESULT] != -1} |
| 170 | 247 | fossil timeline -n 1 |
| 171 | 248 | test amend-close-1.3 {[string match {*Marked*"Closed".*} $RESULT]} |
| 172 | -write_file datafile "changed" | |
| 249 | +write_file datafile "cllf" | |
| 173 | 250 | fossil commit -m "should fail" |
| 174 | 251 | test amend-close-2 {[string first "closed leaf" $RESULT] != -1} |
| 175 | 252 | |
| 253 | +set UUID3 UUID3 | |
| 176 | 254 | fossil revert |
| 177 | 255 | fossil update trunk |
| 178 | 256 | write_file datafile "cb" |
| 179 | 257 | fossil commit -m "closed-branch" --branch "closebranch" |
| 180 | -if {![regexp {^New_Version: ([0-9a-f]{40})$} $RESULT m UUID3]} { | |
| 181 | - test amend-close-3.all false | |
| 182 | -} else { | |
| 183 | - write_file datafile "b1" | |
| 184 | - fossil commit -m "m1" | |
| 185 | - write_file datafile "b2" | |
| 186 | - fossil commit -m "m2" | |
| 187 | - fossil amend $UUID3 --close | |
| 188 | - test amend-close-3.1 {[string match "*uuid:*$UUID3*" $RESULT]} | |
| 189 | - fossil tag ls --raw current | |
| 190 | - test amend-close-3.2 {[string first "closed" $RESULT] != -1} | |
| 191 | - fossil timeline -n 1 | |
| 192 | - test amend-close-3.3 { | |
| 193 | - [string match "*Add*propagating*\"closed\".*" $RESULT] | |
| 194 | - } | |
| 195 | - write_file datafile "changed" | |
| 196 | - fossil commit -m "should fail" | |
| 197 | - test amend-close-3.4 {[string first "closed leaf" $RESULT] != -1} | |
| 198 | -} | |
| 258 | +if {![uuid_from_commit $RESULT UUID3]} { | |
| 259 | + test amend-close-3.setup false | |
| 260 | +} | |
| 261 | +write_file datafile "b1" | |
| 262 | +fossil commit -m "m1" | |
| 263 | +write_file datafile "b2" | |
| 264 | +fossil commit -m "m2" | |
| 265 | +fossil amend $UUID3 --close | |
| 266 | +test amend-close-3.1 {[string match "*uuid:*$UUID3*" $RESULT]} | |
| 267 | +fossil tag ls --raw current | |
| 268 | +test amend-close-3.2 {[string first "closed" $RESULT] != -1} | |
| 269 | +fossil timeline -n 1 | |
| 270 | +test amend-close-3.3 { | |
| 271 | + [string match "*Add*propagating*\"closed\".*" $RESULT] | |
| 272 | +} | |
| 273 | +write_file datafile "changed" | |
| 274 | +fossil commit -m "should fail" | |
| 275 | +test amend-close-3.4 {[string first "closed leaf" $RESULT] != -1} | |
| 199 | 276 | |
| 200 | 277 | ######################################## |
| 201 | 278 | # Test: -tag/-cancel # |
| 202 | 279 | ######################################## |
| 203 | 280 | set tagtests { |
| 204 | 281 |
| --- test/amend.test | |
| +++ test/amend.test | |
| @@ -17,38 +17,58 @@ | |
| 17 | |
| 18 | proc uuid_from_commit {res var} { |
| 19 | upvar $var UUID |
| 20 | regexp {^New_Version: ([0-9a-f]{40})$} $res m UUID |
| 21 | } |
| 22 | |
| 23 | # Make sure we are not in an open repository and initialize new repository |
| 24 | repo_init |
| 25 | |
| 26 | ######################################## |
| 27 | # Setup: Add file and commit # |
| 28 | ######################################## |
| 29 | write_file datafile "data" |
| 30 | |
| 31 | fossil add datafile |
| 32 | fossil commit -m "c1" |
| 33 | write_file datafile "data.file" |
| 34 | fossil commit -m "c2" |
| 35 | if {![uuid_from_commit $RESULT UUID]} { |
| 36 | test amend-setup-failure false |
| 37 | return |
| 38 | } |
| 39 | |
| 40 | ######################################## |
| 41 | # Test: -branch # |
| 42 | ######################################## |
| 43 | fossil amend $UUID -branch amended-branch |
| 44 | test amend-branch-1.1 {[regexp {tags:\s+amended-branch} $RESULT]} |
| 45 | fossil branch ls |
| 46 | test amend-branch-1.2 {[string first "* amended-branch" $RESULT] != -1} |
| 47 | fossil tag list |
| 48 | test amend-branch-1.3 {[string first amended-branch $RESULT] != -1} |
| 49 | fossil tag list --raw $UUID |
| 50 | test amend-branch-1.4 {[string first "branch=amended-branch" $RESULT] != -1} |
| 51 | test amend-branch-1.5 {[string first "sym-amended-branch" $RESULT] != -1} |
| 52 | fossil timeline -n 1 |
| 53 | test amend-branch-1.6 {[string match {*Move*to*branch*amended-branch*} $RESULT]} |
| 54 | |
| @@ -71,48 +91,89 @@ | |
| 71 | 1234 1234 |
| 72 | 123456 #123456 |
| 73 | } { |
| 74 | incr tc |
| 75 | fossil amend $UUID -bgcolor $color |
| 76 | test amend-bgcolor-$tc.1 {[string match "*uuid:*$UUID*" $RESULT]} |
| 77 | fossil tag list --raw $UUID |
| 78 | test amend-bgcolor-$tc.2 {[string first "bgcolor=$result" $RESULT] != -1} |
| 79 | fossil timeline -n 1 |
| 80 | test amend-bgcolor-$tc.3 { |
| 81 | [string match "*Change*background*color*to*\"$result\"*" $RESULT] |
| 82 | } |
| 83 | if {[artifact_from_timeline $RESULT artid]} { |
| 84 | fossil artifact $artid |
| 85 | test amend-bgcolor-$tc.4 { |
| 86 | [string match "*T +bgcolor $UUID $result*" $RESULT] |
| 87 | } |
| 88 | } else { |
| 89 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 90 | test amend-bgcolor-$tc.4 false |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | ######################################## |
| 95 | # Test: -branchcolor # |
| 96 | ######################################## |
| 97 | fossil amend $UUID -branchcolor yellow |
| 98 | test amend-branchcolor-1.1 {[string match "*uuid:*$UUID*" $RESULT]} |
| 99 | fossil tag ls --raw $UUID |
| 100 | test amend-branchcolor-1.2 {[string first "bgcolor=yellow" $RESULT] != -1} |
| 101 | fossil timeline -n 1 |
| 102 | test amend-branchcolor-1.3 { |
| 103 | [string match {*Change*branch*background*color*to*"yellow".*} $RESULT] |
| 104 | } |
| 105 | if {[regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $RESULT m artid]} { |
| 106 | fossil artifact $artid |
| 107 | test amend-branchcolor-1.4 { |
| 108 | [string match "*T \*bgcolor $UUID yellow*" $RESULT] |
| 109 | } |
| 110 | } else { |
| 111 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 112 | test amend-branchcolor-1.4 false |
| 113 | } |
| 114 | |
| 115 | ######################################## |
| 116 | # Test: -author # |
| 117 | ######################################## |
| 118 | fossil amend $UUID -author author-test |
| @@ -127,13 +188,13 @@ | |
| 127 | ######################################## |
| 128 | set timestamp [clock scan yesterday] |
| 129 | set date [clock format $timestamp -format "%Y-%m-%d" -gmt 1] |
| 130 | set time [clock format $timestamp -format "%H:%M:%S" -gmt 1] |
| 131 | set datetime "$date $time" |
| 132 | fossil amend $UUID -date $datetime |
| 133 | test amend-date-1.1 {[string match "*uuid:*$UUID*$datetime*" $RESULT]} |
| 134 | fossil tag ls --raw $UUID |
| 135 | test amend-date-1.2 {[string first "date=$datetime" $RESULT] != -1} |
| 136 | fossil timeline -n 1 |
| 137 | test amend-date-1.3 {[string match "*Timestamp*$date*$time*" $RESULT]} |
| 138 | set badformats { |
| 139 | "%+" |
| @@ -144,60 +205,76 @@ | |
| 144 | } |
| 145 | set sc 0 |
| 146 | foreach badformat $badformats { |
| 147 | incr sc |
| 148 | set datetime [clock format $timestamp -format $badformat -gmt 1] |
| 149 | fossil amend $UUID -date $datetime |
| 150 | test amend-date-2.$sc {[string first "YYYY-MM-DD HH:MM:SS" $RESULT] != -1} |
| 151 | } |
| 152 | |
| 153 | ######################################## |
| 154 | # Test: -hide # |
| 155 | ######################################## |
| 156 | fossil amend $UUID -hide |
| 157 | test amend-hide-1.1 {[string match "*uuid:*$UUID*" $RESULT]} |
| 158 | fossil tag ls --raw $UUID |
| 159 | test amend-hide-1.2 {[string first "hidden" $RESULT] != -1} |
| 160 | fossil timeline -n 1 |
| 161 | test amend-hide-1.3 {[string match {*Add*propagating*"hidden".*} $RESULT]} |
| 162 | |
| 163 | ######################################## |
| 164 | # Test: -close # |
| 165 | ######################################## |
| 166 | fossil amend $UUID -close |
| 167 | test amend-close-1.1 {[string match "*uuid:*$UUID*" $RESULT]} |
| 168 | fossil tag ls --raw $UUID |
| 169 | test amend-close-1.2 {[string first "closed" $RESULT] != -1} |
| 170 | fossil timeline -n 1 |
| 171 | test amend-close-1.3 {[string match {*Marked*"Closed".*} $RESULT]} |
| 172 | write_file datafile "changed" |
| 173 | fossil commit -m "should fail" |
| 174 | test amend-close-2 {[string first "closed leaf" $RESULT] != -1} |
| 175 | |
| 176 | fossil revert |
| 177 | fossil update trunk |
| 178 | write_file datafile "cb" |
| 179 | fossil commit -m "closed-branch" --branch "closebranch" |
| 180 | if {![regexp {^New_Version: ([0-9a-f]{40})$} $RESULT m UUID3]} { |
| 181 | test amend-close-3.all false |
| 182 | } else { |
| 183 | write_file datafile "b1" |
| 184 | fossil commit -m "m1" |
| 185 | write_file datafile "b2" |
| 186 | fossil commit -m "m2" |
| 187 | fossil amend $UUID3 --close |
| 188 | test amend-close-3.1 {[string match "*uuid:*$UUID3*" $RESULT]} |
| 189 | fossil tag ls --raw current |
| 190 | test amend-close-3.2 {[string first "closed" $RESULT] != -1} |
| 191 | fossil timeline -n 1 |
| 192 | test amend-close-3.3 { |
| 193 | [string match "*Add*propagating*\"closed\".*" $RESULT] |
| 194 | } |
| 195 | write_file datafile "changed" |
| 196 | fossil commit -m "should fail" |
| 197 | test amend-close-3.4 {[string first "closed leaf" $RESULT] != -1} |
| 198 | } |
| 199 | |
| 200 | ######################################## |
| 201 | # Test: -tag/-cancel # |
| 202 | ######################################## |
| 203 | set tagtests { |
| 204 |
| --- test/amend.test | |
| +++ test/amend.test | |
| @@ -17,38 +17,58 @@ | |
| 17 | |
| 18 | proc uuid_from_commit {res var} { |
| 19 | upvar $var UUID |
| 20 | regexp {^New_Version: ([0-9a-f]{40})$} $res m UUID |
| 21 | } |
| 22 | |
| 23 | proc uuid_from_branch {res var} { |
| 24 | upvar $var UUID |
| 25 | regexp {^New branch: ([0-9a-f]{40})$} $res m UUID |
| 26 | } |
| 27 | |
| 28 | proc uuid_from_checkout {var} { |
| 29 | global RESULT |
| 30 | upvar $var UUID |
| 31 | fossil status |
| 32 | regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID |
| 33 | } |
| 34 | |
| 35 | # Make sure we are not in an open repository and initialize new repository |
| 36 | repo_init |
| 37 | |
| 38 | ######################################## |
| 39 | # Setup: Add file and commit # |
| 40 | ######################################## |
| 41 | |
| 42 | if {![uuid_from_checkout UUIDINIT]} { |
| 43 | test amend-checkout-failure false |
| 44 | return |
| 45 | } |
| 46 | write_file datafile "data" |
| 47 | fossil add datafile |
| 48 | fossil commit -m "c1" |
| 49 | if {![uuid_from_commit $RESULT UUID]} { |
| 50 | test amend-setup-failure false |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | ######################################## |
| 55 | # Test: -branch # |
| 56 | ######################################## |
| 57 | set UUIDB UUIDB |
| 58 | write_file datafile "data.file" |
| 59 | fossil commit -m "c2" |
| 60 | if {![uuid_from_commit $RESULT UUIDB]} { |
| 61 | test amend-branch.setup false |
| 62 | } |
| 63 | fossil amend $UUIDB -branch amended-branch |
| 64 | test amend-branch-1.1 {[regexp {tags:\s+amended-branch} $RESULT]} |
| 65 | fossil branch ls |
| 66 | test amend-branch-1.2 {[string first "* amended-branch" $RESULT] != -1} |
| 67 | fossil tag list |
| 68 | test amend-branch-1.3 {[string first amended-branch $RESULT] != -1} |
| 69 | fossil tag list --raw $UUIDB |
| 70 | test amend-branch-1.4 {[string first "branch=amended-branch" $RESULT] != -1} |
| 71 | test amend-branch-1.5 {[string first "sym-amended-branch" $RESULT] != -1} |
| 72 | fossil timeline -n 1 |
| 73 | test amend-branch-1.6 {[string match {*Move*to*branch*amended-branch*} $RESULT]} |
| 74 | |
| @@ -71,48 +91,89 @@ | |
| 91 | 1234 1234 |
| 92 | 123456 #123456 |
| 93 | } { |
| 94 | incr tc |
| 95 | fossil amend $UUID -bgcolor $color |
| 96 | test amend-bgcolor-1.$tc.a {[string match "*uuid:*$UUID*" $RESULT]} |
| 97 | fossil tag list --raw $UUID |
| 98 | test amend-bgcolor-1.$tc.b {[string first "bgcolor=$result" $RESULT] != -1} |
| 99 | fossil timeline -n 1 |
| 100 | test amend-bgcolor-1.$tc.c { |
| 101 | [string match "*Change*background*color*to*\"$result\"*" $RESULT] |
| 102 | } |
| 103 | if {[artifact_from_timeline $RESULT artid]} { |
| 104 | fossil artifact $artid |
| 105 | test amend-bgcolor-1.$tc.d { |
| 106 | [string match "*T +bgcolor $UUID $result*" $RESULT] |
| 107 | } |
| 108 | } else { |
| 109 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 110 | test amend-bgcolor-1.$tc.d false |
| 111 | } |
| 112 | } |
| 113 | fossil amend $UUID -bgcolor {} |
| 114 | test amend-bgcolor-2.1 {[string match "*uuid:*$UUID*" $RESULT]} |
| 115 | fossil tag list --raw $UUID |
| 116 | test amend-bgcolor-2.2 { |
| 117 | [string first "bgcolor=" $RESULT] == -1 && |
| 118 | [string first "bgcolor" $RESULT] != -1 |
| 119 | } |
| 120 | fossil timeline -n 1 |
| 121 | test amend-bgcolor-2.3 {[string match "*Cancel*background*color.*" $RESULT]} |
| 122 | if {[artifact_from_timeline $RESULT artid]} { |
| 123 | fossil artifact $artid |
| 124 | test amend-bgcolor-2.4 {[string match "*T -bgcolor $UUID*" $RESULT]} |
| 125 | } else { |
| 126 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 127 | test amend-bgcolor-2.4 false |
| 128 | } |
| 129 | |
| 130 | ######################################## |
| 131 | # Test: -branchcolor # |
| 132 | ######################################## |
| 133 | set UUID2 UUID2 |
| 134 | fossil branch new brclr $UUID |
| 135 | if {![uuid_from_branch $RESULT UUID2]} { |
| 136 | test amend-branchcolor.setup false |
| 137 | } |
| 138 | fossil update $UUID2 |
| 139 | fossil amend $UUID2 -branchcolor yellow |
| 140 | test amend-branchcolor-1.1 {[string match "*uuid:*$UUID2*" $RESULT]} |
| 141 | fossil tag ls --raw $UUID2 |
| 142 | test amend-branchcolor-1.2 {[string first "bgcolor=yellow" $RESULT] != -1} |
| 143 | fossil timeline -n 1 |
| 144 | test amend-branchcolor-1.3 { |
| 145 | [string match {*Change*branch*background*color*to*"yellow".*} $RESULT] |
| 146 | } |
| 147 | if {[regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $RESULT m artid]} { |
| 148 | fossil artifact $artid |
| 149 | test amend-branchcolor-1.4 { |
| 150 | [string match "*T \*bgcolor $UUID2 yellow*" $RESULT] |
| 151 | } |
| 152 | } else { |
| 153 | if {$VERBOSE} { protOut "No artifact found in timeline output" } |
| 154 | test amend-branchcolor-1.4 false |
| 155 | } |
| 156 | |
| 157 | set UUIDN UUIDN |
| 158 | write_file datafile "brclr" |
| 159 | fossil commit -m "brclr" |
| 160 | if {![uuid_from_commit $RESULT UUIDN]} { |
| 161 | test amend-branchcolor-propagating.setup false |
| 162 | } |
| 163 | write_file datafile "bc1" |
| 164 | fossil commit -m "mc1" |
| 165 | write_file datafile "bc2" |
| 166 | fossil commit -m "mc2" |
| 167 | fossil amend $UUIDN -branchcolor deadbe |
| 168 | test amend-branchcolor-2.1 {[string match "*uuid:*$UUIDN*" $RESULT]} |
| 169 | fossil tag ls --raw current |
| 170 | test amend-branchcolor-2.2 {[string first "bgcolor=#deadbe" $RESULT] != -1} |
| 171 | fossil timeline -n 1 |
| 172 | test amend-branchcolor-2.3 { |
| 173 | [string match {*Change*branch*background*color*to*"#deadbe".*} $RESULT] |
| 174 | } |
| 175 | |
| 176 | ######################################## |
| 177 | # Test: -author # |
| 178 | ######################################## |
| 179 | fossil amend $UUID -author author-test |
| @@ -127,13 +188,13 @@ | |
| 188 | ######################################## |
| 189 | set timestamp [clock scan yesterday] |
| 190 | set date [clock format $timestamp -format "%Y-%m-%d" -gmt 1] |
| 191 | set time [clock format $timestamp -format "%H:%M:%S" -gmt 1] |
| 192 | set datetime "$date $time" |
| 193 | fossil amend $UUIDINIT -date $datetime |
| 194 | test amend-date-1.1 {[string match "*uuid:*$UUIDINIT*$datetime*" $RESULT]} |
| 195 | fossil tag ls --raw $UUIDINIT |
| 196 | test amend-date-1.2 {[string first "date=$datetime" $RESULT] != -1} |
| 197 | fossil timeline -n 1 |
| 198 | test amend-date-1.3 {[string match "*Timestamp*$date*$time*" $RESULT]} |
| 199 | set badformats { |
| 200 | "%+" |
| @@ -144,60 +205,76 @@ | |
| 205 | } |
| 206 | set sc 0 |
| 207 | foreach badformat $badformats { |
| 208 | incr sc |
| 209 | set datetime [clock format $timestamp -format $badformat -gmt 1] |
| 210 | fossil amend $UUIDINIT -date $datetime |
| 211 | test amend-date-2.$sc {[string first "YYYY-MM-DD HH:MM:SS" $RESULT] != -1} |
| 212 | } |
| 213 | |
| 214 | ######################################## |
| 215 | # Test: -hide # |
| 216 | ######################################## |
| 217 | set UUIDH UUIDH |
| 218 | fossil revert |
| 219 | fossil update trunk |
| 220 | fossil branch new tohide current |
| 221 | if {![uuid_from_branch $RESULT UUIDH]} { |
| 222 | test amend-hide-setup false |
| 223 | } |
| 224 | fossil amend $UUIDH -hide |
| 225 | test amend-hide-1.1 {[string match "*uuid:*$UUIDH*" $RESULT]} |
| 226 | fossil tag ls --raw $UUIDH |
| 227 | test amend-hide-1.2 {[string first "hidden" $RESULT] != -1} |
| 228 | fossil timeline -n 1 |
| 229 | test amend-hide-1.3 {[string match {*Add*propagating*"hidden".*} $RESULT]} |
| 230 | |
| 231 | ######################################## |
| 232 | # Test: -close # |
| 233 | ######################################## |
| 234 | set UUIDC UUIDC |
| 235 | fossil branch new cllf $UUID |
| 236 | if {![uuid_from_branch $RESULT UUIDC]} { |
| 237 | test amend-close.setup false |
| 238 | } |
| 239 | fossil update $UUIDC |
| 240 | fossil amend $UUIDC -close |
| 241 | test amend-close-1.1.a {[string match "*uuid:*$UUIDC*" $RESULT]} |
| 242 | test amend-close-1.1.b { |
| 243 | [string match "*comment:*Create*new*branch*named*\"cllf\"*" $RESULT] |
| 244 | } |
| 245 | fossil tag ls --raw $UUIDC |
| 246 | test amend-close-1.2 {[string first "closed" $RESULT] != -1} |
| 247 | fossil timeline -n 1 |
| 248 | test amend-close-1.3 {[string match {*Marked*"Closed".*} $RESULT]} |
| 249 | write_file datafile "cllf" |
| 250 | fossil commit -m "should fail" |
| 251 | test amend-close-2 {[string first "closed leaf" $RESULT] != -1} |
| 252 | |
| 253 | set UUID3 UUID3 |
| 254 | fossil revert |
| 255 | fossil update trunk |
| 256 | write_file datafile "cb" |
| 257 | fossil commit -m "closed-branch" --branch "closebranch" |
| 258 | if {![uuid_from_commit $RESULT UUID3]} { |
| 259 | test amend-close-3.setup false |
| 260 | } |
| 261 | write_file datafile "b1" |
| 262 | fossil commit -m "m1" |
| 263 | write_file datafile "b2" |
| 264 | fossil commit -m "m2" |
| 265 | fossil amend $UUID3 --close |
| 266 | test amend-close-3.1 {[string match "*uuid:*$UUID3*" $RESULT]} |
| 267 | fossil tag ls --raw current |
| 268 | test amend-close-3.2 {[string first "closed" $RESULT] != -1} |
| 269 | fossil timeline -n 1 |
| 270 | test amend-close-3.3 { |
| 271 | [string match "*Add*propagating*\"closed\".*" $RESULT] |
| 272 | } |
| 273 | write_file datafile "changed" |
| 274 | fossil commit -m "should fail" |
| 275 | test amend-close-3.4 {[string first "closed leaf" $RESULT] != -1} |
| 276 | |
| 277 | ######################################## |
| 278 | # Test: -tag/-cancel # |
| 279 | ######################################## |
| 280 | set tagtests { |
| 281 |