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-29 21:02:11 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-01 23:09:58 -0700
commiteada7e30a048caffdbcd2bc992efee511ffd5e09 (patch)
tree3106a4096e4aa26e1aaa42786843b310a039e0e2 /subx/run_one_test.sh
parent7a276d63c00dd587acce336c378b971e05bef025 (diff)
downloadmu-eada7e30a048caffdbcd2bc992efee511ffd5e09.tar.gz
.
When rerunning most recently run test, also load the same files as
before. Try the following commands in sequence:

  $ ./run_one_test.sh 056trace.subx test-compute-addresses        # 1
  0 error: missing reference to global 'test-compute-addresses'
  $ ./run_one_test.sh apps/survey.subx test-compute-addresses     # 2
  $ ./run_one_test.sh 056trace.subx trace  # run previous test    # 3

Now command 3 will work, and it will behave identically to command 2.

This way I can switch to another file in Vim and hit `\t` in a random
place in the file and still have the previously run test be rerun.
Diffstat (limited to 'subx/run_one_test.sh')
-rwxr-xr-xsubx/run_one_test.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/subx/run_one_test.sh b/subx/run_one_test.sh
index ded3e6e5..c81bd0c4 100755
--- a/subx/run_one_test.sh
+++ b/subx/run_one_test.sh
@@ -5,14 +5,17 @@
 if [[ $2 == 'test-'* ]]
 then
   TEST_NAME=$2 envsubst '$TEST_NAME' < run_one_test.subx > /tmp/run_one_test.subx
-elif [[ ! -e /tmp/run_one_test.subx ]]
+  FILES=$(ls [0-9]*.subx apps/subx-common.subx $1 |sort |uniq)
+  echo $FILES > /tmp/last_run_files
+elif [[ -e /tmp/last_run_files ]]
 then
+  FILES=`cat /tmp/last_run_files`
+else
   echo "no test found"
   exit 0  # don't open trace
 fi
 
 set -e
-FILES=$(ls [0-9]*.subx apps/subx-common.subx $1 |sort |uniq)
                                       # turn newlines into spaces
 CFLAGS=$CFLAGS subx --debug translate $(echo $FILES) /tmp/run_one_test.subx -o /tmp/a.elf