adapt test suit to travies
* run tests in different tmux versions to benefit from travis matrix feature * tmuxomatic version dependant fixes * add retries
This commit is contained in:
parent
6639db8d73
commit
f444e320a5
14
.travis.yml
14
.travis.yml
|
@ -1,5 +1,15 @@
|
|||
language: generic
|
||||
install:
|
||||
- ./test/provisioning/ubuntu.sh
|
||||
install: ./test/provisioning/ci.sh
|
||||
script: ./test/run.sh within-vm
|
||||
os: linux
|
||||
cache: /opt
|
||||
env:
|
||||
- CI_TMUX_VERSION=2.3
|
||||
- CI_TMUX_VERSION=2.4
|
||||
- CI_TMUX_VERSION=2.5
|
||||
- CI_TMUX_VERSION=2.6
|
||||
- CI_TMUX_VERSION=2.7
|
||||
- CI_TMUX_VERSION=2.8
|
||||
- CI_TMUX_VERSION=2.9
|
||||
- CI_TMUX_VERSION=2.9a
|
||||
- CI_TMUX_VERSION=3.0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# tmux-fingers
|
||||
|
||||
[![CircleCI](https://circleci.com/gh/Morantron/tmux-fingers.svg?style=svg)](https://circleci.com/gh/Morantron/tmux-fingers)
|
||||
[![Build Status](https://travis-ci.com/Morantron/tmux-fingers.svg?branch=develop)](https://travis-ci.com/Morantron/tmux-fingers)
|
||||
|
||||
**tmux-fingers**: copy pasting with vimium/vimperator like hints.
|
||||
|
||||
|
|
|
@ -23,15 +23,6 @@ function is_tmux_ready() {
|
|||
fi
|
||||
}
|
||||
|
||||
function version_major() {
|
||||
echo "$1" | cut -f1 -d. | grep -Eo "[0-9]"
|
||||
}
|
||||
|
||||
function version_minor() {
|
||||
echo "$1" | cut -f2 -d. | grep -Eo "[0-9]"
|
||||
}
|
||||
|
||||
|
||||
function log_message() {
|
||||
log_messages+=("$1")
|
||||
}
|
||||
|
@ -100,7 +91,7 @@ function perform_health_check() {
|
|||
local healthy=1
|
||||
|
||||
# BASH_VERSION is a global
|
||||
local TMUX_VERSION=$(tmux -V | grep -Eio "([0-9]+(\.[0-9]))(?:-rc)?")
|
||||
local TMUX_VERSION=$(get_tmux_version)
|
||||
local GAWK_VERSION=""
|
||||
|
||||
if [[ $(program_exists "gawk") = "1" ]]; then
|
||||
|
|
|
@ -158,3 +158,16 @@ function program_exists() {
|
|||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
function version_major() {
|
||||
echo "$1" | cut -f1 -d. | grep -Eo "[0-9]"
|
||||
}
|
||||
|
||||
function version_minor() {
|
||||
echo "$1" | cut -f2 -d. | grep -Eo "[0-9]"
|
||||
}
|
||||
|
||||
|
||||
function get_tmux_version() {
|
||||
echo "$(tmux -V | grep -Eio "([0-9]+(\.[0-9]))(?:-rc)?")"
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
set -g prefix C-a
|
||||
set -g @fingers-compact-hints '0'
|
||||
run /home/vagrant/shared/tmux-fingers.tmux
|
|
@ -1,4 +0,0 @@
|
|||
set -g prefix F12
|
||||
set -g status off
|
||||
set-window-option -g force-width 80
|
||||
set-window-option -g force-height 24
|
|
@ -49,8 +49,6 @@ function begin_with_conf() {
|
|||
}
|
||||
|
||||
function begin_hook() {
|
||||
tmuxomatic set-window-option force-width 80
|
||||
tmuxomatic set-window-option force-height 24
|
||||
tmuxomatic__exec "tmux kill-session -t test"
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -n "$CI_TMUX_VERSION" ]]; then
|
||||
VERSIONS=("$CI_TMUX_VERSION")
|
||||
else
|
||||
VERSIONS=("2.3" "2.4" "2.5" "2.6" "2.7" "2.8" "2.9" "2.9a" "3.0")
|
||||
fi
|
||||
|
||||
sudo mkdir -p /opt
|
||||
sudo chmod a+w /opt
|
||||
|
||||
pushd /tmp
|
||||
for version in "${VERSIONS[@]}";
|
||||
do
|
||||
if [[ -f "/opt/tmux-${version}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
wget "https://github.com/tmux/tmux/releases/download/${version}/tmux-${version}.tar.gz"
|
||||
tar pfx "tmux-${version}.tar.gz" -C "/opt/"
|
||||
|
||||
pushd "/opt/tmux-${version}"
|
||||
./configure
|
||||
make
|
||||
popd
|
||||
done
|
||||
popd
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source $CURRENT_DIR/ubuntu.sh
|
||||
|
||||
sudo mkdir -p /home/vagrant
|
||||
sudo ln -s "$PWD" /home/vagrant/shared
|
||||
|
||||
sudo usermod -a -G travis fishman
|
|
@ -1,19 +1,14 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
sudo aptitude update
|
||||
sudo aptitude install -y fish gawk
|
||||
sudo aptitude install -y fish gawk xvfb perl
|
||||
|
||||
useradd -m -p "$(perl -e "print crypt('fishman','sa');")" -s "/usr/bin/fish" fishman
|
||||
sudo useradd -m -p "$(perl -e "print crypt('fishman','sa');")" -s "/usr/bin/fish" fishman
|
||||
|
||||
wget https://github.com/tmux/tmux/releases/download/2.6/tmux-2.6.tar.gz
|
||||
|
||||
# install tmux from source
|
||||
# remove system tmux and install tmux dependencies
|
||||
sudo aptitude remove -y tmux
|
||||
sudo aptitude install -y libevent-dev libncurses5-dev
|
||||
tar xvzf tmux-2.6.tar.gz
|
||||
cd tmux-2.6/ || echo "Could not find tmux-2.6/ folder" || exit 1
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
cd - || exit 1
|
||||
$CURRENT_DIR/../install-tmux-versions.sh
|
||||
|
|
29
test/run.sh
29
test/run.sh
|
@ -3,22 +3,41 @@
|
|||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SPEC_OUTPUT_LOG=$CURRENT_DIR/../spec-output.log
|
||||
TEST_LOG=$CURRENT_DIR/../test.log
|
||||
MAX_RETRIES=5
|
||||
target=$1
|
||||
|
||||
cat /dev/null > $SPEC_OUTPUT_LOG
|
||||
cat /dev/null > $TEST_LOG
|
||||
|
||||
if [[ -n "$CI_TMUX_VERSION" ]]; then
|
||||
VERSIONS=("$CI_TMUX_VERSION")
|
||||
else
|
||||
VERSIONS=("2.3" "2.4" "2.5" "2.6" "2.7" "2.8" "2.9" "2.9a" "3.0")
|
||||
fi
|
||||
|
||||
if [[ "$target" == "within-vm" ]]; then
|
||||
stty cols 80
|
||||
stty rows 24
|
||||
fail_count=0
|
||||
for version in "${VERSIONS[@]}"; do
|
||||
$CURRENT_DIR/use-tmux.sh "$version"
|
||||
echo "Running tests in tmux $version"
|
||||
for test_file in $(ls $CURRENT_DIR/specs/*_spec.sh); do
|
||||
result="* $test_file ..."
|
||||
sleep 1
|
||||
|
||||
tries=0
|
||||
while [[ $tries -lt $MAX_RETRIES ]]; do
|
||||
echo "Running $test_file" >> $SPEC_OUTPUT_LOG
|
||||
$test_file &>> $TEST_LOG
|
||||
success=$?
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
if [[ $success ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $success ]]; then
|
||||
result="$result OK"
|
||||
else
|
||||
fail_count=$((fail_count + 1))
|
||||
|
@ -28,6 +47,12 @@ if [[ "$target" == "within-vm" ]]; then
|
|||
echo "$result" >> $SPEC_OUTPUT_LOG
|
||||
echo "$result"
|
||||
done
|
||||
done
|
||||
|
||||
if [[ $fail_count -gt 0 ]]; then
|
||||
echo "Displaying tmuxomatic logs"
|
||||
cat $CURRENT_DIR/../tmuxomatic*
|
||||
fi
|
||||
|
||||
exit $fail_count
|
||||
elif [[ -z "$target" ]]; then
|
||||
|
@ -50,5 +75,5 @@ elif [[ -z "$target" ]]; then
|
|||
else
|
||||
echo "Running tests on $target"
|
||||
vagrant up "$target" &>> /dev/null
|
||||
vagrant ssh "$target" -c "cd shared && ./test/run.sh within-vm" 2> /dev/null
|
||||
vagrant ssh "$target" -c "cd shared && xvfb-run ./test/run.sh within-vm" 2> /dev/null
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#set -x
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $CURRENT_DIR/../tmuxomatic.sh
|
||||
source $CURRENT_DIR/../helpers.sh
|
||||
|
|
|
@ -6,7 +6,8 @@ source $CURRENT_DIR/../helpers.sh
|
|||
|
||||
tmuxomatic__begin begin_hook
|
||||
|
||||
tmuxomatic__exec "sudo su fishman"
|
||||
tmuxomatic__exec "sudo su - fishman"
|
||||
tmuxomatic__exec "cd /home/vagrant/shared"
|
||||
tmuxomatic__exec "tmux -f /home/vagrant/shared/test/conf/basic.conf new -s test"
|
||||
init_pane_fish
|
||||
tmuxomatic__exec "cat ./test/fixtures/grep-output"
|
||||
|
|
|
@ -5,6 +5,8 @@ TMUXOMATIC_SOCKET=tmuxomatic
|
|||
TMUXOMATIC_TIMEOUT="10"
|
||||
TMUXOMATIC_EXIT_CODE=''
|
||||
|
||||
source $TMUXOMATIC_CURRENT_DIR/../scripts/utils.sh
|
||||
|
||||
function tmuxomatic() {
|
||||
TMUX='' tmux -L "$TMUXOMATIC_SOCKET" "$@"
|
||||
}
|
||||
|
@ -18,8 +20,20 @@ function tmuxomatic__begin() {
|
|||
tmuxomatic list-sessions &> /dev/null
|
||||
|
||||
if [[ $? -eq 1 ]]; then
|
||||
tmuxomatic -f "$TMUXOMATIC_CURRENT_DIR/conf/tmuxomatic.conf" new-session -d -s tmuxomatic
|
||||
wait
|
||||
tmuxomatic -f /dev/null new-session -d -s tmuxomatic
|
||||
|
||||
tmuxomatic set -g prefix F12
|
||||
tmuxomatic set -g status off
|
||||
|
||||
tmux_version=$(get_tmux_version)
|
||||
|
||||
if [[ $(version_major "$tmux_version") -ge "2" ]] && [[ $(version_minor "$tmux_version") -lt "9" ]]; then
|
||||
tmuxomatic set-window-option force-width 80
|
||||
tmuxomatic set-window-option force-height 24
|
||||
else
|
||||
tmuxomatic resize-window -x 80 -y 24
|
||||
fi
|
||||
|
||||
tmuxomatic__exec "export TMUX=''"
|
||||
tmuxomatic__exec "clear"
|
||||
fi
|
||||
|
@ -76,7 +90,7 @@ function tmuxomatic__expect() {
|
|||
}
|
||||
|
||||
# TODO ideally specs shouldn't have any sleeps, but life is hard! Since
|
||||
# circle-ci machine is kind of slow, sleeps need to be longer there.
|
||||
# ci machines are usually kind of slow, sleeps need to be longer there.
|
||||
#
|
||||
# Ideally tmuxomatic__exec should now when a command has finished by using
|
||||
# "tmux wait", or alert-silence hook, or some tmux sorcery like that.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
version="$1"
|
||||
sudo rm -rf /usr/local/bin/tmux
|
||||
sudo ln -s /opt/tmux-${version}/tmux /usr/local/bin/tmux
|
Loading…
Reference in New Issue