[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).
Mofei Zhang committed
Apr 24, 2023 at 15:52 UTC
4cf86028c0d6c73066dddb731b651cd07a96f290
1 file changed
+21
-17
compiler/forget/packages/snap/src/runner.ts
+21
-17
@@ -99,28 +99,32 @@ async function run(compilerVersion: number): Promise<Results> {
99
)
100
).sort();
101
102
- // Note: promise.all to ensure parallelism when enabled
103
- const entries: Array<[string, TestResult]> = await Promise.all(
104
- fixtures.map(async (fixture) => {
105
- let output: TestResult;
106
- if (PARALLEL) {
107
- output = await worker.compile(
102
+ let entries: Array<[string, TestResult]>;
103
+ if (PARALLEL) {
104
+ // Note: promise.all to ensure parallelism when enabled
105
+ entries = await Promise.all(
106
+ fixtures.map(async (fixture) => {
107
+ let output = await worker.compile(
108
COMPILER_PATH,
109
FIXTURES_PATH,
110
fixture,
111
compilerVersion
112
);
113
- } else {
114
- output = await compiler.compile(
115
- COMPILER_PATH,
116
- FIXTURES_PATH,
117
- fixture,
118
- compilerVersion
119
- );
120
- }
121
- return [fixture, output];
122
- })
123
- );
113
+ return [fixture, output];
114
+ })
115
+ );
116
+ } else {
117
+ entries = [];
118
+ for (const fixture of fixtures) {
119
+ let output = await compiler.compile(
120
+ COMPILER_PATH,
121
+ FIXTURES_PATH,
122
+ fixture,
123
+ compilerVersion
124
+ );
125
+ entries.push([fixture, output]);
126
+ }
127
+ }
128
129
return new Map(entries);
130
}