test-agent
Advanced tools
Comparing version 0.25.0 to 0.26.0
@@ -63,2 +63,10 @@ var Client = require('../../node/client'), | ||
}). | ||
option('this-chunk', { | ||
desc: 'Current chunk number to run', | ||
default: 1 | ||
}). | ||
option('total-chunks', { | ||
desc: 'Total number of chunks to run', | ||
default: 1 | ||
}). | ||
argv; | ||
@@ -109,3 +117,7 @@ | ||
client.send(launchEvent, {files: files}); | ||
client.send(launchEvent, { | ||
files: files, | ||
thisChunk: argv['this-chunk'], | ||
totalChunks: argv['total-chunks'] | ||
}); | ||
}); | ||
@@ -112,0 +124,0 @@ |
@@ -22,3 +22,3 @@ /** | ||
enhance: function enhance(server) { | ||
enhance: function (server) { | ||
server.on(this.eventNames.connect, this._onWorkerReady.bind(this, server)); | ||
@@ -28,3 +28,3 @@ server.on(this.eventNames.start, this._startTests.bind(this, server)); | ||
_onWorkerReady: function _onWorkerReady(server) { | ||
_onWorkerReady: function (server) { | ||
this.clientReady = true; | ||
@@ -39,3 +39,7 @@ var testData = null; | ||
_startTests: function _startTests(server, data) { | ||
_startTests: function (server, data) { | ||
data = data || {}; | ||
var totalChunks = data.totalChunks || 1; | ||
var thisChunk = data.thisChunk || 1; | ||
// if there are no clients connected | ||
@@ -48,7 +52,7 @@ // simply store the test data for now | ||
if (data && data.files && data.files.length > 0) { | ||
this._broadCastFiles(server, data.files); | ||
if (data.files && data.files.length > 0) { | ||
this._broadCastFiles(server, data.files, totalChunks, thisChunk); | ||
} else { | ||
server.suite.findTestFiles(function(err, files) { | ||
this._broadCastFiles(server, files); | ||
this._broadCastFiles(server, files, totalChunks, thisChunk); | ||
}.bind(this)); | ||
@@ -58,8 +62,19 @@ } | ||
_broadCastFiles: function _broadCastFiles(server, files) { | ||
/** | ||
Tell the clients to run a particular set of tests this function also handles | ||
chunking logic. | ||
*/ | ||
_broadCastFiles: function (server, files, totalChunks, thisChunk) { | ||
// Generate a sorted list of files... | ||
var list = files.map(function(file) { | ||
var result = server.suite.testFromPath(file); | ||
return result.testUrl; | ||
}); | ||
}).sort(); | ||
// Chunking logic this allows running a subset of tests... | ||
var chunkLength = Math.ceil(list.length / totalChunks); | ||
var chunk = (thisChunk - 1) * chunkLength; | ||
list = list.slice(chunk, chunk + chunkLength); | ||
console.log('Running tests: ', list); | ||
server.broadcast(server.stringify(this.eventNames.sendEvent, {tests: list})); | ||
@@ -66,0 +81,0 @@ } |
{ | ||
"name": "test-agent", | ||
"version": "0.25.0", | ||
"version": "0.26.0", | ||
"author": "James Lal", | ||
@@ -5,0 +5,0 @@ "description": "execute client side tests from browser report back to cli", |
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
249136
7630