Add governance testing based on JSCS and consolidate test suite to makefile. Resolves GH-57

This commit is contained in:
Andrew Sliwinski 2014-04-09 01:17:04 -07:00
parent 623dce5402
commit 1bd49e4e49
5 changed files with 57 additions and 14 deletions

27
.jscsrc Normal file
View file

@ -0,0 +1,27 @@
{
"requireCurlyBraces": [
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"default"
],
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowEmptyBlocks": true,
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
"validateIndentation": 4,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"safeContextKeyword": "self"
}

20
makefile Normal file
View file

@ -0,0 +1,20 @@
JSCS_PATH = ./node_modules/.bin/jscs
KARMA_PATH = ./node_modules/.bin/karma
KARMA_CONFIG = ./test/fixtures/karma.conf.js
# Performs code governance (lint + style) test
lint:
@$(JSCS_PATH) ./js/*
@$(JSCS_PATH) ./test/unit/*
# Performs unit tests
unit:
@$(KARMA_PATH) start $(KARMA_CONFIG) $*
# Run all test targets
test:
@make lint
@make unit
# Ignore directory structure
.PHONY: lint unit test

View file

@ -2,10 +2,15 @@
"name": "scratch-html5",
"description": "HTML 5 based Scratch project player",
"repository": "https://github.com/LLK/scratch-html5",
"scripts": {
"test": "make test"
},
"dependencies": {},
"devDependencies": {
"karma" : "~0.10",
"jasmine-jquery" : "1.3.3",
"karma-html2js-preprocessor" : "~0.1.0",
"underscore" : "~1.6.0"
"jasmine-jquery": "~1.3.3",
"jscs": "~1.3.0",
"karma": "~0.10",
"karma-html2js-preprocessor": "~0.1.0",
"underscore": "~1.6.0"
}
}

View file

@ -1,9 +0,0 @@
#!/bin/bash
BASE_DIR=`dirname $0`
echo ""
echo "Starting Karma Server (http://karma-runner.github.io)"
echo "-------------------------------------------------------------------"
$BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma.conf.js $*

View file

@ -1,6 +1,6 @@
module.exports = function(config){
config.set({
basePath : '../',
basePath : '../../',
files : [
'test/artifacts/**/*.js',