-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner, cli: add --test-concurrency flag #49996
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const { deepStrictEqual, strictEqual } = 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'); | ||
|
||
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('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 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), []); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this test if the files really run concurrently? We have fixtures that create a mutex, can we use them?
node/test/parallel/test-runner-concurrency.js
Lines 89 to 98 in 966e3d3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, better to test the
--test-concurrency
within https://github.com/nodejs/node/blob/966e3d34936b28bfb31f00a6f862226baa3bf9d0/test/parallel/test-runner-concurrency.js to avoid the two tests using this "mutex" in parallel (and it is related to this file)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now relaized this assersion.
deepStrictEqual(readdirSync(tmpdir.path), [])
anyway we can still move the test into that file but not a blocker.
also, probably skip second test if
os.availableParallelism() < 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We know that they are not running sequentially because each file never finishes. Since we know that the tests aren't running sequentially, we just need to verify that the batch size is respected. Plus, this change is not introducing any new concurrency functionality, it's just assigning a different value using the existing functionality.