Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #377 - Build: Upgraded to Grunt 0.4.0 #423

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
75 changes: 35 additions & 40 deletions grunt.js → 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: '<json:package.json>',
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: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work fine as files: [...], doesn't need the nested stuff. I might confuse something, but please give it a try. If it works, apply everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same thing ~1 week ago when I tried just what you said but it doesn't work... gives a nasty warning message:

Warning: Cannot use 'in' operator to search for 'src' in addons/**/*.js
Use --force to continue.

What you are thinking of can currently only be done as the value of a target without any options, etc. e.g.

tests: ['test/**/*.js']

Talked to @cowboy about it on IRC last week to confirm. At least 1 other Grunt collaborator thought that would be a great enhancement, though I forgot who... maybe @tkellen or @sindresorhus?

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
Expand Down Expand Up @@ -84,7 +79,7 @@ grunt.registerTask( "testswarm", function( commit, configFile ) {
} )
.addjob(
{
name: 'QUnit commit #<a href="https://github.com/jquery/qunit/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
name: "QUnit commit #<a href='https://github.com/jquery/qunit/commit/" + commit + "'>" + commit.substr( 0, 10 ) + "</a>",
runs: runs,
browserSets: config.browserSets
}, function( err, passed ) {
Expand All @@ -96,6 +91,6 @@ grunt.registerTask( "testswarm", function( commit, configFile ) {
);
});

grunt.registerTask('default', 'lint qunit');
grunt.registerTask("default", ["jshint", "qunit"]);

};
7 changes: 4 additions & 3 deletions addons/phantomjs/runner.js
Expand Up @@ -17,16 +17,17 @@
(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) {
console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite]');
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) {
Expand Down
11 changes: 8 additions & 3 deletions package.json
Expand Up @@ -29,9 +29,14 @@
"jquery"
],
"main": "qunit/qunit.js",
"scripts": {
"test": "grunt"
},
"devDependencies": {
"grunt": "~0.3.17",
"grunt-git-authors": "1.0.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"
}
}
1 change: 1 addition & 0 deletions test/test.js
Expand Up @@ -470,6 +470,7 @@ test("propEqual", 5, function( assert ) {
});

test("raises", 9, function() {
/*jshint es5:true */
function CustomError( message ) {
this.message = message;
}
Expand Down