From 2122a31962aa4bb3a3a668e88906b260333f7260 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 25 Jul 2019 19:42:57 +0200 Subject: [PATCH] Add new instanced test runner This will run the unit tests for each module in a separate Emacs instance. It's a fair bit slower, but much more useful for something as stateful as an Emacs config. Now I just need to push the rewritten tests. --- bin/doom | 1 + bin/doom-test | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 bin/doom-test diff --git a/bin/doom b/bin/doom index 2bbfc13c7..e731f621b 100755 --- a/bin/doom +++ b/bin/doom @@ -7,6 +7,7 @@ ":"; [ "$1" = -d ] || [ "$1" = --debug ] && { shift; export DEBUG=1; } ":"; [ "$1" = doc ] || [ "$1" = doctor ] && { cd "$DOOMBASE"; shift; exec $EMACS --script bin/doom-doctor "$@"; exit 0; } ":"; [ "$1" = run ] && { cd "$DOOMBASE"; shift; exec $EMACS -q --no-splash -l bin/doom "$@"; exit 0; } +":"; [ "$1" = test ] && { cd "$DOOMBASE"; shift; exec bin/doom-test "$@"; } ":"; exec $EMACS --script "$0" -- "$@" ":"; exit 0 diff --git a/bin/doom-test b/bin/doom-test new file mode 100755 index 000000000..63c205a43 --- /dev/null +++ b/bin/doom-test @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Set up test config +export DOOMDIR=/tmp/doom/ +export DOOMLOCALDIR=/tmp/doom/.local/ +if [[ ! -d "$DOOMDIR" ]]; then + mkdir -p "$DOOMDIR" + ln -s ~/.emacs.d/init.test.el "$DOOMDIR"/init.el +fi + +# Set up testing library +BUTTERCUPLIB="${DOOMLOCALDIR}buttercup" +EMACSBIN="emacs --batch -l ~/.emacs.d/init.el -L $BUTTERCUPLIB -l buttercup" +if [[ ! -d "$BUTTERCUPLIB" ]]; then + git clone https://github.com/jorgenschaefer/emacs-buttercup "$BUTTERCUPLIB" +fi + +# Run the tests +if [[ ! -f $DOOMLOCALDIR/init || $1 == "-f" ]]; then + doom -y refresh + echo 1 > $DOOMLOCALDIR/init +fi +echo +echo +error= +args=( $@ ) +(( $# == 0 )) && args=( core modules/*/* ) +for base in $args; do + if [[ -d "$base/test" ]]; then + echo Running $base + $EMACSBIN -f doom-run-tests "$base" || error=1 + fi +done + +[[ $error ]] && exit 1