Fix wdired-tests on MS-Windows

* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-bug32173-02, wdired-test-unfinished-edit-01)
(wdired-test-bug39280): Run test-dir through file-truename, to
avoid failures due to MS-Windows "numeric tails" (mis)feature and
similar issues, which make file names fail to compare 'equal'.
(wdired-test-bug34915, wdired-test-bug61510): Skip if symlinks
fail.
This commit is contained in:
Eli Zaretskii 2023-03-02 14:21:33 +02:00
parent a137f71c67
commit 756225e377

View file

@ -31,6 +31,10 @@
"Test using non-nil wdired-use-interactive-rename. "Test using non-nil wdired-use-interactive-rename.
Partially modifying a file name should succeed." Partially modifying a file name should succeed."
(ert-with-temp-directory test-dir (ert-with-temp-directory test-dir
;; The call to file-truename is for MS-Windows, where numeric
;; tails or some other feature (like SUBST) could cause file names
;; to fail to compare 'equal'.
(setq test-dir (file-truename test-dir))
(let* ((test-file (concat (file-name-as-directory test-dir) "foo.c")) (let* ((test-file (concat (file-name-as-directory test-dir) "foo.c"))
(replace "bar") (replace "bar")
(new-file (string-replace "foo" replace test-file)) (new-file (string-replace "foo" replace test-file))
@ -56,6 +60,7 @@ Partially modifying a file name should succeed."
"Test using non-nil wdired-use-interactive-rename. "Test using non-nil wdired-use-interactive-rename.
Aborting an edit should leaving original file name unchanged." Aborting an edit should leaving original file name unchanged."
(ert-with-temp-directory test-dir (ert-with-temp-directory test-dir
(setq test-dir (file-truename test-dir))
(let* ((test-file (concat (file-name-as-directory test-dir) "foo.c")) (let* ((test-file (concat (file-name-as-directory test-dir) "foo.c"))
(wdired-use-interactive-rename t)) (wdired-use-interactive-rename t))
(write-region "" nil test-file nil 'silent) (write-region "" nil test-file nil 'silent)
@ -106,6 +111,7 @@ only the name before the link arrow."
Finding the new name should be possible while still in Finding the new name should be possible while still in
wdired-mode." wdired-mode."
(ert-with-temp-directory test-dir (ert-with-temp-directory test-dir
(setq test-dir (file-truename test-dir))
(let* ((test-file (concat (file-name-as-directory test-dir) "foo.c")) (let* ((test-file (concat (file-name-as-directory test-dir) "foo.c"))
(replace "bar") (replace "bar")
(new-file (string-replace "foo" replace test-file))) (new-file (string-replace "foo" replace test-file)))
@ -143,7 +149,11 @@ wdired-get-filename before and after editing."
(with-current-buffer buf (with-current-buffer buf
(dired-create-empty-file "foo") (dired-create-empty-file "foo")
(set-file-modes "foo" (file-modes-symbolic-to-number "+x")) (set-file-modes "foo" (file-modes-symbolic-to-number "+x"))
(make-symbolic-link "foo" "bar") (skip-unless
;; This check is for wdired, not symbolic links, so skip
;; it when make-symbolic-link fails for any reason (like
;; insufficient privileges).
(ignore-errors (make-symbolic-link "foo" "bar") t))
(make-directory "foodir") (make-directory "foodir")
(dired-smart-shell-command "mkfifo foopipe") (dired-smart-shell-command "mkfifo foopipe")
(when (featurep 'make-network-process '(:family local)) (when (featurep 'make-network-process '(:family local))
@ -176,6 +186,7 @@ wdired-get-filename before and after editing."
(ert-deftest wdired-test-bug39280 () (ert-deftest wdired-test-bug39280 ()
"Test for https://debbugs.gnu.org/39280." "Test for https://debbugs.gnu.org/39280."
(ert-with-temp-directory test-dir (ert-with-temp-directory test-dir
(setq test-dir (file-truename test-dir))
(let* ((fname "foo") (let* ((fname "foo")
(full-fname (expand-file-name fname test-dir))) (full-fname (expand-file-name fname test-dir)))
(make-empty-file full-fname) (make-empty-file full-fname)
@ -202,7 +213,11 @@ should be invisible again."
(dired-hide-details-hide-symlink-targets t)) (dired-hide-details-hide-symlink-targets t))
(unwind-protect (unwind-protect
(with-current-buffer buf (with-current-buffer buf
(make-symbolic-link "bar" "foo") (skip-unless
;; This check is for wdired, not symbolic links, so skip
;; it when make-symbolic-link fails for any reason (like
;; insufficient privileges).
(ignore-errors (make-symbolic-link "bar" "foo") t))
(dired-hide-details-mode) (dired-hide-details-mode)
(should (memq 'dired-hide-details-link buffer-invisibility-spec)) (should (memq 'dired-hide-details-link buffer-invisibility-spec))
(dired-toggle-read-only) (dired-toggle-read-only)