@travetto/test
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -28,3 +28,3 @@ { | ||
}, | ||
"version": "0.0.6" | ||
"version": "0.0.7" | ||
} |
import * as os from 'os'; | ||
import { Agent } from './agent'; | ||
import { Shutdown } from '@travetto/base'; | ||
@@ -19,2 +20,3 @@ export class AgentPool { | ||
} | ||
Shutdown.onShutdown(this.constructor.__id, () => this.shutdown()); | ||
} | ||
@@ -65,3 +67,3 @@ | ||
} else { | ||
let agent = await Promise.race(Array.from(this.pendingAgents.values()).map(x => x.completion)); | ||
let agent = await Promise.race(Array.from(this.pendingAgents).map(x => x.completion)); | ||
this.returnAgent(agent); | ||
@@ -71,13 +73,21 @@ } | ||
await Promise.all(Array.from(this.pendingAgents.values()).map(x => x.completion)); | ||
await Promise.all(Array.from(this.pendingAgents).map(x => x.completion)); | ||
} | ||
shutdown() { | ||
for (let agent of this.pendingAgents) { | ||
for (let agent of Array.from(this.pendingAgents)) { | ||
this.returnAgent(agent); | ||
} | ||
for (let agent of this.availableAgents) { | ||
agent.process.kill('SIGKILL'); | ||
for (let agent of Array.from(this.availableAgents)) { | ||
if (agent.process) { | ||
try { | ||
console.debug('Killing Process', agent.id) | ||
agent.process.kill('SIGKILL'); | ||
} catch (e) { | ||
console.error('Error', agent.id, e); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
@@ -65,3 +65,2 @@ import * as minimist from 'minimist'; | ||
let files = await TestUtil.getTests(globs); | ||
let agentPool = new AgentPool(require.resolve('../../bin/worker.js')); | ||
@@ -74,2 +73,4 @@ for (let l of listeners) { | ||
let agentPool = new AgentPool(require.resolve('../../bin/worker.js')); | ||
await agentPool.process(files, async (file, run, agent) => { | ||
@@ -76,0 +77,0 @@ if (agent) { |
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
254537
1046