-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
test_runner: add shards support #48639
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
Changes from 14 commits
a93fa41
3bc36b8
bf9d2e5
3663fb2
09c8734
ed19709
5e39d75
5c6ab88
d293da5
51f7697
0625b75
2e0040b
602f767
4ce4d76
b7009d7
76cfcb6
5a846d2
d4f9168
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -39,10 +39,18 @@ const console = require('internal/console/global'); | |||||
const { | ||||||
codes: { | ||||||
ERR_INVALID_ARG_TYPE, | ||||||
ERR_INVALID_ARG_VALUE, | ||||||
ERR_TEST_FAILURE, | ||||||
ERR_OUT_OF_RANGE, | ||||||
}, | ||||||
} = require('internal/errors'); | ||||||
const { validateArray, validateBoolean, validateFunction } = require('internal/validators'); | ||||||
const { | ||||||
validateArray, | ||||||
validateBoolean, | ||||||
validateFunction, | ||||||
validateObject, | ||||||
validateNumber, | ||||||
} = require('internal/validators'); | ||||||
const { getInspectPort, isUsingInspector, isInspectorMessage } = require('internal/util/inspector'); | ||||||
const { isRegExp } = require('internal/util/types'); | ||||||
const { kEmptyObject } = require('internal/util'); | ||||||
|
@@ -417,14 +425,27 @@ function run(options) { | |||||
options = kEmptyObject; | ||||||
} | ||||||
let { testNamePatterns } = options; | ||||||
const { concurrency, timeout, signal, files, inspectPort, watch, setup } = options; | ||||||
const { concurrency, timeout, signal, files, inspectPort, watch, setup, shard } = options; | ||||||
rluvaton marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
if (files != null) { | ||||||
validateArray(files, 'options.files'); | ||||||
} | ||||||
if (watch != null) { | ||||||
validateBoolean(watch, 'options.watch'); | ||||||
} | ||||||
if (shard != null) { | ||||||
validateObject(shard, 'options.shard'); | ||||||
validateNumber(shard.total, 'options.shard.total', 1); | ||||||
rluvaton marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
validateNumber(shard.index, 'options.shard.index'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used the max here as the error message is not really understandable because you don't understand what's the reason for the upper limit |
||||||
|
||||||
if (shard.index <= 0 || shard.total < shard.index) { | ||||||
throw new ERR_OUT_OF_RANGE('options.shard.index', `>= 1 && <= ${shard.total} ("options.shard.total")`, shard.index); | ||||||
} | ||||||
Comment on lines
+444
to
+446
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed based on my previous comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see that comment answer 😄 |
||||||
|
||||||
if (watch) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would you use sharding if you need to watch all the files? watch is for active development There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You had a bug in a certain shard in CI and you want to iteratively fix it? Is there a reason not to allow it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you add a file it will change the sharding, we can add it I just think it won't be really useful |
||||||
throw new ERR_INVALID_ARG_VALUE('options.shard', watch, 'shards not supported with watch mode'); | ||||||
} | ||||||
} | ||||||
if (setup != null) { | ||||||
validateFunction(setup, 'options.setup'); | ||||||
} | ||||||
|
@@ -446,7 +467,11 @@ function run(options) { | |||||
} | ||||||
|
||||||
const root = createTestTree({ concurrency, timeout, signal }); | ||||||
const testFiles = files ?? createTestFileList(); | ||||||
let testFiles = files ?? createTestFileList(); | ||||||
|
||||||
if (shard) { | ||||||
testFiles = testFiles.filter((_, index) => (index % shard.total) === (shard.index - 1)); | ||||||
rluvaton marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
let postRun = () => root.postRun(); | ||||||
let filesWatcher; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('a.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('b.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('c.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('d.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('e.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('f.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('g.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('h.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('i.cjs this should pass'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
const test = require('node:test'); | ||
|
||
test('j.cjs this should pass'); |
Uh oh!
There was an error while loading. Please reload this page.