emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 3c5e3ca 05/10: * test/src/comp-test-funcs.el (comp-t


From: Andrea Corallo
Subject: feature/native-comp 3c5e3ca 05/10: * test/src/comp-test-funcs.el (comp-test-big-interactive): New test
Date: Sun, 29 Mar 2020 09:12:52 -0400 (EDT)

branch: feature/native-comp
commit 3c5e3ca2badeda8637e84586eace6ba619f0110a
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>

    * test/src/comp-test-funcs.el (comp-test-big-interactive): New test
---
 test/src/comp-test-funcs.el | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el
index 46d324b..67b8575 100644
--- a/test/src/comp-test-funcs.el
+++ b/test/src/comp-test-funcs.el
@@ -403,6 +403,41 @@
       (?< 1)
       (?> 2))))
 
+(defun comp-test-big-interactive (filename &optional force arg load)
+  ;; Check non trivial interactive form using `byte-recompile-file'.
+  (interactive
+   (let ((file buffer-file-name)
+        (file-name nil)
+        (file-dir nil))
+     (and file
+         (derived-mode-p 'emacs-lisp-mode)
+         (setq file-name (file-name-nondirectory file)
+               file-dir (file-name-directory file)))
+     (list (read-file-name (if current-prefix-arg
+                              "Byte compile file: "
+                            "Byte recompile file: ")
+                          file-dir file-name nil)
+          current-prefix-arg)))
+  (let ((dest (byte-compile-dest-file filename))
+        ;; Expand now so we get the current buffer's defaults
+        (filename (expand-file-name filename)))
+    (if (if (file-exists-p dest)
+            ;; File was already compiled
+            ;; Compile if forced to, or filename newer
+            (or force
+                (file-newer-than-file-p filename dest))
+          (and arg
+               (or (eq 0 arg)
+                   (y-or-n-p (concat "Compile "
+                                     filename "? ")))))
+        (progn
+          (if (and noninteractive (not byte-compile-verbose))
+              (message "Compiling %s..." filename))
+          (byte-compile-file filename load))
+      (when load
+       (load (if (file-exists-p dest) dest filename)))
+      'no-byte-compile)))
+
 (provide 'comp-test-funcs)
 
 ;;; comp-test-funcs.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]