test-agent
Advanced tools
Comparing version 0.21.1 to 0.22.0
@@ -84,3 +84,3 @@ var Client = require('../../node/client'), | ||
var enableCoverage = argv.coverage; | ||
var enableCoverage = argv.coverage || false; | ||
@@ -90,6 +90,19 @@ client.url = argv.server; | ||
client.on('open', function(socket) { | ||
var type = enableCoverage ? 'start coverages' : 'queue tests'; | ||
var files = argv._.slice(1), | ||
fsPath = require('path'); | ||
files = files.map(function(file) { | ||
file = fsPath.normalize(file); | ||
if (file[0] !== '/') { | ||
file = fsPath.join(process.env.PWD, file); | ||
} | ||
return file; | ||
}); | ||
client.mirrorServerEvents(['set test envs', 'error', 'test data', 'coverage data'], true); | ||
client.send(type, { app: argv.app }); | ||
if (enableCoverage) { | ||
client.send('start coverages', {files: files}); | ||
} else { | ||
client.send('queue tests', {files: files}); | ||
} | ||
}); | ||
@@ -96,0 +109,0 @@ |
@@ -1,2 +0,1 @@ | ||
var MatchFiles = require('match-files'); | ||
/** | ||
@@ -39,3 +38,2 @@ * REQUIRES: suite, responder, broadcast | ||
_startTests: function _startTests(server, data) { | ||
var options = { fileFilters: [] }; | ||
// if there are no clients connected | ||
@@ -48,12 +46,9 @@ // simply store the test data for now | ||
if (data && data.app && typeof data.app === 'string') { | ||
options.fileFilters.push(function(path) { | ||
var reg = new RegExp('^(\\w+/)?' + data.app + '/'); | ||
return reg.test(path); | ||
}); | ||
if (data && data.files && data.files.length > 0) { | ||
this._broadCastFiles(server, data.files); | ||
} else { | ||
server.suite.findTestFiles(function(err, files) { | ||
this._broadCastFiles(server, files); | ||
}.bind(this)); | ||
} | ||
server.suite.findTestFiles(function(err, files) { | ||
this._broadCastFiles(server, files); | ||
}.bind(this), options); | ||
}, | ||
@@ -63,6 +58,6 @@ | ||
var list = files.map(function(file) { | ||
var result = server.suite.testFromPath(file); | ||
return result.testUrl; | ||
}); | ||
server.broadcast(server.stringify(this.eventNames.sendEvent, {tests: list})); | ||
@@ -69,0 +64,0 @@ } |
@@ -9,4 +9,2 @@ var fsPath = require('path'), | ||
libDir: 'lib/', | ||
includeDirs: [], | ||
blacklist: [], | ||
testSuffix: '-test.js', | ||
@@ -19,3 +17,3 @@ libSuffix: '.js', | ||
Suite._pathJoins = [ | ||
'path', | ||
'paths', | ||
'libDir', | ||
@@ -26,3 +24,9 @@ 'testDir' | ||
Suite._joinPath = function _joinPath(key) { | ||
this[key] = fsPath.join(fsPath.normalize(this[key]), '/'); | ||
if (Array.isArray(this[key])) { | ||
this[key].forEach(function(subkey, i) { | ||
this[key][i] = fsPath.join(fsPath.normalize(this[key][i]), '/'); | ||
}, this); | ||
} else { | ||
this[key] = fsPath.join(fsPath.normalize(this[key]), '/'); | ||
} | ||
}; | ||
@@ -82,13 +86,9 @@ | ||
if (file.indexOf(this.path) !== -1) { | ||
match = this.path; | ||
} | ||
file = file.replace(match, ''); | ||
this.includeDirs.forEach(function(dir) { | ||
file = file.replace(new RegExp('^' + dir), ''); | ||
this.paths.forEach(function(path) { | ||
if (file.indexOf(path) !== -1) { | ||
match = path; | ||
} | ||
}); | ||
return file; | ||
return file.replace(match, ''); | ||
}, | ||
@@ -115,2 +115,3 @@ | ||
return function(err, found) { | ||
if (err) { | ||
@@ -145,3 +146,3 @@ callback(err); | ||
_filterFile: function _filterFile(type, path) { | ||
return this.matchesType(type, path) && !this.matchesSkip(path) && this.matchesDir(path); | ||
return this.matchesType(type, path); | ||
}, | ||
@@ -154,15 +155,11 @@ | ||
*/ | ||
findTestFiles: function findTestFiles(callback, options) { | ||
var pending = 1, | ||
joinResults = this._joinResults(pending, callback), | ||
opts = options || {}, | ||
filterFile = this._filterFile.bind(this, 'test'); | ||
findTestFiles: function findTestFiles(callback) { | ||
var pending = this.paths.length, | ||
joinResults = this._joinResults(pending, callback); | ||
if (opts.fileFilters && Array.isArray(opts.fileFilters)) { | ||
opts.fileFilters.unshift(filterFile); | ||
} else { | ||
opts.fileFilters = [filterFile]; | ||
} | ||
MatchFiles.find(this.path, opts, joinResults); | ||
this.paths.forEach(function(path) { | ||
MatchFiles.find(path, { | ||
fileFilters: [this._filterFile.bind(this, 'test')] | ||
}, joinResults); | ||
}, this); | ||
}, | ||
@@ -175,15 +172,11 @@ | ||
*/ | ||
findLibFiles: function findLibFiles(callback, options) { | ||
var pending = 1, | ||
joinResults = this._joinResults(pending, callback), | ||
opts = options || {}, | ||
filterFile = this._filterFile.bind(this, 'lib'); | ||
findLibFiles: function findLibFiles(callback) { | ||
var pending = this.paths.length, | ||
joinResults = this._joinResults(pending, callback); | ||
if (opts.fileFilters && Array.isArray(opts.fileFilters)) { | ||
opts.fileFilters.push(filterFile); | ||
} else { | ||
opts.fileFilters = [filterFile]; | ||
} | ||
MatchFiles.find(this.path, opts, joinResults); | ||
this.paths.forEach(function(path) { | ||
MatchFiles.find(path, { | ||
fileFilters: [this._filterFile.bind(this, 'lib')] | ||
}, joinResults); | ||
}, this); | ||
}, | ||
@@ -209,41 +202,2 @@ | ||
/** | ||
* Checks to see if relative path matches | ||
* the given dir path. | ||
* | ||
* @param {String} path the relative path of the file. | ||
*/ | ||
matchesDir: function matchesDir(path) { | ||
var includeDirs = this.includeDirs, | ||
result = true; | ||
if (includeDirs.length > 0) { | ||
result = this.includeDirs.some(function(dir) { | ||
var reg = new RegExp('^' + dir); | ||
return reg.test(path); | ||
}); | ||
} | ||
return result; | ||
}, | ||
/** | ||
* Checks to see if relative path matches | ||
* the given skip path. | ||
* | ||
* @param {String} path the relative path of the file. | ||
*/ | ||
matchesSkip: function matchesSkip(path) { | ||
var blacklist = this.blacklist, | ||
result = false; | ||
if (blacklist.length > 0) { | ||
result = blacklist.some(function(skip){ | ||
return (skip === path); | ||
}); | ||
} | ||
return result; | ||
}, | ||
testFromPath: function testFromPath(path) { | ||
@@ -250,0 +204,0 @@ var results = {}; |
@@ -47,3 +47,10 @@ (function(window) { | ||
var box = worker.sandbox.getWindow(); | ||
box.require(this.blanketUrl, null, this.blanketConfig); | ||
box.require(this.blanketUrl, function() { | ||
// Using custom reporter to replace blanket defaultReporter | ||
// Send coverage result from each sandbox to the top window for aggregating the result | ||
box.blanket.options('reporter', function(data) { | ||
data = JSON.stringify(['coverage report', data]); | ||
window.top.postMessage(data, "http://test-agent.gaiamobile.org:8080"); | ||
}); | ||
}, this.blanketConfig); | ||
}, | ||
@@ -50,0 +57,0 @@ |
{ | ||
"name": "test-agent", | ||
"version": "0.21.1", | ||
"version": "0.22.0", | ||
"author": "James Lal", | ||
@@ -5,0 +5,0 @@ "description": "execute client side tests from browser report back to cli", |
@@ -6,3 +6,3 @@ //all require paths must be absolute -- use __dirname | ||
suite = new Suite({ | ||
path: __dirname, | ||
paths: [__dirname], | ||
testDir: 'test/test-agent', | ||
@@ -9,0 +9,0 @@ libDir: 'lib/test-agent' |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252050
73
7857
20