Debian Codegraph @

tests/test_navigate_less_history_file

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 set -e
4
5 cleanupscip-shell shell shell-project 0.0.0 cleanup().() {
6 rmscip-shell system . . rm. -r "$TEMPDIR"
7 }
8
9 diescip-shell shell shell-project 0.0.0 die().() {
10 echoscip-shell system . . echo. "$1" 1>&2
11 cleanupscip-shell shell shell-project 0.0.0 cleanup().
12 exit 1
13 }
14
15 DELTA="${1:-./target/release/delta} --no-gitconfig --navigate"
16
17 # Trick delta into thinking that its pager is less, when really it is cat.
18 unset DELTA_PAGER
19 TEMPDIR="$(mktempscip-shell system . . mktemp. -d)"
20 export PAGER="$TEMPDIR/less"
21 catscip-shell system . . cat. >"$PAGER" <<-EOF
22 #!/bin/sh
23 cat
24 EOF
25 chmodscip-shell system . . chmod. 755 $PAGER
26
27 test_delta_less_hist_file_createdscip-shell shell shell-project 0.0.0 test_delta_less_hist_file_created(). () {
28 DELTA_HIST_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/delta/lesshst"
29 rmscip-shell system . . rm. -f ~/.lesshst "$DELTA_HIST_FILE"
30 [scip-shell system . . `[`. -e "$DELTA_HIST_FILE" ] && diescip-shell shell shell-project 0.0.0 die(). "Expected \"$DELTA_HIST_FILE\" not to exist"
31 if [[ "$OSTYPE" = darwin* ]]; then
32 # Trick git and delta into invoking their pager child processes, despite
33 # output not being a tty.
34 scriptscip-shell system . . script. -q /dev/nullscip-shell filesystem . . `/dev/null`. git -c pager.log="$DELTA" log -p HEAD~2...HEAD > /dev/nullscip-shell filesystem . . `/dev/null`.
35 else
36 gitscip-shell system . . git. -c pager.log="$DELTA" log -p HEAD~2...HEAD
37 fi
38 [scip-shell system . . `[`. -e "$DELTA_HIST_FILE" ] || diescip-shell shell shell-project 0.0.0 die(). "Expected \"$DELTA_HIST_FILE\" to exist"
39 }
40
41 # Basic test
42 test_delta_less_hist_file_createdscip-shell shell shell-project 0.0.0 test_delta_less_hist_file_created().
43
44 # Test it works with a custom LESSHISTFILE
45 export LESSHISTFILE=$TEMPDIR/delta.lesshst
46 test_delta_less_hist_file_createdscip-shell shell shell-project 0.0.0 test_delta_less_hist_file_created().
47
48 # Test histfile sections other than `.search` at the end of the file (#1)
49 catscip-shell system . . cat. >$LESSHISTFILE <<-EOF
50 .shell
51 "pwd
52 "ls -Al ../data/
53 EOF
54 test_delta_less_hist_file_createdscip-shell shell shell-project 0.0.0 test_delta_less_hist_file_created().
55
56 # Test histfile sections other than `.search` at the end of the file (#2)
57 catscip-shell system . . cat. >>$LESSHISTFILE <<-EOF
58 .mark
59 m a 1 7740 /etc/gitconfig
60 m b 1 4221 /etc/profile
61 EOF
62 test_delta_less_hist_file_createdscip-shell shell shell-project 0.0.0 test_delta_less_hist_file_created().
63
64 # Cleanup
65 cleanupscip-shell shell shell-project 0.0.0 cleanup().