unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 418c72969483c3bd4f57134cb43d2a335f8e93df 3359 bytes (raw)
name: test/lisp/emacs-lisp/comp-tests.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
;;; comp-tests.el --- Tests for comp.el  -*- lexical-binding:t -*-

;; Copyright (C) 2022 Free Software Foundation, Inc.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;;; Code:

(require 'ert)
(require 'ert-x)
(require 'comp)

(defvar comp-native-version-dir)
(defvar native-comp-eln-load-path)

(defmacro with-test-native-compile-prune-cache (&rest body)
  (declare (indent 0) (debug t))
  `(ert-with-temp-directory testdir
     (let ((usr-cache (expand-file-name "eln-usr-cache" testdir))
	   (sys-cache (expand-file-name "eln-sys-cache" testdir)))
       (make-directory usr-cache)
       (make-directory sys-cache)
       (let* ((c1 (expand-file-name "29.0.50-cur" usr-cache))
              (c2 (expand-file-name "29.0.50-old" usr-cache))
	      (s1 (expand-file-name "29.0.50-cur" sys-cache))
	      (s2 (expand-file-name "preloaded" s1))
              (native-comp-eln-load-path (list usr-cache sys-cache))
              (comp-native-version-dir "29.0.50-cur"))
	 (dolist (d (list c1 c2 s1 s2))
           (make-directory d)
           (with-temp-file (expand-file-name "some.eln" d) (insert "foo"))
           (with-temp-file (expand-file-name "some.eln.tmp" d) (insert "foo")))
	 ,@body))))

(ert-deftest test-native-compile-prune-cache ()
  (skip-unless (featurep 'native-compile))
  (with-test-native-compile-prune-cache
    (native-compile-prune-cache)
    (dolist (d (list c1 s1 s2))
      (should (file-directory-p d))
      (should (file-regular-p (expand-file-name "some.eln" d)))
      (should (file-regular-p (expand-file-name "some.eln.tmp" d))))
    (should-not (file-directory-p c2))
    (should-not (file-regular-p (expand-file-name "some.eln" c2)))
    (should-not (file-regular-p (expand-file-name "some.eln.tmp" c2)))))

(ert-deftest test-native-compile-prune-cache/delete-only-eln ()
  (skip-unless (featurep 'native-compile))
  (with-test-native-compile-prune-cache
    (dolist (d (list c1 c2 s1 s2))
      (with-temp-file (expand-file-name "keep.txt" d) (insert "foo")))
    (native-compile-prune-cache)
    (dolist (d (list c1 c2 s1 s2))
      (should (file-regular-p (expand-file-name "keep.txt" d))))))

(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" usr-cache))
          (f2 (expand-file-name "some.eln" usr-cache))
	  (f3 (expand-file-name "../some.eln" sys-cache))
	  (f4 (expand-file-name "some.eln" sys-cache)))
      (dolist (f (list f1 f2 f3 f4))
	(with-temp-file f (insert "foo")))
      (native-compile-prune-cache)
      (dolist (f (list f1 f2 f3 f4))
	(should (file-regular-p f))))))

;;; comp-tests.el ends here

debug log:

solving 418c729694 ...
found 418c729694 in https://git.savannah.gnu.org/cgit/emacs.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).