From 9e337363f6dc11ff560a618336f31d03e15aebf4 Mon Sep 17 00:00:00 2001 From: Brandon Webster Date: Sun, 12 Apr 2020 09:17:58 -0700 Subject: add helper fn to check cards without killing emacs --- robot/robot.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'robot') diff --git a/robot/robot.el b/robot/robot.el index f7053b8..3d965b0 100644 --- a/robot/robot.el +++ b/robot/robot.el @@ -55,18 +55,25 @@ (run-with-timer 1 1 #'robot-dump-messages) -(defun robot-check-cards-seen-and-die (n) +(defun robot-check-cards-seen (n) + "N is number of cards we expect to have seen this session. +Returns a number representing an exit status code" (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))) + 0) + (progn + (princ + (format "Failed: Saw %s cards, expecting %s\n" + org-drill-cards-in-this-emacs n) + 'external-debugging-output) + -1))) + +(defun robot-check-cards-seen-and-die (n) + "N is number of cards we expect to have seen this session." + (kill-emacs (robot-check-cards-seen n))) ;; Move the package-user-dir somewhere local (require 'package) -- cgit v1.2.3 From ec2c168797380c7e41c13a9260c79139bed3300c Mon Sep 17 00:00:00 2001 From: Brandon Webster Date: Sun, 12 Apr 2020 09:18:24 -0700 Subject: add cram-mode test --- robot/cram-run.el | 24 ++++++++++++++++++++++++ robot/cram-run.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 robot/cram-run.el create mode 100755 robot/cram-run.sh (limited to 'robot') diff --git a/robot/cram-run.el b/robot/cram-run.el new file mode 100644 index 0000000..a754013 --- /dev/null +++ b/robot/cram-run.el @@ -0,0 +1,24 @@ +(load-file "robot/robot.el") +(load-file "org-drill.el") + +;; setup +(copy "basic-run.org" "cram-run-copy.org") + +;; normal run +(find "cram-run-copy.org") +(org-drill) +(set-buffer-modified-p nil) +(kill-buffer) +(robot-check-cards-seen 3) + +;; cram run with all cards reviewed less than `org-drill-cram-hours` +;; ago, so we expect no new cards to be seen +(find "cram-run-copy.org") +(org-drill-cram) +(robot-check-cards-seen 3) + +;; cram run that should include all cards, so we expect seen cards to +;; double +(setq org-drill-cram-hours 0) +(org-drill-cram) +(robot-check-cards-seen-and-die 6) diff --git a/robot/cram-run.sh b/robot/cram-run.sh new file mode 100755 index 0000000..a4d6ec9 --- /dev/null +++ b/robot/cram-run.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e + +this_dir="$(dirname "$0")" +source ${this_dir}/robot.sh + +card_no=3 + +# cram mode doesn't modify the buffer so there is no save prompt +function run_drill_no_save { + sleep_small + + for i in `seq 1 ${card_no}`; + do + echo Answer: "$i" + send_answer + done + + echo press any key to continue + retn +} + +function run_drill { + run_drill_no_save + echo Save file + key y +} + + +launch_emacs ${this_dir}/cram-run.el + +{ + find_bot + run_drill + retn + run_drill_no_save + wait_emacs +} || cat robot/failure.txt -- cgit v1.2.3