Lots of test cleanup.

This commit is contained in:
Eric Freese
2016-03-05 20:53:07 -07:00
parent dffd9beae1
commit e5cdbb6c33
48 changed files with 707 additions and 8321 deletions

View File

@@ -1,80 +0,0 @@
#!/usr/bin/env zsh
SCRIPT_DIR=$(dirname "$0")
TEST_DIR=$SCRIPT_DIR/../test
DIST_DIR=$SCRIPT_DIR/../
source $TEST_DIR/stub-1.0.2.sh
source $DIST_DIR/zsh-autosuggestions.zsh
#--------------------------------------------------------------------#
# Default Suggestions Strategy #
#--------------------------------------------------------------------#
TMPHIST_FILE=/tmp/zsh-autosuggestions-test-tmp-hist
# Use stub.sh for stubbing/mocking
HISTSIZE=0 # Clear history
HISTSIZE=100
cat > $TMPHIST_FILE <<-EOH
one
two
three
four
five
six
seven
eight
nine
ten
eleven
EOH
echo >> $TMPHIST_FILE
fc -R $TMPHIST_FILE
rm $TMPHIST_FILE
ZSH_AUTOSUGGEST_STRATEGY=default
testNoMatch() {
assertEquals \
"Did not pick correct suggestion for prefix 'garbage'" \
"" \
"$(_zsh_autosuggest_suggestion garbage)"
}
testMatch() {
assertEquals \
"Did not pick correct suggestion for prefix 'o'" \
"one" \
"$(_zsh_autosuggest_suggestion o)"
assertEquals \
"Did not pick correct suggestion for prefix 't'" \
"ten" \
"$(_zsh_autosuggest_suggestion t)"
assertEquals \
"Did not pick correct suggestion for prefix 'tw'" \
"two" \
"$(_zsh_autosuggest_suggestion tw)"
assertEquals \
"Did not pick correct suggestion for prefix 'f'" \
"five" \
"$(_zsh_autosuggest_suggestion f)"
assertEquals \
"Did not pick correct suggestion for prefix 'fo'" \
"four" \
"$(_zsh_autosuggest_suggestion fo)"
}
setopt shwordsplit
SHUNIT_PARENT=$0
source $TEST_DIR/shunit2-2.1.6/src/shunit2

View File

@@ -1,122 +0,0 @@
#!/usr/bin/env zsh
SCRIPT_DIR=$(dirname "$0")
TEST_DIR=$SCRIPT_DIR/../test
DIST_DIR=$SCRIPT_DIR/../
# Use stub.sh for stubbing/mocking
source $TEST_DIR/stub-1.0.2.sh
source $DIST_DIR/zsh-autosuggestions.zsh
#--------------------------------------------------------------------#
# Match Previous Command Suggestion Strategy #
#--------------------------------------------------------------------#
TMPHIST_FILE=/tmp/zsh-autosuggestions-test-tmp-hist
HISTSIZE=0 # Clear history
HISTSIZE=100
cat > $TMPHIST_FILE <<-EOH
one
two
three
four
five
six
seven
eight
nine
ten
eleven
EOH
echo >> $TMPHIST_FILE
fc -R $TMPHIST_FILE
rm $TMPHIST_FILE
ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd
testNoMatchPrevIsOne() {
stub_and_echo _zsh_autosuggest_prev_command "one"
assertEquals \
"Did not pick correct suggestion for prefix 'garbage' after 'one'" \
"" \
"$(_zsh_autosuggest_suggestion garbage)"
}
testMatchPrevIsOne() {
stub_and_echo _zsh_autosuggest_prev_command "one"
assertEquals \
"Did not pick correct suggestion for prefix 'o' after 'one'" \
"one" \
"$(_zsh_autosuggest_suggestion o)"
assertEquals \
"Did not pick correct suggestion for prefix 't' after 'one'" \
"two" \
"$(_zsh_autosuggest_suggestion t)"
assertEquals \
"Did not pick correct suggestion for prefix 'th' after 'one'" \
"three" \
"$(_zsh_autosuggest_suggestion th)"
assertEquals \
"Did not pick correct suggestion for prefix 'f' after 'one'" \
"five" \
"$(_zsh_autosuggest_suggestion f)"
assertEquals \
"Did not pick correct suggestion for prefix 'fo' after 'one" \
"four" \
"$(_zsh_autosuggest_suggestion fo)"
}
testNoMatchPrevIsTwo() {
stub_and_echo _zsh_autosuggest_prev_command "two"
assertEquals \
"Did not pick correct suggestion for prefix 'garbage' after 'two'" \
"" \
"$(_zsh_autosuggest_suggestion garbage)"
}
testMatchPrevIsTwo() {
stub_and_echo _zsh_autosuggest_prev_command "two"
assertEquals \
"Did not pick correct suggestion for prefix 'o' after 'two'" \
"one" \
"$(_zsh_autosuggest_suggestion o)"
assertEquals \
"Did not pick correct suggestion for prefix 't' after 'two'" \
"three" \
"$(_zsh_autosuggest_suggestion t)"
assertEquals \
"Did not pick correct suggestion for prefix 'tw' after 'two'" \
"two" \
"$(_zsh_autosuggest_suggestion tw)"
assertEquals \
"Did not pick correct suggestion for prefix 'f' after 'two'" \
"five" \
"$(_zsh_autosuggest_suggestion f)"
assertEquals \
"Did not pick correct suggestion for prefix 'fo' after 'two" \
"four" \
"$(_zsh_autosuggest_suggestion fo)"
}
setopt shwordsplit
SHUNIT_PARENT=$0
source $TEST_DIR/shunit2-2.1.6/src/shunit2

29
script/test_runner.zsh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env zsh
DIR=${0:a:h}
ROOT_DIR="$DIR/.."
TEST_DIR="$ROOT_DIR/test"
header() {
local message="$1"
cat <<-EOF
#====================================================================#
# $message
#====================================================================#
EOF
}
local -a tests
# Test suites to run
tests=($TEST_DIR/**/*_test.zsh)
local retval=0
for suite in $tests; do
header "${suite#"$TEST_DIR"}"
zsh -f "$suite" || retval=$?
done
exit retval