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

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

[nongnu] elpa/org-drill 02b507b839 151/251: Add leitner robot test and f


From: ELPA Syncer
Subject: [nongnu] elpa/org-drill 02b507b839 151/251: Add leitner robot test and fix
Date: Mon, 17 Jan 2022 18:59:11 -0500 (EST)

branch: elpa/org-drill
commit 02b507b839205982f36e3b0ee455168ecda8cb51
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>

    Add leitner robot test and fix
---
 .gitignore                             |  2 ++
 Makefile                               | 12 +++++++++---
 org-drill.el                           |  9 ++++++---
 robot/basic-run.el                     |  4 ++--
 robot/{main-test.org => basic-run.org} |  0
 robot/leitner-run.el                   | 12 ++++++++++++
 robot/leitner-run.org                  | 12 ++++++++++++
 robot/leitner-run.sh                   | 35 ++++++++++++++++++++++++++++++++++
 robot/robot.sh                         |  2 +-
 9 files changed, 79 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index 325f62e158..b884647bcd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ org-drill.html
 /robot/main-test-copy.org~
 /robot/main-test-interactive-copy.org
 /robot/all-card-copy.org
+/robot/basic-run-copy.org
+/robot/leitner-run-copy.org
diff --git a/Makefile b/Makefile
index 4d4e86e00d..11852b3e86 100644
--- a/Makefile
+++ b/Makefile
@@ -35,12 +35,18 @@ docker-test:
        $(MAKE) test-git DOCKER_TAG=25.3
        $(MAKE) test-cp DOCKER_TAG=25.3
 
-basic-robot-test:
+clean-elc:
        $(CASK) clean-elc
+
+all-robot-test: basic-robot-test leitner-robot-test all-card-robot-test
+
+basic-robot-test: clean-elc
        $(EMACS_ENV) ./robot/basic-run.sh
 
-all-card-robot-test:
-       $(CASK) clean-elc
+leitner-robot-test: clean-elc
+       $(EMACS_ENV) ./robot/leitner-run.sh
+
+all-card-robot-test: clean-elc
        $(EMACS_ENV) ./robot/all-card-run.sh
 
 .PHONY: test
diff --git a/org-drill.el b/org-drill.el
index 104f92b6de..efa75f86c7 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -1774,7 +1774,7 @@ Consider reformulating the item to make it easier to 
remember.\n"
 (defun org-drill-response-rtn ()
   (interactive)
   (let ((session org-drill-current-session))
-    (setf (oref session drill-typed-answer) (buffer-string))
+    (setf (oref session typed-answer) (buffer-string))
     (oset session exit-kind t)
     (org-drill-response-complete)))
 
@@ -3829,6 +3829,7 @@ Returns a list of strings."
   (interactive)
   (let ((org-drill-leitner-boxed-entries nil)
         (org-drill-leitner-unboxed-entries nil)
+        (session (setq org-drill-last-session (org-drill-session)))
         (count 0))
     (org-drill-all-leitner-capture)
     ;; make sure we have enough (or at least the maximum number we
@@ -3848,7 +3849,7 @@ Returns a list of strings."
           (seq-map
            (lambda (loc)
              (org-drill-goto-entry loc)
-             (let ((r (org-drill-leitner-entry)))
+             (let ((r (org-drill-leitner-entry session)))
                ;; short circuit if necessary
                (unless (eq t r)
                  (throw 'user-exit (list r loc)))))
@@ -3939,7 +3940,9 @@ shuffling is done in place."
 (defun org-drill-leitner-entry (session)
   "Interactive drill for the current entry."
   (let ((org-drill-question-tag org-drill-leitner-tag))
-    (org-drill-entry-f (apply-partially #'org-drill-leitner-rebox session))))
+    (org-drill-entry-f
+     session
+     (apply-partially #'org-drill-leitner-rebox session))))
 
 (defun org-drill-leitner-rebox (session)
   "Returns quality rating (0-5), or nil if the user quit."
diff --git a/robot/basic-run.el b/robot/basic-run.el
index 2059d7b0eb..8ce43466e1 100644
--- a/robot/basic-run.el
+++ b/robot/basic-run.el
@@ -2,8 +2,8 @@
 (load-file "org-drill.el")
 
 (defun org-drill-do-drill ()
-  (copy "main-test.org" "main-test-copy.org")
-  (find "main-test-copy.org")
+  (copy "basic-run.org" "basic-run-copy.org")
+  (find "basic-run-copy.org")
 
   (org-drill)
   (set-buffer-modified-p nil)
diff --git a/robot/main-test.org b/robot/basic-run.org
similarity index 100%
rename from robot/main-test.org
rename to robot/basic-run.org
diff --git a/robot/leitner-run.el b/robot/leitner-run.el
new file mode 100644
index 0000000000..668e3acba5
--- /dev/null
+++ b/robot/leitner-run.el
@@ -0,0 +1,12 @@
+(load-file "robot/robot.el")
+(load-file "org-drill.el")
+
+(copy "leitner-run.org" "leitner-run-copy.org")
+(find "leitner-run-copy.org")
+
+(org-drill-leitner)
+(set-buffer-modified-p nil)
+(kill-buffer)
+
+
+(robot-check-cards-seen-and-die 3)
diff --git a/robot/leitner-run.org b/robot/leitner-run.org
new file mode 100644
index 0000000000..da3f92aaaf
--- /dev/null
+++ b/robot/leitner-run.org
@@ -0,0 +1,12 @@
+
+* One     :leitner:
+
+One body
+
+* Two     :leitner:
+
+Two body
+
+* Three   :leitner:
+
+Three body
diff --git a/robot/leitner-run.sh b/robot/leitner-run.sh
new file mode 100755
index 0000000000..7c76291d4d
--- /dev/null
+++ b/robot/leitner-run.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+set -e
+
+function run_drill {
+    ## Org-drill should be running at this point, so give three answers
+    ## with a score of file
+    sleep_big
+
+    echo answer one
+    send_answer
+
+    echo answer two
+    send_answer
+
+    echo answer three
+    send_answer
+}
+
+this_dir="$(dirname "$0")"
+source $this_dir/robot.sh
+
+##small_sleep=3
+
+launch_emacs $this_dir/leitner-run.el
+
+{
+    sleep 2
+    find_bot
+
+    ## Run once with default options
+    run_drill
+
+    wait_emacs
+} || cat robot/failure.txt
diff --git a/robot/robot.sh b/robot/robot.sh
index e0c3e6acc0..c9a6169892 100644
--- a/robot/robot.sh
+++ b/robot/robot.sh
@@ -7,7 +7,7 @@ window_id=
 
 ## This is the small sleep between key presses. Change for debugging
 ## when you are not sure what is happening
-small_sleep=0.25
+small_sleep=0.1
 big_sleep=1
 
 emacs_process_pid=



reply via email to

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