Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ module.exports = function (grunt) {
files : {
'tmp/casper/testIncludes-results.xml' : ['test/fixtures/includes/testIncludes.js']
}
}
},
folder : {
options : {
includes : 'test/fixtures/includes/inc.js'
},
folder : 'test/folder-test/'
}
},

clean : {
Expand Down
97 changes: 52 additions & 45 deletions tasks/casper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = function (grunt) {
//Once Current Task is complete
//Log Duration and Finish
function taskComplete(error) {

var msg = "Casper Task '" + taskName + "' took ~" + new Duration(startTime).milliseconds + "ms to run";
grunt.log.success(msg);
if (error) {
Expand All @@ -31,56 +30,64 @@ module.exports = function (grunt) {
}

grunt.verbose.writeflags(args, 'Arguments');
if(this.files.length > 0) {
grunt.util.async.forEachSeries(this.files, function(file, iteratorCb) {

grunt.util.async.forEachSeries(this.files, function(file, iteratorCb) {
if (file.src.length) {

if (file.src.length) {
//Allow Files in each task to be run concurrently
if (options.parallel) {
//Don't Pass this through to spawn
delete options.parallel;
//https://github.com/gruntjs/grunt-contrib-sass/issues/16
//Set Default Concurrency at 5 (Supposed Memory Leak > 10)
var concurrency = 5;
if (options.concurrency) {
if (options.concurrency > 10 ) {
grunt.verbose.writeln('Concurrency Too High. Max 10, updating to 10.');
concurrency = 10;
} else if (options.concurrency < 1) {
grunt.verbose.writeln('Concurrency Too Low. Min 1, updating to default 5.');
} else {
concurrency = options.concurrency;
}
//Allow Files in each task to be run concurrently
if (options.parallel) {
//Don't Pass this through to spawn
delete options.concurrency;
}
//Run Tests In Parallel
if (file.src) {
grunt.util.async.forEachLimit(file.src, concurrency, function(srcFile, next) {
//Spawn Child Process
casperLib.execute(srcFile, file.dest !== 'src' ? file.dest : null, options, args, next);
}, function(err) {
if (err) grunt.log.write('error:', err);
//Call Done and Log Duration
iteratorCb(err);
});
}
} else {
delete options.parallel;
//https://github.com/gruntjs/grunt-contrib-sass/issues/16
//Set Default Concurrency at 5 (Supposed Memory Leak > 10)
var concurrency = 5;
if (options.concurrency) {
if (options.concurrency > 10 ) {
grunt.verbose.writeln('Concurrency Too High. Max 10, updating to 10.');
concurrency = 10;
} else if (options.concurrency < 1) {
grunt.verbose.writeln('Concurrency Too Low. Min 1, updating to default 5.');
} else {
concurrency = options.concurrency;
}
//Don't Pass this through to spawn
delete options.concurrency;
}
//Run Tests In Parallel
if (file.src) {
grunt.util.async.forEachLimit(file.src, concurrency, function(srcFile, next) {
//Spawn Child Process
casperLib.execute(srcFile, file.dest !== 'src' ? file.dest : null, options, args, next);
}, function(err) {
if (err) grunt.log.write('error:', err);
//Call Done and Log Duration
iteratorCb(err);
});
}
} else {

if (file.src) {
casperLib.execute(file.src, file.dest, options, args, function(err) {
//Call Done and Log Duration
iteratorCb(err);
});
if (file.src) {

casperLib.execute(file.src, file.dest, options, args, function(err) {
//Call Done and Log Duration
iteratorCb(err);
});
}
}
} else {
grunt.fail.warn('Unable to compile; no valid source files were found.');
}
} else {
grunt.fail.warn('Unable to compile; no valid source files were found.');
}

}, function(err) {
taskComplete(err);
});

}, function(err) {
taskComplete(err);
});
}else{
if (this.data['folder'] && this.data['folder'].length > 0){
casperLib.execute(this.data['folder'], null, options, args, function(err){
taskComplete(err);
});
}
}
});
};
13 changes: 13 additions & 0 deletions test/folder-test/folderTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
casper.test.begin('Testing that tests in Folder are working', 3, function suite(test) {

casper.start('test/fixtures/basicSite.html', function() {
test.assertTitle('Test Title');
test.assertExists('h1', 'Header Exists');
test.assertExists('p', 'P Tag Exists');
});

casper.run(function() {
test.done();
});

});