4 # set detach key explicitly in case it was changed in config.h
7 [ ! -z "$1" ] && ABDUCO
="$1"
8 [ ! -x "$ABDUCO" ] && echo "usage: $0 /path/to/abduco" && exit 1
36 expected_abduco_prolog
() {
37 printf "\e[?1049h\e[H"
40 # $1 => session-name, $2 => exit status
41 expected_abduco_epilog
() {
42 echo "\e[?25h\e[?1049labduco: $1: session terminated with exit status $2"
45 # $1 => session-name, $2 => cmd to run
46 expected_abduco_attached_output
() {
47 expected_abduco_prolog
49 expected_abduco_epilog
"$1" $?
52 # $1 => session-name, $2 => cmd to run
53 expected_abduco_detached_output
() {
54 expected_abduco_prolog
56 expected_abduco_epilog
"$1" $?
60 [ "`$ABDUCO | wc -l`" -gt 1 ] && echo Abduco session exists
&& exit 1;
61 pgrep abduco
&& echo Abduco process exists
&& exit 1;
65 test_non_existing_command
() {
66 check_environment ||
return 1;
67 $ABDUCO -c test .
/non-existing-command
>/dev
/null
2>&1
68 check_environment ||
return 1;
71 # $1 => session-name, $2 => command to execute
73 check_environment ||
return 1;
77 local output
="$name.out"
78 local output_expected
="$name.expected"
80 TESTS_RUN
=$
((TESTS_RUN
+ 1))
81 echo -n "Running test attached: $name "
82 expected_abduco_attached_output
"$name" "$cmd" > "$output_expected" 2>&1
84 if $ABDUCO -c "$name" $cmd 2>&1 |
sed 's/.$//' > "$output" && sleep 1 &&
85 diff -u "$output_expected" "$output" && check_environment
; then
86 rm "$output" "$output_expected"
87 TESTS_OK
=$
((TESTS_OK
+ 1))
96 # $1 => session-name, $2 => command to execute
98 check_environment ||
return 1;
102 local output
="$name.out"
103 local output_expected
="$name.expected"
105 TESTS_RUN
=$
((TESTS_RUN
+ 1))
106 echo -n "Running test detached: $name "
107 expected_abduco_detached_output
"$name" "$cmd" > "$output_expected" 2>&1
109 if $ABDUCO -n "$name" $cmd >/dev
/null
2>&1 && sleep 1 &&
110 $ABDUCO -a "$name" 2>&1 |
sed 's/.$//' > "$output" &&
111 diff -u "$output_expected" "$output" && check_environment
; then
112 rm "$output" "$output_expected"
113 TESTS_OK
=$
((TESTS_OK
+ 1))
122 # $1 => session-name, $2 => command to execute
123 run_test_attached_detached
() {
124 check_environment ||
return 1;
128 local output
="$name.out"
129 local output_expected
="$name.expected"
131 TESTS_RUN
=$
((TESTS_RUN
+ 1))
132 echo -n "Running test: $name "
134 expected_abduco_epilog
"$name" $?
> "$output_expected" 2>&1
136 if detach |
$ABDUCO $ABDUCO_OPTS -c "$name" $cmd >/dev
/null
2>&1 && sleep 3 &&
137 $ABDUCO -a "$name" 2>&1 |
tail -1 |
sed 's/.$//' > "$output" &&
138 diff -u "$output_expected" "$output" && check_environment
; then
139 rm "$output" "$output_expected"
140 TESTS_OK
=$
((TESTS_OK
+ 1))
150 echo -n "Running dvtm test: "
151 if ! which dvtm
>/dev
/null
2>&1; then
156 TESTS_RUN
=$
((TESTS_RUN
+ 1))
158 local output
="$name.out"
159 local output_expected
="$name.expected"
161 : > "$output_expected"
162 if dvtm_session |
$ABDUCO -c "$name" > "$output" 2>&1 &&
163 diff -u "$output_expected" "$output" && check_environment
; then
164 rm "$output" "$output_expected"
165 TESTS_OK
=$
((TESTS_OK
+ 1))
174 test_non_existing_command ||
echo "Execution of non existing command FAILED"
176 run_test_attached
"awk" "awk 'BEGIN {for(i=1;i<=1000;i++) print i}'"
177 run_test_detached
"awk" "awk 'BEGIN {for(i=1;i<=1000;i++) print i}'"
179 run_test_attached
"false" "false"
180 run_test_detached
"false" "false"
182 run_test_attached
"true" "true"
183 run_test_detached
"true" "true"
185 cat > exit-status.sh
<<-EOT
189 chmod +x exit-status.sh
191 run_test_attached
"exit-status" "./exit-status.sh"
192 run_test_detached
"exit-status" "./exit-status.sh"
196 cat > long-running.sh
<<-EOT
207 chmod +x long-running.sh
209 run_test_attached_detached
"attach-detach" "./long-running.sh"
215 [ $TESTS_OK -eq $TESTS_RUN ]