about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-06-11 23:51:00 -0700
committerKartik Agaram <vc@akkartik.com>2019-06-11 23:51:00 -0700
commitedac54a393674f71a701a71f085003fbd5948491 (patch)
tree3a8195a48a0d0c52e7c43604e2e1da2bdeab3903 /subx
parentfc95aaf8937010600351218c98f89bcc7cc29943 (diff)
downloadmu-edac54a393674f71a701a71f085003fbd5948491.tar.gz
rerun most recent test if cursor not in a test
Diffstat (limited to 'subx')
-rwxr-xr-xsubx/run_one_test.sh14
-rw-r--r--subx/vimrc.vim2
2 files changed, 15 insertions, 1 deletions
diff --git a/subx/run_one_test.sh b/subx/run_one_test.sh
index 4cb82425..8d1d14f2 100755
--- a/subx/run_one_test.sh
+++ b/subx/run_one_test.sh
@@ -1,6 +1,18 @@
 #!/usr/bin/env zsh
+# Either run the test with the given name, or rerun the most recently run test.
+
+if [[ $2 == 'test-'* ]]
+then
+  export TEST_NAME=$2
+  echo $TEST_NAME > /tmp/last_test_run
+elif [[ -e /tmp/last_test_run ]]
+then
+  export TEST_NAME=`cat /tmp/last_test_run`
+else
+  echo "no test found"
+  exit 0  # don't open trace
+fi
 
-export TEST_NAME=$2
 envsubst '$TEST_NAME' < run_one_test.subx > /tmp/run_one_test.subx
 
 subx --debug translate [0-9]*.subx apps/subx-common.subx $1 /tmp/run_one_test.subx -o /tmp/a.elf
diff --git a/subx/vimrc.vim b/subx/vimrc.vim
index 23dd2c7f..57c450d6 100644
--- a/subx/vimrc.vim
+++ b/subx/vimrc.vim
@@ -83,6 +83,8 @@ command! -nargs=0 L exec "%!grep -a label |grep -v clear-stream:loop"
 "   can't put initial cursor movement inside function because we rely on <C-r><C-w> to grab word at cursor
 "   can't put final cursor movement out of function because that disables the wait for <CR> prompt; function must be final operation of map
 "   can't avoid the function because that disables the wait for <CR> prompt
+" known issue:
+"   cursor on '#' causes error
 noremap <Leader>t {j0:call RunTestMoveCursorAndMaybeOpenTrace("<C-r><C-w>")<CR>
 function RunTestMoveCursorAndMaybeOpenTrace(arg)
   exec "!run_one_test.sh ".expand("%")." ".a:arg