diff options
| author | Tino Calancha | 2017-08-04 14:15:51 +0900 |
|---|---|---|
| committer | Tino Calancha | 2017-08-04 14:15:51 +0900 |
| commit | db5d38ddb0de83d8f920b7a128fe3fd5156fdf85 (patch) | |
| tree | 262a72a764827294c4bea1645f7ea3cd85688d9e /test/lisp/vc | |
| parent | 28e000435e1dfdc071cd4b68afe8514dcf9b3aa2 (diff) | |
| download | emacs-db5d38ddb0de83d8f920b7a128fe3fd5156fdf85.tar.gz emacs-db5d38ddb0de83d8f920b7a128fe3fd5156fdf85.zip | |
Fix 2 tests that fail 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.
* test/lisp/dired-tests.el (dired-test-bug25609):
Declare variable 'dired-dwim-target' right before the test.
Add comments to explain the test logic.
Ensure, before test the bug condition, that we are displaying the
2 dired buffers created in this test, and no other dired buffer
is shown.
Diffstat (limited to 'test/lisp/vc')
| -rw-r--r-- | test/lisp/vc/ediff-ptch-tests.el | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el index 387786ced06..6fbc1b0a8bd 100644 --- a/test/lisp/vc/ediff-ptch-tests.el +++ b/test/lisp/vc/ediff-ptch-tests.el | |||
| @@ -66,41 +66,55 @@ index 6a07f80..6e8e947 100644 | |||
| 66 | (write-region nil nil bar nil 'silent)) | 66 | (write-region nil nil bar nil 'silent)) |
| 67 | (call-process git-program nil `(:file ,patch) nil "diff") | 67 | (call-process git-program nil `(:file ,patch) nil "diff") |
| 68 | (call-process git-program nil nil nil "reset" "--hard" "HEAD") | 68 | (call-process git-program nil nil nil "reset" "--hard" "HEAD") |
| 69 | ;; Visit the diff file i.e., patch; extract from it the parts | ||
| 70 | ;; affecting just each of the files: store in patch-bar the part | ||
| 71 | ;; affecting 'bar', and in patch-qux the part affecting 'qux'. | ||
| 69 | (find-file patch) | 72 | (find-file patch) |
| 70 | (unwind-protect | 73 | (unwind-protect |
| 71 | (let* ((info | 74 | (let* ((info |
| 72 | (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map)) | 75 | (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map)) |
| 73 | (patch1 | 76 | (patch-bar |
| 74 | (buffer-substring-no-properties | 77 | (buffer-substring-no-properties |
| 75 | (car (nth 3 (car info))) | 78 | (car (nth 3 (car info))) |
| 76 | (car (nth 4 (car info))))) | 79 | (car (nth 4 (car info))))) |
| 77 | (patch2 | 80 | (patch-qux |
| 78 | (buffer-substring-no-properties | 81 | (buffer-substring-no-properties |
| 79 | (car (nth 3 (cadr info))) | 82 | (car (nth 3 (cadr info))) |
| 80 | (car (nth 4 (cadr info)))))) | 83 | (car (nth 4 (cadr info)))))) |
| 81 | ;; Apply both patches. | 84 | ;; Apply both patches. |
| 82 | (dolist (x (list (cons patch1 bar) (cons patch2 qux))) | 85 | (dolist (x (list (cons patch-bar bar) (cons patch-qux qux))) |
| 83 | (with-temp-buffer | 86 | (with-temp-buffer |
| 84 | (insert (car x)) | 87 | ;; Some windows variants require the option '--binary' |
| 85 | (call-process-region (point-min) | 88 | ;; in order to 'patch' create backup files. |
| 86 | (point-max) | 89 | (let ((opts (format "--backup%s" |
| 87 | ediff-patch-program | 90 | (if (memq system-type '(windows-nt ms-dos)) |
| 88 | nil nil nil | 91 | " --binary" "")))) |
| 89 | "-b" (cdr x)))) | 92 | (insert (car x)) |
| 90 | ;; Check backup files were saved correctly. | 93 | (call-process-region (point-min) |
| 94 | (point-max) | ||
| 95 | ediff-patch-program | ||
| 96 | nil nil nil | ||
| 97 | opts (cdr x))))) | ||
| 98 | ;; Check backup files were saved correctly; in Bug#26084 some | ||
| 99 | ;; of the backup files are overwritten with the actual content | ||
| 100 | ;; of the updated file. To ensure that the bug is fixed we just | ||
| 101 | ;; need to check that every backup file produced has different | ||
| 102 | ;; content that the current updated file. | ||
| 91 | (dolist (x (list qux bar)) | 103 | (dolist (x (list qux bar)) |
| 92 | (let ((backup | 104 | (let ((backup |
| 93 | (car | 105 | (car |
| 94 | (directory-files | 106 | (directory-files |
| 95 | tmpdir 'full | 107 | tmpdir 'full |
| 96 | (concat (file-name-nondirectory x) "."))))) | 108 | (concat (file-name-nondirectory x) "."))))) |
| 97 | (should-not | 109 | ;; Compare files only if the backup has being created. |
| 98 | (string= (with-temp-buffer | 110 | (when backup |
| 99 | (insert-file-contents x) | 111 | (should-not |
| 100 | (buffer-string)) | 112 | (string= (with-temp-buffer |
| 101 | (with-temp-buffer | 113 | (insert-file-contents x) |
| 102 | (insert-file-contents backup) | 114 | (buffer-string)) |
| 103 | (buffer-string)))))) | 115 | (with-temp-buffer |
| 116 | (insert-file-contents backup) | ||
| 117 | (buffer-string))))))) | ||
| 104 | (delete-directory tmpdir 'recursive) | 118 | (delete-directory tmpdir 'recursive) |
| 105 | (delete-file patch))))) | 119 | (delete-file patch))))) |
| 106 | 120 | ||