-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.sh
executable file
·117 lines (102 loc) · 2.68 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
set -e
# This is the complete test suite kit, that allows to run multiple test
# scenarios during development of our app.
#
# We try to abstract most commends into a few options and defined the following
# behavior:
# defaults:
T_BROWSER="puppeteer" # uses headless browser for client tests
T_COVERAGE=0 # has coverage disabled
T_FILTER="" # runs all defined tests
T_RUN_ONCE="" # runs in watch mode
T_VERBOSE=0 # no extra verbosity
T_SERVER=1 # runs server tests
T_CLIENT=1 # runs client tests
# options:
SCRIPT_USAGE="
Usage: $(basename $0) [OPTIONS]
Options:
-a <String> Filter architecture, allowed values: 'server' or 'client'
-b Use a real browser for client tests (default is headless)
-c Activate code-coverage reports
-g <RegExp> Filter tests by a given RegExp (uses Mocha-grep)
-h Show help
-o Runs the tests only once (default is watch-mode)
-v Verbose mode with extra prints
"
while getopts "a:bcg:hov" opt; do
case $opt in
a)
if [ "$OPTARG" = "client" ]
then
T_CLIENT=1
T_SERVER=0
elif [ "$OPTARG" = "server" ]
then
T_CLIENT=0
T_SERVER=1
else
echo "Invalid parameter value for -a: $OPTARG"
echo "$SCRIPT_USAGE"
exit 1
fi
;;
b)
T_BROWSER=""
;;
g)
T_FILTER=${OPTARG}
;;
v)
T_VERBOSE=1
;;
c)
T_COVERAGE=1
;;
o)
T_RUN_ONCE="--once"
;;
h)
echo "$SCRIPT_USAGE"
exit 1
;;
\?)
echo "$SCRIPT_USAGE"
exit 1
;;
esac
done
# build paths:
PROJECT_PATH=$(pwd)
T_PACKAGE_DIRS="../lib:../liboauth:./github"
PORT=5599
if [ "$T_VERBOSE" -eq "1" ];
then
echo "=> Test leaonline-content"
echo "=> Project path: [${PROJECT_PATH}]"
echo "=> Port: [${PORT}]"
echo "=> Lib path(s): [${T_PACKAGE_DIRS}]"
echo "=> Run once? [${T_RUN_ONCE}]"
echo "=> grep pattern: [${T_FILTER}]"
echo "=> coverage: [${T_COVERAGE}]"
echo "=> Browser: [${T_BROWSER}]"
echo "=> Arch: [server: ${T_SERVER}, client: ${T_CLIENT}]"
fi
# create command:
METEOR_PACKAGE_DIRS=${T_PACKAGE_DIRS} \
TEST_BROWSER_DRIVER=${T_BROWSER} \
TEST_SERVER=${T_SERVER} \
TEST_CLIENT=${T_CLIENT} \
MOCHA_GREP=${T_FILTER} \
BABEL_ENV=COVERAGE \
COVERAGE=${T_COVERAGE} \
COVERAGE_OUT_HTML=1 \
COVERAGE_OUT_LCOVONLY=1 \
COVERAGE_APP_FOLDER=$PWD/ \
COVERAGE_VERBOSE_MODE=${T_VERBOSE} \
meteor test \
${T_RUN_ONCE} \
--driver-package=meteortesting:mocha \
--settings=settings.json \
--port=${PORT}