emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/buttercup 12850aa3e7 3/6: Limit trampoline generation as l


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 12850aa3e7 3/6: Limit trampoline generation as locally as possible
Date: Thu, 9 Mar 2023 18:00:42 -0500 (EST)

branch: elpa/buttercup
commit 12850aa3e7e267c00f5d87468b1933d65a24959f
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>

    Limit trampoline generation as locally as possible
    
    Setting native-comp-enable-subr-trampolines to nil only in
    buttercup-with-cleanup will not only make the affected area as small
    as possible, it will also make sure trampoline generation is properly
    disable no matter how the buttercup suites are run.
---
 buttercup.el            | 16 +++++++++-------
 tests/test-buttercup.el | 11 +++++++++++
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/buttercup.el b/buttercup.el
index abcc0e3278..6312b533f5 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1285,7 +1285,11 @@ in a `buttercup-with-cleanup' environment.")
 
 (defmacro buttercup-with-cleanup (&rest body)
   "Execute BODY, cleaning spys and the rest afterwards."
-  `(let ((buttercup--cleanup-functions nil))
+  `(let ((buttercup--cleanup-functions nil)
+         ;; Redefining certain primitive's trampolines will cause problems,
+         ;; see https://github.com/jorgenschaefer/emacs-buttercup/issues/230 
and
+         ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61880
+         (native-comp-enable-subr-trampolines nil))
      (unwind-protect (progn ,@body)
        (dolist (fun buttercup--cleanup-functions)
          (ignore-errors
@@ -1586,12 +1590,10 @@ Signal an error if any spec fail or if no suites have 
been
 defined. Signal no errors if NOERROR is non-nil. Return t if all
 specs pass, nil if at least one spec fail, and :no-suites if no suites
 have been defined."
-  ;; See https://github.com/jorgenschaefer/emacs-buttercup/issues/230.
-  (let ((native-comp-enable-subr-trampolines nil))
-    (if buttercup-suites
-        (buttercup--run-suites buttercup-suites noerror)
-      (or (and noerror :no-suites)
-          (error "No suites defined")))))
+  (if buttercup-suites
+      (buttercup--run-suites buttercup-suites noerror)
+    (or (and noerror :no-suites)
+        (error "No suites defined"))))
 
 (define-error 'buttercup-run-specs-failed "buttercup-run failed" 
'buttercup-error-base)
 
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 84b4c9e1d7..e12f2b598a 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -1344,6 +1344,17 @@ text properties using `ansi-color-apply'."
          (test-function 1 2)
          :to-throw 'error))
 
+      (it "works on native-compilation primitives"
+        ;; Redefining certain primitive's trampolines will cause problems,
+        ;; see https://github.com/jorgenschaefer/emacs-buttercup/issues/230 and
+        ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61880
+        (spy-on 'file-exists-p :and-return-value t)
+        (expect (spy-on 'buffer-file-name) :not :to-throw)
+        (expect (file-exists-p "foobar"))
+        (expect (buffer-file-name) :not :to-be-truthy)
+        (expect 'file-exists-p :to-have-been-called)
+        (expect 'buffer-file-name :to-have-been-called))
+
       (describe "will signal en error if"
         (it "used in before-all"
           (with-local-buttercup



reply via email to

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