tests/: bash -> sh
This commit is contained in:
parent
9251451554
commit
0aa5163545
|
@ -1,21 +1,50 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
FAIL="false"
|
FAIL="false"
|
||||||
|
|
||||||
|
mkdir_p()
|
||||||
|
{ #portable mkdir -p function
|
||||||
|
local dir subdir
|
||||||
|
for dir; do
|
||||||
|
mkdir_p__IFS="$IFS"
|
||||||
|
IFS="/"
|
||||||
|
set -- $dir
|
||||||
|
IFS="$mkdir_p__IFS"
|
||||||
|
(
|
||||||
|
case "$dir" in
|
||||||
|
/*) cd /; shift ;;
|
||||||
|
esac
|
||||||
|
for subdir; do
|
||||||
|
[ -z "${subdir}" ] && continue
|
||||||
|
if [ -d "${subdir}" ] || mkdir "${subdir}"; then
|
||||||
|
if cd "${subdir}"; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
printf "%s\\n" "mkdir_p: Can't enter ${subdir} while creating ${dir}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
set_tmux_conf_helper() {
|
set_tmux_conf_helper() {
|
||||||
> ~/.tmux.conf # empty filename
|
> ~/.tmux.conf # empty filename
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
echo $line >> ~/.tmux.conf
|
printf "%s\\n" "${line}" >> ~/.tmux.conf
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
create_test_plugin_helper() {
|
create_test_plugin_helper() {
|
||||||
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
|
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
|
||||||
rm -rf $plugin_path
|
rm -rf "$plugin_path"
|
||||||
mkdir -p $plugin_path
|
mkdir_p "$plugin_path"
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
echo $line >> "$plugin_path/test_plugin.tmux"
|
printf "%s\\n" "$line" >> "$plugin_path/test_plugin.tmux"
|
||||||
done
|
done
|
||||||
chmod +x "$plugin_path/test_plugin.tmux"
|
chmod +x "$plugin_path/test_plugin.tmux"
|
||||||
}
|
}
|
||||||
|
@ -37,19 +66,19 @@ check_dir_exists_helper() {
|
||||||
|
|
||||||
fail_helper() {
|
fail_helper() {
|
||||||
local message="$1"
|
local message="$1"
|
||||||
echo "$message" >&2
|
printf "%s\\n" "$message" >&2
|
||||||
FAIL="true"
|
FAIL="true"
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_value_helper() {
|
exit_value_helper() {
|
||||||
local fail="$1"
|
local fail="$1"
|
||||||
if [ "$FAIL" == "true" ]; then
|
if [ "$FAIL" = "true" ]; then
|
||||||
echo "FAIL!"
|
printf "%s\\n" "FAIL!"
|
||||||
echo
|
printf "\\n"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "SUCCESS"
|
printf "%s\\n" "SUCCESS"
|
||||||
echo
|
printf "\\n"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,47 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
# A test runner file.
|
# A test runner file.
|
||||||
# Intended to be run from `./run-tests` script *within* a virtual machine.
|
# Intended to be run from `./run-tests` script *within* a virtual machine.
|
||||||
# DO NOT run it locally as it might overwrite your `.tmux.conf` (that's what it
|
# DO NOT run it locally as it might overwrite your `.tmux.conf` (that's what it
|
||||||
# does during the tests).
|
# does during the tests).
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
_dirname()
|
||||||
|
{ #portable dirname
|
||||||
|
[ -z "${1}" ] && return 1
|
||||||
|
|
||||||
|
#http://www.linuxselfhelp.com/gnu/autoconf/html_chapter/autoconf_10.html
|
||||||
|
case "${1}" in
|
||||||
|
/*|*/*) local dir; dir=$(expr "x${1}" : 'x\(.*\)/[^/]*' \| '.' : '.')
|
||||||
|
printf "%s\\n" "${dir}" ;;
|
||||||
|
*) printf "%s\\n" ".";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( _dirname "$0" )" && pwd )"
|
||||||
|
|
||||||
# running test suite is successful by default
|
# running test suite is successful by default
|
||||||
tests_exit_value=0
|
tests_exit_value="0"
|
||||||
|
|
||||||
set_global_exit_val_to_false() {
|
set_global_exit_val_to_false() {
|
||||||
tests_exit_value=1
|
tests_exit_value="1"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_files() {
|
test_files() {
|
||||||
ls -1 "$CURRENT_DIR" | # test files are in the current dir
|
ls -1 "$CURRENT_DIR" | # test files are in the current dir
|
||||||
grep -i '^test' | # test file names start with 'test'
|
grep -i '^test' | # test file names start with 'test'
|
||||||
xargs # file names in one line
|
xargs # file names in one line
|
||||||
}
|
}
|
||||||
|
|
||||||
run_tests() {
|
run_tests() {
|
||||||
local test_file
|
local test_file
|
||||||
for test_file in $(test_files); do
|
for test_file in "$CURRENT_DIR"/test*; do
|
||||||
echo "Running test: $test_file"
|
[ -f "${test_file}" ] || continue
|
||||||
$CURRENT_DIR/$test_file
|
printf "%s\\n" "Running test: ${test_file##*/}"
|
||||||
|
"$test_file"
|
||||||
|
|
||||||
# handling exit value
|
# handling exit value
|
||||||
local exit_value="$?"
|
local exit_value="$?"
|
||||||
if [ "$exit_value" != 0 ]; then
|
if [ "$exit_value" != "0" ]; then
|
||||||
set_global_exit_val_to_false
|
set_global_exit_val_to_false
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
_dirname()
|
||||||
|
{ #portable dirname
|
||||||
|
[ -z "${1}" ] && return 1
|
||||||
|
|
||||||
source $CURRENT_DIR/helpers.sh
|
#http://www.linuxselfhelp.com/gnu/autoconf/html_chapter/autoconf_10.html
|
||||||
|
case "${1}" in
|
||||||
|
/*|*/*) local dir; dir=$(expr "x${1}" : 'x\(.*\)/[^/]*' \| '.' : '.')
|
||||||
|
printf "%s\\n" "${dir}" ;;
|
||||||
|
*) printf "%s\\n" ".";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( _dirname "$0" )" && pwd )"
|
||||||
|
|
||||||
|
. "$CURRENT_DIR"/helpers.sh
|
||||||
|
|
||||||
test_plugin_installation() {
|
test_plugin_installation() {
|
||||||
set_tmux_conf_helper <<- HERE
|
set_tmux_conf_helper <<- HERE
|
||||||
|
@ -11,7 +23,7 @@ test_plugin_installation() {
|
||||||
HERE
|
HERE
|
||||||
|
|
||||||
# opens tmux and test it with `expect`
|
# opens tmux and test it with `expect`
|
||||||
$CURRENT_DIR/expect_successful_plugin_download ||
|
"$CURRENT_DIR"/expect_successful_plugin_download ||
|
||||||
fail_helper "Tmux plugin installation fails"
|
fail_helper "Tmux plugin installation fails"
|
||||||
|
|
||||||
# check plugin dir exists after download
|
# check plugin dir exists after download
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
_dirname()
|
||||||
|
{ #portable dirname
|
||||||
|
[ -z "${1}" ] && return 1
|
||||||
|
|
||||||
source $CURRENT_DIR/helpers.sh
|
#http://www.linuxselfhelp.com/gnu/autoconf/html_chapter/autoconf_10.html
|
||||||
|
case "${1}" in
|
||||||
|
/*|*/*) local dir; dir=$(expr "x${1}" : 'x\(.*\)/[^/]*' \| '.' : '.')
|
||||||
|
printf "%s\\n" "${dir}" ;;
|
||||||
|
*) printf "%s\\n" ".";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( _dirname "$0" )" && pwd )"
|
||||||
|
|
||||||
|
. "$CURRENT_DIR"/helpers.sh
|
||||||
|
|
||||||
check_binding_defined() {
|
check_binding_defined() {
|
||||||
local binding="$1"
|
local binding="$1"
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
_dirname()
|
||||||
|
{ #portable dirname
|
||||||
|
[ -z "${1}" ] && return 1
|
||||||
|
|
||||||
source $CURRENT_DIR/helpers.sh
|
#http://www.linuxselfhelp.com/gnu/autoconf/html_chapter/autoconf_10.html
|
||||||
|
case "${1}" in
|
||||||
|
/*|*/*) local dir; dir=$(expr "x${1}" : 'x\(.*\)/[^/]*' \| '.' : '.')
|
||||||
|
printf "%s\\n" "${dir}" ;;
|
||||||
|
*) printf "%s\\n" ".";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( _dirname "$0" )" && pwd )"
|
||||||
|
|
||||||
|
. "$CURRENT_DIR"/helpers.sh
|
||||||
|
|
||||||
manually_install_the_plugin() {
|
manually_install_the_plugin() {
|
||||||
mkdir -p ~/.tmux/plugins/
|
mkdir_p ~/.tmux/plugins/
|
||||||
cd ~/.tmux/plugins/
|
cd ~/.tmux/plugins/
|
||||||
git clone --quiet https://github.com/tmux-plugins/tmux-example-plugin
|
git clone --quiet https://github.com/tmux-plugins/tmux-example-plugin
|
||||||
}
|
}
|
||||||
|
@ -19,10 +31,10 @@ test_plugin_installation() {
|
||||||
manually_install_the_plugin
|
manually_install_the_plugin
|
||||||
|
|
||||||
# opens tmux and test it with `expect`
|
# opens tmux and test it with `expect`
|
||||||
$CURRENT_DIR/expect_successful_update_of_all_plugins ||
|
"$CURRENT_DIR"/expect_successful_update_of_all_plugins ||
|
||||||
fail_helper "Tmux 'update all plugins' fails"
|
fail_helper "Tmux 'update all plugins' fails"
|
||||||
|
|
||||||
$CURRENT_DIR/expect_successful_update_of_a_single_plugin ||
|
"$CURRENT_DIR"/expect_successful_update_of_a_single_plugin ||
|
||||||
fail_helper "Tmux 'update single plugin' fails"
|
fail_helper "Tmux 'update single plugin' fails"
|
||||||
|
|
||||||
teardown_helper
|
teardown_helper
|
||||||
|
|
Loading…
Reference in a new issue