blob: f86881610b3a443a4f9c9a6f2ac226e32efda5d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#! /usr/bin/env sh
set -e
msg() {
if [ "$#" -ne 0 ]; then
echo "$@" | tee --append "$__TEST_EVAL_LOG_FILE" >&2
else
cat | tee --append "$__TEST_EVAL_LOG_FILE" >&2
fi
}
__test_eval() {
tmux="$__TEST_TMUX"
tpane="$__TEST_TMUX_PANE"
file="$1"
awk --file "$__TEST_EVAL_AWK_CLEAN_FILE" "$file" | while read -r cmd args; do
case "$cmd" in
"Type")
msg "Sending keys to application '$args'.."
"$tmux" send-keys -t "$tpane": "$args"
;;
"Sleep")
msg "Sleeping for '$args' seconds.."
sleep "$args"
;;
"Expect" | "ExpectNot")
msg "Trying to match regex ('$args') for currently visible content.."
matched=""
if "$tmux" capture-pane -t "$tpane" -p -S 0 -E - | grep "$args"; then
matched=true
else
matched=false
fi
case "$cmd" in
"Expect")
if [ "$matched" = true ]; then
msg "Regex matched."
else
msg "Failed to find string, matched by regex '$args' on the screen"
msg current screen:
"$tmux" capture-pane -t "$tpane" -p -S 0 -E - | msg
exit 1
fi
;;
"ExpectNot")
if [ "$matched" = false ]; then
msg "Regex successfully not matched."
else
msg "Found to find string, matched by regex '$args' on the screen. But expected none"
msg current screen:
"$tmux" capture-pane -t "$tpane" -p -S 0 -E - | msg
exit 1
fi
;;
*)
msg "Entered unrechable code. This is a bug."
exit 1
;;
esac
;;
"SetGolden")
msg "Trying to set '$args' as golden file."
[ -f "$args" ] || {
msg "Argument is not a file!"
exit 1
}
printf "%s" "$args" >"$__TEST_EVAL_GOLDEN_FILE"
msg "Set golden file to: '$args'"
;;
*)
msg "Unrecognized command: '$cmd'"
exit 1
;;
esac
done
}
|