Skip to content

Commit

Permalink
Destroy the agent pool when tests are completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
bterlson committed Jul 23, 2016
1 parent b6ddcda commit 9ba4269
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const files = paths.map(pathToTestFile);
const tests = files.map(compileFile);
const scenarios = tests.flatMap(scenariosForTest);
const pairs = Rx.Observable.zip(pool, scenarios);
const rawResults = pairs.flatMap(pool.runTest);
const rawResults = pairs.flatMap(pool.runTest).tapOnCompleted(() => pool.destroy());;
const results = rawResults.map(function (test) {
test.result = validator(test);
return test;
Expand Down
13 changes: 10 additions & 3 deletions lib/agentPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ const Rx = require('rx');
const eshost = require('eshost');

module.exports = makePool;
function makePool(agents, hostType, hostArgs, hostPath) {
function makePool(agentCount, hostType, hostArgs, hostPath) {
const pool = new Rx.Subject();
const agents = [];

for (var i = 0; i < agents; i++) {
for (var i = 0; i < agentCount; i++) {
eshost.createAgent(hostType, {
hostArguments: hostArgs,
hostPath: hostPath
})
.then(agent => {
agents.push(agent);
pool.onNext(agent);
})
.catch(e => {
Expand All @@ -35,5 +37,10 @@ function makePool(agents, hostType, hostArgs, hostPath) {
process.exit(1);
});
}
return pool;

pool.destroy = function () {
agents.forEach(agent => agent.destroy());
}

return pool
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "test262-harness",
"repository": "bterlson/test262-harness",
"version": "2.0.5",
"version": "2.0.6",
"description": "Node-based harness for test262",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 9ba4269

Please sign in to comment.