For #78 we'll end up limiting the number of concurrent forks. We should implement a pool of forks that the Api can use to run each test file.
Here's a rough sketch of a possible implementation:
import assert from 'assert'
import fork from './fork'
class Pool extends EventEmitter {
constructor (limit) {
this.limit = limit
this.active = 0
}
fork (file, opts) {
assert(this.active < this.limit)
this.active++
const promise = fork(file, opts)
promise.catch(() => {}).then(() => {
this.active--
this.emit('free')
})
return promise
}
}
For #78 we'll end up limiting the number of concurrent forks. We should implement a pool of forks that the Api can use to run each test file.
Here's a rough sketch of a possible implementation: