1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
1 |
#!/bin/bash
|
2 |
||
3 |
set -o errexit
|
|
4 |
||
5 |
function usage { |
|
6 |
echo "Usage: $0 [OPTION]..." |
|
7 |
echo "Run Horizon's test suite(s)" |
|
8 |
echo "" |
|
9 |
echo " -V, --virtual-env Always use virtualenv. Install automatically" |
|
10 |
echo " if not present" |
|
11 |
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local" |
|
12 |
echo " environment" |
|
13 |
echo " -c, --coverage Generate reports using Coverage" |
|
14 |
echo " -f, --force Force a clean re-build of the virtual" |
|
15 |
echo " environment. Useful when dependencies have" |
|
16 |
echo " been added." |
|
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
17 |
echo " -m, --manage Run a Django management command." |
1.1.38
by James Page
Import upstream version 2014.1~rc1 |
18 |
echo " --makemessages Create/Update English translation files." |
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
19 |
echo " --compilemessages Compile all translation files." |
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
20 |
echo " --check-only Do not update translation files (--makemessages only)." |
1.2.6
by Corey Bryant
Import upstream version 2015.1~b2 |
21 |
echo " --pseudo Pseudo translate a language." |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
22 |
echo " -p, --pep8 Just run pep8" |
1.1.43
by James Page
Import upstream version 2014.2~b3 |
23 |
echo " -8, --pep8-changed [<basecommit>]" |
24 |
echo " Just run PEP8 and HACKING compliance check" |
|
25 |
echo " on files changed since HEAD~1 (or <basecommit>)" |
|
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
26 |
echo " -P, --no-pep8 Don't run pep8 by default" |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
27 |
echo " -t, --tabs Check for tab characters in files." |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
28 |
echo " -y, --pylint Just run pylint" |
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
29 |
echo " -j, --jshint Just run jshint" |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
30 |
echo " -q, --quiet Run non-interactively. (Relatively) quiet." |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
31 |
echo " Implies -V if -N is not set." |
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
32 |
echo " --only-selenium Run only the Selenium unit tests" |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
33 |
echo " --with-selenium Run unit tests including Selenium tests" |
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
34 |
echo " --selenium-headless Run Selenium tests headless" |
1.1.37
by James Page
Import upstream version 2014.1~b3 |
35 |
echo " --integration Run the integration tests (requires a running " |
36 |
echo " OpenStack environment)" |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
37 |
echo " --runserver Run the Django development server for" |
13
by Chuck Short
* New upstream version. |
38 |
echo " openstack_dashboard in the virtual" |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
39 |
echo " environment." |
40 |
echo " --docs Just build the documentation" |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
41 |
echo " --backup-environment Make a backup of the environment on exit" |
42 |
echo " --restore-environment Restore the environment before running" |
|
1.1.30
by Adam Gandelman
Import upstream version 2013.2~b3 |
43 |
echo " --destroy-environment Destroy the environment and exit" |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
44 |
echo " -h, --help Print this usage message" |
45 |
echo "" |
|
46 |
echo "Note: with no options specified, the script will try to run the tests in" |
|
47 |
echo " a virtual environment, If no virtualenv is found, the script will ask" |
|
48 |
echo " if you would like to create one. If you prefer to run tests NOT in a" |
|
49 |
echo " virtual environment, simply pass the -N option." |
|
50 |
exit
|
|
51 |
}
|
|
52 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
53 |
# DEFAULTS FOR RUN_TESTS.SH
|
54 |
#
|
|
1.1.36
by James Page
Import upstream version 2014.1~b2 |
55 |
root=`pwd -P` |
1.1.6
by Chuck Short
Import upstream version 2012.1~e4~20120217.1354 |
56 |
venv=$root/.venv |
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
57 |
venv_env_version=$venv/environments |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
58 |
with_venv=tools/with_venv.sh |
13
by Chuck Short
* New upstream version. |
59 |
included_dirs="openstack_dashboard horizon" |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
60 |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
61 |
always_venv=0 |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
62 |
backup_env=0 |
63 |
command_wrapper="" |
|
64 |
destroy=0 |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
65 |
force=0 |
66 |
just_pep8=0 |
|
1.1.43
by James Page
Import upstream version 2014.2~b3 |
67 |
just_pep8_changed=0 |
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
68 |
no_pep8=0 |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
69 |
just_pylint=0 |
70 |
just_docs=0 |
|
71 |
just_tabs=0 |
|
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
72 |
just_jshint=0 |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
73 |
never_venv=0 |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
74 |
quiet=0 |
75 |
restore_env=0 |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
76 |
runserver=0 |
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
77 |
only_selenium=0 |
78 |
with_selenium=0 |
|
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
79 |
selenium_headless=0 |
1.1.37
by James Page
Import upstream version 2014.1~b3 |
80 |
integration=0 |
1.1.22
by Chuck Short
Import upstream version 2013.1~g1 |
81 |
testopts="" |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
82 |
testargs="" |
83 |
with_coverage=0 |
|
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
84 |
makemessages=0 |
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
85 |
compilemessages=0 |
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
86 |
check_only=0 |
1.2.6
by Corey Bryant
Import upstream version 2015.1~b2 |
87 |
pseudo=0 |
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
88 |
manage=0 |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
89 |
|
90 |
# Jenkins sets a "JOB_NAME" variable, if it's not set, we'll make it "default"
|
|
91 |
[ "$JOB_NAME" ] || JOB_NAME="default" |
|
92 |
||
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
93 |
function process_option { |
1.1.28
by Chuck Short
Import upstream version 2013.2~b1 |
94 |
# If running manage command, treat the rest of options as arguments.
|
95 |
if [ $manage -eq 1 ]; then |
|
96 |
testargs="$testargs $1" |
|
97 |
return 0 |
|
98 |
fi
|
|
99 |
||
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
100 |
case "$1" in |
101 |
-h|--help) usage;; |
|
102 |
-V|--virtual-env) always_venv=1; never_venv=0;; |
|
103 |
-N|--no-virtual-env) always_venv=0; never_venv=1;; |
|
104 |
-p|--pep8) just_pep8=1;; |
|
1.1.43
by James Page
Import upstream version 2014.2~b3 |
105 |
-8|--pep8-changed) just_pep8_changed=1;; |
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
106 |
-P|--no-pep8) no_pep8=1;; |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
107 |
-y|--pylint) just_pylint=1;; |
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
108 |
-j|--jshint) just_jshint=1;; |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
109 |
-f|--force) force=1;; |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
110 |
-t|--tabs) just_tabs=1;; |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
111 |
-q|--quiet) quiet=1;; |
112 |
-c|--coverage) with_coverage=1;; |
|
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
113 |
-m|--manage) manage=1;; |
114 |
--makemessages) makemessages=1;; |
|
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
115 |
--compilemessages) compilemessages=1;; |
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
116 |
--check-only) check_only=1;; |
1.2.6
by Corey Bryant
Import upstream version 2015.1~b2 |
117 |
--pseudo) pseudo=1;; |
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
118 |
--only-selenium) only_selenium=1;; |
119 |
--with-selenium) with_selenium=1;; |
|
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
120 |
--selenium-headless) selenium_headless=1;; |
1.1.37
by James Page
Import upstream version 2014.1~b3 |
121 |
--integration) integration=1;; |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
122 |
--docs) just_docs=1;; |
123 |
--runserver) runserver=1;; |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
124 |
--backup-environment) backup_env=1;; |
125 |
--restore-environment) restore_env=1;; |
|
126 |
--destroy-environment) destroy=1;; |
|
1.1.22
by Chuck Short
Import upstream version 2013.1~g1 |
127 |
-*) testopts="$testopts $1";; |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
128 |
*) testargs="$testargs $1" |
129 |
esac
|
|
130 |
}
|
|
131 |
||
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
132 |
function run_management_command { |
1.1.22
by Chuck Short
Import upstream version 2013.1~g1 |
133 |
${command_wrapper} python $root/manage.py $testopts $testargs |
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
134 |
}
|
135 |
||
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
136 |
function run_server { |
137 |
echo "Starting Django development server..." |
|
1.1.22
by Chuck Short
Import upstream version 2013.1~g1 |
138 |
${command_wrapper} python $root/manage.py runserver $testopts $testargs |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
139 |
echo "Server stopped." |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
140 |
}
|
141 |
||
142 |
function run_pylint { |
|
143 |
echo "Running pylint ..." |
|
13
by Chuck Short
* New upstream version. |
144 |
PYTHONPATH=$root ${command_wrapper} pylint --rcfile=.pylintrc -f parseable $included_dirs > pylint.txt || true |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
145 |
CODE=$? |
146 |
grep Global -A2 pylint.txt |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
147 |
if [ $CODE -lt 32 ]; then |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
148 |
echo "Completed successfully." |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
149 |
exit 0 |
150 |
else
|
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
151 |
echo "Completed with problems." |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
152 |
exit $CODE |
153 |
fi
|
|
154 |
}
|
|
155 |
||
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
156 |
function run_jshint { |
157 |
echo "Running jshint ..." |
|
158 |
jshint horizon/static/horizon/js |
|
159 |
jshint horizon/static/horizon/tests |
|
0.11.2
by James Page
Import upstream version 2015.1~b3 |
160 |
jshint horizon/static/angular/ |
161 |
jshint openstack_dashboard/static/dashboard/ |
|
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
162 |
}
|
163 |
||
1.1.43
by James Page
Import upstream version 2014.2~b3 |
164 |
function warn_on_flake8_without_venv { |
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
165 |
set +o errexit
|
166 |
${command_wrapper} python -c "import hacking" 2>/dev/null |
|
167 |
no_hacking=$? |
|
168 |
set -o errexit
|
|
169 |
if [ $never_venv -eq 1 -a $no_hacking -eq 1 ]; then |
|
170 |
echo "**WARNING**:" >&2 |
|
171 |
echo "OpenStack hacking is not installed on your host. Its detection will be missed." >&2 |
|
172 |
echo "Please install or use virtual env if you need OpenStack hacking detection." >&2 |
|
173 |
fi
|
|
1.1.43
by James Page
Import upstream version 2014.2~b3 |
174 |
}
|
175 |
||
176 |
function run_pep8 { |
|
177 |
echo "Running flake8 ..." |
|
178 |
warn_on_flake8_without_venv |
|
1.1.31
by James Page
Import upstream version 2013.2~rc1 |
179 |
DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings ${command_wrapper} flake8 |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
180 |
}
|
181 |
||
1.1.43
by James Page
Import upstream version 2014.2~b3 |
182 |
function run_pep8_changed { |
183 |
# NOTE(gilliard) We want use flake8 to check the entirety of every file that has
|
|
184 |
# a change in it. Unfortunately the --filenames argument to flake8 only accepts
|
|
185 |
# file *names* and there are no files named (eg) "nova/compute/manager.py". The
|
|
186 |
# --diff argument behaves surprisingly as well, because although you feed it a
|
|
187 |
# diff, it actually checks the file on disk anyway.
|
|
188 |
local base_commit=${testargs:-HEAD~1} |
|
189 |
files=$(git diff --name-only $base_commit | tr '\n' ' ') |
|
190 |
echo "Running flake8 on ${files}" |
|
191 |
warn_on_flake8_without_venv |
|
192 |
diff -u --from-file /dev/null ${files} | DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings ${command_wrapper} flake8 --diff |
|
193 |
exit
|
|
194 |
}
|
|
195 |
||
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
196 |
function run_sphinx { |
197 |
echo "Building sphinx..." |
|
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
198 |
DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings ${command_wrapper} python setup.py build_sphinx |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
199 |
echo "Build complete." |
200 |
}
|
|
201 |
||
202 |
function tab_check { |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
203 |
TAB_VIOLATIONS=`find $included_dirs -type f -regex ".*\.\(css\|js\|py\|html\)" -print0 | xargs -0 awk '/\t/' | wc -l` |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
204 |
if [ $TAB_VIOLATIONS -gt 0 ]; then |
205 |
echo "TABS! $TAB_VIOLATIONS of them! Oh no!" |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
206 |
HORIZON_FILES=`find $included_dirs -type f -regex ".*\.\(css\|js\|py|\html\)"` |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
207 |
for TABBED_FILE in $HORIZON_FILES |
208 |
do
|
|
209 |
TAB_COUNT=`awk '/\t/' $TABBED_FILE | wc -l` |
|
210 |
if [ $TAB_COUNT -gt 0 ]; then |
|
211 |
echo "$TABBED_FILE: $TAB_COUNT" |
|
212 |
fi
|
|
213 |
done
|
|
214 |
fi
|
|
215 |
return $TAB_VIOLATIONS; |
|
216 |
}
|
|
217 |
||
218 |
function destroy_venv { |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
219 |
echo "Cleaning environment..." |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
220 |
echo "Removing virtualenv..." |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
221 |
rm -rf $venv
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
222 |
echo "Virtualenv removed." |
223 |
}
|
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
224 |
|
225 |
function environment_check { |
|
226 |
echo "Checking environment." |
|
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
227 |
if [ -f $venv_env_version ]; then |
228 |
set +o errexit
|
|
229 |
cat requirements.txt test-requirements.txt | cmp $venv_env_version - > /dev/null |
|
230 |
local env_check_result=$? |
|
231 |
set -o errexit
|
|
232 |
if [ $env_check_result -eq 0 ]; then |
|
233 |
# If the environment exists and is up-to-date then set our variables
|
|
234 |
command_wrapper="${root}/${with_venv}" |
|
235 |
echo "Environment is up to date." |
|
236 |
return 0 |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
237 |
fi
|
238 |
fi
|
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
239 |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
240 |
if [ $always_venv -eq 1 ]; then |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
241 |
install_venv |
242 |
else
|
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
243 |
if [ ! -e ${venv} ]; then |
244 |
echo -e "Environment not found. Install? (Y/n) \c" |
|
245 |
else
|
|
246 |
echo -e "Your environment appears to be out of date. Update? (Y/n) \c" |
|
247 |
fi
|
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
248 |
read update_env
|
249 |
if [ "x$update_env" = "xY" -o "x$update_env" = "x" -o "x$update_env" = "xy" ]; then |
|
250 |
install_venv |
|
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
251 |
else
|
252 |
# Set our command wrapper anyway.
|
|
253 |
command_wrapper="${root}/${with_venv}" |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
254 |
fi
|
255 |
fi
|
|
256 |
}
|
|
257 |
||
258 |
function sanity_check { |
|
259 |
# Anything that should be determined prior to running the tests, server, etc.
|
|
1.1.2
by Chuck Short
Import upstream version 2012.1~e2 |
260 |
# Don't sanity-check anything environment-related in -N flag is set
|
261 |
if [ $never_venv -eq 0 ]; then |
|
262 |
if [ ! -e ${venv} ]; then |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
263 |
echo "Virtualenv not found at $venv. Did install_venv.py succeed?" |
264 |
exit 1 |
|
265 |
fi
|
|
266 |
fi
|
|
1.1.5
by Chuck Short
Import upstream version 2012.1~e4~20120202.1300 |
267 |
# Remove .pyc files. This is sanity checking because they can linger
|
268 |
# after old files are deleted.
|
|
269 |
find . -name "*.pyc" -exec rm -rf {} \; |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
270 |
}
|
271 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
272 |
function backup_environment { |
273 |
if [ $backup_env -eq 1 ]; then |
|
274 |
echo "Backing up environment \"$JOB_NAME\"..." |
|
275 |
if [ ! -e ${venv} ]; then |
|
276 |
echo "Environment not installed. Cannot back up." |
|
277 |
return 0 |
|
278 |
fi
|
|
279 |
if [ -d /tmp/.horizon_environment/$JOB_NAME ]; then |
|
280 |
mv /tmp/.horizon_environment/$JOB_NAME /tmp/.horizon_environment/$JOB_NAME.old |
|
281 |
rm -rf /tmp/.horizon_environment/$JOB_NAME
|
|
282 |
fi
|
|
283 |
mkdir -p /tmp/.horizon_environment/$JOB_NAME
|
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
284 |
cp -r $venv /tmp/.horizon_environment/$JOB_NAME/ |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
285 |
# Remove the backup now that we've completed successfully
|
286 |
rm -rf /tmp/.horizon_environment/$JOB_NAME.old
|
|
287 |
echo "Backup completed" |
|
288 |
fi
|
|
289 |
}
|
|
290 |
||
291 |
function restore_environment { |
|
292 |
if [ $restore_env -eq 1 ]; then |
|
293 |
echo "Restoring environment from backup..." |
|
294 |
if [ ! -d /tmp/.horizon_environment/$JOB_NAME ]; then |
|
295 |
echo "No backup to restore from." |
|
296 |
return 0 |
|
297 |
fi
|
|
298 |
||
1.1.6
by Chuck Short
Import upstream version 2012.1~e4~20120217.1354 |
299 |
cp -r /tmp/.horizon_environment/$JOB_NAME/.venv ./ || true |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
300 |
|
301 |
echo "Environment restored successfully." |
|
302 |
fi
|
|
303 |
}
|
|
304 |
||
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
305 |
function install_venv { |
13
by Chuck Short
* New upstream version. |
306 |
# Install with install_venv.py
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
307 |
export PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE-/tmp/.pip_download_cache} |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
308 |
export PIP_USE_MIRRORS=true |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
309 |
if [ $quiet -eq 1 ]; then |
310 |
export PIP_NO_INPUT=true |
|
311 |
fi
|
|
1.1.5
by Chuck Short
Import upstream version 2012.1~e4~20120202.1300 |
312 |
echo "Fetching new src packages..." |
313 |
rm -rf $venv/src
|
|
314 |
python tools/install_venv.py |
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
315 |
command_wrapper="$root/${with_venv}" |
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
316 |
# Make sure it worked and record the environment version
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
317 |
sanity_check |
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
318 |
chmod -R 754 $venv |
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
319 |
cat requirements.txt test-requirements.txt > $venv_env_version
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
320 |
}
|
321 |
||
322 |
function run_tests { |
|
323 |
sanity_check |
|
324 |
||
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
325 |
if [ $with_selenium -eq 1 ]; then |
326 |
export WITH_SELENIUM=1 |
|
327 |
elif [ $only_selenium -eq 1 ]; then |
|
328 |
export WITH_SELENIUM=1 |
|
329 |
export SKIP_UNITTESTS=1 |
|
330 |
fi
|
|
331 |
||
1.1.38
by James Page
Import upstream version 2014.1~rc1 |
332 |
if [ $with_selenium -eq 0 -a $integration -eq 0 ]; then |
333 |
testopts="$testopts --exclude-dir=openstack_dashboard/test/integration_tests" |
|
334 |
fi
|
|
335 |
||
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
336 |
if [ $selenium_headless -eq 1 ]; then |
337 |
export SELENIUM_HEADLESS=1 |
|
338 |
fi
|
|
339 |
||
1.1.22
by Chuck Short
Import upstream version 2013.1~g1 |
340 |
if [ -z "$testargs" ]; then |
341 |
run_tests_all |
|
342 |
else
|
|
343 |
run_tests_subset |
|
344 |
fi
|
|
345 |
}
|
|
346 |
||
347 |
function run_tests_subset { |
|
348 |
project=`echo $testargs | awk -F. '{print $1}'` |
|
349 |
${command_wrapper} python $root/manage.py test --settings=$project.test.settings $testopts $testargs |
|
350 |
}
|
|
351 |
||
352 |
function run_tests_all { |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
353 |
echo "Running Horizon application tests" |
1.1.16
by Chuck Short
Import upstream version 2012.2~f2 |
354 |
export NOSE_XUNIT_FILE=horizon/nosetests.xml |
1.1.18
by Chuck Short
Import upstream version 2012.2~rc1~20120904.2043 |
355 |
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then |
356 |
export NOSE_HTML_OUT_FILE='horizon_nose_results.html' |
|
357 |
fi
|
|
1.1.37
by James Page
Import upstream version 2014.1~b3 |
358 |
if [ $with_coverage -eq 1 ]; then |
1.1.41
by Chuck Short
Import upstream version 2014.2~b1 |
359 |
${command_wrapper} python -m coverage.__main__ erase |
360 |
coverage_run="python -m coverage.__main__ run -p" |
|
1.1.37
by James Page
Import upstream version 2014.1~b3 |
361 |
fi
|
362 |
${command_wrapper} ${coverage_run} $root/manage.py test horizon --settings=horizon.test.settings $testopts |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
363 |
# get results of the Horizon tests
|
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
364 |
HORIZON_RESULT=$? |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
365 |
|
1.1.9
by Chuck Short
Import upstream version 2012.1~rc1~20120308.1479 |
366 |
echo "Running openstack_dashboard tests" |
1.1.16
by Chuck Short
Import upstream version 2012.2~f2 |
367 |
export NOSE_XUNIT_FILE=openstack_dashboard/nosetests.xml |
1.1.18
by Chuck Short
Import upstream version 2012.2~rc1~20120904.2043 |
368 |
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then |
369 |
export NOSE_HTML_OUT_FILE='dashboard_nose_results.html' |
|
370 |
fi
|
|
1.1.37
by James Page
Import upstream version 2014.1~b3 |
371 |
${command_wrapper} ${coverage_run} $root/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings $testopts |
1.1.9
by Chuck Short
Import upstream version 2012.1~rc1~20120308.1479 |
372 |
# get results of the openstack_dashboard tests
|
373 |
DASHBOARD_RESULT=$? |
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
374 |
|
375 |
if [ $with_coverage -eq 1 ]; then |
|
376 |
echo "Generating coverage reports" |
|
1.1.41
by Chuck Short
Import upstream version 2014.2~b1 |
377 |
${command_wrapper} python -m coverage.__main__ combine |
378 |
${command_wrapper} python -m coverage.__main__ xml -i --include="horizon/*,openstack_dashboard/*" --omit='/usr*,setup.py,*egg*,.venv/*' |
|
379 |
${command_wrapper} python -m coverage.__main__ html -i --include="horizon/*,openstack_dashboard/*" --omit='/usr*,setup.py,*egg*,.venv/*' -d reports |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
380 |
fi
|
1.1.6
by Chuck Short
Import upstream version 2012.1~e4~20120217.1354 |
381 |
# Remove the leftover coverage files from the -p flag earlier.
|
382 |
rm -f .coverage.* |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
383 |
|
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
384 |
PEP8_RESULT=0 |
385 |
if [ $no_pep8 -eq 0 ] && [ $only_selenium -eq 0 ]; then |
|
386 |
run_pep8 |
|
387 |
PEP8_RESULT=$? |
|
388 |
fi
|
|
389 |
||
390 |
TEST_RESULT=$(($HORIZON_RESULT || $DASHBOARD_RESULT || $PEP8_RESULT)) |
|
391 |
if [ $TEST_RESULT -eq 0 ]; then |
|
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
392 |
echo "Tests completed successfully." |
393 |
else
|
|
394 |
echo "Tests failed." |
|
395 |
fi
|
|
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
396 |
exit $TEST_RESULT |
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
397 |
}
|
398 |
||
1.1.37
by James Page
Import upstream version 2014.1~b3 |
399 |
function run_integration_tests { |
400 |
export INTEGRATION_TESTS=1 |
|
401 |
||
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
402 |
if [ $selenium_headless -eq 1 ]; then |
403 |
export SELENIUM_HEADLESS=1 |
|
404 |
fi
|
|
405 |
||
1.1.37
by James Page
Import upstream version 2014.1~b3 |
406 |
echo "Running Horizon integration tests..." |
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
407 |
if [ -z "$testargs" ]; then |
408 |
${command_wrapper} nosetests openstack_dashboard/test/integration_tests/tests |
|
409 |
else
|
|
410 |
${command_wrapper} nosetests $testargs |
|
411 |
fi
|
|
1.1.37
by James Page
Import upstream version 2014.1~b3 |
412 |
exit 0 |
413 |
}
|
|
414 |
||
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
415 |
function run_makemessages { |
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
416 |
OPTS="-l en --no-obsolete --settings=openstack_dashboard.test.settings" |
1.1.38
by James Page
Import upstream version 2014.1~rc1 |
417 |
DASHBOARD_OPTS="--extension=html,txt,csv --ignore=openstack" |
1.1.31
by James Page
Import upstream version 2013.2~rc1 |
418 |
echo -n "horizon: " |
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
419 |
cd horizon
|
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
420 |
${command_wrapper} $root/manage.py makemessages $OPTS |
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
421 |
HORIZON_PY_RESULT=$? |
1.1.31
by James Page
Import upstream version 2013.2~rc1 |
422 |
echo -n "horizon javascript: " |
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
423 |
${command_wrapper} $root/manage.py makemessages -d djangojs $OPTS |
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
424 |
HORIZON_JS_RESULT=$? |
1.1.31
by James Page
Import upstream version 2013.2~rc1 |
425 |
echo -n "openstack_dashboard: " |
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
426 |
cd ../openstack_dashboard
|
1.1.35
by Chuck Short
Import upstream version 2014.1~b1 |
427 |
${command_wrapper} $root/manage.py makemessages $DASHBOARD_OPTS $OPTS |
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
428 |
DASHBOARD_RESULT=$? |
429 |
cd ..
|
|
1.2.5
by Corey Bryant
Import upstream version 2015.1~b1 |
430 |
if [ $check_only -eq 1 ]; then |
431 |
git checkout -- horizon/locale/en/LC_MESSAGES/django*.po |
|
432 |
git checkout -- openstack_dashboard/locale/en/LC_MESSAGES/django.po |
|
433 |
fi
|
|
1.1.17
by Chuck Short
Import upstream version 2012.2~f3 |
434 |
exit $(($HORIZON_PY_RESULT || $HORIZON_JS_RESULT || $DASHBOARD_RESULT)) |
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
435 |
}
|
436 |
||
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
437 |
function run_compilemessages { |
438 |
cd horizon
|
|
0.11.3
by James Page
Import upstream version 2015.1~rc1 |
439 |
${command_wrapper} $root/manage.py compilemessages |
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
440 |
HORIZON_PY_RESULT=$? |
441 |
cd ../openstack_dashboard
|
|
0.11.3
by James Page
Import upstream version 2015.1~rc1 |
442 |
${command_wrapper} $root/manage.py compilemessages |
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
443 |
DASHBOARD_RESULT=$? |
444 |
cd ..
|
|
1.1.38
by James Page
Import upstream version 2014.1~rc1 |
445 |
# English is the source language, so compiled catalogs are unnecessary.
|
446 |
rm -vf horizon/locale/en/LC_MESSAGES/django*.mo |
|
447 |
rm -vf openstack_dashboard/locale/en/LC_MESSAGES/django.mo |
|
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
448 |
exit $(($HORIZON_PY_RESULT || $DASHBOARD_RESULT)) |
449 |
}
|
|
450 |
||
1.2.6
by Corey Bryant
Import upstream version 2015.1~b2 |
451 |
function run_pseudo { |
452 |
for lang in $testargs |
|
453 |
# Use English po file as the source file/pot file just like real Horizon translations
|
|
454 |
do
|
|
455 |
${command_wrapper} $root/tools/pseudo.py openstack_dashboard/locale/en/LC_MESSAGES/django.po openstack_dashboard/locale/$lang/LC_MESSAGES/django.po $lang |
|
456 |
${command_wrapper} $root/tools/pseudo.py horizon/locale/en/LC_MESSAGES/django.po horizon/locale/$lang/LC_MESSAGES/django.po $lang |
|
457 |
${command_wrapper} $root/tools/pseudo.py horizon/locale/en/LC_MESSAGES/djangojs.po horizon/locale/$lang/LC_MESSAGES/djangojs.po $lang |
|
458 |
done
|
|
459 |
exit $? |
|
460 |
}
|
|
461 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
462 |
|
463 |
# ---------PREPARE THE ENVIRONMENT------------ #
|
|
464 |
||
465 |
# PROCESS ARGUMENTS, OVERRIDE DEFAULTS
|
|
466 |
for arg in "$@"; do |
|
467 |
process_option $arg
|
|
468 |
done
|
|
469 |
||
1.1.3
by Chuck Short
Import upstream version 2012.1~e3~20120113.1213 |
470 |
if [ $quiet -eq 1 ] && [ $never_venv -eq 0 ] && [ $always_venv -eq 0 ] |
471 |
then
|
|
472 |
always_venv=1 |
|
473 |
fi
|
|
474 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
475 |
# If destroy is set, just blow it away and exit.
|
476 |
if [ $destroy -eq 1 ]; then |
|
477 |
destroy_venv |
|
478 |
exit 0 |
|
479 |
fi
|
|
480 |
||
481 |
# Ignore all of this if the -N flag was set
|
|
482 |
if [ $never_venv -eq 0 ]; then |
|
483 |
||
484 |
# Restore previous environment if desired
|
|
485 |
if [ $restore_env -eq 1 ]; then |
|
486 |
restore_environment |
|
487 |
fi
|
|
488 |
||
489 |
# Remove the virtual environment if --force used
|
|
490 |
if [ $force -eq 1 ]; then |
|
491 |
destroy_venv |
|
492 |
fi
|
|
493 |
||
494 |
# Then check if it's up-to-date
|
|
495 |
environment_check |
|
496 |
||
497 |
# Create a backup of the up-to-date environment if desired
|
|
498 |
if [ $backup_env -eq 1 ]; then |
|
499 |
backup_environment |
|
500 |
fi
|
|
501 |
fi
|
|
502 |
||
503 |
# ---------EXERCISE THE CODE------------ #
|
|
504 |
||
1.1.14
by Chuck Short
Import upstream version 2012.2~f1 |
505 |
# Run management commands
|
506 |
if [ $manage -eq 1 ]; then |
|
507 |
run_management_command |
|
508 |
exit $? |
|
509 |
fi
|
|
510 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
511 |
# Build the docs
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
512 |
if [ $just_docs -eq 1 ]; then |
513 |
run_sphinx |
|
514 |
exit $? |
|
515 |
fi
|
|
516 |
||
1.1.10
by Adam Gandelman
Import upstream version 2012.1~rc1~20120315.1545 |
517 |
# Update translation files
|
518 |
if [ $makemessages -eq 1 ]; then |
|
519 |
run_makemessages |
|
520 |
exit $? |
|
521 |
fi
|
|
522 |
||
1.1.20
by Chuck Short
Import upstream version 2012.2~rc2 |
523 |
# Compile translation files
|
524 |
if [ $compilemessages -eq 1 ]; then |
|
525 |
run_compilemessages |
|
526 |
exit $? |
|
527 |
fi
|
|
528 |
||
1.2.6
by Corey Bryant
Import upstream version 2015.1~b2 |
529 |
# Generate Pseudo translation
|
530 |
if [ $pseudo -eq 1 ]; then |
|
531 |
run_pseudo |
|
532 |
exit $? |
|
533 |
fi
|
|
534 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
535 |
# PEP8
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
536 |
if [ $just_pep8 -eq 1 ]; then |
537 |
run_pep8 |
|
538 |
exit $? |
|
539 |
fi
|
|
540 |
||
1.1.43
by James Page
Import upstream version 2014.2~b3 |
541 |
if [ $just_pep8_changed -eq 1 ]; then |
542 |
run_pep8_changed |
|
543 |
exit $? |
|
544 |
fi
|
|
545 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
546 |
# Pylint
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
547 |
if [ $just_pylint -eq 1 ]; then |
548 |
run_pylint |
|
549 |
exit $? |
|
550 |
fi
|
|
551 |
||
1.1.42
by Chuck Short
Import upstream version 2014.2~b2 |
552 |
# Jshint
|
553 |
if [ $just_jshint -eq 1 ]; then |
|
554 |
run_jshint |
|
555 |
exit $? |
|
556 |
fi
|
|
557 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
558 |
# Tab checker
|
559 |
if [ $just_tabs -eq 1 ]; then |
|
560 |
tab_check |
|
561 |
exit $? |
|
562 |
fi
|
|
563 |
||
1.1.37
by James Page
Import upstream version 2014.1~b3 |
564 |
# Integration tests
|
565 |
if [ $integration -eq 1 ]; then |
|
566 |
run_integration_tests |
|
567 |
exit $? |
|
568 |
fi
|
|
569 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
570 |
# Django development server
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
571 |
if [ $runserver -eq 1 ]; then |
572 |
run_server |
|
573 |
exit $? |
|
574 |
fi
|
|
575 |
||
2
by Jamie Strandboge, Chuck Short, Jamie Strandboge
[ Chuck Short ] |
576 |
# Full test suite
|
1
by Jamie Strandboge
Import upstream version 2012.1~e1 |
577 |
run_tests || exit |