Add jshint for javascript linting

Added nodeenv as a test requirement.

Added a jshint environment to tox.ini, which installs node.js into the
python virtual environment with nodeenv, installs jshint using npm,
and calls runtest.sh to run the tests.

runtest.sh now supports the -j|--jshint flags to run jshint on the
javascript files. jshint must be installed before running runtest.sh

The documentation also got updated to include some info about jshint.

This patch does not add jshint to the OpenStack codebase, just provides
a way to install it for testing, to avoid license clash (jshint has a
slightly modified MIT license, which is incompatible with OpenStack's
Apache license).

Change-Id: I9dd0743eaee50fdba3dbb527c29f2501bdd44ca6
Implements: blueprint node-toolchain
Implements: blueprint jshint-codestyle
This commit is contained in:
Peter Belanyi 2014-06-04 15:35:06 +02:00
parent 108898e7d3
commit 0a83ae972e
4 changed files with 30 additions and 0 deletions

View File

@ -160,6 +160,15 @@ For more detailed code analysis you can run::
The output will be saved in ``./pylint.txt``.
JsHint
------
For code analysis of JavaScript files::
./run_tests.sh --jshint
You need to have jshint installed before running the command.
Tab Characters
--------------

View File

@ -28,6 +28,7 @@ function usage {
echo " -P, --no-pep8 Don't run pep8 by default"
echo " -t, --tabs Check for tab characters in files."
echo " -y, --pylint Just run pylint"
echo " -j, --jshint Just run jshint"
echo " -q, --quiet Run non-interactively. (Relatively) quiet."
echo " Implies -V if -N is not set."
echo " --only-selenium Run only the Selenium unit tests"
@ -67,6 +68,7 @@ no_pep8=0
just_pylint=0
just_docs=0
just_tabs=0
just_jshint=0
never_venv=0
quiet=0
restore_env=0
@ -98,6 +100,7 @@ function process_option {
-p|--pep8) just_pep8=1;;
-P|--no-pep8) no_pep8=1;;
-y|--pylint) just_pylint=1;;
-j|--jshint) just_jshint=1;;
-f|--force) force=1;;
-t|--tabs) just_tabs=1;;
-q|--quiet) quiet=1;;
@ -142,6 +145,12 @@ function run_pylint {
fi
}
function run_jshint {
echo "Running jshint ..."
jshint horizon/static/horizon/js
jshint horizon/static/horizon/tests
}
function run_pep8 {
echo "Running flake8 ..."
set +o errexit
@ -477,6 +486,12 @@ if [ $just_pylint -eq 1 ]; then
exit $?
fi
# Jshint
if [ $just_jshint -eq 1 ]; then
run_jshint
exit $?
fi
# Tab checker
if [ $just_tabs -eq 1 ]; then
tab_check

View File

@ -3,6 +3,7 @@ django-nose
docutils==0.9.1
hacking>=0.8.0,<0.9
mox>=0.5.3
nodeenv>=0.9.4
nose
nose-exclude
nosehtmloutput>=0.0.3

View File

@ -44,6 +44,11 @@ commands = /bin/bash run_tests.sh -N --integration {posargs}
basepython = python2.6
commands = /bin/bash run_tests.sh -N --integration {posargs}
[testenv:jshint]
commands = nodeenv -p
npm install jshint -g
/bin/bash run_tests.sh -N --jshint
[testenv:docs]
setenv = DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings
commands = python setup.py build_sphinx