Commit 428f8000 428f8000c0241794179890be346fea5cafe72cee by Julien Moulin

First init of pre/post modification

1 parent 5ed461e8
......@@ -56,6 +56,8 @@ var Tester = function Tester(casper, options) {
this.currentTestFile = null;
this.exporter = require('xunit').create();
this.includes = [];
this.pre = [];
this.post = [];
this.running = false;
this.suites = [];
this.options = utils.mergeObjects({
......@@ -729,7 +731,9 @@ var Tester = function Tester(casper, options) {
self.bar(f("Path %s doesn't exist", path), "RED_BAR");
}
if (fs.isDirectory(path)) {
testFiles = testFiles.concat(this.pre);
testFiles = testFiles.concat(self.findTestFiles(path));
testFiles = testFiles.concat(this.post);
} else if (fs.isFile(path)) {
testFiles.push(path);
}
......
......@@ -3,13 +3,14 @@ if (!phantom.casperLoaded) {
phantom.exit(1);
}
var colorizer = require('colorizer');
var fs = require('fs');
var utils = require('utils');
var f = utils.format;
var fs = require('fs');
var utils = require('utils');
var f = utils.format;
var includes = [];
var tests = [];
var casper = require('casper').create({
var pre = [];
var post = [];
var tests = [];
var casper = require('casper').create({
exitOnError: false
});
......@@ -65,6 +66,28 @@ if (casper.cli.has('includes')) {
casper.test.includes = utils.unique(includes);
}
// pre handling
if (casper.cli.has('pre')) {
pre = casper.cli.get('pre').split(',').map(function(unique_pre) {
// we can't use filter() directly because of abspath transformation
return checkIncludeFile(unique_pre);
}).filter(function(unique_pre) {
return utils.isString(unique_pre);
});
casper.test.pre = utils.unique(pre);
}
// post handling
if (casper.cli.has('post')) {
post = casper.cli.get('post').split(',').map(function(unique_post) {
// we can't use filter() directly because of abspath transformation
return checkIncludeFile(unique_post);
}).filter(function(unique_post) {
return utils.isString(unique_post);
});
casper.test.post = utils.unique(post);
}
// test suites completion listener
casper.test.on('tests.complete', function() {
this.renderResults(true, undefined, casper.cli.get('xunit') || undefined);
......