From 02b507b839205982f36e3b0ee455168ecda8cb51 Mon Sep 17 00:00:00 2001 From: Phillip Lord Date: Mon, 17 Jun 2019 23:11:59 +0100 Subject: Add leitner robot test and fix --- .gitignore | 2 ++ Makefile | 12 +++++++++--- org-drill.el | 9 ++++++--- robot/basic-run.el | 4 ++-- robot/basic-run.org | 12 ++++++++++++ robot/leitner-run.el | 12 ++++++++++++ robot/leitner-run.org | 12 ++++++++++++ robot/leitner-run.sh | 35 +++++++++++++++++++++++++++++++++++ robot/main-test.org | 12 ------------ robot/robot.sh | 2 +- 10 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 robot/basic-run.org create mode 100644 robot/leitner-run.el create mode 100644 robot/leitner-run.org create mode 100755 robot/leitner-run.sh delete mode 100644 robot/main-test.org 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/basic-run.org b/robot/basic-run.org new file mode 100644 index 0000000..28a3efb --- /dev/null +++ b/robot/basic-run.org @@ -0,0 +1,12 @@ + +* One :drill: + +One body + +* Two :drill: + +Two body + +* Three :drill: + +Three body 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/main-test.org b/robot/main-test.org deleted file mode 100644 index 28a3efb..0000000 --- a/robot/main-test.org +++ /dev/null @@ -1,12 +0,0 @@ - -* One :drill: - -One body - -* Two :drill: - -Two body - -* Three :drill: - -Three body 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= -- cgit v1.2.3