mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-08 13:49:07 -04:00
add tmux
This commit is contained in:
parent
c21063c727
commit
9c06dba63b
236 changed files with 7786 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This file is a symlink from 'tmux-test' plugin.
|
||||
# You probably don't want to edit it.
|
||||
|
||||
# This script should be run within an isolated enviroment (Vagrant, travis).
|
||||
# Depending on what the tests do, it might NOT be safe to run this script
|
||||
# directly on the development machine.
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
EXIT_VALUE=0 # running a test suite is successful by default
|
||||
|
||||
all_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 a single line
|
||||
}
|
||||
|
||||
set_exit_val_to_false() {
|
||||
EXIT_VALUE=1
|
||||
}
|
||||
|
||||
run_tests() {
|
||||
local test_file tests_files
|
||||
if [ "$#" -gt 0 ]; then
|
||||
test_files="${@//tests\//}" # remove 'tests/' directory prefix
|
||||
else
|
||||
test_files="$(all_test_files)"
|
||||
fi
|
||||
for test_file in $test_files; do
|
||||
echo "Running test: $test_file"
|
||||
"${CURRENT_DIR}/${test_file}"
|
||||
|
||||
# handling exit value
|
||||
local test_exit_value="$?"
|
||||
if [ "$test_exit_value" -ne 0 ]; then
|
||||
set_exit_val_to_false
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
run_tests "$@"
|
||||
exit "$EXIT_VALUE"
|
||||
}
|
||||
main "$@"
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,24 @@
|
|||
#/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# bash helpers provided by 'tmux-test'
|
||||
source $CURRENT_DIR/helpers/helpers.sh
|
||||
|
||||
# installs plugin from current repo in Vagrant (or on Travis)
|
||||
install_tmux_plugin_under_test_helper
|
||||
|
||||
# start tmux in background (plugin under test is sourced)
|
||||
tmux new -d
|
||||
|
||||
# get first session name
|
||||
session_name="$(tmux list-sessions -F "#{session_name}")"
|
||||
|
||||
# fail the test if first session name is not "0"
|
||||
if ! [ "$session_name" == "0" ]; then
|
||||
# fail_helper is also provided by 'tmux-test'
|
||||
fail_helper "First session name is not '0' by default"
|
||||
fi
|
||||
|
||||
# sets the right script exit code ('tmux-test' helper)
|
||||
exit_helper
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source $CURRENT_DIR/helpers/helpers.sh
|
||||
|
||||
number_of_windows() {
|
||||
tmux list-windows |
|
||||
wc -l |
|
||||
sed "s/ //g"
|
||||
}
|
||||
|
||||
main() {
|
||||
# start tmux in the background
|
||||
tmux new -d
|
||||
tmux new-window
|
||||
|
||||
local number_of_windows="$(number_of_windows)"
|
||||
if ! [ "$number_of_windows" -eq 2 ]; then
|
||||
fail_helper "Incorrect number of windows. Expected 2, got $number_of_windows"
|
||||
fi
|
||||
exit_helper
|
||||
}
|
||||
main
|
|
@ -0,0 +1,68 @@
|
|||
# This file is a symlink from 'tmux-test' plugin.
|
||||
# You probably don't want to edit it.
|
||||
|
||||
|
||||
# Global variable that keeps the value of test status (success/fail).
|
||||
# Suggested usage is via `fail_helper` and `exit_helper` functions.
|
||||
TEST_STATUS="success"
|
||||
|
||||
# PRIVATE FUNCTIONS
|
||||
|
||||
_clone_the_plugin() {
|
||||
local plugin_path="${HOME}/.tmux/plugins/tmux-plugin-under-test/"
|
||||
rm -rf "$plugin_path"
|
||||
git clone --recursive "${CURRENT_DIR}/../" "$plugin_path" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
_add_plugin_to_tmux_conf() {
|
||||
set_tmux_conf_helper<<-HERE
|
||||
run-shell '~/.tmux/plugins/tmux-plugin-under-test/*.tmux'
|
||||
HERE
|
||||
}
|
||||
|
||||
# PUBLIC HELPER FUNCTIONS
|
||||
|
||||
teardown_helper() {
|
||||
rm -f ~/.tmux.conf
|
||||
rm -rf ~/.tmux/
|
||||
tmux kill-server >/dev/null 2>&1
|
||||
}
|
||||
|
||||
set_tmux_conf_helper() {
|
||||
> ~/.tmux.conf # empty tmux.conf file
|
||||
while read line; do
|
||||
echo "$line" >> ~/.tmux.conf
|
||||
done
|
||||
}
|
||||
|
||||
fail_helper() {
|
||||
local message="$1"
|
||||
echo "$message" >&2
|
||||
TEST_STATUS="fail"
|
||||
}
|
||||
|
||||
exit_helper() {
|
||||
teardown_helper
|
||||
if [ "$TEST_STATUS" == "fail" ]; then
|
||||
echo "FAIL!"
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
echo "SUCCESS"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
install_tmux_plugin_under_test_helper() {
|
||||
_clone_the_plugin
|
||||
_add_plugin_to_tmux_conf
|
||||
}
|
||||
|
||||
run_tests() {
|
||||
# get all the functions starting with 'test_' and invoke them
|
||||
for test in $(compgen -A function | grep "^test_"); do
|
||||
"$test"
|
||||
done
|
||||
exit_helper
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue