diff --git a/doc/source/ref/run_tests.rst b/doc/source/ref/run_tests.rst index 2127a0d2b1..55c3d56281 100644 --- a/doc/source/ref/run_tests.rst +++ b/doc/source/ref/run_tests.rst @@ -165,6 +165,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 -------------- diff --git a/run_tests.sh b/run_tests.sh index 2c8dffc191..1b054d5d4e 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -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 @@ -481,6 +490,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 diff --git a/test-requirements.txt b/test-requirements.txt index 36ba741236..6a1251670b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index 03d0225e85..78353fcf83 100644 --- a/tox.ini +++ b/tox.ini @@ -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