all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Fabrice Popineau <fabrice.popineau@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Emacs developers <emacs-devel@gnu.org>,
	Tino Calancha <tino.calancha@gmail.com>
Subject: Re: dired-tests.el fails on MS-Windows
Date: Wed, 2 Aug 2017 15:44:59 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1708021543570.29825@calancha-pc> (raw)
In-Reply-To: <CAFgFV9OoN0YWoaBhnybjPn1HXhD_XCh4gdHhShmSE+aZ6QXG3g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5134 bytes --]



On Tue, 1 Aug 2017, Fabrice Popineau wrote:

> 
> 
> 2017-08-01 21:04 GMT+02:00 Eli Zaretskii <eliz@gnu.org>:
>
>       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 <tino.calancha@gmail.com>
Date:   Wed Aug 2 15:37:11 2017 +0900

     Fix an ediff test which fails in MS-Windows

     https://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00018.html
     * 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)
      (unwind-protect
          (let* ((info
                  (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map))
-               (patch1
+               (patch-bar
                  (buffer-substring-no-properties
                   (car (nth 3 (car info)))
                   (car (nth 4 (car info)))))
-               (patch2
+               (patch-qux
                  (buffer-substring-no-properties
                   (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)))
              (with-temp-buffer
-              (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
                     (car
                      (directory-files
                       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	other threads:[~2017-08-02  6:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01 15:22 dired-tests.el fails on MS-Windows Eli Zaretskii
2017-08-01 17:02 ` Tino Calancha
2017-08-01 19:04   ` Eli Zaretskii
2017-08-01 20:56     ` Fabrice Popineau
2017-08-02  6:44       ` Tino Calancha [this message]
2017-08-04 13:18         ` Eli Zaretskii
2017-08-04 13:30           ` Fabrice Popineau
2017-08-04 13:44             ` Tino Calancha
2017-08-04 14:01               ` Fabrice Popineau
2017-08-04 14:00             ` Eli Zaretskii
2017-08-04  5:21     ` Tino Calancha
2017-08-04 13:14       ` Eli Zaretskii
2017-08-04 13:39         ` Tino Calancha
2017-08-04 14:23         ` Fabrice Popineau
2017-08-04 14:39           ` Fabrice Popineau
2017-08-04 14:49             ` Tino Calancha
2017-08-04 14:58               ` Fabrice Popineau
2017-08-04 15:10                 ` Tino Calancha
2017-08-01 20:52 ` Fabrice Popineau
2017-08-02  3:38   ` Tino Calancha
2017-08-02  6:31     ` Michael Albinus
2017-08-02  7:59       ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1708021543570.29825@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=fabrice.popineau@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.