-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·82 lines (64 loc) · 1.77 KB
/
entrypoint.sh
File metadata and controls
executable file
·82 lines (64 loc) · 1.77 KB
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
#!/bin/bash
# Check env variable presence
if [ -z $env ]; then
echo "Please set environment using 'env' parameter"
exit 1
fi
# Check env variable correctness
re='^(api|e2e|all):(qa)$'
if ! [[ "$env" =~ $re ]]; then
echo 'Please enter correct environment api:[env] or e2e:[env] or all:[env], where env in [qa]'
exit 1
fi
# it's needed to change browser config with passed environment variables
# see here for more details: https://github.com/lorenwest/node-config/wiki/Environment-Variables#allow_config_mutations
eval export ALLOW_CONFIG_MUTATIONS=true
echo 'PARSED VARIABLES'
echo '----------------------------------------'
echo 'Environment: "'$env'"'
echo 'Browser: "'$browser'"'
echo 'Headless: "'$headless'"'
echo 'SlowMo: "'$slowmo'"'
echo '----------------------------------------'
# Parse env variable
IFS=':' read -r -a env_arr <<< "$env"
tests=${env_arr[0]}
nodejs_env=${env_arr[1]}
case $tests in
'all')
base_dir='test/**'
mocha_env=''
;;
'api')
base_dir='test/api/**'
mocha_env='_'$tests
;;
'e2e')
base_dir='test/e2e/**'
mocha_env='_'$tests
;;
esac
if [[ $suites ]]; then
mocha_env='_common'
fi
# amount of milliseconds to mark slow test
SLOW_MS=10000
mocha_run="NODE_ENV=${nodejs_env} ./node_modules/mocha/bin/mocha"
mocha_config="--slow ${SLOW_MS} --config=mocha-configs/.mocharc${mocha_env}.js"
suites=${suites//[[:blank:]]/}
IFS=',' read -r -a suites_arr <<< "$suites"
specs=()
for((i=0; i < ${#suites_arr[@]}; i++)); do
specs[$i]="$base_dir/\*${suites_arr[$i]}\*.spec.ts"
done
spec_list=$( IFS=" "; echo "${specs[*]}" )
if [[ $suites ]]; then
mocha_run="${mocha_run} ${spec_list}"
fi
grep=${grep//[,]/|}
if [[ $grep ]]; then
mocha_run="${mocha_run} --grep '${grep}'"
fi
command="${mocha_run} ${mocha_config}"
echo $command
eval $command