[Top][All Lists]

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

Re: dired-tests.el fails on MS-Windows

From: Tino Calancha
Subject: Re: dired-tests.el fails on MS-Windows
Date: Wed, 2 Aug 2017 15:44:59 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

On Tue, 1 Aug 2017, Fabrice Popineau wrote:

2017-08-01 21:04 GMT+02:00 Eli Zaretskii <address@hidden>:

      Only if there's no better way.  The Patch invocation definitely needs
      the --binary switch on Windows, though.  But the failure above is not
      about that, it's about something else, because directory-files returns
      an empty list.  Something prevents Patch from creating backup files.

When I add the '--binary' option to patch, the test passes.
Again, windows 10, mingw64.
Fabrice, Eli
does the following work in your environments?

--8<-----------------------------cut here---------------start------------->8---
commit 16fd5bf68538240b7a601e0975bdd92f0521b7e5
Author: Tino Calancha <address@hidden>
Date:   Wed Aug 2 15:37:11 2017 +0900

    Fix an ediff test which fails in MS-Windows

    * test/lisp/vc/ediff-ptch-tests.el (ediff-ptch-test-bug26084):
    Add comments to explain the test logic.
    Pass '--binary' option to 'patch' program in windows environments.
    Check explicitely that a backup is created before compare file contents.

diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el
index 387786ced0..6fbc1b0a8b 100644
--- a/test/lisp/vc/ediff-ptch-tests.el
+++ b/test/lisp/vc/ediff-ptch-tests.el
@@ -66,41 +66,55 @@
       (write-region nil nil bar nil 'silent))
     (call-process git-program nil `(:file ,patch) nil "diff")
     (call-process git-program nil nil nil "reset" "--hard" "HEAD")
+    ;; Visit the diff file i.e., patch; extract from it the parts
+    ;; affecting just each of the files: store in patch-bar the part
+    ;; affecting 'bar', and in patch-qux the part affecting 'qux'.
     (find-file patch)
         (let* ((info
                 (progn (ediff-map-patch-buffer (current-buffer)) 
-               (patch1
+               (patch-bar
                  (car (nth 3 (car info)))
                  (car (nth 4 (car info)))))
-               (patch2
+               (patch-qux
                  (car (nth 3 (cadr info)))
                  (car (nth 4 (cadr info))))))
           ;; Apply both patches.
-          (dolist (x (list (cons patch1 bar) (cons patch2 qux)))
+          (dolist (x (list (cons patch-bar bar) (cons patch-qux qux)))
-              (insert (car x))
-              (call-process-region (point-min)
-                                   (point-max)
-                                   ediff-patch-program
-                                   nil nil nil
-                                   "-b" (cdr x))))
-          ;; Check backup files were saved correctly.
+              ;; Some windows variants require the option '--binary'
+              ;; in order to 'patch' create backup files.
+              (let ((opts (format "--backup%s"
+                                  (if (memq system-type '(windows-nt ms-dos))
+                                      " --binary" ""))))
+                (insert (car x))
+                (call-process-region (point-min)
+                                     (point-max)
+                                     ediff-patch-program
+                                     nil nil nil
+                                     opts (cdr x)))))
+          ;; Check backup files were saved correctly; in Bug#26084 some
+          ;; of the backup files are overwritten with the actual content
+          ;; of the updated file.  To ensure that the bug is fixed we just
+          ;; need to check that every backup file produced has different
+          ;; content that the current updated file.
           (dolist (x (list qux bar))
             (let ((backup
                      tmpdir 'full
                      (concat (file-name-nondirectory x) ".")))))
-              (should-not
-               (string= (with-temp-buffer
-                          (insert-file-contents x)
-                          (buffer-string))
-                        (with-temp-buffer
-                          (insert-file-contents backup)
-                          (buffer-string))))))
+              ;; Compare files only if the backup has being created.
+              (when backup
+                (should-not
+                 (string= (with-temp-buffer
+                            (insert-file-contents x)
+                            (buffer-string))
+                          (with-temp-buffer
+                            (insert-file-contents backup)
+                            (buffer-string)))))))
           (delete-directory tmpdir 'recursive)
           (delete-file patch)))))

--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-08-02 built
Repository revision: 0fd6de9cb444d6cc553ea67815ccfb7a923012a2

reply via email to

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