Skip to content

Commit

Permalink
refactor: Removed install queue from versioned runner. It will instal…
Browse files Browse the repository at this point in the history
…l before running a given test and rely on the jobs limit (#221)
  • Loading branch information
bizob2828 authored Jul 16, 2024
1 parent 582efe6 commit d9c6d1b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
2 changes: 0 additions & 2 deletions bin/version-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const { buildGlobs, resolveGlobs } = require('../lib/versioned/globber')
cmd
.arguments('[test-globs...]')
.option('-j, --jobs <n>', 'Max parallel test executions. Defaults to max available CPUs.', int)
.option('-i, --install <n>', 'Max parallel installations [1]', int, 1)
.option('-p, --print <mode>', 'Specify print mode [pretty]', printMode, 'pretty')
.option('-s, --skip <keyword>[,<keyword>]', 'Skip files containing the supplied keyword(s)')
.option(
Expand Down Expand Up @@ -110,7 +109,6 @@ async function run(files, patterns) {

const runner = new Suite(directories, {
limit: maxParallelRuns,
installLimit: cmd.install,
versions: mode,
testPatterns: patterns,
globalSamples: cmd.samples,
Expand Down
21 changes: 4 additions & 17 deletions lib/versioned/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function Suite(testFolders, opts) {
{},
{
limit: 1,
installLimit: 1,
versions: 'minor',
testPatterns: [],
globalSamples: null
Expand Down Expand Up @@ -115,12 +114,6 @@ Suite.prototype._runTests = async function _runTests(pkgVersions) {
this.failures = []
const self = this

const installQueue = a.queue(function install(test, installCb) {
self.emit('update', test.test, 'installing')
test.testRun.continue()
test.testRun.once('completed', installCb)
}, this.opts.installLimit)

const queue = a.queue(function done(test, queueCb) {
const testRun = test.run()
if (!testRun) {
Expand Down Expand Up @@ -148,19 +141,13 @@ Suite.prototype._runTests = async function _runTests(pkgVersions) {
})

if (testRun.needsInstall) {
self.emit('update', test, 'waiting')
installQueue.push({ test: test, testRun: testRun }, doRun)
} else {
// Even if nothing is being installed the runner must go through the
// install phase.
testRun.continue()
testRun.once('completed', doRun)
self.emit('update', test, 'installing')
}

function doRun() {
testRun.continue()
testRun.once('completed', () => {
self.emit('update', test, 'running')
testRun.continue()
}
})
}, this.opts.limit)

// Build and queue all of our test directories. The tests are sorted by number
Expand Down
1 change: 0 additions & 1 deletion tests/unit/versioned/suite.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ tap.test('Suite method and members', function (t) {

t.test('Suite#start', async function (t) {
const updates = [
{ test: 'redis.mock.test.js', status: 'waiting' },
{ test: 'redis.mock.test.js', status: 'installing' },
{ test: 'redis.mock.test.js', status: 'running' },
{ test: 'redis.mock.test.js', status: 'success' },
Expand Down

0 comments on commit d9c6d1b

Please sign in to comment.