-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·65 lines (53 loc) · 1.53 KB
/
test.sh
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
#!/bin/bash
error() {
printf "%s\n" "$@"
FAILED=$((FAILED+1))
}
run() {
local -a first=()
while [[ "${1:-"--"}" != "--" ]]; do
first+=( "$1" )
shift
done
shift
python3 ./shortcuts.py --no-sleep -e /dev/stdout "${first[@]}" \
| python3 ./shortcuts.py --no-sleep -e /dev/stdin "$@"
}
run_replay() {
local file="$1"
shift
run --replay -- "$@" < "$file"
}
run_generated() {
local name="$1"
shift
run --replay-action "$name" -- "$@"
}
rgrep() {
local key="$1"
shift
"$@" -vn 2>&1 >/dev/null | grep -q "$key"
}
FAILED=0
run_replay tests/monkey-touch.record \
|| error "monkey-touch crashed"
rgrep left run_replay tests/double-tap-left.record \
|| error "left didn't act on left"
rgrep right run_replay tests/double-tap-right.record \
|| error "right didn't act on right"
rgrep top run_replay tests/double-tap-top.record \
|| error "top didn't act on top"
rgrep top run_replay tests/double-tap-slow-top-no-event.record \
&& error "shouldn't trigger top on slow taps"
[[ "$(run_replay tests/double-tap-left.record -o /dev/stdout | wc -c)" = 2520 ]] \
|| error "left replay does not have correct length"
rgrep left run_generated double_tap_left \
|| error "left didn't act on synthetic left"
rgrep right run_generated double_tap_right \
|| error "right didn't act on synthetic right"
rgrep top run_generated double_tap_top \
|| error "top didn't act on synthetic top"
run_generated double_tap_left --record \
| rgrep left run --replay --\
|| error "replay of recording of synthetic left didn't recognize left"
[ "$FAILED" = 0 ]