Fossil SCM
Added the ability to pass the knownBug constraint through test_status_list to test. Added capability for known bug marking of segments of stash-test, and use it to mark problems with stashing renamed files. Also added checking in stash-test for the exit status, and support for -expectError.
Commit
1a34614273d998829b9ef2c9826d59d2c9c71081
Parent
8b727021af01020…
2 files changed
+64
-12
+3
-3
+64
-12
| --- test/stash.test | ||
| +++ test/stash.test | ||
| @@ -17,31 +17,63 @@ | ||
| 17 | 17 | # |
| 18 | 18 | # |
| 19 | 19 | # Tests for 'fossil stash' |
| 20 | 20 | # |
| 21 | 21 | # |
| 22 | + | |
| 23 | +proc knownBug {t tests} { | |
| 24 | + return [expr {$t in $tests ? "knownBug" : ""}] | |
| 25 | +} | |
| 22 | 26 | |
| 23 | 27 | # Test 'fossil stash' against expected results from 'fossil changes' and |
| 24 | 28 | # 'fossil addremove -n', as well as by verifying the existence of files |
| 25 | -# on the file system. 'fossil undo' is called after each test | |
| 29 | +# on the file system. Unlike the similar function found in | |
| 30 | +# revert.test, 'fossil undo' is not called after each test because | |
| 31 | +# many stash operations aren't undoable, and because further testing | |
| 32 | +# of the stash content is more likely to be useful. | |
| 33 | +# | |
| 34 | +# The extra list "-knownbugs" is a list of areas that should be | |
| 35 | +# marked as "knownBug" to the inner call to test. Known areas are: | |
| 36 | +# -code The exit status of fossil stash | |
| 37 | +# -result The result string didn't match | |
| 38 | +# -changes The changed file set didn't match | |
| 39 | +# -addremove The addremove result set didn't match | |
| 40 | +# -exists One or more listed files don't exist | |
| 41 | +# -notexists One or more listed files do exist | |
| 26 | 42 | # |
| 43 | +# Also, if the exit status of fossil stash does not match | |
| 44 | +# expectations, the rest of the areas are not tested. | |
| 27 | 45 | proc stash-test {testid stashArgs expectedStashOutput args} { |
| 28 | 46 | global RESULT |
| 29 | 47 | set passed 1 |
| 30 | 48 | |
| 31 | 49 | set args [dict merge { |
| 32 | - -changes {} -addremove {} -exists {} -notexists {} | |
| 50 | + -changes {} -addremove {} -exists {} -notexists {} -knownbugs {} | |
| 33 | 51 | } $args] |
| 34 | - | |
| 52 | + | |
| 53 | + set knownbugs [dict get $args "-knownbugs"] | |
| 54 | + | |
| 35 | 55 | set result [fossil stash {*}$stashArgs] |
| 36 | - test_status_list stash-$testid $result $expectedStashOutput | |
| 56 | + set code $::CODE | |
| 57 | + if {[lindex $stashArgs end] eq "-expectError"} { | |
| 58 | + test stash-$testid-CODE {$code} [knownBug "-code" $knownbugs] | |
| 59 | + if {!$code} { | |
| 60 | + return | |
| 61 | + } | |
| 62 | + } else { | |
| 63 | + test stash-$testid-CODE {!$code} [knownBug "-code" $knownbugs] | |
| 64 | + if {$code} { | |
| 65 | + return | |
| 66 | + } | |
| 67 | + } | |
| 68 | + test_status_list stash-$testid $result $expectedStashOutput [knownBug "-result" $knownbugs] | |
| 37 | 69 | |
| 38 | 70 | set statusListTests [list -changes changes -addremove {addremove -n}] |
| 39 | 71 | foreach {key fossilArgs} $statusListTests { |
| 40 | 72 | set expected [dict get $args $key] |
| 41 | 73 | set result [fossil {*}$fossilArgs] |
| 42 | - test_status_list stash-$testid$key $result $expected | |
| 74 | + test_status_list stash-$testid$key $result $expected [knownBug $key $knownbugs] | |
| 43 | 75 | } |
| 44 | 76 | |
| 45 | 77 | set fileExistsTests [list -exists 1 does -notexists 0 should] |
| 46 | 78 | foreach {key expected verb} $fileExistsTests { |
| 47 | 79 | foreach path [dict get $args $key] { |
| @@ -48,11 +80,11 @@ | ||
| 48 | 80 | if {[file exists $path] != $expected} { |
| 49 | 81 | set passed 0 |
| 50 | 82 | protOut " Failure: File $verb not exist: $path" |
| 51 | 83 | } |
| 52 | 84 | } |
| 53 | - test stash-$testid$key $passed | |
| 85 | + test stash-$testid$key $passed [knownBug $key $knownbugs] | |
| 54 | 86 | } |
| 55 | 87 | |
| 56 | 88 | #fossil undo |
| 57 | 89 | } |
| 58 | 90 | |
| @@ -165,38 +197,58 @@ | ||
| 165 | 197 | |
| 166 | 198 | # Confirm there is no longer a stash saved |
| 167 | 199 | fossil stash list |
| 168 | 200 | test stash-2-list {[first_data_line] eq "empty stash"} |
| 169 | 201 | |
| 170 | -if {false} { | |
| 171 | -# skip this test, what should stash actually do with a | |
| 172 | -# soft rename? | |
| 173 | 202 | |
| 174 | 203 | # Test stashed mv without touching the file system |
| 175 | 204 | fossil checkout --force c1 |
| 176 | 205 | fossil clean |
| 177 | 206 | fossil mv --soft f1 f1new |
| 178 | 207 | #no such file: c:/Users/Ross/Documents/tmp/ftest/stash/f1b |
| 179 | -stash-test x1 {save -m "B 2016-02-09"} { | |
| 208 | +stash-test x1 {save -m "Reported 2016-02-09"} { | |
| 180 | 209 | REVERT f1 |
| 181 | 210 | DELETE f1new |
| 182 | 211 | } -changes { |
| 183 | 212 | } -addremove { |
| 184 | -} -exists {f1 f2 f3} -notexists {f1new} | |
| 213 | +} -exists {f1 f2 f3} -notexists {f1new} -knownbugs {-code -result} | |
| 214 | + | |
| 185 | 215 | # Issue reported by email to fossil-users |
| 186 | 216 | # from Warren Young, dated Tue, 9 Feb 2016 01:22:54 -0700 |
| 187 | 217 | # with checkin [b8c7af5bd9] plus a local patch on CentOS 5 |
| 188 | 218 | # 64 bit intel, 8-byte pointer, 4-byte integer |
| 189 | 219 | # Stashed renamed file said: |
| 190 | 220 | # fossil: ./src/delta.c:231: checksum: Assertion '...' failed. |
| 191 | 221 | # Should be triggered by the above stash-x1 test. |
| 192 | 222 | |
| 193 | -} | |
| 223 | + | |
| 224 | +# Test stashing the combination of a renamed file and an added file that | |
| 225 | +# uses the renamed file's original filename. I expect to see the same | |
| 226 | +# behavior as fossil revert: calmly back out both the rename and the | |
| 227 | +# add, and presumably stash the content of the added file before it | |
| 228 | +# is replaced by the revert. | |
| 229 | +# | |
| 230 | +repo_init | |
| 231 | +write_file f1 "f1" | |
| 232 | +fossil add f1 | |
| 233 | +fossil commit -m "add f1" | |
| 234 | + | |
| 235 | +write_file f1n "f1n" | |
| 236 | +fossil mv f1 f1n | |
| 237 | +write_file f1 "f1b" | |
| 238 | +fossil add f1 | |
| 239 | + | |
| 240 | +stash-test 2-1 {save -m "f1b"} { | |
| 241 | + REVERT f1 | |
| 242 | + DELETE f1n | |
| 243 | +} -exists {f1} -notexists {f1n} -knownbugs {-code -result} | |
| 244 | +# TODO: add tests that verify the saved stash is sensible. Possibly | |
| 245 | +# by applying it and checking results. | |
| 194 | 246 | |
| 195 | 247 | |
| 196 | 248 | # fossil stash snapshot ?-m|--comment COMMENT? ?FILES...? |
| 197 | 249 | # fossil stash apply ?STASHID? |
| 198 | 250 | # fossil stash goto ?STASHID? |
| 199 | 251 | # fossil stash rm|drop ?STASHID? ?-a|--all? |
| 200 | 252 | |
| 201 | 253 | #fossil checkout --force c1 |
| 202 | 254 | #fossil clean |
| 203 | 255 |
| --- test/stash.test | |
| +++ test/stash.test | |
| @@ -17,31 +17,63 @@ | |
| 17 | # |
| 18 | # |
| 19 | # Tests for 'fossil stash' |
| 20 | # |
| 21 | # |
| 22 | |
| 23 | # Test 'fossil stash' against expected results from 'fossil changes' and |
| 24 | # 'fossil addremove -n', as well as by verifying the existence of files |
| 25 | # on the file system. 'fossil undo' is called after each test |
| 26 | # |
| 27 | proc stash-test {testid stashArgs expectedStashOutput args} { |
| 28 | global RESULT |
| 29 | set passed 1 |
| 30 | |
| 31 | set args [dict merge { |
| 32 | -changes {} -addremove {} -exists {} -notexists {} |
| 33 | } $args] |
| 34 | |
| 35 | set result [fossil stash {*}$stashArgs] |
| 36 | test_status_list stash-$testid $result $expectedStashOutput |
| 37 | |
| 38 | set statusListTests [list -changes changes -addremove {addremove -n}] |
| 39 | foreach {key fossilArgs} $statusListTests { |
| 40 | set expected [dict get $args $key] |
| 41 | set result [fossil {*}$fossilArgs] |
| 42 | test_status_list stash-$testid$key $result $expected |
| 43 | } |
| 44 | |
| 45 | set fileExistsTests [list -exists 1 does -notexists 0 should] |
| 46 | foreach {key expected verb} $fileExistsTests { |
| 47 | foreach path [dict get $args $key] { |
| @@ -48,11 +80,11 @@ | |
| 48 | if {[file exists $path] != $expected} { |
| 49 | set passed 0 |
| 50 | protOut " Failure: File $verb not exist: $path" |
| 51 | } |
| 52 | } |
| 53 | test stash-$testid$key $passed |
| 54 | } |
| 55 | |
| 56 | #fossil undo |
| 57 | } |
| 58 | |
| @@ -165,38 +197,58 @@ | |
| 165 | |
| 166 | # Confirm there is no longer a stash saved |
| 167 | fossil stash list |
| 168 | test stash-2-list {[first_data_line] eq "empty stash"} |
| 169 | |
| 170 | if {false} { |
| 171 | # skip this test, what should stash actually do with a |
| 172 | # soft rename? |
| 173 | |
| 174 | # Test stashed mv without touching the file system |
| 175 | fossil checkout --force c1 |
| 176 | fossil clean |
| 177 | fossil mv --soft f1 f1new |
| 178 | #no such file: c:/Users/Ross/Documents/tmp/ftest/stash/f1b |
| 179 | stash-test x1 {save -m "B 2016-02-09"} { |
| 180 | REVERT f1 |
| 181 | DELETE f1new |
| 182 | } -changes { |
| 183 | } -addremove { |
| 184 | } -exists {f1 f2 f3} -notexists {f1new} |
| 185 | # Issue reported by email to fossil-users |
| 186 | # from Warren Young, dated Tue, 9 Feb 2016 01:22:54 -0700 |
| 187 | # with checkin [b8c7af5bd9] plus a local patch on CentOS 5 |
| 188 | # 64 bit intel, 8-byte pointer, 4-byte integer |
| 189 | # Stashed renamed file said: |
| 190 | # fossil: ./src/delta.c:231: checksum: Assertion '...' failed. |
| 191 | # Should be triggered by the above stash-x1 test. |
| 192 | |
| 193 | } |
| 194 | |
| 195 | |
| 196 | # fossil stash snapshot ?-m|--comment COMMENT? ?FILES...? |
| 197 | # fossil stash apply ?STASHID? |
| 198 | # fossil stash goto ?STASHID? |
| 199 | # fossil stash rm|drop ?STASHID? ?-a|--all? |
| 200 | |
| 201 | #fossil checkout --force c1 |
| 202 | #fossil clean |
| 203 |
| --- test/stash.test | |
| +++ test/stash.test | |
| @@ -17,31 +17,63 @@ | |
| 17 | # |
| 18 | # |
| 19 | # Tests for 'fossil stash' |
| 20 | # |
| 21 | # |
| 22 | |
| 23 | proc knownBug {t tests} { |
| 24 | return [expr {$t in $tests ? "knownBug" : ""}] |
| 25 | } |
| 26 | |
| 27 | # Test 'fossil stash' against expected results from 'fossil changes' and |
| 28 | # 'fossil addremove -n', as well as by verifying the existence of files |
| 29 | # on the file system. Unlike the similar function found in |
| 30 | # revert.test, 'fossil undo' is not called after each test because |
| 31 | # many stash operations aren't undoable, and because further testing |
| 32 | # of the stash content is more likely to be useful. |
| 33 | # |
| 34 | # The extra list "-knownbugs" is a list of areas that should be |
| 35 | # marked as "knownBug" to the inner call to test. Known areas are: |
| 36 | # -code The exit status of fossil stash |
| 37 | # -result The result string didn't match |
| 38 | # -changes The changed file set didn't match |
| 39 | # -addremove The addremove result set didn't match |
| 40 | # -exists One or more listed files don't exist |
| 41 | # -notexists One or more listed files do exist |
| 42 | # |
| 43 | # Also, if the exit status of fossil stash does not match |
| 44 | # expectations, the rest of the areas are not tested. |
| 45 | proc stash-test {testid stashArgs expectedStashOutput args} { |
| 46 | global RESULT |
| 47 | set passed 1 |
| 48 | |
| 49 | set args [dict merge { |
| 50 | -changes {} -addremove {} -exists {} -notexists {} -knownbugs {} |
| 51 | } $args] |
| 52 | |
| 53 | set knownbugs [dict get $args "-knownbugs"] |
| 54 | |
| 55 | set result [fossil stash {*}$stashArgs] |
| 56 | set code $::CODE |
| 57 | if {[lindex $stashArgs end] eq "-expectError"} { |
| 58 | test stash-$testid-CODE {$code} [knownBug "-code" $knownbugs] |
| 59 | if {!$code} { |
| 60 | return |
| 61 | } |
| 62 | } else { |
| 63 | test stash-$testid-CODE {!$code} [knownBug "-code" $knownbugs] |
| 64 | if {$code} { |
| 65 | return |
| 66 | } |
| 67 | } |
| 68 | test_status_list stash-$testid $result $expectedStashOutput [knownBug "-result" $knownbugs] |
| 69 | |
| 70 | set statusListTests [list -changes changes -addremove {addremove -n}] |
| 71 | foreach {key fossilArgs} $statusListTests { |
| 72 | set expected [dict get $args $key] |
| 73 | set result [fossil {*}$fossilArgs] |
| 74 | test_status_list stash-$testid$key $result $expected [knownBug $key $knownbugs] |
| 75 | } |
| 76 | |
| 77 | set fileExistsTests [list -exists 1 does -notexists 0 should] |
| 78 | foreach {key expected verb} $fileExistsTests { |
| 79 | foreach path [dict get $args $key] { |
| @@ -48,11 +80,11 @@ | |
| 80 | if {[file exists $path] != $expected} { |
| 81 | set passed 0 |
| 82 | protOut " Failure: File $verb not exist: $path" |
| 83 | } |
| 84 | } |
| 85 | test stash-$testid$key $passed [knownBug $key $knownbugs] |
| 86 | } |
| 87 | |
| 88 | #fossil undo |
| 89 | } |
| 90 | |
| @@ -165,38 +197,58 @@ | |
| 197 | |
| 198 | # Confirm there is no longer a stash saved |
| 199 | fossil stash list |
| 200 | test stash-2-list {[first_data_line] eq "empty stash"} |
| 201 | |
| 202 | |
| 203 | # Test stashed mv without touching the file system |
| 204 | fossil checkout --force c1 |
| 205 | fossil clean |
| 206 | fossil mv --soft f1 f1new |
| 207 | #no such file: c:/Users/Ross/Documents/tmp/ftest/stash/f1b |
| 208 | stash-test x1 {save -m "Reported 2016-02-09"} { |
| 209 | REVERT f1 |
| 210 | DELETE f1new |
| 211 | } -changes { |
| 212 | } -addremove { |
| 213 | } -exists {f1 f2 f3} -notexists {f1new} -knownbugs {-code -result} |
| 214 | |
| 215 | # Issue reported by email to fossil-users |
| 216 | # from Warren Young, dated Tue, 9 Feb 2016 01:22:54 -0700 |
| 217 | # with checkin [b8c7af5bd9] plus a local patch on CentOS 5 |
| 218 | # 64 bit intel, 8-byte pointer, 4-byte integer |
| 219 | # Stashed renamed file said: |
| 220 | # fossil: ./src/delta.c:231: checksum: Assertion '...' failed. |
| 221 | # Should be triggered by the above stash-x1 test. |
| 222 | |
| 223 | |
| 224 | # Test stashing the combination of a renamed file and an added file that |
| 225 | # uses the renamed file's original filename. I expect to see the same |
| 226 | # behavior as fossil revert: calmly back out both the rename and the |
| 227 | # add, and presumably stash the content of the added file before it |
| 228 | # is replaced by the revert. |
| 229 | # |
| 230 | repo_init |
| 231 | write_file f1 "f1" |
| 232 | fossil add f1 |
| 233 | fossil commit -m "add f1" |
| 234 | |
| 235 | write_file f1n "f1n" |
| 236 | fossil mv f1 f1n |
| 237 | write_file f1 "f1b" |
| 238 | fossil add f1 |
| 239 | |
| 240 | stash-test 2-1 {save -m "f1b"} { |
| 241 | REVERT f1 |
| 242 | DELETE f1n |
| 243 | } -exists {f1} -notexists {f1n} -knownbugs {-code -result} |
| 244 | # TODO: add tests that verify the saved stash is sensible. Possibly |
| 245 | # by applying it and checking results. |
| 246 | |
| 247 | |
| 248 | # fossil stash snapshot ?-m|--comment COMMENT? ?FILES...? |
| 249 | # fossil stash apply ?STASHID? |
| 250 | # fossil stash goto ?STASHID? |
| 251 | # fossil stash rm|drop ?STASHID? ?-a|--all? |
| 252 | |
| 253 | #fossil checkout --force c1 |
| 254 | #fossil clean |
| 255 |
+3
-3
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -266,19 +266,19 @@ | ||
| 266 | 266 | return $normalized |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | # Perform a test comparing two status lists |
| 270 | 270 | # |
| 271 | -proc test_status_list {name result expected} { | |
| 271 | +proc test_status_list {name result expected {constraints ""}} { | |
| 272 | 272 | set expected [normalize_status_list $expected] |
| 273 | 273 | set result [normalize_status_list $result] |
| 274 | 274 | if {$result eq $expected} { |
| 275 | - test $name 1 | |
| 275 | + test $name 1 $constraints | |
| 276 | 276 | } else { |
| 277 | 277 | protOut " Expected:\n [join $expected "\n "]" 1 |
| 278 | 278 | protOut " Got:\n [join $result "\n "]" 1 |
| 279 | - test $name 0 | |
| 279 | + test $name 0 $constraints | |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | # Append all arguments into a single value and then returns it. |
| 284 | 284 | # |
| 285 | 285 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -266,19 +266,19 @@ | |
| 266 | return $normalized |
| 267 | } |
| 268 | |
| 269 | # Perform a test comparing two status lists |
| 270 | # |
| 271 | proc test_status_list {name result expected} { |
| 272 | set expected [normalize_status_list $expected] |
| 273 | set result [normalize_status_list $result] |
| 274 | if {$result eq $expected} { |
| 275 | test $name 1 |
| 276 | } else { |
| 277 | protOut " Expected:\n [join $expected "\n "]" 1 |
| 278 | protOut " Got:\n [join $result "\n "]" 1 |
| 279 | test $name 0 |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | # Append all arguments into a single value and then returns it. |
| 284 | # |
| 285 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -266,19 +266,19 @@ | |
| 266 | return $normalized |
| 267 | } |
| 268 | |
| 269 | # Perform a test comparing two status lists |
| 270 | # |
| 271 | proc test_status_list {name result expected {constraints ""}} { |
| 272 | set expected [normalize_status_list $expected] |
| 273 | set result [normalize_status_list $result] |
| 274 | if {$result eq $expected} { |
| 275 | test $name 1 $constraints |
| 276 | } else { |
| 277 | protOut " Expected:\n [join $expected "\n "]" 1 |
| 278 | protOut " Got:\n [join $result "\n "]" 1 |
| 279 | test $name 0 $constraints |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | # Append all arguments into a single value and then returns it. |
| 284 | # |
| 285 |