Commit 32fbb020 by Andy Armstrong

Clean up build scripts

 - add a .jshintrc file
 - add a test-js target
 - make test scripts not use coverage by default
parent 94559a0f
// --------------------------------------------------------------------
// JSHint Configuration
// --------------------------------------------------------------------
//
// http://www.jshint.com/
// http://jshint.com/docs/options/
{
// == Enforcing Options ===============================================
"bitwise" : false, // Prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others. Bitwise operators are very rare in JavaScript programs and quite often & is simply a mistyped &&.
"camelcase" : false, // Allows you to force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly" : true, // Requires you to always put curly braces around blocks in loops and conditionals. JavaScript allows you to omit curly braces when the block consists of only one statement
"eqeqeq" : true, // Prohibits the use of == and != in favor of === and !==.
"es3" : false, // Tells JSHint that your code needs to adhere to ECMAScript 3 specification. Use this option if you need your program to be executable in older browsers—such as Internet Explorer 6/7/8/9.
"forin" : true, // Requires all for in loops to filter object's items.
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array, Date and so on.
"immed" : true, // Prohibits the use of immediate function invocations without wrapping them in parentheses.
// "indent" : 4, // Enforces specific tab width for your code. Has no effect when "white" option is not used.
"latedef" : "nofunc", // Prohibits the use of a variable before it was defined. Setting this option to "nofunc" will allow function declarations to be ignored.
"newcap" : true, // Requires you to capitalize names of constructor functions.
"noarg" : true, // Prohibits the use of arguments.caller and arguments.callee.
"noempty" : true, // Warns when you have an empty block in your code.
"nonbsp" : true, // Warns about "non-breaking whitespace" characters.
"nonew" : false, // Prohibits the use of constructor functions for side-effects.
"plusplus" : false, // Prohibits the use of unary increment and decrement operators.
"quotmark" : "single", // Enforces the consistency of quotation marks used throughout your code. It accepts three values: true, "single", and "double".
"undef" : true, // Prohibits the use of explicitly undeclared variables.
"unused" : true, // Warns when you define and never use your variables.
"strict" : true, // Requires all functions to run in ECMAScript 5's strict mode.
"trailing" : true, // Makes it an error to leave a trailing whitespace in your code.
"maxlen" : 120, // Lets you set the maximum length of a line.
//"maxparams" : 4, // Lets you set the max number of formal parameters allowed per function.
//"maxdepth" : 4, // Lets you control how nested do you want your blocks to be.
//"maxstatements" : 4, // Lets you set the max number of statements allowed per function.
//"maxcomplexity" : 4, // Lets you control cyclomatic complexity throughout your code.
// == Relaxing Options ================================================
"asi" : false, // Suppresses warnings about missing semicolons.
"boss" : false, // Suppresses warnings about the use of assignments in cases where comparisons are expected.
"debug" : false, // Suppresses warnings about the debugger statements in your code.
"eqnull" : false, // Suppresses warnings about == null comparisons.
"esnext" : false, // Tells JSHint that your code uses ECMAScript 6 specific syntax.
"evil" : false, // Suppresses warnings about the use of eval.
"expr" : false, // Suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls.
"funcscope" : false, // Suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
"gcl" : false, // Makes JSHint compatible with Google Closure Compiler.
"globalstrict" : false, // Suppresses warnings about the use of global strict mode.
"iterator" : false, // Suppresses warnings about the __iterator__ property.
"lastsemic" : false, // Suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block.
"laxbreak" : false, // Suppresses most of the warnings about possibly unsafe line breaks in your code.
"laxcomma" : false, // Suppresses warnings about comma-first coding style.
"loopfunc" : false, // Suppresses warnings about functions inside of loops.
"maxerr" : 100, // Set the maximum amount of warnings JSHint will produce before giving up.
"moz" : false, // Tells JSHint that your code uses Mozilla JavaScript extensions.
"notypeof" : false, // Suppresses warnings about invalid typeof operator values.
"proto" : false, // Suppresses warnings about the __proto__ property.
"scripturl" : false, // Suppresses warnings about the use of script-targeted URLs—such as javascript:...
"smarttabs" : false, // Suppresses warnings about mixed tabs and spaces when the latter are used for alignment only.
"shadow" : false, // Suppresses warnings about variable shadowing i.e. declaring a variable that had been already declared somewhere in the outer scope.
"sub" : false, // Suppresses warnings about using [] notation when it can be expressed in dot notation.
"supernew" : false, // Suppresses warnings about "weird" constructions like new function () { ... } and new Object;.
"validthis" : true, // Suppresses warnings about possible strict violations when the code is running in strict mode and you use this in a non-constructor function.
"noyield" : false, // Suppresses warnings about generator functions with no yield statement in them.
// == Environments ====================================================
//
// These options pre-define global variables that are exposed by
// popular JavaScript libraries and runtime environments—such as
// browser or node.js.
"browser" : true, // Defines globals exposed by modern browsers: all the way from good old document and navigator to the HTML5 FileReader and other new developments in the browser world.
"devel" : true, // Defines globals that are usually used for logging poor-man's debugging: console, alert, etc.
// The rest should remain `false`. Please see explanation for the "predef" parameter below.
"couch" : false, // Defines globals exposed by CouchDB.
"dojo" : false, // Defines globals exposed by the Dojo Toolkit
"jquery" : false, // Defines globals exposed by the jQuery JavaScript library.
"mootools" : false, // Defines globals exposed by the MooTools JavaScript framework.
"node" : true, // Defines globals available when your code is running inside of the Node runtime environment.
"nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape.
"phantom" : false, // Defines globals available when your core is running inside of the PhantomJS runtime environment.
"prototypejs" : false, // Defines globals exposed by the Prototype JavaScript framework.
"rhino" : false, // Defines globals available when your code is running inside of the Rhino runtime environment.
"worker" : false, // Defines globals available when your code is running inside of a Web Worker.
"wsh" : false, // Defines globals available when your code is running as a script for the Windows Script Host.
"yui" : false, // Defines globals exposed by the YUI JavaScript framework.
// == JSLint Legacy ===================================================
//
// These options are legacy from JSLint. Aside from bug fixes they will
// not be improved in any way and might be removed at any point.
// "nomen" : false, // Disallows the use of dangling _ in variables.
// "onevar" : false, // Allows only one var statement per function.
// "passfail" : false, // Makes JSHint stop on the first error or warning.
// "white" : false, // make JSHint check your source code against Douglas Crockford's JavaScript coding style.
// == Undocumented Options ============================================
//
// If you are using some global variable, for example `define`, or `$`, please
// make it available within your JS file by passing it to the wrapper anonymous
// function like so:
//
// (function (define, $) {
// 'use strict';
// // Your content goes here which uses `define`, and `$`.
// }).call(this, window.define, window.jQuery);
//
// The parameter "predef" should remain empty for this configuration file
// to remain as general as possible.
"predef": [
// jQuery library.
"jQuery", "$",
// Underscore.js library.
"_",
// Backbone.js library.
"Backbone",
// require Library
"require",
"requirejs",
"RequireJS",
"define",
// Jasmine library.
"jasmine",
"describe", "xdescribe",
"it", "xit",
"spyOn",
"beforeEach",
"afterEach",
"expect",
"waitsFor",
"runs",
// jQuery-Jasmine library.
"loadFixtures",
"appendLoadFixtures",
"readFixtures",
"setFixtures",
"appendSetFixtures",
"spyOnEvent"
]
}
\ No newline at end of file
...@@ -48,3 +48,6 @@ install: install-wheels install-python install-js install-nltk-data install-test ...@@ -48,3 +48,6 @@ install: install-wheels install-python install-js install-nltk-data install-test
test: test:
./scripts/test.sh ./scripts/test.sh
test-js:
./scripts/test-js.sh
...@@ -11,7 +11,7 @@ module.exports = function(config) { ...@@ -11,7 +11,7 @@ module.exports = function(config) {
'karma-coverage', 'karma-coverage',
'karma-jasmine', 'karma-jasmine',
'karma-chrome-launcher', 'karma-chrome-launcher',
'karma-phantomjs-launcher', 'karma-phantomjs-launcher'
], ],
// frameworks to use // frameworks to use
...@@ -36,7 +36,7 @@ module.exports = function(config) { ...@@ -36,7 +36,7 @@ module.exports = function(config) {
{ {
pattern: 'fixtures/*.html', pattern: 'fixtures/*.html',
served: true, included: false served: true, included: false
}, }
], ],
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
cd `dirname $BASH_SOURCE` && cd .. cd `dirname $BASH_SOURCE` && cd ..
echo "Generating HTML fixtures for JavaScript tests..." echo "Generating HTML fixtures for JavaScript tests..."
export DJANGO_SETTINGS_MODULE="settings.test" export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-"settings.test"}
./scripts/render_templates.py openassessment/xblock/static/js/fixtures/templates.json ./scripts/render_templates.py openassessment/xblock/static/js/fixtures/templates.json
echo "Running JavaScript tests..." echo "Running JavaScript tests..."
......
...@@ -6,5 +6,5 @@ cd `dirname $BASH_SOURCE` && cd .. ...@@ -6,5 +6,5 @@ cd `dirname $BASH_SOURCE` && cd ..
git clean -xfd "./storage/test/" git clean -xfd "./storage/test/"
echo "Running Python tests..." echo "Running Python tests..."
export DJANGO_SETTINGS_MODULE="settings.test" export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-"settings.test"}
python manage.py test $1 python manage.py test $1
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
set -e set -e
cd `dirname $BASH_SOURCE` && cd .. cd `dirname $BASH_SOURCE` && cd ..
export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-"settings.test_with_coverage"}
./scripts/test-python.sh $1 ./scripts/test-python.sh $1
./scripts/test-js.sh ./scripts/test-js.sh
./scripts/build-docs.sh ./scripts/build-docs.sh
...@@ -9,7 +9,7 @@ make install-js ...@@ -9,7 +9,7 @@ make install-js
make javascript make javascript
# Configure Django settings # Configure Django settings
export DJANGO_SETTINGS_MODULE="settings.dev" export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-"settings.dev"}
# Create the database # Create the database
echo "Updating the database..." echo "Updating the database..."
......
...@@ -15,10 +15,6 @@ TEST_APPS = ( ...@@ -15,10 +15,6 @@ TEST_APPS = (
# Configure nose # Configure nose
NOSE_ARGS = [ NOSE_ARGS = [
"-a !acceptance", "-a !acceptance",
'--with-coverage',
'--cover-package=' + ",".join(TEST_APPS),
'--cover-branches',
'--cover-erase',
] ]
DATABASES = { DATABASES = {
......
"""
Django settings for running tests with coverage.
"""
# Inherit from the test settings
from .test import * # pylint:disable=W0614,W0401
# Configure nose so that tests are run with coverage
NOSE_ARGS = [
"-a !acceptance",
'--with-coverage',
'--cover-package=' + ",".join(TEST_APPS),
'--cover-branches',
'--cover-erase',
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment