diff options
author | Kriss <kr1ss.x@yandex.com> | 2021-03-09 21:53:29 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-03-09 21:53:45 -0500 |
commit | b4a36d78867327b321077ac94ee224f9845fa2ac (patch) | |
tree | 152dce9183274538db505412dd2ea8ff8cf46da0 | |
parent | e72b0ea1da594922d77dedc65e621728a2edfb69 (diff) |
Update navigate tests
-rwxr-xr-x | tests/test_navigate_less_history_file | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/tests/test_navigate_less_history_file b/tests/test_navigate_less_history_file index c99c1d2c..4ba7e0b7 100755 --- a/tests/test_navigate_less_history_file +++ b/tests/test_navigate_less_history_file @@ -2,35 +2,57 @@ set -e -die () { +cleanup() { + rm -r "$TEMPDIR" +} + +die() { echo "$1" 1>&2 + cleanup exit 1 } -DELTA_BIN=${1:-./target/release/delta} -DELTA="$DELTA_BIN --no-gitconfig --navigate" +DELTA="${1:-./target/release/delta} --no-gitconfig --navigate" # Trick delta into thinking that its pager is less, when really it is cat. -TEMPDIR=$(mktemp -d) -DELTA_TEST_PAGER=$TEMPDIR/less -echo cat > $DELTA_TEST_PAGER -chmod +x $DELTA_TEST_PAGER -export PAGER=$DELTA_TEST_PAGER +unset DELTA_PAGER +TEMPDIR="$(mktemp -d)" +export PAGER="$TEMPDIR/less" +install -m755 /dev/stdin "$PAGER" <<-EOF + #!/bin/sh + cat +EOF test_delta_less_hist_file_created () { - DELTA_HIST_FILE=~/.local/share/delta/lesshst - rm -f ~/.lesshst $DELTA_HIST_FILE - [ -e $DELTA_HIST_FILE ] && die "Expected $DELTA_HIST_FILE not to exist" - git -c core.pager="$DELTA" log -p HEAD~2...HEAD - [ -e $DELTA_HIST_FILE ] || die "Expected $DELTA_HIST_FILE to exist" + DELTA_HIST_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/delta/lesshst" + rm -f ~/.lesshst "$DELTA_HIST_FILE" + [ -e "$DELTA_HIST_FILE" ] && die "Expected \"$DELTA_HIST_FILE\" not to exist" + git -c pager.log="$DELTA" log -p HEAD~2...HEAD + [ -e "$DELTA_HIST_FILE" ] || die "Expected \"$DELTA_HIST_FILE\" to exist" } +# Basic test test_delta_less_hist_file_created # Test it works with a custom LESSHISTFILE -DELTA_TEST_LESSHISTFILE=$(mktemp) -export LESSHISTFILE=TEMPDIR/delta.lesshst +export LESSHISTFILE=$TEMPDIR/delta.lesshst +test_delta_less_hist_file_created + +# Test histfile sections other than `.search` at the end of the file (#1) +cat >$LESSHISTFILE <<-EOF + .shell + "pwd + "ls -Al ../data/ +EOF +test_delta_less_hist_file_created + +# Test histfile sections other than `.search` at the end of the file (#2) +cat >>$LESSHISTFILE <<-EOF + .mark + m a 1 7740 /etc/gitconfig + m b 1 4221 /etc/profile +EOF test_delta_less_hist_file_created # Cleanup -rm -r "$TEMPDIR" +cleanup |