Skip to content

Commit

Permalink
add history-/history-cases-test, using readline
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandwalker committed Aug 24, 2017
1 parent 8a1a2c6 commit f8d83c7
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/prompt/history-cases-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh

. libtest.sh
. libgit.sh

export LINES=3
export COLUMNS=80

test_require readline

in_work_dir create_repo_from_tgz "$base_dir/files/scala-js-benchmarks.tgz"

test_case one \
--before='rm -f -- "$HOME/.tig_history"' \
--tigrc='set history-size = 10' \
--keystrokes=':echo keys_one\r:quit\r' \
--assert-equals=".tig_history"='echo keys_one
quit
' \
<<EOF
2014-03-01 17:26 Jonas Fonseca o [master] WIP: Upgrade to 0.4-SNAPSHOT and
[main] ee912870202200a0b9cf4fd86ba57243212d341e - commit 1 of 48 2%
EOF

test_case two \
--before='rm -f -- "$HOME/.tig_history"' \
--tigrc='set history-size = 10' \
--keystrokes=':echo keys_two\r:quit\r' \
--assert-equals=".tig_history"="echo first_line
echo second_line
save-display $HOME/two.screen
echo keys_two
quit
" \
--script=':echo first_line
:echo second_line' \
<<EOF
2014-03-01 17:26 Jonas Fonseca o [master] WIP: Upgrade to 0.4-SNAPSHOT and
[main] ee912870202200a0b9cf4fd86ba57243212d341e - commit 1 of 48 2%
EOF

test_case three \
--before='rm -f -- "$HOME/.tig_history"' \
--tigrc='set history-size = 10' \
--assert-equals=".tig_history"="echo first_line
echo second_line
save-display $HOME/three.screen
quit
" \
--script=':echo first_line
:echo second_line' <<EOF
2014-03-01 17:26 Jonas Fonseca o [master] WIP: Upgrade to 0.4-SNAPSHOT and
[main] ee912870202200a0b9cf4fd86ba57243212d341e - commit 1 of 48 2%
EOF

test_case four \
--before='rm -f -- "$HOME/.tig_history"' \
--tigrc='set history-size = 10' \
--keystrokes=':echo keys_four\r:quit\r' \
--assert-equals=".tig_history"='echo keys_four
quit
' \
<<EOF
2014-03-01 17:26 Jonas Fonseca o [master] WIP: Upgrade to 0.4-SNAPSHOT and
[main] ee912870202200a0b9cf4fd86ba57243212d341e - commit 1 of 48 2%
EOF

run_test_cases
30 changes: 30 additions & 0 deletions test/prompt/history-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

. libtest.sh
. libgit.sh

export LINES=3
export COLUMNS=80

test_require readline

in_work_dir create_repo_from_tgz "$base_dir/files/scala-js-benchmarks.tgz"

tigrc <<EOF
set history-size = 3
EOF

keystrokes ':none'
keystrokes -append -keysym 'Enter'
keystrokes -append ':quit'
keystrokes -append -keysym 'Enter'

test_tig

assert_equals stderr <<EOF
EOF

assert_equals "$HOME/.tig_history" <<EOF
none
quit
EOF

0 comments on commit f8d83c7

Please sign in to comment.