From 40b734c5003c71dc533d588bb00ea51a983bd730 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Mon, 17 Oct 2022 15:26:21 +0200
Subject: Don't prune *.eln files in parent of eln-load-path

* lisp/emacs-lisp/comp.el (native-compile-prune-cache): Don't
prune *.eln files in parent directory of `native-comp-eln-load-path'.
* test/lisp/emacs-lisp/comp-tests.el
(test-native-compile-prune-cache/dont-delete-in-parent-of-cache):
New test.
---
 test/lisp/emacs-lisp/comp-tests.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'test/lisp/emacs-lisp/comp-tests.el')

diff --git a/test/lisp/emacs-lisp/comp-tests.el b/test/lisp/emacs-lisp/comp-tests.el
index 97761cd728e..31f32dad1f5 100644
--- a/test/lisp/emacs-lisp/comp-tests.el
+++ b/test/lisp/emacs-lisp/comp-tests.el
@@ -59,4 +59,15 @@
    (should (file-regular-p (expand-file-name "keep1.txt" c1)))
    (should (file-regular-p (expand-file-name "keep2.txt" c2)))))
 
+(ert-deftest test-native-compile-prune-cache/dont-delete-in-parent-of-cache ()
+  (skip-unless (featurep 'native-compile))
+  (with-test-native-compile-prune-cache
+   (let ((f1 (expand-file-name "some.eln" (expand-file-name ".." testdir)))
+         (f2 (expand-file-name "some.eln" testdir)))
+     (with-temp-file f1 (insert "foo"))
+     (with-temp-file f2 (insert "foo"))
+     (native-compile-prune-cache)
+     (should (file-regular-p f1))
+     (should (file-regular-p f2)))))
+
 ;;; comp-tests.el ends here
-- 
cgit v1.2.3