[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7fad959: Ensure that byte compilation works for relative files (B
From: |
Philipp Stephani |
Subject: |
master 7fad959: Ensure that byte compilation works for relative files (Bug#45287). |
Date: |
Thu, 17 Dec 2020 06:20:42 -0500 (EST) |
branch: master
commit 7fad9591142f9d9d0bfce37dd8c65a847dbe8aa9
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>
Ensure that byte compilation works for relative files (Bug#45287).
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don’t fail if
target filename doesn’t contain a directory name.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--target-file-no-directory): New unit test.
---
lisp/emacs-lisp/bytecomp.el | 6 +++++-
test/lisp/emacs-lisp/bytecomp-tests.el | 15 +++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e23bb9f..64f2c01 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1967,7 +1967,11 @@ See also `emacs-lisp-byte-compile-and-load'."
;; We attempt to create a temporary file in the
;; target directory, so the target directory must be
;; writable.
- (file-writable-p (file-name-directory target-file)))
+ (file-writable-p
+ (file-name-directory
+ ;; Need to expand in case TARGET-FILE doesn't
+ ;; include a directory (Bug#45287).
+ (expand-file-name target-file))))
;; We must disable any code conversion here.
(let* ((coding-system-for-write 'no-conversion)
;; Write to a tempfile so that if another Emacs
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el
b/test/lisp/emacs-lisp/bytecomp-tests.el
index c2a3e3b..4a6e28f 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -1016,6 +1016,21 @@ mountpoint (Bug#44631)."
(set-file-modes directory #o700)
(delete-directory directory :recursive))))))
+(ert-deftest bytecomp-tests--target-file-no-directory ()
+ "Check that Bug#45287 is fixed."
+ (let ((directory (make-temp-file "bytecomp-tests-" :directory)))
+ (unwind-protect
+ (let* ((default-directory directory)
+ (byte-compile-dest-file-function (lambda (_) "test.elc"))
+ (byte-compile-error-on-warn t))
+ (write-region "" nil "test.el" nil nil nil 'excl)
+ (should (byte-compile-file "test.el"))
+ (should (file-regular-p "test.elc"))
+ (should (cl-plusp (file-attribute-size
+ (file-attributes "test.elc")))))
+ (with-demoted-errors "Error cleaning up directory: %s"
+ (delete-directory directory :recursive)))))
+
;; Local Variables:
;; no-byte-compile: t
;; End:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7fad959: Ensure that byte compilation works for relative files (Bug#45287).,
Philipp Stephani <=