-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner,test: fix flaky test-runner-cli-concurrency.js
This test was flaky on Windows when trying to clean up the tmp directory, probably because it relied on child processes timing out and being killed. This commit updates the test to check for debug output from the test runner. This should be adequate because the original change was effectively: let concurrency = getOptionValue('--test-concurrency') || true; The test runner now logs the value of the concurrency variable. Fixes: #50101 PR-URL: #50108 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
- Loading branch information
Showing
2 changed files
with
30 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,26 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const { deepStrictEqual, strictEqual } = require('node:assert'); | ||
require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const assert = require('node:assert'); | ||
const { spawnSync } = require('node:child_process'); | ||
const { readdirSync, writeFileSync } = require('node:fs'); | ||
const { join } = require('node:path'); | ||
const { beforeEach, test } = require('node:test'); | ||
const { test } = require('node:test'); | ||
const cwd = fixtures.path('test-runner', 'default-behavior'); | ||
const env = { ...process.env, 'NODE_DEBUG': 'test_runner' }; | ||
|
||
function createTestFile(name) { | ||
writeFileSync(join(tmpdir.path, name), ` | ||
const fs = require('node:fs'); | ||
fs.unlinkSync(__filename); | ||
setTimeout(() => {}, 1_000_000_000); | ||
`); | ||
} | ||
|
||
beforeEach(() => { | ||
tmpdir.refresh(); | ||
createTestFile('test-1.js'); | ||
createTestFile('test-2.js'); | ||
test('default concurrency', async () => { | ||
const args = ['--test']; | ||
const cp = spawnSync(process.execPath, args, { cwd, env }); | ||
assert.match(cp.stderr.toString(), /concurrency: true,/); | ||
}); | ||
|
||
test('concurrency of one', () => { | ||
const cp = spawnSync(process.execPath, ['--test', '--test-concurrency=1'], { | ||
cwd: tmpdir.path, | ||
timeout: common.platformTimeout(1000), | ||
}); | ||
|
||
strictEqual(cp.stderr.toString(), ''); | ||
strictEqual(cp.error.code, 'ETIMEDOUT'); | ||
deepStrictEqual(readdirSync(tmpdir.path), ['test-2.js']); | ||
test('concurrency of one', async () => { | ||
const args = ['--test', '--test-concurrency=1']; | ||
const cp = spawnSync(process.execPath, args, { cwd, env }); | ||
assert.match(cp.stderr.toString(), /concurrency: 1,/); | ||
}); | ||
|
||
test('concurrency of two', () => { | ||
const cp = spawnSync(process.execPath, ['--test', '--test-concurrency=2'], { | ||
cwd: tmpdir.path, | ||
timeout: common.platformTimeout(1000), | ||
}); | ||
|
||
strictEqual(cp.stderr.toString(), ''); | ||
strictEqual(cp.error.code, 'ETIMEDOUT'); | ||
deepStrictEqual(readdirSync(tmpdir.path), []); | ||
test('concurrency of two', async () => { | ||
const args = ['--test', '--test-concurrency=2']; | ||
const cp = spawnSync(process.execPath, args, { cwd, env }); | ||
assert.match(cp.stderr.toString(), /concurrency: 2,/); | ||
}); |