Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Add a test for loading tests asynchronously
[qunit.git] / grunt.js
index 9c6ce6c..ad60639 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -1,58 +1,84 @@
 /*global config:true, task:true*/
 module.exports = function( grunt ) {
 
+grunt.loadNpmTasks( "grunt-git-authors" );
+
 grunt.initConfig({
        pkg: '<json:package.json>',
        qunit: {
                // TODO include 'test/logs.html' as well
-               files: ['test/index.html']
+               qunit: 'test/index.html',
+               addons: [
+                       'addons/canvas/canvas.html',
+                       'addons/close-enough/close-enough.html',
+                       'addons/composite/composite-demo-test.html'
+               ],
+               async: 'test/async.html'
        },
        lint: {
                qunit: 'qunit/qunit.js',
+               addons: 'addons/**.js',
                grunt: 'grunt.js'
-               // TODO need to figure out which warnings to fix and which to disable
-               // tests: 'test/*.js'
+               // TODO fix remaining warnings
+               // tests: 'test/**.js'
        },
-       jshint: {
-               qunit: {
-                       options: {
-                               onevar: true,
-                               browser: true,
-                               bitwise: true,
-                               curly: true,
-                               trailing: true,
-                               immed: true,
-                               latedef: false,
-                               newcap: true,
-                               noarg: false,
-                               noempty: true,
-                               nonew: true,
-                               sub: true,
-                               undef: true,
-                               eqnull: true,
-                               proto: true
-                       },
-                       globals: {
-                               jQuery: true,
-                               exports: true
-                       }
-               },
-               tests: {
-                       tests: {
-                               globals: {
-                                       module: true,
-                                       test: true,
-                                       ok: true,
-                                       equal: true,
-                                       deepEqual: true,
-                                       QUnit: true
-                               }
-                       }
+       // TODO rmeove this one 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;
                }
+
+               return {
+                       addons: parserc( "addons/" ),
+                       qunit: parserc( "qunit/" ),
+                       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 );
        }
+       grunt.file.copy( "qunit/qunit.css", "dist/qunit-git.css", {
+               process: processor
+       });
+       grunt.file.copy( "qunit/qunit.js", "dist/qunit-git.js", {
+               process: processor
+       });
+});
+
+grunt.registerTask( "testswarm", function( commit, configFile ) {
+       var testswarm = require( "testswarm" ),
+               config = grunt.file.readJSON( configFile ).qunit;
+       testswarm({
+               url: config.swarmUrl,
+               pollInterval: 10000,
+               timeout: 1000 * 60 * 30,
+               done: this.async()
+       }, {
+               authUsername: "qunit",
+               authToken: config.authToken,
+               jobName: 'QUnit commit #<a href="https://github.com/jquery/qunit/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
+               runMax: config.runMax,
+               "runNames[]": "QUnit",
+               "runUrls[]": config.testUrl + commit + "/test/index.html",
+               "browserSets[]": ["popular"]
+       });
 });
 
-// Default task.
 grunt.registerTask('default', 'lint qunit');
 
 };

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf