From 74f5fafc126ab4ee78450b791a2bfa00e5db3ae6 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Thu, 7 Mar 2013 16:36:35 -0600 Subject: [PATCH 1/2] Build: Upgraded to Grunt 0.4.0. Fixes #377. --- qunit/.jshintrc => .jshintrc | 0 grunt.js => Gruntfile.js | 75 +++++++++++++++++------------------- addons/phantomjs/runner.js | 7 ++-- package.json | 10 ++++- test/test.js | 1 + 5 files changed, 48 insertions(+), 45 deletions(-) rename qunit/.jshintrc => .jshintrc (100%) rename grunt.js => Gruntfile.js (55%) diff --git a/qunit/.jshintrc b/.jshintrc similarity index 100% rename from qunit/.jshintrc rename to .jshintrc diff --git a/grunt.js b/Gruntfile.js similarity index 55% rename from grunt.js rename to Gruntfile.js index c28765cf0..adbf3bbca 100644 --- a/grunt.js +++ b/Gruntfile.js @@ -1,60 +1,55 @@ -/*global config:true, task:true*/ +/*jshint node:true */ module.exports = function( grunt ) { grunt.loadNpmTasks( "grunt-git-authors" ); +grunt.loadNpmTasks( "grunt-contrib-jshint" ); +grunt.loadNpmTasks( "grunt-contrib-qunit" ); grunt.initConfig({ - pkg: '', qunit: { qunit: [ - 'test/index.html', - 'test/async.html' + "test/index.html", + "test/async.html" // TODO figure out why this fails on our Jenkins server (Linux) - // 'test/logs.html' + //"test/logs.html" ], addons: [ - 'addons/canvas/canvas.html', - 'addons/close-enough/close-enough.html', - 'addons/composite/composite.html' + "addons/canvas/canvas.html", + "addons/close-enough/close-enough.html", + "addons/composite/composite.html" // TODO same as above - // 'addons/step/step.html' + // "addons/step/step.html" ] }, - lint: { - qunit: 'qunit/qunit.js', - addons: 'addons/**.js', - tests: 'test/**.js', - grunt: 'grunt.js' - }, - // TODO remove this once grunt 0.4 is out, see jquery-ui for other details - jshint: (function() { - function parserc( path ) { - var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ), - settings = { - options: rc, - globals: {} - }; - - (rc.predef || []).forEach(function( prop ) { - settings.globals[ prop ] = true; - }); - delete rc.predef; - - return settings; + jshint: { + options: { + jshintrc: ".jshintrc" + }, + gruntfile: [ "Gruntfile.js" ], + qunit: [ "qunit/**/*.js" ], + addons: { + options: { + jshintrc: "addons/.jshintrc" + }, + files: { + src: [ "addons/**/*.js" ] + } + }, + tests: { + options: { + jshintrc: "test/.jshintrc" + }, + files: { + src: [ "test/**/*.js" ] + } } - - return { - qunit: parserc( "qunit/" ), - addons: parserc( "addons/" ), - tests: parserc( "test/" ) - }; - })() + } }); grunt.registerTask( "build-git", function( sha ) { function processor( content ) { var tagline = " - A JavaScript Unit Testing Framework"; - return content.replace( tagline, "-" + sha + " " + grunt.template.today('isoDate') + tagline ); + return content.replace( tagline, "-" + sha + " " + grunt.template.today("isoDate") + tagline ); } grunt.file.copy( "qunit/qunit.css", "dist/qunit-git.css", { process: processor @@ -84,7 +79,7 @@ grunt.registerTask( "testswarm", function( commit, configFile ) { } ) .addjob( { - name: 'QUnit commit #' + commit.substr( 0, 10 ) + '', + name: "QUnit commit #" + commit.substr( 0, 10 ) + "", runs: runs, browserSets: config.browserSets }, function( err, passed ) { @@ -96,6 +91,6 @@ grunt.registerTask( "testswarm", function( commit, configFile ) { ); }); -grunt.registerTask('default', 'lint qunit'); +grunt.registerTask("default", ["jshint", "qunit"]); }; diff --git a/addons/phantomjs/runner.js b/addons/phantomjs/runner.js index 4b1d38b1b..ab0ca083a 100644 --- a/addons/phantomjs/runner.js +++ b/addons/phantomjs/runner.js @@ -17,7 +17,8 @@ (function() { 'use strict'; - var args = require('system').args; + var url, page, + args = require('system').args; // arg[0]: scriptName, args[1...]: arguments if (args.length !== 2) { @@ -25,8 +26,8 @@ phantom.exit(1); } - var url = args[1], - page = require('webpage').create(); + url = args[1]; + page = require('webpage').create(); // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`) page.onConsoleMessage = function(msg) { diff --git a/package.json b/package.json index 0d184e2b3..89b87b798 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,15 @@ "jquery" ], "main": "qunit/qunit.js", + "scripts": { + "test": "grunt" + }, "devDependencies": { - "grunt": "~0.3.17", - "grunt-git-authors": "1.0.0", + "grunt-cli": "0.1.6", + "grunt": "0.4.0", + "grunt-contrib-jshint": "0.2.0", + "grunt-contrib-qunit": "0.2.0", + "grunt-git-authors": "1.1.0", "testswarm": "1.0.1" } } diff --git a/test/test.js b/test/test.js index 69c665967..ecc4f0187 100644 --- a/test/test.js +++ b/test/test.js @@ -470,6 +470,7 @@ test("propEqual", 5, function( assert ) { }); test("raises", 9, function() { + /*jshint es5:true */ function CustomError( message ) { this.message = message; } From 756d35e3970eb6a7da43178ab1b4c9f5940392b6 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Fri, 8 Mar 2013 07:56:11 -0600 Subject: [PATCH 2/2] Build: Switched to tilde versions for dependencies --- package.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 89b87b798..346798aa3 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,10 @@ "test": "grunt" }, "devDependencies": { - "grunt-cli": "0.1.6", - "grunt": "0.4.0", - "grunt-contrib-jshint": "0.2.0", - "grunt-contrib-qunit": "0.2.0", - "grunt-git-authors": "1.1.0", - "testswarm": "1.0.1" + "grunt": "~0.4.0", + "grunt-contrib-jshint": "~0.2.0", + "grunt-contrib-qunit": "~0.2.0", + "grunt-git-authors": "~1.1.0", + "testswarm": "~1.0.1" } }