mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-07 21:39:07 -04:00
add tmux
This commit is contained in:
parent
c21063c727
commit
9c06dba63b
236 changed files with 7786 additions and 0 deletions
45
dot_config/tmux/plugins/tpm/lib/tmux-test/CHANGELOG.md
Normal file
45
dot_config/tmux/plugins/tpm/lib/tmux-test/CHANGELOG.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Changelog
|
||||
|
||||
### master
|
||||
- move `setup` task to `.travis.yml` for travis tests
|
||||
- "merge" travis.yml and travis_for_plugins.yml files (no need to keep em
|
||||
separate)
|
||||
- add more useful helper functions
|
||||
- remove tmux-test repo as a submodule from self, this causes issues with
|
||||
`$ git submodule update --recursive --init` command that some users use for
|
||||
managing other plugins
|
||||
- add new helper `teardown_helper`
|
||||
- add `run_tests` helper
|
||||
- change CLI syntax for choosing vagrant machine to run the tests on
|
||||
- enable running just a single test via `run_tests` cli interface
|
||||
- add `--keep-running` cli option to continue running vagrant after the tests
|
||||
are done executing
|
||||
- start using tmux 2.0 for tests
|
||||
|
||||
### v0.2.0, 2015-02-22
|
||||
- `setup` script gitignores `tests/helpers.sh`
|
||||
- move `tests/helpers.sh` to `tests/helpers/helpers.sh`
|
||||
- `setup` undo removes added lines from gitignore file
|
||||
|
||||
### v0.1.0, 2015-02-22
|
||||
- changes so that 'tmux-test' can be included with tmux plugins
|
||||
- do not gitignore submodules directory
|
||||
- add installation and usage instructions
|
||||
- copy `.travis.yml` to the project root when running `setup` script
|
||||
- add a brief mention of travis CI to the readme
|
||||
- add test helpers
|
||||
- `setup` script symlinks helpers file to `tests/` directory
|
||||
- `setup` script can undo most of its actions
|
||||
- add a tmux scripting test
|
||||
- `tmux-test` uses `tmux-test` to test itself
|
||||
- update `tmux-test` submodule
|
||||
- a different `travis.yml` for `tmux-test` and for plugins
|
||||
|
||||
### v0.0.1, 2015-02-21
|
||||
- git init
|
||||
- add vagrant provisioning scripts for ubuntu and debian
|
||||
- add a ".travis.yml" file
|
||||
- generic "run_tests" script
|
||||
- "run_tests_in_isolation" script
|
||||
- add "Vagrantfile"
|
||||
- enable passing VM names as arguments to "run_tests" script
|
19
dot_config/tmux/plugins/tpm/lib/tmux-test/LICENSE.md
Normal file
19
dot_config/tmux/plugins/tpm/lib/tmux-test/LICENSE.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (C) Bruno Sutic
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
134
dot_config/tmux/plugins/tpm/lib/tmux-test/README.md
Normal file
134
dot_config/tmux/plugins/tpm/lib/tmux-test/README.md
Normal file
|
@ -0,0 +1,134 @@
|
|||
# tmux-test
|
||||
|
||||
[](https://travis-ci.org/tmux-plugins/tmux-test)
|
||||
|
||||
A small framework for isolated testing of tmux plugins. Isolation is achieved by
|
||||
running the tests in `Vagrant`. Works on [travis](travis-ci.org) too.
|
||||
|
||||
Extracted from [tmux plugin manager](https://github.com/tmux-plugins/tpm) and
|
||||
[tmux-copycat](https://github.com/tmux-plugins/tmux-copycat).
|
||||
|
||||
Dependencies: `Vagrant` (no required when running on travis).
|
||||
|
||||
### Setup
|
||||
|
||||
Let's say you made tmux plugin with the following file hierarchy:
|
||||
|
||||
```text
|
||||
/tmux-plugin
|
||||
|-- plugin.tmux
|
||||
`-- scripts
|
||||
`-- plugin_script.sh
|
||||
```
|
||||
|
||||
From your project root directory (tmux-plugin/) execute the following shell
|
||||
command to fetch `tmux-test` and add it as a submodule:
|
||||
|
||||
$ git submodule add https://github.com/tmux-plugins/tmux-test.git lib/tmux-test
|
||||
|
||||
Run the `setup` script:
|
||||
|
||||
$ lib/tmux-test/setup
|
||||
|
||||
The project directory will now look like this (additions have comments):
|
||||
|
||||
```text
|
||||
/tmux-plugin
|
||||
|-- plugin.tmux
|
||||
|-- run_tests # symlink, gitignored
|
||||
|-- .gitignore # 2 lines appended to gitignore
|
||||
|-- .travis.yml # added
|
||||
|-- lib/tmux-test/ # git submodule
|
||||
|-- scripts
|
||||
| `-- plugin_script.sh
|
||||
`-- tests # dir to put the tests in
|
||||
`-- run_tests_in_isolation.sh # symlink, gitignored
|
||||
`-- helpers
|
||||
`-- helpers.sh # symlinked bash helpers, gitignored
|
||||
```
|
||||
|
||||
`tmux-test` is now set up. You are ok to commit the additions to the repo.
|
||||
|
||||
### Writing and running tests
|
||||
|
||||
A test is any executable with a name starting with `test_` in `tests/`
|
||||
directory.
|
||||
|
||||
Now that you installed `tmux-test` let's create an example test.
|
||||
|
||||
- create a `tests/test_example.sh` file with the following content (it's a
|
||||
`bash` script but it can be any executable):
|
||||
|
||||
#/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
|
||||
|
||||
- make the test file executable with `$ chmod +x tests/test_example.sh`
|
||||
- run the test by executing `./run_tests` from the project root directory
|
||||
- the first invocation might take some time because Vagrant's ubuntu virtual
|
||||
machine is downloading. You should see `Success, tests pass!` message when it's
|
||||
done.
|
||||
|
||||
Check out more example test scripts in this project's [tests/ directory](tests/).
|
||||
|
||||
### Continuous integration
|
||||
|
||||
The setup script (`lib/tmux-test/setup`) added a `.travis.yml` file to the
|
||||
project root. To setup continuous integration, just add/enable the project on
|
||||
[travis](travis-ci.org).
|
||||
|
||||
### Notes
|
||||
|
||||
- The `tests/` directory for tests and `lib/tmux-test/` for cloning `tmux-test`
|
||||
into cannot be changed currently
|
||||
- Don't run `tests/run_tests_in_isolation` script on your local development
|
||||
environment. That's an internal test runner meant to be executed in an
|
||||
isolated environment like `vagrant` or `travis`.<br/>
|
||||
Use `./run_tests` script.
|
||||
- You can use `KEEP_RUNNING=true ./run_tests` for faster test running cycle.
|
||||
If this case `Vagrant` will keep running even after the tests are done.
|
||||
- You can use `VAGRANT_CWD=lib/tmux-text/ vagrant ssh ubuntu` for ssh login to
|
||||
`Vagrant`.
|
||||
|
||||
### Running `tmux-test` framework tests
|
||||
|
||||
`tmux-test` uses itself to test itself. To run framework tests:
|
||||
|
||||
- clone this project `$ git clone git@github.com:tmux-plugins/tmux-test.git`
|
||||
- `$ cd tmux-test`
|
||||
- run `$ ./run_framework_tests`
|
||||
|
||||
### Other goodies
|
||||
|
||||
- [tmux-copycat](https://github.com/tmux-plugins/tmux-copycat) - a plugin for
|
||||
regex searches in tmux and fast match selection
|
||||
- [tmux-continuum](https://github.com/tmux-plugins/tmux-continuum) - automatic
|
||||
restoring and continuous saving of tmux env
|
||||
|
||||
You might want to follow [@brunosutic](https://twitter.com/brunosutic) on
|
||||
twitter if you want to hear about new tmux plugins or feature updates.
|
||||
|
||||
### License
|
||||
|
||||
[MIT](LICENSE.md)
|
17
dot_config/tmux/plugins/tpm/lib/tmux-test/Vagrantfile
vendored
Normal file
17
dot_config/tmux/plugins/tpm/lib/tmux-test/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
config.vm.synced_folder "../../", "/vagrant"
|
||||
|
||||
config.vm.define :ubuntu do |ubuntu|
|
||||
ubuntu.vm.box = "hashicorp/precise64"
|
||||
ubuntu.vm.provision "shell", path: "vagrant_ubuntu_provisioning.sh"
|
||||
end
|
||||
|
||||
config.vm.define :centos do |centos|
|
||||
centos.vm.box = "chef/centos-6.5"
|
||||
centos.vm.provision "shell", path: "vagrant_centos_provisioning.sh"
|
||||
end
|
||||
|
||||
end
|
1
dot_config/tmux/plugins/tpm/lib/tmux-test/dot_git
Normal file
1
dot_config/tmux/plugins/tpm/lib/tmux-test/dot_git
Normal file
|
@ -0,0 +1 @@
|
|||
gitdir: ../../.git/modules/lib/tmux-test
|
2
dot_config/tmux/plugins/tpm/lib/tmux-test/dot_gitignore
Normal file
2
dot_config/tmux/plugins/tpm/lib/tmux-test/dot_gitignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
.vagrant/
|
||||
lib/
|
19
dot_config/tmux/plugins/tpm/lib/tmux-test/dot_travis.yml
Normal file
19
dot_config/tmux/plugins/tpm/lib/tmux-test/dot_travis.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
# generic packages and tmux
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y git-core expect
|
||||
- sudo apt-get install -y python-software-properties software-properties-common
|
||||
- sudo apt-get install -y libevent-dev libncurses-dev
|
||||
- git clone https://github.com/tmux/tmux.git
|
||||
- cd tmux
|
||||
- git checkout 2.0
|
||||
- sh autogen.sh
|
||||
- ./configure && make && sudo make install
|
||||
|
||||
install:
|
||||
- git fetch --unshallow --recurse-submodules || git fetch --recurse-submodules
|
||||
# manual `git clone` required for testing `tmux-test` plugin itself
|
||||
- git clone https://github.com/tmux-plugins/tmux-test lib/tmux-test; true
|
||||
- lib/tmux-test/setup
|
||||
|
||||
script: ./tests/run_tests_in_isolation
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This file is used to run "tmux-test" framework tests.
|
||||
|
||||
# "setup" script is needed to run the tests, but it overrides some working dir
|
||||
# files. To address that, "setup" is run before the tests and it's actions are
|
||||
# undone after.
|
||||
|
||||
main() {
|
||||
git clone https://github.com/tmux-plugins/tmux-test lib/tmux-test
|
||||
lib/tmux-test/setup
|
||||
./run_tests
|
||||
local exit_value=$?
|
||||
lib/tmux-test/setup "undo"
|
||||
exit "$exit_value"
|
||||
}
|
||||
main
|
|
@ -0,0 +1,145 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This file is a symlink from 'tmux-test' plugin.
|
||||
# You probably don't want to edit it.
|
||||
|
||||
# Run this script when running a test suite.
|
||||
|
||||
# For each virtual machine where tests run, this script performs the following:
|
||||
# - starts VM
|
||||
# - starts the test suite witin a VM
|
||||
# - stops the VM after the test suite is done
|
||||
|
||||
export BOXES=""
|
||||
export FILES=""
|
||||
export KEEP_RUNNING=""
|
||||
|
||||
# global variable for script exit value
|
||||
export EXIT_VALUE=0
|
||||
|
||||
display_help() {
|
||||
echo "Usage:"
|
||||
echo " ./run_tests # runs tests on default VM ubuntu"
|
||||
echo " ./run_tests -m ubuntu # runs tests on ubuntu VM"
|
||||
echo " ./run_tests -m ubuntu -m centos # runs tests on ubuntu and cents VMs"
|
||||
echo " ./run_tests tests/some_test # run a single test file"
|
||||
echo " ./run_tests --keep-running # don't stop vagrant after the tests are done"
|
||||
}
|
||||
|
||||
parse_arguments() {
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
-m | --machine)
|
||||
local machine="$2"
|
||||
if [ "$machine" == "ubuntu" ] || [ "$machine" == "centos" ]; then
|
||||
BOXES="$BOXES $machine"
|
||||
else
|
||||
echo "Unknown machine '$machine'"
|
||||
echo ""
|
||||
display_help
|
||||
exit 1
|
||||
fi
|
||||
shift 2
|
||||
;;
|
||||
|
||||
-k | --keep-running)
|
||||
KEEP_RUNNING="true"
|
||||
shift
|
||||
;;
|
||||
|
||||
-h | --help)
|
||||
display_help
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--) # End of all options
|
||||
shift
|
||||
FILES="$*"
|
||||
break
|
||||
;;
|
||||
|
||||
-* )
|
||||
echo "Error: Unknown option: $1" >&2
|
||||
echo ""
|
||||
display_help
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*) # No more options
|
||||
FILES="$*"
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# default options
|
||||
if [ -z "$BOXES" ]; then
|
||||
BOXES="ubuntu"
|
||||
fi
|
||||
}
|
||||
|
||||
register_failing_tests() {
|
||||
EXIT_VALUE=1
|
||||
}
|
||||
|
||||
run_vagrant() {
|
||||
local box="$1"
|
||||
VAGRANT_CWD=lib/tmux-test/ vagrant up "$box"
|
||||
}
|
||||
|
||||
# Halt vagrant after tests are done running, unless `--keep-running`
|
||||
# option is given
|
||||
stop_vagrant() {
|
||||
local box="$1"
|
||||
if [ -z "$KEEP_RUNNING" ]; then
|
||||
VAGRANT_CWD=lib/tmux-test/ vagrant halt "$box"
|
||||
else
|
||||
echo
|
||||
echo "--keep-running option set, Vagrant not halted"
|
||||
fi
|
||||
}
|
||||
|
||||
run_tests() {
|
||||
local box="$1"
|
||||
local test_file="/vagrant/tests/run_tests_in_isolation"
|
||||
echo "Running test suite on $box from: $test_file"
|
||||
echo
|
||||
VAGRANT_CWD=lib/tmux-test/ vagrant ssh "$box" -c "cd /vagrant; $test_file $FILES"
|
||||
}
|
||||
|
||||
exit_message() {
|
||||
local exit_val="$1"
|
||||
echo
|
||||
if [ "$exit_val" == 0 ]; then
|
||||
echo "Success, tests pass!"
|
||||
else
|
||||
echo "Tests failed!" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
run_tests_on_vm() {
|
||||
local vm="$1"
|
||||
run_vagrant "$vm"
|
||||
run_tests "$vm"
|
||||
local tests_exit_value="$?"
|
||||
stop_vagrant "$vm"
|
||||
if [ "$tests_exit_value" -gt 0 ]; then
|
||||
register_failing_tests
|
||||
fi
|
||||
}
|
||||
|
||||
run_tests_on_virtual_machines() {
|
||||
local box
|
||||
for box in $BOXES; do
|
||||
run_tests_on_vm "$box"
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
parse_arguments "$@"
|
||||
run_tests_on_virtual_machines
|
||||
exit_message "$EXIT_VALUE"
|
||||
exit "$EXIT_VALUE"
|
||||
}
|
||||
main "$@"
|
93
dot_config/tmux/plugins/tpm/lib/tmux-test/executable_setup
Normal file
93
dot_config/tmux/plugins/tpm/lib/tmux-test/executable_setup
Normal file
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# invoke this script from your projects root directory
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# pass "undo" as a script arg to undo most of the setup actions
|
||||
UNDO_SETUP="$1"
|
||||
undo() {
|
||||
[ "$UNDO_SETUP" == "undo" ]
|
||||
}
|
||||
|
||||
restore() {
|
||||
local file="$1"
|
||||
rm -f "$file"
|
||||
git checkout -- "$file" 2>/dev/null
|
||||
}
|
||||
|
||||
gitignore() {
|
||||
local file="$1"
|
||||
grep -q "^${file}$" .gitignore 2>/dev/null || echo "$file" >> .gitignore
|
||||
}
|
||||
|
||||
remove_from_gitignore() {
|
||||
local file="$1"
|
||||
local escaped_filename="$(echo "$file" | sed "s,/,\\\/,g")"
|
||||
sed -i"" "/^${escaped_filename}$/d" .gitignore
|
||||
}
|
||||
|
||||
add_files_to_gitignore() {
|
||||
if ! undo; then
|
||||
gitignore "run_tests"
|
||||
gitignore "tests/run_tests_in_isolation"
|
||||
gitignore "tests/helpers/helpers.sh"
|
||||
else
|
||||
remove_from_gitignore "run_tests"
|
||||
remove_from_gitignore "tests/run_tests_in_isolation"
|
||||
remove_from_gitignore "tests/helpers/helpers.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
symlink_user_test_runner() {
|
||||
local file="run_tests"
|
||||
if ! undo; then
|
||||
ln -sf "lib/tmux-test/${file}" "$file"
|
||||
else
|
||||
restore "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
create_directory_for_tests() {
|
||||
if ! undo; then
|
||||
mkdir -p tests/helpers/
|
||||
fi
|
||||
}
|
||||
|
||||
symlink_internal_test_runner() {
|
||||
local file="tests/run_tests_in_isolation"
|
||||
if ! undo; then
|
||||
ln -sf "../lib/tmux-test/${file}" "$file"
|
||||
else
|
||||
restore "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
symlink_test_helpers() {
|
||||
local file="tests/helpers/helpers.sh"
|
||||
if ! undo; then
|
||||
ln -sf "../../lib/tmux-test/${file}" "$file"
|
||||
else
|
||||
restore "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_travis_yml() {
|
||||
local file=".travis.yml"
|
||||
if ! undo; then
|
||||
cp "lib/tmux-test/${file}" "$file"
|
||||
else
|
||||
restore "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
add_files_to_gitignore
|
||||
symlink_user_test_runner
|
||||
create_directory_for_tests
|
||||
symlink_internal_test_runner
|
||||
symlink_test_helpers
|
||||
copy_travis_yml
|
||||
}
|
||||
main
|
||||
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# libevent2 installation instructions from here
|
||||
# https://gist.github.com/rschuman/6168833
|
||||
|
||||
sudo su -
|
||||
|
||||
yum -y install gcc kernel-devel make automake autoconf ncurses-devel
|
||||
yum -y install git-core expect vim ruby ruby-devel ruby-irb
|
||||
|
||||
# install libevent2 from source
|
||||
curl http://sourceforge.net/projects/levent/files/latest/download?source=files -L -o libevent2.tar.gz -w 'Last URL was: %{url_effective}'
|
||||
cd ~/downloads
|
||||
tar zxvf libevent2.tar.gz
|
||||
cd ./libevent-*
|
||||
./configure --prefix=/usr/local
|
||||
make
|
||||
make install
|
||||
|
||||
# compile tmux
|
||||
git clone https://github.com/tmux/tmux.git ~/tmux_source
|
||||
cd ~/tmux_source
|
||||
git checkout 2.0
|
||||
sh autogen.sh
|
||||
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/local
|
||||
make && sudo make install
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y git-core expect vim
|
||||
sudo apt-get install -y python-software-properties software-properties-common
|
||||
sudo apt-get install -y build-essential libtool autotools-dev autoconf
|
||||
sudo apt-get install -y pkg-config libevent-dev libncurses-dev
|
||||
|
||||
# install tmux 2.0
|
||||
git clone https://github.com/tmux/tmux.git ~/tmux_source
|
||||
cd ~/tmux_source
|
||||
git checkout 2.0
|
||||
sh autogen.sh
|
||||
./configure && make && sudo make install
|
Loading…
Add table
Add a link
Reference in a new issue