mirror of
https://github.com/tmux-plugins/tpm.git
synced 2024-12-04 18:58:49 +00:00
Switch to using tmux-test
framework
This commit is contained in:
parent
274098a029
commit
830feaae69
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
**/.vagrant/
|
**/.vagrant/
|
||||||
|
run_tests
|
||||||
|
tests/run_tests_in_isolation
|
||||||
|
tests/helpers/helpers.sh
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "lib/tmux-test"]
|
||||||
|
path = lib/tmux-test
|
||||||
|
url = https://github.com/tmux-plugins/tmux-test.git
|
11
.travis.yml
11
.travis.yml
@ -1,13 +1,14 @@
|
|||||||
# generic packages
|
# generic packages and latest Tmux 1.9a
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
- sudo apt-get install -y git-core expect
|
- sudo apt-get install -y git-core expect
|
||||||
- sudo apt-get install -y python-software-properties software-properties-common
|
- sudo apt-get install -y python-software-properties software-properties-common
|
||||||
|
|
||||||
# install latest Tmux 1.9a
|
|
||||||
install:
|
|
||||||
- sudo add-apt-repository -y ppa:pi-rho/dev
|
- sudo add-apt-repository -y ppa:pi-rho/dev
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
- sudo apt-get install -y tmux=1.9a-1~ppa1~p
|
- sudo apt-get install -y tmux=1.9a-1~ppa1~p
|
||||||
|
|
||||||
script: ./tests/run-tests-within-vm
|
install:
|
||||||
|
- git clone https://github.com/tmux-plugins/tmux-test lib/tmux-test
|
||||||
|
- lib/tmux-test/setup
|
||||||
|
|
||||||
|
script: ./tests/run_tests_in_isolation
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
- move all instructions to `docs/` dir
|
- move all instructions to `docs/` dir
|
||||||
- add `bin/install_plugins` cli executable script
|
- add `bin/install_plugins` cli executable script
|
||||||
- improved test runner function
|
- improved test runner function
|
||||||
|
- switch to using [tmux-test](https://github.com/tmux-plugins/tmux-test)
|
||||||
|
framework
|
||||||
|
|
||||||
### v2.0.0, 2015-07-07
|
### v2.0.0, 2015-07-07
|
||||||
- enable overriding default key bindings
|
- enable overriding default key bindings
|
||||||
|
@ -85,7 +85,7 @@ When run locally, [vagrant](https://www.vagrantup.com/) is required.
|
|||||||
Run tests with:
|
Run tests with:
|
||||||
|
|
||||||
# within project directory
|
# within project directory
|
||||||
$ ./run-tests
|
$ ./run_tests
|
||||||
|
|
||||||
### Other goodies
|
### Other goodies
|
||||||
|
|
||||||
|
10
Vagrantfile
vendored
10
Vagrantfile
vendored
@ -1,10 +0,0 @@
|
|||||||
VAGRANTFILE_API_VERSION = '2'
|
|
||||||
|
|
||||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
||||||
config.vm.box = 'precise32'
|
|
||||||
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
|
|
||||||
|
|
||||||
config.vm.synced_folder './', '/home/vagrant/tpm'
|
|
||||||
|
|
||||||
config.vm.provision 'shell', path: 'vagrant_provisioning.sh'
|
|
||||||
end
|
|
1
lib/tmux-test
Submodule
1
lib/tmux-test
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 672b2c3883df2f99acb27b3c302d4b773e62aa28
|
31
run-tests
31
run-tests
@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
# running test suite is successful by default
|
|
||||||
tests_exit_value=0
|
|
||||||
|
|
||||||
run_vagrant() {
|
|
||||||
vagrant up
|
|
||||||
}
|
|
||||||
|
|
||||||
# Halt vagrant after tests are done running, unless KEEP_RUNNING environment
|
|
||||||
# variable is set to 'true'.
|
|
||||||
stop_vagrant() {
|
|
||||||
if [ -z "$KEEP_RUNNING" ]; then
|
|
||||||
vagrant halt
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
run_tests() {
|
|
||||||
vagrant ssh -c "cd ~/tpm; ./tests/run-tests-within-vm"
|
|
||||||
tests_exit_value=$?
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
run_vagrant
|
|
||||||
run_tests
|
|
||||||
stop_vagrant
|
|
||||||
exit "$tests_exit_value"
|
|
||||||
}
|
|
||||||
main
|
|
@ -1,73 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
FAIL="false"
|
|
||||||
|
|
||||||
set_tmux_conf_helper() {
|
|
||||||
> ~/.tmux.conf # empty filename
|
|
||||||
while read line; do
|
|
||||||
echo "$line" >> ~/.tmux.conf
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
create_test_plugin_helper() {
|
|
||||||
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
|
|
||||||
rm -rf $plugin_path
|
|
||||||
mkdir -p $plugin_path
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
echo $line >> "$plugin_path/test_plugin.tmux"
|
|
||||||
done
|
|
||||||
chmod +x "$plugin_path/test_plugin.tmux"
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown_helper() {
|
|
||||||
rm ~/.tmux.conf
|
|
||||||
rm -rf ~/.tmux/
|
|
||||||
tmux kill-server >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
check_dir_exists_helper() {
|
|
||||||
local dir_path=$1
|
|
||||||
if [ -d "$dir_path" ]; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# runs the scripts and asserts it has the correct output and exit code
|
|
||||||
script_run_helper() {
|
|
||||||
local script="$1"
|
|
||||||
local expected_output="$2"
|
|
||||||
local expected_exit_code="${3:-0}"
|
|
||||||
"$script" |
|
|
||||||
grep "$expected_output" >/dev/null 2>&1 && # grep -q flag quits the script early
|
|
||||||
[ "${PIPESTATUS[0]}" -eq "$expected_exit_code" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
fail_helper() {
|
|
||||||
local message="$1"
|
|
||||||
echo "$message" >&2
|
|
||||||
FAIL="true"
|
|
||||||
}
|
|
||||||
|
|
||||||
exit_value_helper() {
|
|
||||||
local fail="$1"
|
|
||||||
if [ "$FAIL" == "true" ]; then
|
|
||||||
echo "FAIL!"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "SUCCESS"
|
|
||||||
echo
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
run_tests() {
|
|
||||||
# get all the functions starting with 'test_' and invoke them
|
|
||||||
for test in $(compgen -A function | grep "^test_"); do
|
|
||||||
"$test"
|
|
||||||
done
|
|
||||||
exit_value_helper
|
|
||||||
}
|
|
18
tests/helpers/tpm.sh
Normal file
18
tests/helpers/tpm.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
check_dir_exists_helper() {
|
||||||
|
local dir_path=$1
|
||||||
|
if [ -d "$dir_path" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# runs the scripts and asserts it has the correct output and exit code
|
||||||
|
script_run_helper() {
|
||||||
|
local script="$1"
|
||||||
|
local expected_output="$2"
|
||||||
|
local expected_exit_code="${3:-0}"
|
||||||
|
"$script" |
|
||||||
|
grep "$expected_output" >/dev/null 2>&1 && # grep -q flag quits the script early
|
||||||
|
[ "${PIPESTATUS[0]}" -eq "$expected_exit_code" ]
|
||||||
|
}
|
@ -1,41 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# A test runner file.
|
|
||||||
# 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
|
|
||||||
# does during the tests).
|
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
# running test suite is successful by default
|
|
||||||
tests_exit_value=0
|
|
||||||
|
|
||||||
set_global_exit_val_to_false() {
|
|
||||||
tests_exit_value=1
|
|
||||||
}
|
|
||||||
|
|
||||||
test_files() {
|
|
||||||
ls -1 "$CURRENT_DIR" | # test files are in the current dir
|
|
||||||
grep -i '^test' | # test file names start with 'test'
|
|
||||||
xargs # file names in one line
|
|
||||||
}
|
|
||||||
|
|
||||||
run_tests() {
|
|
||||||
local test_file
|
|
||||||
for test_file in $(test_files); do
|
|
||||||
echo "Running test: $test_file"
|
|
||||||
"$CURRENT_DIR/$test_file"
|
|
||||||
|
|
||||||
# handling exit value
|
|
||||||
local exit_value="$?"
|
|
||||||
if [ "$exit_value" != 0 ]; then
|
|
||||||
set_global_exit_val_to_false
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
run_tests
|
|
||||||
exit "$tests_exit_value"
|
|
||||||
}
|
|
||||||
main
|
|
@ -4,7 +4,8 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
TPM_DIR="$PWD"
|
TPM_DIR="$PWD"
|
||||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||||
|
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||||
|
|
||||||
manually_install_the_plugin() {
|
manually_install_the_plugin() {
|
||||||
rm -rf "$PLUGINS_DIR"
|
rm -rf "$PLUGINS_DIR"
|
||||||
|
@ -6,7 +6,8 @@ TPM_DIR="$PWD"
|
|||||||
|
|
||||||
CUSTOM_PLUGINS_DIR="$HOME/foo/plugins"
|
CUSTOM_PLUGINS_DIR="$HOME/foo/plugins"
|
||||||
|
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||||
|
|
||||||
# TMUX KEY-BINDING TESTS
|
# TMUX KEY-BINDING TESTS
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||||
TPM_DIR="$PWD"
|
TPM_DIR="$PWD"
|
||||||
|
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||||
|
|
||||||
# TMUX KEY-BINDING TESTS
|
# TMUX KEY-BINDING TESTS
|
||||||
|
|
||||||
|
@ -3,13 +3,25 @@
|
|||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
TPM_DIR="$PWD"
|
TPM_DIR="$PWD"
|
||||||
|
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||||
|
|
||||||
check_binding_defined() {
|
check_binding_defined() {
|
||||||
local binding="$1"
|
local binding="$1"
|
||||||
tmux list-keys | grep -q "$binding"
|
tmux list-keys | grep -q "$binding"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_test_plugin_helper() {
|
||||||
|
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
|
||||||
|
rm -rf $plugin_path
|
||||||
|
mkdir -p $plugin_path
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
echo $line >> "$plugin_path/test_plugin.tmux"
|
||||||
|
done
|
||||||
|
chmod +x "$plugin_path/test_plugin.tmux"
|
||||||
|
}
|
||||||
|
|
||||||
test_plugin_sourcing() {
|
test_plugin_sourcing() {
|
||||||
set_tmux_conf_helper <<- HERE
|
set_tmux_conf_helper <<- HERE
|
||||||
set -g @plugin "doesnt_matter/tmux_test_plugin"
|
set -g @plugin "doesnt_matter/tmux_test_plugin"
|
||||||
|
@ -4,7 +4,8 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
TPM_DIR="$PWD"
|
TPM_DIR="$PWD"
|
||||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||||
|
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||||
|
|
||||||
manually_install_the_plugin() {
|
manually_install_the_plugin() {
|
||||||
mkdir -p "$PLUGINS_DIR"
|
mkdir -p "$PLUGINS_DIR"
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y git-core expect python-software-properties software-properties-common
|
|
||||||
|
|
||||||
# install latest Tmux 1.9a
|
|
||||||
sudo add-apt-repository -y ppa:pi-rho/dev
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y tmux=1.9a-1~ppa1~p
|
|
Loading…
Reference in New Issue
Block a user