Moving linting and unit tests to gulp, they can still be called via grunt

This commit is contained in:
sebv 2015-02-06 15:25:01 +08:00
Родитель c2a879d27b
Коммит fb33d0d2ce
9 изменённых файлов: 87 добавлений и 74 удалений

Просмотреть файл

@ -1,8 +1,7 @@
{
"excludeFiles": ["submodules/**", "node_modules/**",
"./lib/server/static/**", "./lib/devices/firefoxos/atoms/*.js",
"./test/harmony/**/*.js", "./sample-code/**",
"./sample-code/apps/**", "./sample-code/examples/php/vendor/**"],
"./sample-code/**"],
"requireCurlyBraces": ["for", "while", "do", "try", "catch"],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch",
"return", "try", "catch", "function"],

5
.jshintignore Normal file
Просмотреть файл

@ -0,0 +1,5 @@
submodules
node_modules
lib/server/static
lib/devices/firefoxos/atoms

Просмотреть файл

@ -23,67 +23,12 @@ var path = require('path')
, setGitRev = gruntHelpers.setGitRev
, getGitRev = require('./lib/helpers').getGitRev;
var GULP_BIN = 'node_modules/.bin/gulp';
module.exports = function (grunt) {
grunt.initConfig({
jshint: {
options: {
laxcomma: true
, node: true
, strict: true
, indent: 2
, undef: true
, unused: true
, eqeqeq: true
},
files: {
src: ['*.js', './**/*.js'],
options: {
ignores: ['./submodules/**/*.js', './node_modules/**/*.js', './sample-code/**/*.js', './test/**/*.js', './lib/server/static/**/*.js', './lib/devices/firefoxos/atoms/*.js', './lib/devices/ios/uiauto/**/*.js']
}
},
test: {
src: ['test/**/*.js']
, options: {
ignores: ['./test/harmony/**/*.js', './test/functional/_joined/*.js']
, expr: true
, globals: {
'describe': true
, 'it': true
, 'before': true
, 'after': true
, 'beforeEach': true
, 'afterEach': true
}
}
},
examples: {
src: ['sample-code/examples/node/**/*.js']
, options: {
expr: true
, globals: {
'describe': true
, 'it': true
, 'before': true
, 'after': true
, 'beforeEach': true
, 'afterEach': true
}
}
}
}
, jscs: {
files: [
'**/*.js', '!submodules/**', '!node_modules/**',
'!lib/server/static/**', '!lib/devices/firefoxos/atoms/*.js',
'!test/harmony/**/*.js', '!sample-code/examples/node/**/*-yiewd.js',
'!sample-code/apps/**', '!sample-code/examples/php/vendor/**'],
options: {
config: ".jscs.json"
}
}
, mochaTest: {
unit: ['test/unit/*.js']
, appiumutils: ['test/functional/appium/appiumutils.js']
mochaTest: {
appiumutils: ['test/functional/appium/appiumutils.js']
}
, mochaTestConfig: {
options: {
@ -92,15 +37,21 @@ module.exports = function (grunt) {
}
}
, maxBuffer: 2000 * 1024
, exec: {
'gulp-test-unit': GULP_BIN + ' test-unit --color',
'gulp-jshint': GULP_BIN + ' jshint --color',
'gulp-jscs': GULP_BIN + ' jscs --color',
'gulp-lint': GULP_BIN + ' lint --color'
},
});
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks("grunt-jscs");
grunt.registerTask('lint', ['newer:jshint','jscs']);
grunt.registerTask('test', 'mochaTest:unit');
grunt.registerTask('unit', 'mochaTest:unit');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('jshint', 'exec:gulp-jshint');
grunt.registerTask('jscs', 'exec:gulp-jscs');
grunt.registerTask('lint', 'exec:gulp-lint');
grunt.registerTask('test', 'exec:gulp-test-unit');
grunt.registerTask('unit', 'exec:gulp-test-unit');
grunt.registerTask('default', ['test']);
grunt.registerTask('travis', ['jshint','jscs', 'unit']);
grunt.registerTask('buildApp', "Build the test app", function (appDir, sdk) {

43
gulpfile.js Normal file
Просмотреть файл

@ -0,0 +1,43 @@
"use strict";
var gulp = require('gulp'),
path = require('path'),
mochaStream = require('spawn-mocha-parallel').mochaStream,
jshint = require('gulp-jshint'),
jshintStylish = require('jshint-stylish'),
jscs = require('gulp-jscs');
var mochaOpts = {
flags: {
u: 'bdd-with-opts',
R: 'nyan'
},
bin: path.join(__dirname, 'node_modules/.bin/mocha'),
concurrency: 5
};
var JS_SOURCES = ['*.js', 'bin/**/*.js', 'ci/**/*.js', 'new-ci/**/*.js', 'lib/**/*.js', 'test/**/*.js'];
gulp.task('jshint', function () {
return gulp.src(JS_SOURCES)
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', function () {
return gulp.src(JS_SOURCES)
.pipe(jscs({configPath: __dirname + '/.jscsrc'}));
});
gulp.task('lint', ['jshint', 'jscs']);
gulp.task('test-unit', function () {
var opts = mochaOpts;
var mocha = mochaStream(opts);
return gulp.src('test/unit/**/*-specs.js', {read: false})
.pipe(mocha)
.on('error', console.warn.bind(console));
});
gulp.task('default', ['test-unit']);

Просмотреть файл

@ -104,23 +104,31 @@
"test": "grunt travis"
},
"devDependencies": {
"assert": "~1.1.1",
"assert": "~1.3.0",
"bdd-with-opts": "^1.0.0",
"chai": "~1.10.0",
"chai-as-promised": "~4.1.1",
"gps-demo-app": "https://github.com/appium/gps-demo-app/archive/master.tar.gz",
"grunt-contrib-jshint": "~0.10.0",
"grunt-jscs": "~1.2",
"grunt-contrib-jshint": "~0.11.0",
"grunt-exec": "^0.4.6",
"grunt-mocha-test": "~0.12.3",
"grunt-newer": "~0.8.0",
"grunt-newer": "~1.1.0",
"gulp": "^3.8.10",
"gulp-jscs": "^1.4.0",
"gulp-jshint": "^1.9.2",
"gulp-util": "^3.0.3",
"js-yaml": "~3.2.3",
"mocha": "~2.0.1",
"jshint-stylish": "^1.0.0",
"merge-stream": "^0.1.7",
"mocha": "~2.1.0",
"monocle-js": "~1.0.0",
"node-static": "~0.7.3",
"saucelabs": "~0.1.1",
"sinon": "~1.12.0",
"sinon-chai": "~2.6.0",
"socket.io-client": "~1.2.1",
"socket.io-client": "~1.3.3",
"socks": "~0.0.1",
"spawn-mocha-parallel": "^1.0.0",
"underscore-cli": "~0.2.17",
"unorm": "~1.3.3",
"wd": "~0.3.8",

Просмотреть файл

@ -7,7 +7,6 @@
"node": true,
"eqeqeq": true,
"trailing": true,
"es5": true,
"expr": true,
"white": true,
"indent": 2,

Просмотреть файл

@ -2,8 +2,11 @@
var common = require('../../lib/devices/common.js')
, checkValidLocStrat = common.checkValidLocStrat
, chai = require('chai')
, _ = require('underscore');
chai.should();
describe('devices/common.js', function () {
var nullCb = function () {};

Просмотреть файл

@ -1,8 +1,11 @@
"use strict";
var getAppium = require('../../lib/appium')
, chai = require('chai')
, _ = require('underscore');
chai.should();
var assertCapsGiveCorrectDevices = function (appium, args) {
var spec = 'should turn ' + JSON.stringify(args[0]) + ' args and ' +
JSON.stringify(args[1]) + ' caps into ' + args[2] + ' device';

2
trigger.txt Normal file
Просмотреть файл

@ -0,0 +1,2 @@
This is used to test github webhooks.
1