aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2016-04-09 21:14:40 +0200
committerMichael Albinus2016-04-09 21:14:40 +0200
commit5e1c32e7916420a447b060a4ff2507364aff41a4 (patch)
tree3b497ce863abd971c6c866ee9ac40abdf975f2f2
parent6b0d58be9f6caa2fc4125ed98294e1937ee56d2a (diff)
downloademacs-5e1c32e7916420a447b060a4ff2507364aff41a4.tar.gz
emacs-5e1c32e7916420a447b060a4ff2507364aff41a4.zip
Add vc-backend and vc-responsible-backend tests
* lisp/vc/vc-hooks.el (vc-file-setprop, vc-file-getprop) (vc-file-clearprops): Use properties on absolute files. * test/lisp/vc/vc-tests.el (vc-test--unregister-function): Clear file properties. (vc-test--register): Add tests for `vc-backend' and `vc-responsible-backend'. Catch other errors but `vc-not-supported'. (vc-test--state, vc-test--checkout-model): Catch other errors but `vc-not-supported'. (vc-test--working-revision): Fix test for RCS and SCCS. Catch other errors but `vc-not-supported'. (vc-test-src02-state): Mark as an expected failure.
-rw-r--r--lisp/vc/vc-hooks.el6
-rw-r--r--test/lisp/vc/vc-tests.el73
2 files changed, 58 insertions, 21 deletions
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index c6512e95e49..97ccec84550 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -206,17 +206,17 @@ VC commands are globally reachable under the prefix `\\[vc-prefix-map]':
206 (not (memq property vc-touched-properties))) 206 (not (memq property vc-touched-properties)))
207 (setq vc-touched-properties (append (list property) 207 (setq vc-touched-properties (append (list property)
208 vc-touched-properties))) 208 vc-touched-properties)))
209 (put (intern file vc-file-prop-obarray) property value)) 209 (put (intern (expand-file-name file) vc-file-prop-obarray) property value))
210 210
211(defun vc-file-getprop (file property) 211(defun vc-file-getprop (file property)
212 "Get per-file VC PROPERTY for FILE." 212 "Get per-file VC PROPERTY for FILE."
213 (get (intern file vc-file-prop-obarray) property)) 213 (get (intern (expand-file-name file) vc-file-prop-obarray) property))
214 214
215(defun vc-file-clearprops (file) 215(defun vc-file-clearprops (file)
216 "Clear all VC properties of FILE." 216 "Clear all VC properties of FILE."
217 (if (boundp 'vc-parent-buffer) 217 (if (boundp 'vc-parent-buffer)
218 (kill-local-variable 'vc-parent-buffer)) 218 (kill-local-variable 'vc-parent-buffer))
219 (setplist (intern file vc-file-prop-obarray) nil)) 219 (setplist (intern (expand-file-name file) vc-file-prop-obarray) nil))
220 220
221 221
222;; We keep properties on each symbol naming a backend as follows: 222;; We keep properties on each symbol naming a backend as follows:
diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el
index 2faa1436522..2b3445aa56a 100644
--- a/test/lisp/vc/vc-tests.el
+++ b/test/lisp/vc/vc-tests.el
@@ -137,7 +137,7 @@ For backends which dont support it, it is emulated."
137 (tdir tmp-dir)) 137 (tdir tmp-dir))
138 ;; If CVS executable is an MSYS program, reformat the file 138 ;; If CVS executable is an MSYS program, reformat the file
139 ;; name of TMP-DIR to have the /d/foo/bar form supported by 139 ;; name of TMP-DIR to have the /d/foo/bar form supported by
140 ;; MSYS programs. (FIXME: What about Cygwin cvs.exe?) 140 ;; MSYS programs. (FIXME What about Cygwin cvs.exe?)
141 (if (eq (w32-application-type cvs-prog) 'msys) 141 (if (eq (w32-application-type cvs-prog) 'msys)
142 (setq tdir 142 (setq tdir
143 (concat "/" (substring tmp-dir 0 1) (substring tmp-dir 2)))) 143 (concat "/" (substring tmp-dir 0 1) (substring tmp-dir 2))))
@@ -201,19 +201,24 @@ For backends which dont support it, it is emulated."
201 ;; Save exit. 201 ;; Save exit.
202 (ignore-errors (run-hooks 'vc-test--cleanup-hook))))) 202 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
203 203
204;; Why isn't there `vc-unregister'? 204;; FIXME Why isn't there `vc-unregister'?
205(defun vc-test--unregister-function (backend file) 205(defun vc-test--unregister-function (backend file)
206 "Run the `vc-unregister' backend function. 206 "Run the `vc-unregister' backend function.
207For backends which dont support it, `vc-not-supported' is signalled." 207For backends which dont support it, `vc-not-supported' is signalled."
208 208
209 (let ((symbol (intern (downcase (format "vc-%s-unregister" backend))))) 209 (unwind-protect
210 (if (functionp symbol) 210 (let ((symbol (intern (downcase (format "vc-%s-unregister" backend)))))
211 (funcall symbol file) 211 (if (functionp symbol)
212 ;; CVS, SVN, SCCS, SRC and Mtn are not supported. 212 (funcall symbol file)
213 (signal 'vc-not-supported (list 'unregister backend))))) 213 ;; CVS, SVN, SCCS, SRC and Mtn are not supported.
214 (signal 'vc-not-supported (list 'unregister backend))))
215
216 ;; FIXME This shall be called in `vc-unregister'.
217 (vc-file-clearprops file)))
214 218
215(defun vc-test--register (backend) 219(defun vc-test--register (backend)
216 "Register and unregister a file." 220 "Register and unregister a file.
221This checks also `vc-backend' and `vc-reponsible-backend'."
217 222
218 (let ((vc-handled-backends `(,backend)) 223 (let ((vc-handled-backends `(,backend))
219 (default-directory 224 (default-directory
@@ -232,32 +237,58 @@ For backends which dont support it, `vc-not-supported' is signalled."
232 ;; Create empty repository. 237 ;; Create empty repository.
233 (make-directory default-directory) 238 (make-directory default-directory)
234 (vc-test--create-repo-function backend) 239 (vc-test--create-repo-function backend)
240 ;; For file oriented backends CVS, RCS and SVN the backend is
241 ;; returned, and the directory is registered already.
242 ;; FIXME is this correct?
243 (should (if (vc-backend default-directory)
244 (vc-registered default-directory)
245 (not (vc-registered default-directory))))
246 (should (eq (vc-responsible-backend default-directory) backend))
235 247
236 (let ((tmp-name1 (expand-file-name "foo" default-directory)) 248 (let ((tmp-name1 (expand-file-name "foo" default-directory))
237 (tmp-name2 "bla")) 249 (tmp-name2 "bla"))
238 ;; Register files. Check for it. 250 ;; Register files. Check for it.
239 (write-region "foo" nil tmp-name1 nil 'nomessage) 251 (write-region "foo" nil tmp-name1 nil 'nomessage)
240 (should (file-exists-p tmp-name1)) 252 (should (file-exists-p tmp-name1))
253 (should-not (vc-backend tmp-name1))
254 (should (eq (vc-responsible-backend tmp-name1) backend))
241 (should-not (vc-registered tmp-name1)) 255 (should-not (vc-registered tmp-name1))
256
242 (write-region "bla" nil tmp-name2 nil 'nomessage) 257 (write-region "bla" nil tmp-name2 nil 'nomessage)
243 (should (file-exists-p tmp-name2)) 258 (should (file-exists-p tmp-name2))
259 (should-not (vc-backend tmp-name2))
260 (should (eq (vc-responsible-backend tmp-name2) backend))
244 (should-not (vc-registered tmp-name2)) 261 (should-not (vc-registered tmp-name2))
262
245 (vc-register (list backend (list tmp-name1 tmp-name2))) 263 (vc-register (list backend (list tmp-name1 tmp-name2)))
246 (should (file-exists-p tmp-name1)) 264 (should (file-exists-p tmp-name1))
265 (should (eq (vc-backend tmp-name1) backend))
266 (should (eq (vc-responsible-backend tmp-name1) backend))
247 (should (vc-registered tmp-name1)) 267 (should (vc-registered tmp-name1))
268
248 (should (file-exists-p tmp-name2)) 269 (should (file-exists-p tmp-name2))
270 (should (eq (vc-backend tmp-name2) backend))
271 (should (eq (vc-responsible-backend tmp-name2) backend))
249 (should (vc-registered tmp-name2)) 272 (should (vc-registered tmp-name2))
250 273
274 ;; FIXME `vc-backend' accepts also a list of files,
275 ;; `vc-responsible-backend' doesn't. Is this right?
276 (should (vc-backend (list tmp-name1 tmp-name2)))
277
251 ;; Unregister the files. 278 ;; Unregister the files.
252 (condition-case err 279 (condition-case err
253 (progn 280 (progn
254 (vc-test--unregister-function backend tmp-name1) 281 (vc-test--unregister-function backend tmp-name1)
282 (should-not (vc-backend tmp-name1))
255 (should-not (vc-registered tmp-name1)) 283 (should-not (vc-registered tmp-name1))
256 (vc-test--unregister-function backend tmp-name2) 284 (vc-test--unregister-function backend tmp-name2)
285 (should-not (vc-backend tmp-name2))
257 (should-not (vc-registered tmp-name2))) 286 (should-not (vc-registered tmp-name2)))
258 ;; CVS, SVN, SCCS, SRC and Mtn are not supported. 287 ;; CVS, SVN, SCCS, SRC and Mtn are not supported.
259 (vc-not-supported t)) 288 (vc-not-supported t)
260 ;; The files shall still exist. 289 (t (signal (car err) (cdr err))))
290
291 ;; The files shall still exist.
261 (should (file-exists-p tmp-name1)) 292 (should (file-exists-p tmp-name1))
262 (should (file-exists-p tmp-name2)))) 293 (should (file-exists-p tmp-name2))))
263 294
@@ -331,7 +362,7 @@ For backends which dont support it, `vc-not-supported' is signalled."
331 (should (memq (vc-state tmp-name) '(added unregistered up-to-date))) 362 (should (memq (vc-state tmp-name) '(added unregistered up-to-date)))
332 363
333 ;; Unregister the file. Check state. 364 ;; Unregister the file. Check state.
334 (condition-case nil 365 (condition-case err
335 (progn 366 (progn
336 (vc-test--unregister-function backend tmp-name) 367 (vc-test--unregister-function backend tmp-name)
337 368
@@ -343,7 +374,8 @@ For backends which dont support it, `vc-not-supported' is signalled."
343 (should (eq (vc-state tmp-name) (vc-state tmp-name backend))) 374 (should (eq (vc-state tmp-name) (vc-state tmp-name backend)))
344 (should (memq (vc-state tmp-name) 375 (should (memq (vc-state tmp-name)
345 '(added unregistered up-to-date)))) 376 '(added unregistered up-to-date))))
346 (vc-not-supported (message "vc-state5 unsupported"))))) 377 (vc-not-supported (message "vc-state5 unsupported"))
378 (t (signal (car err) (cdr err))))))
347 379
348 ;; Save exit. 380 ;; Save exit.
349 (ignore-errors (run-hooks 'vc-test--cleanup-hook))))) 381 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
@@ -403,15 +435,16 @@ For backends which dont support it, `vc-not-supported' is signalled."
403 (vc-register 435 (vc-register
404 (list backend (list (file-name-nondirectory tmp-name)))) 436 (list backend (list (file-name-nondirectory tmp-name))))
405 437
406 ;; nil: Mtn Git RCS SCCS 438 ;; nil: Mtn Git
407 ;; "0": Bzr CVS Hg SRC SVN 439 ;; "0": Bzr CVS Hg SRC SVN
440 ;; "1.1" RCS SCCS
408 (message "vc-working-revision4 %s" (vc-working-revision tmp-name)) 441 (message "vc-working-revision4 %s" (vc-working-revision tmp-name))
409 (should (eq (vc-working-revision tmp-name) 442 (should (eq (vc-working-revision tmp-name)
410 (vc-working-revision tmp-name backend))) 443 (vc-working-revision tmp-name backend)))
411 (should (member (vc-working-revision tmp-name) '(nil "0"))) 444 (should (member (vc-working-revision tmp-name) '(nil "0" "1.1")))
412 445
413 ;; Unregister the file. Check working revision. 446 ;; Unregister the file. Check working revision.
414 (condition-case nil 447 (condition-case err
415 (progn 448 (progn
416 (vc-test--unregister-function backend tmp-name) 449 (vc-test--unregister-function backend tmp-name)
417 450
@@ -423,7 +456,8 @@ For backends which dont support it, `vc-not-supported' is signalled."
423 (should (eq (vc-working-revision tmp-name) 456 (should (eq (vc-working-revision tmp-name)
424 (vc-working-revision tmp-name backend))) 457 (vc-working-revision tmp-name backend)))
425 (should (member (vc-working-revision tmp-name) '(nil "0")))) 458 (should (member (vc-working-revision tmp-name) '(nil "0"))))
426 (vc-not-supported (message "vc-working-revision5 unsupported"))))) 459 (vc-not-supported (message "vc-working-revision5 unsupported"))
460 (t (signal (car err) (cdr err))))))
427 461
428 ;; Save exit. 462 ;; Save exit.
429 (ignore-errors (run-hooks 'vc-test--cleanup-hook))))) 463 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
@@ -494,7 +528,7 @@ For backends which dont support it, `vc-not-supported' is signalled."
494 '(announce implicit locking))) 528 '(announce implicit locking)))
495 529
496 ;; Unregister the file. Check checkout model. 530 ;; Unregister the file. Check checkout model.
497 (condition-case nil 531 (condition-case err
498 (progn 532 (progn
499 (vc-test--unregister-function backend tmp-name) 533 (vc-test--unregister-function backend tmp-name)
500 534
@@ -505,7 +539,8 @@ For backends which dont support it, `vc-not-supported' is signalled."
505 "vc-checkout-model5 %s" (vc-checkout-model backend tmp-name)) 539 "vc-checkout-model5 %s" (vc-checkout-model backend tmp-name))
506 (should (memq (vc-checkout-model backend tmp-name) 540 (should (memq (vc-checkout-model backend tmp-name)
507 '(announce implicit locking)))) 541 '(announce implicit locking))))
508 (vc-not-supported (message "vc-checkout-model5 unsupported"))))) 542 (vc-not-supported (message "vc-checkout-model5 unsupported"))
543 (t (signal (car err) (cdr err))))))
509 544
510 ;; Save exit. 545 ;; Save exit.
511 (ignore-errors (run-hooks 'vc-test--cleanup-hook))))) 546 (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
@@ -580,6 +615,8 @@ For backends which dont support it, `vc-not-supported' is signalled."
580 (ert-deftest 615 (ert-deftest
581 ,(intern (format "vc-test-%s02-state" backend-string)) () 616 ,(intern (format "vc-test-%s02-state" backend-string)) ()
582 ,(format "Check `vc-state' for the %s backend." backend-string) 617 ,(format "Check `vc-state' for the %s backend." backend-string)
618 ;; FIXME make this pass.
619 :expected-result ,(if (equal backend 'SRC) :failed :passed)
583 (skip-unless 620 (skip-unless
584 (ert-test-passed-p 621 (ert-test-passed-p
585 (ert-test-most-recent-result 622 (ert-test-most-recent-result