[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-simulated-input b030953ca0 050/134: Fix a bug with ac
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/with-simulated-input b030953ca0 050/134: Fix a bug with actually-wait, and add tests for it |
Date: |
Mon, 10 Jan 2022 23:00:04 -0500 (EST) |
branch: elpa/with-simulated-input
commit b030953ca053c7372d2f5a415813f5cc3a66b89a
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>
Fix a bug with actually-wait, and add tests for it
---
tests/test-with-simulated-input.el | 16 ++++++++++++++++
with-simulated-input.el | 16 +++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/tests/test-with-simulated-input.el
b/tests/test-with-simulated-input.el
index 9f32fc0c24..e509661e7f 100644
--- a/tests/test-with-simulated-input.el
+++ b/tests/test-with-simulated-input.el
@@ -216,6 +216,22 @@
(wsi-simulate-idle-time)
(expect 'idle-canary :to-have-been-called))
+ (it "should simulate the appropriate value for `(current-idle-time)'")
+
+ (it "should actually wait the specified time when `actually-wait' is non-nil"
+ (spy-on 'sleep-for :and-call-through)
+ (run-with-idle-timer 0.01 nil 'idle-canary)
+ (run-with-idle-timer 0.02 nil 'idle-canary)
+ (run-with-idle-timer 0.03 nil 'idle-canary)
+ (run-with-idle-timer 0.04 nil 'idle-canary)
+ ;; These shouldn't get called
+ (run-with-idle-timer 1 nil 'idle-canary)
+ (run-with-idle-timer 2 nil 'idle-canary)
+ (run-with-idle-timer 3 nil 'idle-canary)
+ (wsi-simulate-idle-time 0.05 t)
+ (expect 'idle-canary :to-have-been-called-times 4)
+ (expect 'sleep-for :to-have-been-called-times 5))
+
(describe "used within `with-simulated-input'"
(it "should allow idle timers to trigger during simulated input"
(run-with-idle-timer 500 nil 'insert "world")
diff --git a/with-simulated-input.el b/with-simulated-input.el
index 663c6a02d7..dc2c837df6 100644
--- a/with-simulated-input.el
+++ b/with-simulated-input.el
@@ -255,7 +255,14 @@ in `progn'."
(error "Reached end of simulated input while evaluating body")
result)))
-(defvar wsi-simulated-idle-time nil)
+(defvar wsi-simulated-idle-time nil
+ "The current simulated idle time.
+
+While simulating idle time using `wsi-simulated-idle-time', this
+variable will always be set to the amount of idle time that has
+been simulated so far. For example, if an idle time is set to run
+every 5 seconds while idle, then on its first run, this will be
+set to 5 seconds, then 10 seconds the next time, and so on.")
(defun current-idle-time@simulate-idle-time (orig-fun &rest args)
"Return the faked value while simulating idle time.
@@ -311,9 +318,12 @@ add other idle timers."
;; timers to the list, and picking up at the same list position
;; would ignore those new timers.
for next-timer = (car (cl-member-if-not
- (lambda (timer) (memq timer already-run-timers))
+ (lambda (timer)
+ (and (memq timer already-run-timers)))
timer-idle-list))
- while next-timer
+ ;; Stop if we reach the end of the idle timer list, or if the next
+ ;; timer's idle time is greater than SECS
+ while (and next-timer (time-less-p (timer--time next-timer) stop-time))
for previous-idle-time = wsi-simulated-idle-time
if (time-less-p wsi-simulated-idle-time
(timer--time next-timer))
- [nongnu] elpa/with-simulated-input e66a24d067 031/134: Add Makefile and code coverage, (continued)
- [nongnu] elpa/with-simulated-input e66a24d067 031/134: Add Makefile and code coverage, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 1012ccbec7 033/134: Convert defadvice to advice-add, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input d0f7795942 034/134: Update buttercup, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input af9a38ce28 036/134: Add LICENSE file, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 3b847dec31 037/134: Add tests for wsi-get-unbound-key, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input a718d66c5d 039/134: Don't generate a new canary for each call, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input e8738fe72c 040/134: Fix issue #4 and add a test for it, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 011183121d 042/134: Remove Emacs 26.3 from Travis config, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input d66b8b853f 041/134: Test in Emacs 26 on Travis, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 3d88179352 044/134: Version 2.4, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input b030953ca0 050/134: Fix a bug with actually-wait, and add tests for it,
ELPA Syncer <=
- [nongnu] elpa/with-simulated-input a71ecf18f7 051/134: Fix a bug in current-idle-time advice and add a test for it, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input ea666ecab7 064/134: Remove hacky closure modification, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input cc15ccfe5a 062/134: Switch CI to Github Actions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input af15d1a1f5 068/134: Remove interpolation test, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 6ac56316df 074/134: Revert version change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 057946280f 070/134: Greeting test: don't use dynamic forms, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 214ca2c4b1 087/134: Improve test coverage for current-idle-time advice, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 1a610d6587 089/134: Reorganize test suite, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input c8389984e6 088/134: Update Eldev file, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 15581a4459 076/134: (symbol ...) KEYS are now function-call strings, ELPA Syncer, 2022/01/10