irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit 6f6fef046a076c8bc7c9dae47b7a6eac6130243e
parent 90bd4869e60a141ba141c9e981c73355ff192a6e
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat, 21 Jul 2012 02:00:36 +0200

add test cases

Diffstat:
test/all.sh | 12++++++++++++
test/autojoin.sh | 18++++++++++++++++++
test/change-nick.sh | 19+++++++++++++++++++
test/filterprune.sh | 20++++++++++++++++++++
test/first.sh | 12++++++++++++
test/force-nick.sh | 16++++++++++++++++
test/host.sh | 12++++++++++++
test/last-posted.sh | 29+++++++++++++++++++++++++++++
test/own.sh | 12++++++++++++
9 files changed, 150 insertions(+), 0 deletions(-)

diff --git a/test/all.sh b/test/all.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^.*/[#testa] <out> &\n[#testb] <out> &/' > ref +cat fifo | ../irctk in@localhost \#testa \#testb > heard & +PID=$! +sleep 1 +seq 3 | ../irctk out@localhost -l \#testa \#testb +sleep 1 +kill $PID +diff ref heard diff --git a/test/autojoin.sh b/test/autojoin.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/.*/[#test] <out&> &/' > ref +(echo '/mode +n'; cat fifo) | ../irctk in@localhost \#test > heard & +PID=$! +sleep 1 +echo 1 | ../irctk -J out1@localhost \#test \#testb +sleep 1 +echo '[#test] 2' | ../irctk out2@localhost \#testb +sleep 1 +echo 3 | ../irctk -l out3@localhost \#testb \#test +sleep 1 +echo '[#test] 4' | ../irctk -J out4@localhost \#testb +sleep 1 +kill $PID +diff ref heard diff --git a/test/change-nick.sh b/test/change-nick.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^/[#testb] <in__> /' > ref +cat fifo1 | ../irctk in@localhost \#testb > heard1 & +PID1=$! +sleep 1 +cat fifo2 | ../irctk in@localhost > heard2 2>error2 & +PID2=$! +sleep 1 +cat fifo3| ../irctk out@localhost \#test > heard3 2>error3 & +PID3=$! +sleep 1 +seq 3 | ../irctk -o in@localhost \#testb > heard4 2>error4 +sleep 1 +kill $PID1 $PID2 $PID3 +diff ref heard1 && diff ref heard4 && grep -q taken error2 \ + && grep -q taken error4 diff --git a/test/filterprune.sh b/test/filterprune.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^/good/' > ref +cat fifo | ../irctk -F in@localhost \#test > heard & +PID=$! +sleep 1 +cat > input <<EOF +blah + in:good1 + in2: bleh +in good2 +i nblah + in, good3 +EOF +../irctk out@localhost \#test < input +sleep 1 +kill $PID +diff ref heard diff --git a/test/first.sh b/test/first.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^/[#testa] <out> /' > ref +cat fifo | ../irctk in@localhost \#testa \#testb > heard & +PID=$! +sleep 1 +seq 3 | ../irctk out@localhost -0 \#testa \#testb +sleep 1 +kill $PID +diff ref heard diff --git a/test/force-nick.sh b/test/force-nick.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^/[#test] <out> /' > ref +cat fifo | ../irctk in@localhost \#test > heard & +PID=$! +sleep 1 +if ../irctk -N in@localhost \#test 2>error >/dev/null +then + echo fail + exit 1 +fi +sleep 1 +kill $PID +grep "in use" error > /dev/null diff --git a/test/host.sh b/test/host.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^/[#test] <out!~username@localhost> /' > ref +cat fifo | ../irctk -w in@localhost \#test > heard & +PID=$! +sleep 1 +seq 3 | ../irctk -U "username" -o out@localhost \#test > /dev/null +sleep 1 +kill $PID +diff ref heard diff --git a/test/last-posted.sh b/test/last-posted.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +cat > say <<EOF +[#testa] 1 +[#testa] 2 +[#testb] 3 +[#testb] 4 +[#testc] 5 +[#testa] 6 +[#testa] 7 +EOF +cat say | sed 's/]/] <out>/' > ref +cat fifo | ../irctk in@localhost \#testa \#testb \#testc > heard & +PID=$! +sleep 1 +awk '{if ($1 == l) {print $2} else {print $0}} {l = $1}' say | tee said | + ../irctk out@localhost -p \#testa \#testb \#testc +sleep 1 +kill $PID +for chan in testa testb testc +do + if diff <(grep $chan ref) <(grep $chan heard) + then + diff <(grep $chan ref) <(grep $chan heard) + exec $CMD + fi +done diff --git a/test/own.sh b/test/own.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +trap 'kill $(jobs -p)' EXIT + +seq 3 | sed 's/^/[#test] <out> /' > ref +cat fifo | ../irctk in@localhost \#test > heard & +PID=$! +sleep 1 +seq 3 | ../irctk -o out@localhost \#test > heard2 +sleep 1 +kill $PID +diff ref heard && diff ref heard2