[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-simulated-input 4eedb0eee8 126/134: Use an alternate
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/with-simulated-input 4eedb0eee8 126/134: Use an alternate method to disable eager macro-expansion for testing |
Date: |
Mon, 10 Jan 2022 23:00:13 -0500 (EST) |
branch: elpa/with-simulated-input
commit 4eedb0eee8ba9ffbb0c0f988ad789e79b4d7a23e
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>
Use an alternate method to disable eager macro-expansion for testing
---
Eldev | 23 +++++++++++++++++++++++
tests/test-with-simulated-input.el | 25 ++++---------------------
2 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/Eldev b/Eldev
index ed4367454c..b7c9a1f1cd 100644
--- a/Eldev
+++ b/Eldev
@@ -9,3 +9,26 @@
;; Tell checkdoc not to demand two spaces after a period.
(setq sentence-end-double-space nil)
+
+;; Disable eager macro expansion during test loading, so that macros
+;; get expanded *during* test execution, not before.
+(defvar internal-macroexpand-for-load-original-symbol-function
+ (symbol-function 'internal-macroexpand-for-load))
+
+(add-hook
+ 'eldev-before-loading-dependencies-hook
+ (lambda (type additional-sets)
+ ;; Execute before loading test deps. This hook is the closest I can
+ ;; find to "right before loading the test files".
+ (when (and type
+ (memq 'test (if (listp additional-sets)
+ additional-sets
+ (list additional-sets))))
+ (fmakunbound 'internal-macroexpand-for-load))))
+
+;; In order to minimize the possibility of disruption, put the
+;; function back after loading the tests.
+(add-hook 'eldev-test-buttercup-hook
+ (lambda (&rest _)
+ (fset 'internal-macroexpand-for-load
+ internal-macroexpand-for-load-original-symbol-function)))
diff --git a/tests/test-with-simulated-input.el
b/tests/test-with-simulated-input.el
index 8675c9a686..f896424ac6 100644
--- a/tests/test-with-simulated-input.el
+++ b/tests/test-with-simulated-input.el
@@ -46,24 +46,6 @@ from byte-compiled code."
(wsi-get-unbound-key)
:not :to-equal previous-key))))
-(defmacro progn-at-runtime (&rest body)
- "Like `progn', but evaluate BODY entirely at runtime.
-
-This is useful if BODY involves macros and you want to defer the
-expansion of those macros until BODY is evaluated.
-
-Note: I don't recommend this function for general use, because it
-doesn't seem to properly put BODY in the correct lexical scope,
-but it's good enough for use in this test suite. Lexical scopes
-established *inside* BODY work just fine, so just make sure to
-put this outside any relevant `let' forms."
- (declare (debug body))
- `(eval
- '(progn
- ,@(cl-loop for expr in body
- collect `(funcall (lambda () ,expr)))
- lexical-binding)))
-
(defvar warnings-displayed-count 0
"Count of warnings that have been displayed.")
(defsubst reset-warnings-count (&optional n)
@@ -80,9 +62,10 @@ put this outside any relevant `let' forms."
BODY is wrapped in `progn-at-runtime', so warnings produced
during macro expansion will be caught as well."
(declare (debug body))
- `(let ((warnings-displayed-count 0))
- (prog1 (progn-at-runtime ,@body)
- (expect warnings-displayed-count :to-be-greater-than 0))))
+ `(progn
+ (spy-on #'display-warning :and-call-through)
+ (prog1 (progn ,@body)
+ (expect #'display-warning :to-have-been-called))))
(describe "`with-simulated-input'"
- [nongnu] elpa/with-simulated-input 5bdbde591d 058/134: Eliminate spurious warning in test file, (continued)
- [nongnu] elpa/with-simulated-input 5bdbde591d 058/134: Eliminate spurious warning in test file, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 433ee087ce 066/134: Test: handle `undercover' not being installed, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input ea6735cf1b 083/134: KEYS: support a single variable, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input d32cbc3ac9 093/134: Revert "Remove interpolation test", ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 39dbadff0b 120/134: Update the README to reflect current supported syntax, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input e7a7a6c39d 109/134: Don't use "define-advice" in tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 334f9f244f 119/134: Implement support for characters in KEYS, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 00209c2be3 128/134: Test on 27.2 instead of 27.1, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 1006e93000 125/134: Add more tests to improve coverage, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 9c160b2d81 106/134: Add warnings for quoted list KEYS and nil/constant BODY, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 4eedb0eee8 126/134: Use an alternate method to disable eager macro-expansion for testing,
ELPA Syncer <=
- [nongnu] elpa/with-simulated-input 9d082a372a 113/134: Be more selective about which file changes trigger a CI run, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 681397b90d 130/134: Also test variables containing characters, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 9ecf7c3f84 107/134: Improve code for detecting warnings in tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input ddd7bd71b1 011/134: Add "wsi-simulate-idle-time" and tests for it, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 662055c0a5 029/134: Handle non-lexical contexts as well as lexical, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 7f37451dcf 019/134: Use closures instead of quoted expressions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input e7e8829eee 020/134: Make SECS arg to wsi-simulated-idle-time optional, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 47aa40dbe1 021/134: Handle the case where SECS exactly equals a timer's time, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 5ce98adda7 022/134: Add test for SECS = nil and for repeated idle simulations, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input e860a39bba 024/134: Version 2.1, ELPA Syncer, 2022/01/10