forked from radiasoft/sirepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
69 lines (62 loc) · 1.85 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
#!/bin/bash
#
# Check for debug statements and run all tests
#
set -euo pipefail
test_err() {
test_msg "$@"
return 1
}
test_jshint() {
if [[ ! -x ./node_modules/jshint/bin/jshint ]]; then
if ! type node >& /dev/null; then
# Will fail in vag
test_msg Installing nodejs
sudo dnf install -y -q nodejs
fi
test_msg Installing jshint
# npm gets ECONNRESET due to a node error, which shouldn't happen
# https://github.com/nodejs/node/issues/3595
npm install jshint >& /dev/null || true
fi
./node_modules/jshint/bin/jshint --config=etc/jshint.conf "${jsfiles[@]}"
}
test_main() {
local pyfiles=( $(find sirepo -name \*.py | sort) )
test_no_prints '\s(pkdp|print)\(' "${pyfiles[@]}"
local jsfiles=( sirepo/package_data/static/js/*.js )
test_no_prints '\s(srdbg|console.log)\(' "${jsfiles[@]}"
test_no_prints '(startsWith|Object\.assign)\(' "${jsfiles[@]}"
test_no_h5py
test_jshint
if [[ -x ./node_modules/karma/bin/karma ]]; then
./node_modules/karma/bin/karma start etc/karma-conf.js
fi
echo SIREPO_FEATURE_CONFIG_JOB=1 pykern test
SIREPO_FEATURE_CONFIG_JOB=1 pykern test
echo SIREPO_FEATURE_CONFIG_JOB= pykern test
SIREPO_FEATURE_CONFIG_JOB= pykern test
if [[ -n ${PKSETUP_PYPI_PASSWORD:+hide-secret} ]]; then
python setup.py pkdeploy
fi
}
test_msg() {
echo "$@" 1>&2
}
test_no_h5py() {
local f=( $(find sirepo -name \*.py | egrep -v '/(package_data|flash|opal|rs4pi|synergia|warp|server.py)') )
local r=$(grep -l 'import.*h5py' "${f[@]}")
if [[ $r ]]; then
test_err "import h5py found in: $r"
fi
}
test_no_prints() {
local pat=$1
shift
local f=( $@ )
local r=$(egrep -l "$pat" "${f[@]}")
if [[ $r ]]; then
test_err "$pat found in: $r"
fi
}
test_main "$@"