Skip to content

Commit

Permalink
Revert "test: run WPT files in parallel again"
Browse files Browse the repository at this point in the history
This reverts commit c05689e.
  • Loading branch information
panva committed Apr 20, 2023
1 parent b229d02 commit 787b72f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 87 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ test-wpt-report:
$(RM) -r out/wpt
mkdir -p out/wpt
WPT_REPORT=1 $(PYTHON) tools/test.py --shell $(NODE) $(PARALLEL_ARGS) wpt
$(NODE) "$$PWD/tools/merge-wpt-reports.mjs"

.PHONY: test-internet
test-internet: all
Expand Down
83 changes: 30 additions & 53 deletions test/common/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const os = require('os');
const { inspect } = require('util');
const { Worker } = require('worker_threads');

const workerPath = path.join(__dirname, 'wpt/worker.js');

function getBrowserProperties() {
const { node: version } = process.versions; // e.g. 18.13.0, 20.0.0-nightly202302078e6e215481
const release = /^\d+\.\d+\.\d+$/.test(version);
Expand Down Expand Up @@ -59,8 +57,7 @@ function codeUnitStr(char) {
}

class WPTReport {
constructor(path) {
this.filename = `report-${path.replaceAll('/', '-')}.json`;
constructor() {
this.results = [];
this.time_start = Date.now();
}
Expand Down Expand Up @@ -99,18 +96,26 @@ class WPTReport {
return result;
});

/**
* Return required and some optional properties
* https://github.com/web-platform-tests/wpt.fyi/blob/60da175/api/README.md?plain=1#L331-L335
*/
this.run_info = {
product: 'node.js',
...getBrowserProperties(),
revision: process.env.WPT_REVISION || 'unknown',
os: getOs(),
};
if (fs.existsSync('out/wpt/wptreport.json')) {
const prev = JSON.parse(fs.readFileSync('out/wpt/wptreport.json'));
this.results = [...prev.results, ...this.results];
this.time_start = prev.time_start;
this.time_end = Math.max(this.time_end, prev.time_end);
this.run_info = prev.run_info;
} else {
/**
* Return required and some optional properties
* https://github.com/web-platform-tests/wpt.fyi/blob/60da175/api/README.md?plain=1#L331-L335
*/
this.run_info = {
product: 'node.js',
...getBrowserProperties(),
revision: process.env.WPT_REVISION || 'unknown',
os: getOs(),
};
}

fs.writeFileSync(`out/wpt/${this.filename}`, JSON.stringify(this));
fs.writeFileSync('out/wpt/wptreport.json', JSON.stringify(this));
}
}

Expand Down Expand Up @@ -397,29 +402,6 @@ const kIncomplete = 'incomplete';
const kUncaught = 'uncaught';
const NODE_UNCAUGHT = 100;

const limit = (concurrency) => {
let running = 0;
const queue = [];

const execute = async (fn) => {
if (running < concurrency) {
running++;
try {
await fn();
} finally {
running--;
if (queue.length > 0) {
execute(queue.shift());
}
}
} else {
queue.push(fn);
}
};

return execute;
};

class WPTRunner {
constructor(path) {
this.path = path;
Expand All @@ -443,7 +425,7 @@ class WPTRunner {
this.scriptsModifier = null;

if (process.env.WPT_REPORT != null) {
this.report = new WPTReport(path);
this.report = new WPTReport();
}
}

Expand Down Expand Up @@ -561,8 +543,6 @@ class WPTRunner {

this.inProgress = new Set(queue.map((spec) => spec.filename));

const run = limit(os.availableParallelism());

for (const spec of queue) {
const testFileName = spec.filename;
const content = spec.getContent();
Expand Down Expand Up @@ -596,7 +576,15 @@ class WPTRunner {
this.scriptsModifier?.(obj);
scriptsToRun.push(obj);

const runWorker = async (variant) => {
/**
* Example test with no META variant
* https://github.com/nodejs/node/blob/03854f6/test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.https.any.js#L1-L4
*
* Example test with multiple META variants
* https://github.com/nodejs/node/blob/03854f6/test/fixtures/wpt/WebCryptoAPI/generateKey/successes_RSASSA-PKCS1-v1_5.https.any.js#L1-L9
*/
for (const variant of meta.variant || ['']) {
const workerPath = path.join(__dirname, 'wpt/worker.js');
const worker = new Worker(workerPath, {
execArgv: this.flags,
workerData: {
Expand Down Expand Up @@ -647,17 +635,6 @@ class WPTRunner {
});

await events.once(worker, 'exit').catch(() => {});
};

/**
* Example test with no META variant
* https://github.com/nodejs/node/blob/03854f6/test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.https.any.js#L1-L4
*
* Example test with multiple META variants
* https://github.com/nodejs/node/blob/03854f6/test/fixtures/wpt/WebCryptoAPI/generateKey/successes_RSASSA-PKCS1-v1_5.https.any.js#L1-L9
*/
for (const variant of meta.variant || ['']) {
run(() => runWorker(variant));
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/wpt/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import testpy

def GetConfiguration(context, root):
return testpy.ParallelTestConfiguration(context, root, 'wpt')
return testpy.SimpleTestConfiguration(context, root, 'wpt')
32 changes: 0 additions & 32 deletions tools/merge-wpt-reports.mjs

This file was deleted.

0 comments on commit 787b72f

Please sign in to comment.