[snap tester] Patch runner for sync mode

--- 

`yarn snap --sync` currently fails on `error.file-has-non-critical-errors`. This 
is because we're relying on a globally overwritten `console.error` function to 
report non-fatal errors. However, executing `Promise.all(...)` on a single 
nodejs thread will interleave calls to `run` (which is an async function).
This commit is contained in:
Mofei Zhang
2023-04-24 15:52:54 -04:00
parent 46752845eb
commit 4cf86028c0
+21 -17
View File
@@ -99,28 +99,32 @@ async function run(compilerVersion: number): Promise<Results> {
)
).sort();
// Note: promise.all to ensure parallelism when enabled
const entries: Array<[string, TestResult]> = await Promise.all(
fixtures.map(async (fixture) => {
let output: TestResult;
if (PARALLEL) {
output = await worker.compile(
let entries: Array<[string, TestResult]>;
if (PARALLEL) {
// Note: promise.all to ensure parallelism when enabled
entries = await Promise.all(
fixtures.map(async (fixture) => {
let output = await worker.compile(
COMPILER_PATH,
FIXTURES_PATH,
fixture,
compilerVersion
);
} else {
output = await compiler.compile(
COMPILER_PATH,
FIXTURES_PATH,
fixture,
compilerVersion
);
}
return [fixture, output];
})
);
return [fixture, output];
})
);
} else {
entries = [];
for (const fixture of fixtures) {
let output = await compiler.compile(
COMPILER_PATH,
FIXTURES_PATH,
fixture,
compilerVersion
);
entries.push([fixture, output]);
}
}
return new Map(entries);
}