build: fix linux tests (#42496)
* build: use runuser for electron spec runner * chown * run tests in priv * fixed * build: setup testing on arm for GHA * no build-tools for test * start xvfb for the right user * no more gn-build-type * debug env * ue xvfb-run * use 8 core for node tests * build: do test sharding on linux * fix: disable hung node test * build: index splits are hard * build: use --init to reap children * allow write junit * use custom xvfb wrapper * pipefail * dont kill xvfb, its already dead --------- Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
c1094013eb
commit
c2c3673e8a
9 changed files with 76 additions and 27 deletions
32
script/split-tests.js
Normal file
32
script/split-tests.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const fs = require('node:fs');
|
||||
const glob = require('glob');
|
||||
|
||||
const currentShard = parseInt(process.argv[2], 10);
|
||||
const shardCount = parseInt(process.argv[3], 10);
|
||||
|
||||
const specFiles = glob.sync('spec/*-spec.ts');
|
||||
|
||||
const buckets = [];
|
||||
|
||||
for (let i = 0; i < shardCount; i++) {
|
||||
buckets.push([]);
|
||||
}
|
||||
|
||||
const testsInSpecFile = Object.create(null);
|
||||
for (const specFile of specFiles) {
|
||||
const testContent = fs.readFileSync(specFile, 'utf8');
|
||||
testsInSpecFile[specFile] = testContent.split('it(').length;
|
||||
}
|
||||
|
||||
specFiles.sort((a, b) => {
|
||||
return testsInSpecFile[b] - testsInSpecFile[a];
|
||||
});
|
||||
|
||||
let shard = 0;
|
||||
for (const specFile of specFiles) {
|
||||
buckets[shard].push(specFile);
|
||||
shard++;
|
||||
if (shard === shardCount) shard = 0;
|
||||
}
|
||||
|
||||
console.log(buckets[currentShard - 1].join(' '));
|
Loading…
Add table
Add a link
Reference in a new issue