Merge "Add jshint for javascript linting"

This commit is contained in:
Jenkins 2014-05-29 13:10:08 +00:00 committed by Gerrit Code Review
commit 339a8d3450
4 changed files with 50 additions and 2 deletions

View File

@ -1,5 +1,5 @@
Contributing
------------
============
The code repository is located at `OpenStack <https://github.com/openstack>`__.
Please go there if you want to check it out:
@ -24,6 +24,34 @@ If you're interested in the code, here are some key places to start:
* `tuskar_ui/infrastructure <https://github.com/openstack/tuskar-ui/tree/master/tuskar_ui/infrastructure>`_
- The Tuskar UI code is contained within this directory.
Running tests
=============
There are several ways to run tests for tuskar-ui.
Using ``tox``:
This is the easiest way to run tests. When run, tox installs dependencies,
prepares the virtual python environment, then runs test commands. The gate
tests in gerrit usually also use tox to run tests. For avaliable tox
environments, see ``tox.ini``.
By running ``run_tests.sh``:
Tests can also be run using the ``run_tests.sh`` script, to see available
options, run it with the ``--help`` option. It handles preparing the
virtual environment and executing tests, but in contrast with tox, it does
not install all dependencies, e.g. ``jshint`` must be installed before
running the jshint testcase.
Manual tests:
To manually check tuskar-ui, it is possible to run a development server
for tuskar-ui by running ``run_tests.sh --runserver``.
To run the server with the settings used by the test environment:
``run_tests.sh --runserver 0.0.0.0:8000 --settings=tuskar_ui.test.settings``
OpenStack Style Commandments
============================

View File

@ -27,6 +27,7 @@ function usage {
echo " -p, --pep8 Just run pep8"
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"
@ -63,6 +64,7 @@ just_pep8=0
just_pylint=0
just_docs=0
just_tabs=0
just_jshint=0
never_venv=0
quiet=0
restore_env=0
@ -94,6 +96,7 @@ function process_option {
-N|--no-virtual-env) always_venv=0; never_venv=1;;
-p|--pep8) just_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;;
@ -137,6 +140,11 @@ function run_pylint {
fi
}
function run_jshint {
echo "Running jshint ..."
jshint tuskar_ui/infrastructure/static/infrastructure
}
function run_pep8 {
echo "Running flake8 ..."
DJANGO_SETTINGS_MODULE=tuskar_ui.test.settings ${command_wrapper} flake8 $included_dirs
@ -438,6 +446,12 @@ if [ $just_tabs -eq 1 ]; then
exit $?
fi
# Jshint
if [ $just_jshint -eq 1 ]; then
run_jshint
exit $?
fi
# Django development server
if [ $runserver -eq 1 ]; then
run_server

View File

@ -5,6 +5,7 @@ coverage>=3.6
django-nose
mock>=1.0
mox>=0.5.3
nodeenv
nose
nose-exclude
nosexcover

View File

@ -1,5 +1,5 @@
[tox]
envlist = py26,py27,py27dj14,py27dj15,py27dj16,pep8
envlist = py26,py27,py27dj14,py27dj15,py27dj16,pep8,selenium,jshint
[testenv]
setenv = VIRTUAL_ENV={envdir}
@ -39,6 +39,11 @@ commands = pip install django>=1.6,<1.7
[testenv:selenium]
commands = /bin/bash run_tests.sh -N --only-selenium
[testenv:jshint]
commands = nodeenv -p
npm install jshint -g
/bin/bash run_tests.sh -N --jshint
[tox:jenkins]
downloadcache = ~/cache/pip