about summary refs log tree commit diff stats
path: root/subx/run_one_test.sh
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/run_one_test.sh
parentfc95aaf8937010600351218c98f89bcc7cc29943 (diff)
downloadmu-edac54a393674f71a701a71f085003fbd5948491.tar.gz
rerun most recent test if cursor not in a test
Diffstat (limited to 'subx/run_one_test.sh')
-rwxr-xr-xsubx/run_one_test.sh14
1 files changed, 13 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