[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill 50885fbeea 146/251: Refactor robot testing to al
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill 50885fbeea 146/251: Refactor robot testing to allow multiple tests |
Date: |
Mon, 17 Jan 2022 18:59:10 -0500 (EST) |
branch: elpa/org-drill
commit 50885fbeea8a282dc027b03b19097de3c6dabd18
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>
Refactor robot testing to allow multiple tests
---
org-drill.el | 9 +++++++-
robot/basic-run.el | 50 +++------------------------------------------
robot/basic-run.sh | 5 +----
robot/robot.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
robot/robot.sh | 20 +++++++++++++++---
5 files changed, 89 insertions(+), 55 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index 694d51befa..3c550624b4 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -652,6 +652,11 @@ for review unless they were already reviewed in the recent
past?"
(defvar org-drill-current-session nil)
(defvar org-drill-last-session nil)
+(defvar org-drill-cards-in-this-emacs 0
+ "The total number of cards displayed in this Emacs invocation.
+
+This variable is not functionally important, but is used for
+ debugging.")
(defvar org-drill-scheduling-properties
'("LEARN_DATA" "DRILL_LAST_INTERVAL" "DRILL_REPEATS_SINCE_FAIL"
@@ -2578,6 +2583,7 @@ See `org-drill' for more details."
(mapc
(apply-partially 'org-drill-card-tag-caller 3)
(org-get-tags))
+ (cl-incf org-drill-cards-in-this-emacs)
(org-remove-latex-fragment-image-overlays)
rtn))))))
@@ -3056,7 +3062,8 @@ work correctly with older versions of org mode. Your org
mode version (%s) appea
(let ((session
(if resume-p
org-drill-last-session
- (org-drill-session)))
+ (setq org-drill-last-session
+ (org-drill-session))))
(end-pos nil)
(cnt 0))
(cl-block org-drill
diff --git a/robot/basic-run.el b/robot/basic-run.el
index 1469fef4bb..8e853e3dc9 100644
--- a/robot/basic-run.el
+++ b/robot/basic-run.el
@@ -1,50 +1,4 @@
-;; Shutup
-(setq make-backup-files nil)
-(setq auto-save-default nil)
-
-(setq top-dir default-directory)
-
-;; Clean up
-(delete-file (concat top-dir "robot/failure.txt"))
-(delete-file (concat top-dir "robot/messages.txt"))
-
-(set-frame-name "emacs-bot")
-
-(setq debug-on-error t)
-(setq debug-on-quit t)
-
-(defun die ()
- (interactive)
- (kill-emacs)
- )
-
-(defun dump-buffer (buffer file)
- (save-excursion
- (when (get-buffer buffer)
- (set-buffer buffer)
- (write-region (point-min) (point-max)
- (concat top-dir "robot/" file)
- nil 'dont-display-wrote-file-message
- ))))
-
-(add-hook 'debugger-mode-hook
- 'org-drill-launcher-dump-in-a-bit)
-
-(defun org-drill-launcher-dump-in-a-bit ()
- (run-with-timer 1 nil #'org-drill-launcher-dump))
-
-(defun org-drill-dump-messages ()
- (dump-buffer "*Messages*" "messages.txt"))
-
-(run-with-timer 1 1 #'org-drill-dump-messages)
-
-
-(defun org-drill-launcher-dump ()
- (dump-buffer "*Backtrace*" "failure.txt")
- (dump-buffer "*Messages*" "messages.txt")
- (kill-emacs -1)
- )
-
+(load-file "robot/robot.el")
(load-file "org-drill.el")
(defun org-drill-do-drill ()
@@ -62,3 +16,5 @@
(setq org-drill-presentation-prompt-with-typing t)
(org-drill-do-drill)
+
+(robot-check-cards-seen-and-die 6)
diff --git a/robot/basic-run.sh b/robot/basic-run.sh
index 5f68cab655..d92172df10 100755
--- a/robot/basic-run.sh
+++ b/robot/basic-run.sh
@@ -31,9 +31,6 @@ source $this_dir/robot.sh
launch_emacs $this_dir/basic-run.el
-#small_sleep=5
-#big_sleep=10
-
{
sleep 2
find_bot
@@ -44,6 +41,6 @@ launch_emacs $this_dir/basic-run.el
## Run once with presentation-prompt-with-typing
run_drill
- kill_emacs
+ wait_emacs
} || cat robot/failure.txt
$EMACS -Q -l $1 &
diff --git a/robot/robot.el b/robot/robot.el
new file mode 100644
index 0000000000..43f31da63a
--- /dev/null
+++ b/robot/robot.el
@@ -0,0 +1,60 @@
+;; Shutup
+(setq make-backup-files nil)
+(setq auto-save-default nil)
+
+(setq top-dir default-directory)
+
+(set-frame-name "emacs-bot")
+
+(setq debug-on-error t)
+(setq debug-on-quit t)
+
+(defun clean (file)
+ (delete-file (concat top-dir "robot/" file)))
+
+;; Clean up
+(clean "failure.txt")
+(clean "messages.txt")
+
+(defun die ()
+ (interactive)
+ (kill-emacs))
+
+(defun dump-buffer (buffer file)
+ (save-excursion
+ (when (get-buffer buffer)
+ (set-buffer buffer)
+ (write-region (point-min) (point-max)
+ (concat top-dir "robot/" file)
+ nil 'dont-display-wrote-file-message
+ ))))
+
+
+(add-hook 'debugger-mode-hook
+ 'robot-dump-in-a-bit)
+
+(defun robot-dump-in-a-bit ()
+ (run-with-timer 1 nil #'robot-dump))
+
+(defun robot-dump ()
+ (dump-buffer "*Backtrace*" "failure.txt")
+ (dump-buffer "*Messages*" "messages.txt")
+ (kill-emacs -1))
+
+(defun robot-dump-messages ()
+ (dump-buffer "*Messages*" "messages.txt"))
+
+(run-with-timer 1 1 #'robot-dump-messages)
+
+(defun robot-check-cards-seen-and-die (n)
+ (if (= n org-drill-cards-in-this-emacs)
+ (progn
+ (princ
+ (format "Succeeded: Saw %s cards as expected\n" n)
+ 'external-debugging-output)
+ (kill-emacs 0))
+ (princ
+ (format "Failed: Saw %s cards, expecting %s\n"
+ org-drill-cards-in-this-emacs n)
+ 'external-debugging-output)
+ (kill-emacs -1)))
diff --git a/robot/robot.sh b/robot/robot.sh
index e013308351..022b567428 100644
--- a/robot/robot.sh
+++ b/robot/robot.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+set -e
+
## call find_bot to init this
window_id=
@@ -8,6 +10,8 @@ window_id=
small_sleep=0.25
big_sleep=1
+emacs_process_pid=
+
function sleep_small {
sleep $small_sleep
}
@@ -26,6 +30,7 @@ function send_answer {
function launch_emacs {
echo Launching $EMACS -Q -l $1 &
$EMACS -Q -l $1 &
+ emacs_process_pid=$!
}
function kill_emacs {
@@ -34,16 +39,25 @@ function kill_emacs {
retn
}
+function xdo {
+ xdotool $1 --window $window_id $2 || {
+ echo "Failed command: $1, $2";exit 1
+ }
+}
function key {
- xdotool key --window $window_id $1
+ xdo key $1
}
function command {
- xdotool type --window $window_id $1
+ xdo type $1
}
function retn {
- xdotool key --window $window_id Return
+ key Return
+}
+
+function wait_emacs {
+ wait $emacs_process_pid
}
function find_bot {
- [nongnu] elpa/org-drill 849be174b6 093/251: Added tag 2.4.10 for changeset 2d622b26469c, (continued)
- [nongnu] elpa/org-drill 849be174b6 093/251: Added tag 2.4.10 for changeset 2d622b26469c, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 44289690b7 089/251: Added tag 2.4.9 for changeset 355c05642208, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ddd9b056cd 106/251: Merge answer typing, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill a9d771052e 107/251: Fix matching of lock files, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 4d9bdb6836 115/251: Add org-learn, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 939f2a65b2 114/251: Enable cask testing, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 533a3a84ee 117/251: Add gitlab-ci.yml, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 54cde2dbf7 132/251: Move to eieio objects, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill be851b9eb4 142/251: Refactor robot testing, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 1470bdb487 131/251: Remove org-drill-new-entries, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 50885fbeea 146/251: Refactor robot testing to allow multiple tests,
ELPA Syncer <=
- [nongnu] elpa/org-drill c58cb90ff0 123/251: Update gitignore, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 644b0a5cbc 126/251: Remove org-learn as a separate package, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9aa3e98ea0 130/251: Remove org-drill-start-time, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill b161277f82 156/251: Replace more non-namespaced commands, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 61fe47deb8 152/251: Replace drill-answer, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 02b507b839 151/251: Add leitner robot test and fix, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6533b73246 164/251: Support changing small sleep on command line, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill a949ece724 165/251: Remove more dynamic scoping errors, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 82c2ec8b1f 189/251: Replace call to gensym with cl-gensym, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 4300ef9d4c 168/251: Fix broken form in org-drill-resume, ELPA Syncer, 2022/01/17