eng: fix snapshot tests in macos webkit for real? (#193734)

Second attempt at this, which should work. Stop trying to use
exposeFunction, which seems to work poorly on macOS webkit in CI, and
just run a server with HTTP endpoints to do the "RPC."

Reuses Alex's "yaserver" module that we were already using for other
tests. Uses a secure random prefix for security in each run.
This commit is contained in:
Connor Peet
2023-09-21 14:48:21 -07:00
committed by GitHub
parent f92db2f96e
commit 31067371f2
5 changed files with 96 additions and 43 deletions

View File

@@ -51,7 +51,7 @@
const baseUrl = window.location.href;
require.config({
catchError: true,
baseUrl: new URL('../../../src', baseUrl).href,
baseUrl: urlParams.get('baseUrl'),
paths: {
vs: new URL(`../../../${!!isBuild ? 'out-build' : 'out'}/vs`, baseUrl).href,
assert: new URL('../assert.js', baseUrl).href,
@@ -116,6 +116,27 @@
runner.on('pending', test => window.mocha_report('pending', serializeRunnable(test)));
};
const remoteMethods = [
'__readFileInTests',
'__writeFileInTests',
'__readDirInTests',
'__unlinkInTests',
'__mkdirPInTests',
];
for (const method of remoteMethods) {
const prefix = window.location.pathname.split('/')[1];
globalThis[method] = async (...args) => {
const res = await fetch(`/${prefix}/remoteMethod/${method}`, {
body: JSON.stringify(args),
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
return res.json();
}
}
async function loadModules(modules) {
for (const file of modules) {
@@ -129,25 +150,8 @@
}
}
/**
* There is some bug in WebKit on macOS in CI only that causes the first
* invokation of the file functions to (sometimes) take an inordinately
* long period of time to run. Get around this by invoking them here.
*/
async function doIoWarmup() {
const dir = url.searchParams.get('ioWarmup');
if (!dir) {
return;
}
// these are the only two functions actually used in CI presently:
await __readFileInTests(dir + '/' + 'renderer.html');
await __readDirInTests(dir);
}
window.loadAndRun = async function loadAndRun({ modules, grep }, manual = false) {
// load
await doIoWarmup();
await loadModules(modules);
// await new Promise((resolve, reject) => {
// require(modules, resolve, err => {