aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@russet.org.uk>2019-06-17 23:11:59 +0100
committerPhillip Lord <phillip.lord@russet.org.uk>2019-06-17 23:11:59 +0100
commit02b507b839205982f36e3b0ee455168ecda8cb51 (patch)
tree5ff8250a67cdcef7318f86b291a0a698f44f7ec1
parent01842209269e290676e38b764d23b408850cb747 (diff)
downloadorg-drill-02b507b839205982f36e3b0ee455168ecda8cb51.tar.gz
org-drill-02b507b839205982f36e3b0ee455168ecda8cb51.zip
Add leitner robot test and fix
-rw-r--r--.gitignore2
-rw-r--r--Makefile12
-rw-r--r--org-drill.el9
-rw-r--r--robot/basic-run.el4
-rw-r--r--robot/basic-run.org (renamed from robot/main-test.org)0
-rw-r--r--robot/leitner-run.el12
-rw-r--r--robot/leitner-run.org12
-rwxr-xr-xrobot/leitner-run.sh35
-rw-r--r--robot/robot.sh2
9 files changed, 79 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 325f62e..b884647 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 4d4e86e..11852b3 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 104f92b..efa75f8 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 2059d7b..8ce4346 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
index 28a3efb..28a3efb 100644
--- a/robot/main-test.org
+++ b/robot/basic-run.org
diff --git a/robot/leitner-run.el b/robot/leitner-run.el
new file mode 100644
index 0000000..668e3ac
--- /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 0000000..da3f92a
--- /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 0000000..7c76291
--- /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 e0c3e6a..c9a6169 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=