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
33 expected_abduco_prolog
() {
34 printf "\e[?1049h\e[H"
37 # $1 => session-name, $2 => exit status
38 expected_abduco_epilog
() {
39 echo "\e[?25h\e[?1049labduco: $1: session terminated with exit status $2"
42 # $1 => session-name, $2 => cmd to run
43 expected_abduco_attached_output
() {
44 expected_abduco_prolog
46 expected_abduco_epilog
"$1" $?
49 # $1 => session-name, $2 => cmd to run
50 expected_abduco_detached_output
() {
51 expected_abduco_prolog
53 expected_abduco_epilog
"$1" $?
57 [ "`$ABDUCO | wc -l`" -gt 1 ] && echo Abduco session exists
&& exit 1;
58 pgrep abduco
&& echo Abduco process exists
&& exit 1;
62 test_non_existing_command
() {
63 check_environment ||
return 1;
64 $ABDUCO -c test .
/non-existing-command
>/dev
/null
2>&1
65 check_environment ||
return 1;
68 # $1 => session-name, $2 => command to execute
70 check_environment ||
return 1;
74 local output
="$name.out"
75 local output_expected
="$name.expected"
77 echo -n "Running test attached: $name "
78 expected_abduco_attached_output
"$name" "$cmd" > "$output_expected" 2>&1
80 if $ABDUCO -c "$name" $cmd 2>&1 |
sed 's/.$//' > "$output" && sleep 1 &&
81 diff -u "$output_expected" "$output" && check_environment
; then
82 rm "$output" "$output_expected"
91 # $1 => session-name, $2 => command to execute
93 check_environment ||
return 1;
97 local output
="$name.out"
98 local output_expected
="$name.expected"
100 echo -n "Running test detached: $name "
101 expected_abduco_detached_output
"$name" "$cmd" > "$output_expected" 2>&1
103 if $ABDUCO -n "$name" $cmd >/dev
/null
2>&1 && sleep 1 &&
104 $ABDUCO -a "$name" 2>&1 |
sed 's/.$//' > "$output" &&
105 diff -u "$output_expected" "$output" && check_environment
; then
106 rm "$output" "$output_expected"
115 # $1 => session-name, $2 => command to execute
116 run_test_attached_detached
() {
117 check_environment ||
return 1;
121 local output
="$name.out"
122 local output_expected
="$name.expected"
124 echo -n "Running test: $name "
126 expected_abduco_epilog
"$name" $?
> "$output_expected" 2>&1
128 if detach |
$ABDUCO $ABDUCO_OPTS -c "$name" $cmd >/dev
/null
2>&1 && sleep 3 &&
129 $ABDUCO -a "$name" 2>&1 |
tail -1 |
sed 's/.$//' > "$output" &&
130 diff -u "$output_expected" "$output" && check_environment
; then
131 rm "$output" "$output_expected"
141 echo -n "Running dvtm test: "
142 if ! which dvtm
>/dev
/null
2>&1; then
148 local output
="$name.out"
149 local output_expected
="$name.expected"
151 : > "$output_expected"
152 if dvtm_session |
$ABDUCO -c "$name" > "$output" 2>&1 &&
153 diff -u "$output_expected" "$output" && check_environment
; then
154 rm "$output" "$output_expected"
163 test_non_existing_command ||
echo "Execution of non existing command FAILED"
165 run_test_attached
"seq" "seq 1 1000"
166 run_test_detached
"seq" "seq 1 1000"
168 run_test_attached
"false" "false"
169 run_test_detached
"false" "false"
171 run_test_attached
"true" "true"
172 run_test_detached
"true" "true"
174 cat > exit-status.sh
<<-EOT
178 chmod +x exit-status.sh
180 run_test_attached
"exit-status" "./exit-status.sh"
181 run_test_detached
"exit-status" "./exit-status.sh"
185 cat > long-running.sh
<<-EOT
196 chmod +x long-running.sh
198 run_test_attached_detached
"attach-detach" "./long-running.sh"