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.

rberteig 2016-02-11 20:32 trunk
Commit 1a34614273d998829b9ef2c9826d59d2c9c71081
2 files changed +64 -12 +3 -3
+64 -12
--- test/stash.test
+++ test/stash.test
@@ -17,31 +17,63 @@
1717
#
1818
#
1919
# Tests for 'fossil stash'
2020
#
2121
#
22
+
23
+proc knownBug {t tests} {
24
+ return [expr {$t in $tests ? "knownBug" : ""}]
25
+}
2226
2327
# Test 'fossil stash' against expected results from 'fossil changes' and
2428
# '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
2642
#
43
+# Also, if the exit status of fossil stash does not match
44
+# expectations, the rest of the areas are not tested.
2745
proc stash-test {testid stashArgs expectedStashOutput args} {
2846
global RESULT
2947
set passed 1
3048
3149
set args [dict merge {
32
- -changes {} -addremove {} -exists {} -notexists {}
50
+ -changes {} -addremove {} -exists {} -notexists {} -knownbugs {}
3351
} $args]
34
-
52
+
53
+ set knownbugs [dict get $args "-knownbugs"]
54
+
3555
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]
3769
3870
set statusListTests [list -changes changes -addremove {addremove -n}]
3971
foreach {key fossilArgs} $statusListTests {
4072
set expected [dict get $args $key]
4173
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]
4375
}
4476
4577
set fileExistsTests [list -exists 1 does -notexists 0 should]
4678
foreach {key expected verb} $fileExistsTests {
4779
foreach path [dict get $args $key] {
@@ -48,11 +80,11 @@
4880
if {[file exists $path] != $expected} {
4981
set passed 0
5082
protOut " Failure: File $verb not exist: $path"
5183
}
5284
}
53
- test stash-$testid$key $passed
85
+ test stash-$testid$key $passed [knownBug $key $knownbugs]
5486
}
5587
5688
#fossil undo
5789
}
5890
@@ -165,38 +197,58 @@
165197
166198
# Confirm there is no longer a stash saved
167199
fossil stash list
168200
test stash-2-list {[first_data_line] eq "empty stash"}
169201
170
-if {false} {
171
-# skip this test, what should stash actually do with a
172
-# soft rename?
173202
174203
# Test stashed mv without touching the file system
175204
fossil checkout --force c1
176205
fossil clean
177206
fossil mv --soft f1 f1new
178207
#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"} {
180209
REVERT f1
181210
DELETE f1new
182211
} -changes {
183212
} -addremove {
184
-} -exists {f1 f2 f3} -notexists {f1new}
213
+} -exists {f1 f2 f3} -notexists {f1new} -knownbugs {-code -result}
214
+
185215
# Issue reported by email to fossil-users
186216
# from Warren Young, dated Tue, 9 Feb 2016 01:22:54 -0700
187217
# with checkin [b8c7af5bd9] plus a local patch on CentOS 5
188218
# 64 bit intel, 8-byte pointer, 4-byte integer
189219
# Stashed renamed file said:
190220
# fossil: ./src/delta.c:231: checksum: Assertion '...' failed.
191221
# Should be triggered by the above stash-x1 test.
192222
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.
194246
195247
196248
# fossil stash snapshot ?-m|--comment COMMENT? ?FILES...?
197249
# fossil stash apply ?STASHID?
198250
# fossil stash goto ?STASHID?
199251
# fossil stash rm|drop ?STASHID? ?-a|--all?
200252
201253
#fossil checkout --force c1
202254
#fossil clean
203255
--- 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 @@
266266
return $normalized
267267
}
268268
269269
# Perform a test comparing two status lists
270270
#
271
-proc test_status_list {name result expected} {
271
+proc test_status_list {name result expected {constraints ""}} {
272272
set expected [normalize_status_list $expected]
273273
set result [normalize_status_list $result]
274274
if {$result eq $expected} {
275
- test $name 1
275
+ test $name 1 $constraints
276276
} else {
277277
protOut " Expected:\n [join $expected "\n "]" 1
278278
protOut " Got:\n [join $result "\n "]" 1
279
- test $name 0
279
+ test $name 0 $constraints
280280
}
281281
}
282282
283283
# Append all arguments into a single value and then returns it.
284284
#
285285
--- 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

Keyboard Shortcuts

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