aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2014-12-11 13:01:45 +0100
committerMichael Albinus2014-12-11 13:01:45 +0100
commit9ff164ac6fb3a7a3551679f75e95b306c24fdf33 (patch)
treee0df54cf9ff493077ab28ebf38b2b9730f75a791
parent452921cfc11b0e0f93130e57c4aa31036d91964e (diff)
downloademacs-9ff164ac6fb3a7a3551679f75e95b306c24fdf33.tar.gz
emacs-9ff164ac6fb3a7a3551679f75e95b306c24fdf33.zip
* automated/vc-tests.el (vc-test--revision-granularity-function):
New defun. (vc-test--create-repo-function): Rename from `vc-test--create-repo-if-not-supported'. Adapt all callees. (vc-test--create-repo): Check also for revision-granularity. (vc-test--unregister-function): Additional argument FILE. Adapt all callees. (vc-test--working-revision): New defun. (vc-test-*-working-revision): New tests.
-rw-r--r--test/ChangeLog12
-rw-r--r--test/automated/vc-tests.el114
2 files changed, 102 insertions, 24 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 8b7b74d43bd..c4ff2c70147 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,15 @@
12014-12-11 Michael Albinus <michael.albinus@gmx.de>
2
3 * automated/vc-tests.el (vc-test--revision-granularity-function):
4 New defun.
5 (vc-test--create-repo-function): Rename from
6 `vc-test--create-repo-if-not-supported'. Adapt all callees.
7 (vc-test--create-repo): Check also for revision-granularity.
8 (vc-test--unregister-function): Additional argument FILE. Adapt
9 all callees.
10 (vc-test--working-revision): New defun.
11 (vc-test-*-working-revision): New tests.
12
12014-12-10 Michael Albinus <michael.albinus@gmx.de> 132014-12-10 Michael Albinus <michael.albinus@gmx.de>
2 14
3 * automated/vc-tests.el (vc-test--register): Check, that the file 15 * automated/vc-tests.el (vc-test--register): Check, that the file
diff --git a/test/automated/vc-tests.el b/test/automated/vc-tests.el
index d0f2dc7f989..32cf0ddd8be 100644
--- a/test/automated/vc-tests.el
+++ b/test/automated/vc-tests.el
@@ -115,8 +115,13 @@
115 "Functions for cleanup at the end of an ert test. 115 "Functions for cleanup at the end of an ert test.
116Don't set it globally, the functions shall be let-bound.") 116Don't set it globally, the functions shall be let-bound.")
117 117
118(defun vc-test--create-repo-if-not-supported (backend) 118(defun vc-test--revision-granularity-function (backend)
119 "Create a local repository for backends which don't support `vc-create-repo'." 119 "Run the `vc-revision-granularity' backend function."
120 (funcall (intern (downcase (format "vc-%s-revision-granularity" backend)))))
121
122(defun vc-test--create-repo-function (backend)
123 "Run the `vc-create-repo' backend function.
124For backends which dont support it, it is emulated."
120 125
121 (cond 126 (cond
122 ((eq backend 'CVS) 127 ((eq backend 'CVS)
@@ -152,7 +157,7 @@ Don't set it globally, the functions shall be let-bound.")
152 (shell-command-to-string 157 (shell-command-to-string
153 (format "mtn --db=%s --branch=foo setup ." archive-name)))) 158 (format "mtn --db=%s --branch=foo setup ." archive-name))))
154 159
155 (t (signal 'vc-not-supported (list 'create-repo backend))))) 160 (t (vc-create-repo backend))))
156 161
157(defun vc-test--create-repo (backend) 162(defun vc-test--create-repo (backend)
158 "Create a test repository in `default-directory', a temporary directory." 163 "Create a test repository in `default-directory', a temporary directory."
@@ -171,23 +176,27 @@ Don't set it globally, the functions shall be let-bound.")
171 'vc-test--cleanup-hook 176 'vc-test--cleanup-hook
172 `(lambda () (delete-directory ,default-directory 'recursive))) 177 `(lambda () (delete-directory ,default-directory 'recursive)))
173 178
179 ;; Check the revision granularity.
180 (should (memq (vc-test--revision-granularity-function backend)
181 '(file repository)))
182
174 ;; Create empty repository. 183 ;; Create empty repository.
175 (make-directory default-directory) 184 (make-directory default-directory)
176 (should (file-directory-p default-directory)) 185 (should (file-directory-p default-directory))
177 (condition-case err 186 (vc-test--create-repo-function backend))
178 (vc-create-repo backend)
179 ;; CVS, Mtn and Arch need special handling.
180 (vc-not-supported (vc-test--create-repo-if-not-supported backend))))
181 187
182 ;; Save exit. 188 ;; Save exit.
183 (ignore-errors (run-hooks 'vc-test--cleanup-hook))))) 189 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
184 190
185(defun vc-test--unregister-function (backend) 191;; Why isn't there `vc-unregister'?
186 "Return the `vc-unregister' backend function." 192(defun vc-test--unregister-function (backend file)
193 "Run the `vc-unregister' backend function.
194For backends which dont support it, `vc-not-supported' is signalled."
187 195
188 (let ((symbol (intern (downcase (format "vc-%s-unregister" backend))))) 196 (let ((symbol (intern (downcase (format "vc-%s-unregister" backend)))))
189 (if (functionp symbol) 197 (if (functionp symbol)
190 symbol 198 (funcall symbol file)
199 ;; CVS, SVN, SCCS, SRC and Mtn are not supported.
191 (signal 'vc-not-supported (list 'unregister backend))))) 200 (signal 'vc-not-supported (list 'unregister backend)))))
192 201
193(defun vc-test--register (backend) 202(defun vc-test--register (backend)
@@ -209,10 +218,7 @@ Don't set it globally, the functions shall be let-bound.")
209 218
210 ;; Create empty repository. 219 ;; Create empty repository.
211 (make-directory default-directory) 220 (make-directory default-directory)
212 (condition-case err 221 (vc-test--create-repo-function backend)
213 (vc-create-repo backend)
214 ;; CVS, Mtn and Arch need special handling.
215 (vc-not-supported (vc-test--create-repo-if-not-supported backend)))
216 222
217 (let ((tmp-name1 (expand-file-name "foo" default-directory)) 223 (let ((tmp-name1 (expand-file-name "foo" default-directory))
218 (tmp-name2 "bla")) 224 (tmp-name2 "bla"))
@@ -230,12 +236,12 @@ Don't set it globally, the functions shall be let-bound.")
230 (should (file-exists-p tmp-name2)) 236 (should (file-exists-p tmp-name2))
231 (should (vc-registered tmp-name2)) 237 (should (vc-registered tmp-name2))
232 238
233 ;; Unregister the files. Why isn't there `vc-unregister'? 239 ;; Unregister the files.
234 (condition-case err 240 (condition-case err
235 (progn 241 (progn
236 (funcall (vc-test--unregister-function backend) tmp-name1) 242 (vc-test--unregister-function backend tmp-name1)
237 (should-not (vc-registered tmp-name1)) 243 (should-not (vc-registered tmp-name1))
238 (funcall (vc-test--unregister-function backend) tmp-name2) 244 (vc-test--unregister-function backend tmp-name2)
239 (should-not (vc-registered tmp-name2))) 245 (should-not (vc-registered tmp-name2)))
240 ;; CVS, SVN, SCCS, SRC and Mtn are not supported. 246 ;; CVS, SVN, SCCS, SRC and Mtn are not supported.
241 (vc-not-supported (message "%s" (error-message-string err)))) 247 (vc-not-supported (message "%s" (error-message-string err))))
@@ -266,10 +272,7 @@ Don't set it globally, the functions shall be let-bound.")
266 272
267 ;; Create empty repository. 273 ;; Create empty repository.
268 (make-directory default-directory) 274 (make-directory default-directory)
269 (condition-case err 275 (vc-test--create-repo-function backend)
270 (vc-create-repo backend)
271 ;; CVS, Mtn and Arch need special handling.
272 (vc-not-supported (vc-test--create-repo-if-not-supported backend)))
273 276
274 (message "%s" (vc-state default-directory backend)) 277 (message "%s" (vc-state default-directory backend))
275 ;(should (eq (vc-state default-directory backend) 'up-to-date)) 278 ;(should (eq (vc-state default-directory backend) 'up-to-date))
@@ -293,10 +296,62 @@ Don't set it globally, the functions shall be let-bound.")
293 ;; Unregister the file. Check for state. 296 ;; Unregister the file. Check for state.
294 (condition-case nil 297 (condition-case nil
295 (progn 298 (progn
296 (funcall (vc-test--unregister-function backend) tmp-name) 299 (vc-test--unregister-function backend tmp-name)
297 (message "%s" (vc-state tmp-name backend)) 300 (message "%s" (vc-state tmp-name backend))
298 );(should (eq (vc-state tmp-name backend) 'unregistered))) 301 );(should (eq (vc-state tmp-name backend) 'unregistered)))
299 ;; CVS, SVN, SCCS, SRC and Mtn are not supported. 302 (vc-not-supported (message "%s" 'unsupported)))))
303
304 ;; Save exit.
305 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
306
307(defun vc-test--working-revision (backend)
308 "Check the working revision of a repository."
309
310 (let ((vc-handled-backends `(,backend))
311 (default-directory
312 (file-name-as-directory
313 (expand-file-name
314 (make-temp-name "vc-test") temporary-file-directory)))
315 vc-test--cleanup-hook errors)
316
317 (unwind-protect
318 (progn
319 ;; Cleanup.
320 (add-hook
321 'vc-test--cleanup-hook
322 `(lambda () (delete-directory ,default-directory 'recursive)))
323
324 ;; Create empty repository.
325 (make-directory default-directory)
326 (vc-test--create-repo-function backend)
327
328 (should
329 (member
330 (vc-working-revision default-directory backend) '("0" "master")))
331
332 (let ((tmp-name (expand-file-name "foo" default-directory)))
333 ;; Check for initial state.
334 (should
335 (member (vc-working-revision tmp-name backend) '("0" "master")))
336
337 ;; Write a new file. Check for state.
338 (write-region "foo" nil tmp-name nil 'nomessage)
339 (should
340 (member (vc-working-revision tmp-name backend) '("0" "master")))
341
342 ;; Register a file. Check for state.
343 (vc-register
344 (list backend (list (file-name-nondirectory tmp-name))))
345 (should
346 (member (vc-working-revision tmp-name backend) '("0" "master")))
347
348 ;; Unregister the file. Check for working-revision.
349 (condition-case nil
350 (progn
351 (vc-test--unregister-function backend tmp-name)
352 (should
353 (member
354 (vc-working-revision tmp-name backend) '("0" "master"))))
300 (vc-not-supported (message "%s" 'unsupported))))) 355 (vc-not-supported (message "%s" 'unsupported)))))
301 356
302 ;; Save exit. 357 ;; Save exit.
@@ -383,7 +438,18 @@ Don't set it globally, the functions shall be let-bound.")
383 (ert-get-test 438 (ert-get-test
384 ',(intern 439 ',(intern
385 (format "vc-test-%s01-register" backend-string)))))) 440 (format "vc-test-%s01-register" backend-string))))))
386 (vc-test--state ',backend))))))) 441 (vc-test--state ',backend))
442
443 (ert-deftest
444 ,(intern (format "vc-test-%s03-working-revision" backend-string)) ()
445 ,(format "Check `vc-working-revision' for the %s backend." backend-string)
446 (skip-unless
447 (ert-test-passed-p
448 (ert-test-most-recent-result
449 (ert-get-test
450 ',(intern
451 (format "vc-test-%s01-register" backend-string))))))
452 (vc-test--working-revision ',backend)))))))
387 453
388(provide 'vc-tests) 454(provide 'vc-tests)
389;;; vc-tests.el ends here 455;;; vc-tests.el ends here