[engineering] add testSplit option to unit-test runner (#253049)

helpful to run tests in parallel
This commit is contained in:
Aman Karmani
2025-07-07 13:34:30 -07:00
committed by GitHub
parent dadbc584d9
commit 7deabf42e7
2 changed files with 11 additions and 2 deletions

View File

@@ -171,7 +171,14 @@ async function loadTestModules(opts) {
const pattern = opts.runGlob || _tests_glob;
const files = await globAsync(pattern, { cwd: loadFn._out });
const modules = files.map(file => file.replace(/\.js$/, ''));
let modules = files.map(file => file.replace(/\.js$/, ''));
if (opts.testSplit) {
const [i, n] = opts.testSplit.split('/').map(Number);
const chunkSize = Math.floor(modules.length / n);
const start = (i - 1) * chunkSize;
const end = i === n ? modules.length : i * chunkSize;
modules = modules.slice(start, end);
}
return loadModules(modules);
}