aboutsummaryrefslogtreecommitdiff
path: root/robot
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@russet.org.uk>2019-06-12 22:28:38 +0100
committerPhillip Lord <phillip.lord@russet.org.uk>2019-06-12 22:28:38 +0100
commit11abbd27472d032f0f272cd45206f5af855aafea (patch)
tree8e3c36139451ac8ce8ab5c6cc5872d55613c7485 /robot
parentc58cb90ff0cd6bd6dc3a338fd2a8bc7392c06fec (diff)
downloadorg-drill-11abbd27472d032f0f272cd45206f5af855aafea.tar.gz
org-drill-11abbd27472d032f0f272cd45206f5af855aafea.zip
Add robotized test
Diffstat (limited to 'robot')
-rw-r--r--robot/main-test-copy.org48
-rw-r--r--robot/main-test.org12
-rw-r--r--robot/org-drill-launch.el31
-rwxr-xr-xrobot/robot-test.sh49
4 files changed, 140 insertions, 0 deletions
diff --git a/robot/main-test-copy.org b/robot/main-test-copy.org
new file mode 100644
index 0000000..e57adcc
--- /dev/null
+++ b/robot/main-test-copy.org
@@ -0,0 +1,48 @@
+
+* One :drill:
+ SCHEDULED: <2019-06-16 Sun>
+ :PROPERTIES:
+ :ID: 8ac0c150-4bda-4d52-aadf-c09b6568076e
+ :DRILL_LAST_INTERVAL: 3.56
+ :DRILL_REPEATS_SINCE_FAIL: 2
+ :DRILL_TOTAL_REPEATS: 1
+ :DRILL_FAILURE_COUNT: 0
+ :DRILL_AVERAGE_QUALITY: 5.0
+ :DRILL_EASE: 2.6
+ :DRILL_LAST_QUALITY: 5
+ :DRILL_LAST_REVIEWED: [2019-06-12 Wed 22:27]
+ :END:
+
+One body
+
+* Two :drill:
+ SCHEDULED: <2019-06-16 Sun>
+ :PROPERTIES:
+ :ID: 20b11d4a-68f4-4afa-b7b4-93aef89de9d4
+ :DRILL_LAST_INTERVAL: 3.56
+ :DRILL_REPEATS_SINCE_FAIL: 2
+ :DRILL_TOTAL_REPEATS: 1
+ :DRILL_FAILURE_COUNT: 0
+ :DRILL_AVERAGE_QUALITY: 5.0
+ :DRILL_EASE: 2.6
+ :DRILL_LAST_QUALITY: 5
+ :DRILL_LAST_REVIEWED: [2019-06-12 Wed 22:27]
+ :END:
+
+Two body
+
+* Three :drill:
+ SCHEDULED: <2019-06-16 Sun>
+ :PROPERTIES:
+ :ID: 253358dc-ce97-4c01-bdbb-ad97f7b16d3a
+ :DRILL_LAST_INTERVAL: 3.56
+ :DRILL_REPEATS_SINCE_FAIL: 2
+ :DRILL_TOTAL_REPEATS: 1
+ :DRILL_FAILURE_COUNT: 0
+ :DRILL_AVERAGE_QUALITY: 5.0
+ :DRILL_EASE: 2.6
+ :DRILL_LAST_QUALITY: 5
+ :DRILL_LAST_REVIEWED: [2019-06-12 Wed 22:26]
+ :END:
+
+Three body
diff --git a/robot/main-test.org b/robot/main-test.org
new file mode 100644
index 0000000..28a3efb
--- /dev/null
+++ b/robot/main-test.org
@@ -0,0 +1,12 @@
+
+* One :drill:
+
+One body
+
+* Two :drill:
+
+Two body
+
+* Three :drill:
+
+Three body
diff --git a/robot/org-drill-launch.el b/robot/org-drill-launch.el
new file mode 100644
index 0000000..bab57ec
--- /dev/null
+++ b/robot/org-drill-launch.el
@@ -0,0 +1,31 @@
+;; Shutup
+(setq make-backup-files nil)
+(setq auto-save-default nil)
+
+;; Clean up
+(delete-file "./robot/failure.txt")
+
+(set-frame-name "emacs-bot")
+
+(condition-case e
+ (progn (load-file "org-learn.el")
+ (load-file "org-drill.el"))
+ (error
+ (with-temp-buffer
+ (insert (format "%s" (error-message-string e)))
+ (write-region (point-min) (point-max) "./robot/failure.txt"))
+ (let ((kill-emacs-hook nil))
+ (kill-emacs))))
+
+(copy-file "robot/main-test.org" "robot/main-test-copy.org" t)
+(find-file "robot/main-test-copy.org")
+
+(condition-case e
+ (org-drill)
+ (error
+ (with-temp-buffer
+ (insert (format "%s" (error-message-string e)))
+ ;; write to ./ now because we have changed directory
+ (write-region (point-min) (point-max) "./failure.txt"))
+ (let ((kill-emacs-hook nil))
+ (kill-emacs))))
diff --git a/robot/robot-test.sh b/robot/robot-test.sh
new file mode 100755
index 0000000..31a6f09
--- /dev/null
+++ b/robot/robot-test.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+set -e
+
+$EMACS -Q -l ./robot/org-drill-launch.el &
+
+sleep 1
+
+window_id=`xdotool search --name "emacs-bot"`
+if [ -z "$window_id" ]
+then
+ echo "Could not find window ID for Emacs-bot"
+ exit 1
+fi
+
+## Org-drill should be running at this point, so give three answers
+## with a score of file
+echo answer one
+xdotool key --window $window_id KP_Enter
+sleep 0.25
+xdotool key --window $window_id 5
+sleep 0.25
+
+
+echo answer two
+xdotool key --window $window_id KP_Enter
+sleep 0.25
+xdotool key --window $window_id 5
+sleep 0.25
+
+echo answer three
+xdotool key --window $window_id KP_Enter
+sleep 0.25
+xdotool key --window $window_id 5
+sleep 0.25
+
+# ## Press any key to continue
+echo press any key to continue
+xdotool key --window $window_id KP_Enter
+sleep 0.25
+
+echo Save file
+xdotool key --window $window_id y
+sleep 0.25
+
+echo Goodnight Emacs
+xdotool key --window $window_id alt+x
+xdotool type --window $window_id kill-emacs
+xdotool key --window $window_id KP_Enter