initial setup of automated tests
This commit is contained in:
parent
9cd1aae509
commit
bfbc8001ee
|
@ -1,5 +1,7 @@
|
|||
# tmux-fingers
|
||||
|
||||
[![CircleCI](https://circleci.com/gh/Morantron/tmux-fingers.svg?style=svg)](https://circleci.com/gh/Morantron/tmux-fingers)
|
||||
|
||||
**tmux-fingers**: copy pasting with vimium/vimperator like hints.
|
||||
|
||||
![yay](http://i.imgur.com/5bSrBew.gif)
|
||||
|
|
|
@ -4,11 +4,20 @@
|
|||
# requires nfs-utils on host
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
config.vm.box = "freebsd/FreeBSD-11.0-CURRENT"
|
||||
config.ssh.shell = "/bin/sh"
|
||||
config.vm.define "bsd" do |machine|
|
||||
machine.vm.box = "freebsd/FreeBSD-10.3-RELEASE"
|
||||
machine.ssh.shell = "/bin/sh"
|
||||
|
||||
config.vm.network "private_network", ip: "10.0.1.10", mac: "5CA1AB1E0001"
|
||||
config.vm.synced_folder ".", "/home/vagrant/shared", :nfs => true
|
||||
machine.vm.base_mac = "080027D14C66"
|
||||
machine.vm.network "private_network", ip: "10.0.1.10", mac: "5CA1AB1E0001"
|
||||
machine.vm.synced_folder ".", "/home/vagrant/shared", :nfs => true
|
||||
|
||||
config.vm.provision "shell", path: './test/bsd_provisioning.sh'
|
||||
machine.vm.provision "shell", path: './test/provisioning/bsd.sh'
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu" do |machine|
|
||||
machine.vm.box = "ubuntu/trusty64"
|
||||
machine.vm.synced_folder ".", "/home/vagrant/shared"
|
||||
machine.vm.provision "shell", path: './test/provisioning/ubuntu.sh'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
dependencies:
|
||||
pre:
|
||||
- if [[ ! -e tmux-2.2 ]]; then sudo bash ./test/provisioning/ubuntu.sh; fi
|
||||
- sudo mkdir -p /home/vagrant/ && sudo chmod a+w /home/vagrant && ln -s $(pwd) /home/vagrant/shared
|
||||
- tmux -V
|
||||
test:
|
||||
override:
|
||||
- ./test/run.sh within-vm
|
|
@ -0,0 +1,2 @@
|
|||
set -g prefix C-a
|
||||
run /home/vagrant/shared/tmux-fingers.tmux
|
|
@ -0,0 +1,4 @@
|
|||
set -g prefix C-Space
|
||||
set -g mode-keys vi
|
||||
|
||||
run /home/vagrant/shared/tmux-fingers.tmux
|
|
@ -0,0 +1,2 @@
|
|||
scripts/debug.sh:# Source this file and call `tail -f fingers.log` when you don't know WTF is
|
||||
scripts/hints.sh:IFS=$(echo -en "\n\b") # wtf bash?
|
|
@ -0,0 +1,18 @@
|
|||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
inet 127.0.0.1 scope host lo
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 ::1 scope host
|
||||
valid_lft forever preferred_lft forever
|
||||
2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
|
||||
link/ether 78:31:c1:d5:40:ce brd ff:ff:ff:ff:ff:ff
|
||||
inet 192.168.1.39 brd 192.168.1.255 scope global dynamic wlp3s0
|
||||
valid_lft 33919sec preferred_lft 33919sec
|
||||
inet6 fe80::7a31:c1ff:fed5:40ce scope link tentative dadfailed
|
||||
valid_lft forever preferred_lft forever
|
||||
3: vboxnet0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
|
||||
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
|
||||
inet 10.0.1.1 brd 10.0.1.255 scope global vboxnet0
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 fe80::800:27ff:fe00:0 scope link
|
||||
valid_lft forever preferred_lft forever
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
set exit_code 2
|
||||
|
||||
proc test_clean_up {} {
|
||||
exec "tmux kill-session -t test";
|
||||
sleep 0.5;
|
||||
}
|
||||
|
||||
proc exec {cmd} {
|
||||
sleep 0.5;
|
||||
send "$cmd";
|
||||
sleep 0.5;
|
||||
send "\r";
|
||||
sleep 0.5;
|
||||
}
|
||||
|
||||
proc tmux_send {key} {
|
||||
global tmux_prefix;
|
||||
sleep 0.5;
|
||||
send $tmux_prefix;
|
||||
sleep 0.5;
|
||||
send "$key";
|
||||
sleep 0.5;
|
||||
}
|
||||
|
||||
proc init_pane {} {
|
||||
tmux_send "c";
|
||||
exec "export PS1='# '; clear";
|
||||
}
|
||||
|
||||
proc invoke_fingers {} {
|
||||
tmux_send "F";
|
||||
sleep 0.5;
|
||||
}
|
||||
|
||||
proc echo_yanked {} {
|
||||
exec "clear";
|
||||
send "echo yanked text is ";
|
||||
tmux_send "]";
|
||||
send "\r";
|
||||
}
|
||||
|
||||
proc exit_ok {} {
|
||||
global exit_code
|
||||
set exit_code 0;
|
||||
test_clean_up;
|
||||
}
|
||||
|
||||
proc exit_fail {} {
|
||||
global exit_code
|
||||
set exit_code 1;
|
||||
exec "tmux list-buffers >> ./spec-output.log"
|
||||
test_clean_up;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
pkg install -y bash tmux
|
||||
pkg install -y bash tmux expect
|
||||
chsh -s bash vagrant
|
||||
|
||||
echo "run /home/vagrant/shared/tmux-fingers.tmux" > .tmux.conf
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
apt-get remove -y tmux
|
||||
apt-get install -y libevent-dev libncurses5-dev expect
|
||||
|
||||
wget https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz
|
||||
|
||||
tar xvzf tmux-2.2.tar.gz
|
||||
cd tmux-2.2/ || echo "Could not find tmux-2.2/ folder" || exit 1
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SPEC_OUTPUT_LOG=$CURRENT_DIR/../spec-output.log
|
||||
TEST_LOG=$CURRENT_DIR/../test.log
|
||||
target=$1
|
||||
|
||||
cat /dev/null > $SPEC_OUTPUT_LOG
|
||||
cat /dev/null > $TEST_LOG
|
||||
|
||||
if [[ "$target" == "within-vm" ]]; then
|
||||
fail_count=0
|
||||
for test_file in $(ls $CURRENT_DIR/specs/*_spec.exp); do
|
||||
result="* $test_file ..."
|
||||
sleep 1
|
||||
echo "Running $test_file" >> $SPEC_OUTPUT_LOG
|
||||
$test_file &>> $TEST_LOG
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
result="$result OK"
|
||||
else
|
||||
fail_count=$((fail_count + 1))
|
||||
result="$result FAIL"
|
||||
fi
|
||||
|
||||
echo "$result" >> $SPEC_OUTPUT_LOG
|
||||
echo "$result"
|
||||
done
|
||||
|
||||
exit $fail_count
|
||||
elif [[ -z "$target" ]]; then
|
||||
$CURRENT_DIR/run.sh ubuntu
|
||||
ubuntu_fail_count=$?
|
||||
|
||||
$CURRENT_DIR/run.sh bsd
|
||||
bsd_fail_count=$?
|
||||
|
||||
total_fail_count=$((ubuntu_fail_count + bsd_fail_count))
|
||||
|
||||
if [[ $total_fail_count == 0 ]]; then
|
||||
echo "All tests passed, awesome!"
|
||||
else
|
||||
echo "$total_fail_count tests failed."
|
||||
cat $SPEC_OUTPUT_LOG
|
||||
fi
|
||||
|
||||
exit $total_fail_count
|
||||
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
|
||||
fi
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
set timeout 1;
|
||||
set tmux_prefix "";
|
||||
|
||||
source "./test/helpers.exp"
|
||||
|
||||
exec "tmux kill-session -t test";
|
||||
spawn tmux -f ./test/conf/basic.conf new -s test;
|
||||
sleep 0.5;
|
||||
|
||||
init_pane
|
||||
exec "cat ./test/fixtures/grep-output";
|
||||
invoke_fingers;
|
||||
send "i";
|
||||
echo_yanked;
|
||||
|
||||
expect {
|
||||
"yanked text is scripts/hints.sh" { exit_ok }
|
||||
timeout { exit_fail }
|
||||
}
|
||||
|
||||
exit $exit_code;
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
set timeout 1;
|
||||
set tmux_prefix "";
|
||||
|
||||
source "./test/helpers.exp"
|
||||
|
||||
exec "tmux kill-session -t test";
|
||||
spawn tmux -f ./test/conf/basic.conf new -s test;
|
||||
sleep 0.5;
|
||||
|
||||
init_pane
|
||||
exec "cat ./test/fixtures/ip-output";
|
||||
invoke_fingers;
|
||||
send "t";
|
||||
echo_yanked;
|
||||
|
||||
expect {
|
||||
"yanked text is 10.0.1.255" { exit_ok }
|
||||
timeout { exit_fail }
|
||||
}
|
||||
|
||||
exit $exit_code;
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue