diff options
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | robot/basic-run.el (renamed from robot/org-drill-launch.el) | 8 | ||||
| -rwxr-xr-x | robot/basic-run.sh | 49 | ||||
| -rwxr-xr-x | robot/robot-test.sh | 66 | ||||
| -rw-r--r-- | robot/robot.sh | 56 |
5 files changed, 116 insertions, 71 deletions
@@ -7,14 +7,14 @@ ifdef EMACS EMACS_ENV=EMACS=$(EMACS) endif -all: +all: robot-and-test install: $(EMACS_ENV) $(CASK) install test: install just-test -robot-and-test: robot-test just-test +robot-and-test: basic-robot-test just-test just-test: $(EMACS_ENV) $(CASK) emacs --batch -q \ @@ -35,8 +35,8 @@ docker-test: $(MAKE) test-git DOCKER_TAG=25.3 $(MAKE) test-cp DOCKER_TAG=25.3 -robot-test: +basic-robot-test: $(CASK) clean-elc - $(EMACS_ENV) ./robot/robot-test.sh + $(EMACS_ENV) ./robot/basic-run.sh .PHONY: test diff --git a/robot/org-drill-launch.el b/robot/basic-run.el index 2de9219..1469fef 100644 --- a/robot/org-drill-launch.el +++ b/robot/basic-run.el @@ -13,6 +13,11 @@ (setq debug-on-error t) (setq debug-on-quit t) +(defun die () + (interactive) + (kill-emacs) + ) + (defun dump-buffer (buffer file) (save-excursion (when (get-buffer buffer) @@ -37,7 +42,8 @@ (defun org-drill-launcher-dump () (dump-buffer "*Backtrace*" "failure.txt") (dump-buffer "*Messages*" "messages.txt") - (kill-emacs -1)) + (kill-emacs -1) + ) (load-file "org-drill.el") diff --git a/robot/basic-run.sh b/robot/basic-run.sh new file mode 100755 index 0000000..497f157 --- /dev/null +++ b/robot/basic-run.sh @@ -0,0 +1,49 @@ +#!/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 + + ## Press any key to continue + echo press any key to continue + retn + sleep_small + + echo Save file + key y +} + +this_dir="$(dirname "$0")" +source $this_dir/robot.sh + + +launch_emacs $this_dir/basic-run.el + +bsmall_sleep=5 +big_sleep=10 + +{ + sleep 2 + find_bot + + ## Run once with default options + run_drill + + ## Run once with presentation-prompt-with-typing + run_drill + + # kill_emacs +} || cat robot/failure.txt + $EMACS -Q -l $1 & diff --git a/robot/robot-test.sh b/robot/robot-test.sh deleted file mode 100755 index c27b94b..0000000 --- a/robot/robot-test.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/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 1 - echo answer one - #xdotool type --window $window_id answer - xdotool key --window $window_id Return - sleep 0.25 - xdotool key --window $window_id 5 - sleep 0.25 - - - echo answer two - #xdotool type --window $window_id answer - xdotool key --window $window_id Return - sleep 0.25 - xdotool key --window $window_id 5 - sleep 0.25 - - echo answer three - #xdotool type --window $window_id answer - xdotool key --window $window_id Return - 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 Return - sleep 0.25 - - echo Save file - xdotool key --window $window_id y -} - -function kill_emacs { - echo Goodnight Emacs - xdotool key --window $window_id alt+x - xdotool type --window $window_id kill-emacs - xdotool key --window $window_id KP_Enter -} - -$EMACS -Q -l ./robot/org-drill-launch.el & - -{ - sleep 2 - - window_id=`xdotool search --name "emacs-bot"` - if [ -z "$window_id" ] - then - echo "Could not find window ID for Emacs-bot" - exit 1 - fi - - ## Run once with default options - run_drill - - ## Run once with presentation-prompt-with-typing - run_drill - - kill_emacs -} || cat robot/failure.txt diff --git a/robot/robot.sh b/robot/robot.sh new file mode 100644 index 0000000..e013308 --- /dev/null +++ b/robot/robot.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +## call find_bot to init this +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 +big_sleep=1 + +function sleep_small { + sleep $small_sleep +} + +function sleep_big { + sleep $big_sleep +} + +function send_answer { + retn + sleep_small + key 5 + sleep_small +} + +function launch_emacs { + echo Launching $EMACS -Q -l $1 & + $EMACS -Q -l $1 & +} + +function kill_emacs { + key alt+x + command kill-emacs + retn +} + +function key { + xdotool key --window $window_id $1 +} + +function command { + xdotool type --window $window_id $1 +} + +function retn { + xdotool key --window $window_id Return +} + +function find_bot { + window_id=`xdotool search --name "emacs-bot"` + if [ -z "$window_id" ] + then + echo "Could not find window ID for Emacs-bot" + exit 1 + fi +} |
