forked from mobile-dev-inc/Maestro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests
executable file
·87 lines (67 loc) · 1.99 KB
/
run_tests
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
82
83
84
85
86
87
#!/usr/bin/env sh
set -eu
# Runs all tests in the workspaces directory.
command -v maestro >/dev/null 2>&1 || { echo "maestro is required" && exit 1; }
[ "$(basename "$PWD")" = "e2e" ] || { echo "must be run from e2e directory" && exit 1; }
ALL_PASS=true
_h1() {
printf "=>\n=> %s\n=>\n" "$1"
}
_h2() {
printf "==> [%s] %s\n" "$1" "$2"
}
_h3() {
printf "==> [%s] [%s] => %s\n" "$1" "$2" "$3"
}
platform="${1:-}"
if [ "$platform" = "android" ]; then
exclude_tags="ios,ai"
elif [ "$platform" = "ios" ]; then
exclude_tags="android,ai"
else
echo "usage: $0 <android|ios>"
exit 1
fi
mkfifo pipe
trap 'rm -f pipe' EXIT
# Run passing tests
for workspace_dir in ./workspaces/*; do
WORKSPACE_PASS=true
app_name="$(basename "$workspace_dir")"
_h1 "run tests for app \"$app_name\" on platform \"$platform\""
###
### Run passing tests
###
_h2 "$app_name" "run passing tests"
while IFS= read -r line; do
_h3 "$app_name" "passing" "$line"
done < pipe &
maestro --verbose --platform "$platform" test --include-tags passing --exclude-tags "$exclude_tags" "$workspace_dir" 1>pipe 2>&1 || WORKSPACE_PASS=false
if [ "$WORKSPACE_PASS" = "false" ]; then
_h2 "$app_name" "FAIL! Expected all pass, but at least some failed instead"
ALL_PASS=false
fi
###
### Run failing tests
###
# edge case: the wikipedia workspace has no failing flows
if [ "$(basename "$workspace_dir")" = "wikipedia" ]; then
continue
fi
WORKSPACE_PASS=true # Reset for failing flows
_h2 "$app_name" "run failing tests"
while IFS= read -r line; do
_h3 "$app_name" "failing" "$line"
done < pipe &
maestro --verbose --platform "$platform" test --include-tags failing --exclude-tags "$exclude_tags" "$workspace_dir" 1>pipe 2>&1 && WORKSPACE_PASS=false
if [ "$WORKSPACE_PASS" = "false" ]; then
_h2 "$app_name" "FAIL! Expected all to fail, but at least some passed instead"
ALL_PASS=false
fi
done
if [ "$ALL_PASS" = "false" ]; then
_h1 "FAILURE: some tests failed!"
exit 1
else
_h1 "SUCCESS: all tests passed!"
fi