emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is vc-diff-mergebase broken on master?


From: Matthias Meulien
Subject: Re: Is vc-diff-mergebase broken on master?
Date: Fri, 03 Sep 2021 00:54:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Dmitry,

Dmitry Gutov <dgutov@yandex.ru> writes:

> (...) I just pushed commit d2ad64b which seems to fix
> vc-diff-mergebase, as well similar problems that could still remain in
> any less frequently used commands, check it out.
>
> That said, new contributions to vc-tests.el would be quite welcome.
>
> If there was even one test scenario in there that called
> vc-diff-mergebase, we wouldn't have let this bug slip by.

I tried to write a test for with vc-version-diff to start with something
that looks easier to me. (Almost copy-pasta I'm afraid of.)

I installed RCS, CVS, SVN, Git, Bzr. Unfortunately the test fails with
the first two; Still no idea why...

Since it's the first time I use ERT and before I spend more time
investigating, can you confirm it's the kind of test you had in mind?

>From 6fc74be7a410233c0f71651ffdac49adbf82334e Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Fri, 3 Sep 2021 00:42:29 +0200
Subject: [PATCH] Extend vc tests

* test/lisp/vc/vc-tests.el (vc-test--version-diff): Test vc-version-diff
---
 test/lisp/vc/vc-tests.el | 71 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el
index f2807a3f06..beb79d1b36 100644
--- a/test/lisp/vc/vc-tests.el
+++ b/test/lisp/vc/vc-tests.el
@@ -547,6 +547,65 @@ vc-test--checkout-model
         (if tempdir (delete-directory tempdir t))
         (run-hooks 'vc-test--cleanup-hook)))))
 
+(defun vc-test--version-diff (backend)
+  "Check the diff version of a repository."
+
+  (let ((vc-handled-backends `(,backend))
+       (default-directory
+         (file-name-as-directory
+          (expand-file-name
+           (make-temp-name "vc-test") temporary-file-directory)))
+       (process-environment process-environment)
+       tempdir
+       vc-test--cleanup-hook)
+    (when (eq backend 'Bzr)
+      (setq tempdir (make-temp-file "vc-test--version-diff" t)
+           process-environment (cons (format "BZR_HOME=%s" tempdir)
+                                     process-environment)))
+
+    (unwind-protect
+       (progn
+         ;; Cleanup.
+         (add-hook
+          'vc-test--cleanup-hook
+          `(lambda () (delete-directory ,default-directory 'recursive)))
+
+         ;; Create empty repository.  Check repository checkout model.
+         (make-directory default-directory)
+         (vc-test--create-repo-function backend)
+
+         (let* ((tmp-name (expand-file-name "foo" default-directory))
+                 (files (list (file-name-nondirectory tmp-name))))
+           ;; Write and register a new file.
+           (write-region "originaltext" nil tmp-name nil 'nomessage)
+           (vc-register (list backend files))
+
+            ;; Checkin file.
+            (let ((buff (find-file tmp-name)))
+              (with-current-buffer buff
+                  (progn
+                    (vc-checkin files backend)
+                    (insert "Testing vc-version-diff")
+                    (log-edit-done))))
+
+            ;; Modify file content.
+            (write-region "updatedtext" nil tmp-name nil 'nomessage)
+
+           ;; Check version diff.
+            (message "vc-version-diff")
+            (vc-version-diff files nil nil)
+            (with-current-buffer "*vc-diff*"
+              (progn
+                (let ((rawtext (buffer-substring-no-properties (point-min)
+                                                               (point-max))))
+                  (should (string-search "-originaltext" rawtext))
+                  (should (string-search "+updatedtext" rawtext)))))))
+
+      ;; Save exit.
+      (ignore-errors
+        (if tempdir (delete-directory tempdir t))
+        (run-hooks 'vc-test--cleanup-hook)))))
+
 (defun vc-test--rename-file (backend)
   "Check the rename-file action."
 
@@ -712,6 +771,18 @@ vc-test--arch-enabled
               ',(intern
                  (format "vc-test-%s01-register" backend-string))))))
           (vc-test--rename-file ',backend))
+
+        (ert-deftest
+           ,(intern (format "vc-test-%s06-version-diff" backend-string)) ()
+         ,(format "Check `vc-version-diff' for the %s backend."
+                  backend-string)
+         (skip-unless
+          (ert-test-passed-p
+           (ert-test-most-recent-result
+            (ert-get-test
+             ',(intern
+                (format "vc-test-%s01-register" backend-string))))))
+         (vc-test--version-diff ',backend))
         ))))
 
 (provide 'vc-tests)
-- 
2.30.2

-- 
Matthias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]