-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests.sh
executable file
·159 lines (143 loc) · 4.62 KB
/
run_tests.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
function usage {
echo "Usage: $0 [OPTION]..."
echo "Run Openstack Dashboard's test suite(s)"
echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically"
echo " if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local"
echo " environment"
echo " -f, --force Force a clean re-build of the virtual"
echo " environment. Useful when dependencies have"
echo " been added."
echo " -p, --pep8 Just run pep8"
echo " -y, --pylint Just run pylint"
echo " -h, --help Print this usage message"
echo ""
echo "Note: with no options specified, the script will try to run the tests in"
echo " a virtual environment, If no virtualenv is found, the script will ask"
echo " if you would like to create one. If you prefer to run tests NOT in a"
echo " virtual environment, simply pass the -N option."
exit
}
function process_option {
case "$1" in
-h|--help) usage;;
-V|--virtual-env) let always_venv=1; let never_venv=0;;
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
-p|--pep8) let just_pep8=1;;
-y|--pylint) let just_pylint=1;;
-f|--force) let force=1;;
*) testargs="$testargs $1"
esac
}
function run_pylint {
echo "Running pylint ..."
PYLINT_INCLUDE="openstack-dashboard/dashboard django-openstack/django_openstack"
${django_wrapper} pylint --rcfile=.pylintrc -f parseable $PYLINT_INCLUDE > pylint.txt
CODE=$?
grep Global -A2 pylint.txt
if [ $CODE -lt 32 ]
then
exit 0
else
exit $CODE
fi
}
function run_pep8 {
echo "Running pep8 ..."
PEP8_EXCLUDE=vcsversion.py
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat"
PEP8_INCLUDE="openstack-dashboard/dashboard django-openstack/django_openstack"
echo "${django_wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE > pep8.txt"
#${django_wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE > pep8.txt
#perl string strips out the [ and ] characters
${django_wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE | perl -ple 's/: ([WE]\d+)/: [$1]/' > pep8.txt
}
# DEFAULTS FOR RUN_TESTS.SH
#
venv=openstack-dashboard/.dashboard-venv
django_with_venv=openstack-dashboard/tools/with_venv.sh
dashboard_with_venv=tools/with_venv.sh
always_venv=0
never_venv=0
force=0
testargs=""
django_wrapper=""
dashboard_wrapper=""
just_pep8=0
just_pylint=0
# PROCESS ARGUMENTS, OVERRIDE DEFAULTS
for arg in "$@"; do
process_option $arg
done
if [ $never_venv -eq 0 ]
then
# Remove the virtual environment if --force used
if [ $force -eq 1 ]; then
echo "Cleaning virtualenv..."
rm -rf ${venv}
fi
if [ -e ${venv} ]; then
django_wrapper="${django_with_venv}"
dashboard_wrapper="${dashboard_with_venv}"
else
if [ $always_venv -eq 1 ]; then
# Automatically install the virtualenv
cd openstack-dashboard
python tools/install_venv.py
cd ..
django_wrapper="${django_with_venv}"
dashboard_wrapper="${dashboard_with_venv}"
else
echo -e "No virtual environment found...create one? (Y/n) \c"
read use_ve
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
# Install the virtualenv and run the test suite in it
cd openstack-dashboard
python tools/install_venv.py
cd ..
django_wrapper="${django_with_venv}"
dashboard_wrapper="${dashboard_with_venv}"
fi
fi
fi
fi
function run_tests {
echo "Running django-openstack (core django) tests"
${django_wrapper} coverage erase
cd django-openstack
python bootstrap.py
bin/buildout
cd ..
${django_wrapper} coverage run django-openstack/bin/test
# get results of the django-openstack tests
OPENSTACK_RESULT=$?
echo "Running openstack-dashboard (django website) tests"
cd openstack-dashboard
cp local/local_settings.py.example local/local_settings.py
${dashboard_wrapper} coverage run dashboard/manage.py test
# get results of the openstack-dashboard tests
DASHBOARD_RESULT=$?
cd ..
echo "Generating coverage reports"
${django_wrapper} coverage combine
${django_wrapper} coverage xml --omit='/usr*,setup.py,*egg*'
${django_wrapper} coverage html --omit='/usr*,setup.py,*egg*' -d reports
exit $(($OPENSTACK_RESULT || $DASHBOARD_RESULT))
}
if [ $just_pep8 -eq 1 ]; then
run_pep8
#capability discovery
#capability discovery
#store & compare arista -> Mongo - quarantine
#SMBios probes
#store & compare arista -> Mongo - quarantine
#SMBios probes
exit $?
fi
if [ $just_pylint -eq 1 ]; then
run_pylint
exit $?
fi
run_tests || exit