Skip to content

Commit 42015be

Browse files
committed
test time to compile examples
1 parent e482294 commit 42015be

File tree

2 files changed

+30
-64
lines changed

2 files changed

+30
-64
lines changed

tests/docstrings_examples/DocTest.res

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ let runtimeTests = async code => {
149149
},
150150
)
151151

152-
Console.log({
153-
"code": code,
154-
"exitCode": exitCode,
155-
"stdout": stdout,
156-
"stderr": stderr,
157-
})
158-
159152
// Some expressions, like, `console.error("error")` is printed to stderr but
160153
// exit code is 0
161154
let std = switch exitCode->Null.toOption {
@@ -315,7 +308,7 @@ let main = async () => {
315308
// Ignore Js modules and RescriptTools for now
316309
->Array.filter(f => !String.startsWith(f, "Js") && !String.startsWith(f, "RescriptTools"))
317310
->Array.filter(f => f->String.endsWith(".res") || f->String.endsWith(".resi"))
318-
->Array.filter(f => f === "Uint8ClampedArray.res")
311+
// ->Array.filter(f => f === "Uint8ClampedArray.res")
319312
->Array.reduce([], (acc, cur) => {
320313
let isInterface = cur->String.endsWith(".resi")
321314

@@ -446,31 +439,32 @@ let main = async () => {
446439
(lhs, rhs)
447440
})
448441

449-
let batches = chunkArray(compiled, batchSize)
450-
451-
let a =
452-
await batches
453-
->Array.map(async t => {
454-
(await t
455-
->Array.filter((({id}, _, _)) => !Array.includes(ignoreRuntimeTests, id))
456-
->Array.map(async ((example, rescriptCode, jsCode)) => {
457-
let nodeTest = await runtimeTests(jsCode)
458-
switch nodeTest {
459-
| Ok(_) => None
460-
| Error(error) => Some(example, RuntimeError({rescript: rescriptCode, js: jsCode, error}))
461-
}
462-
})
463-
->Promise.all)
464-
->Array.filterMap(i =>
465-
switch i {
466-
| Some(i) => Some(i)
467-
| None => None
468-
}
469-
)
470-
})
471-
->Promise.all
442+
let _batches = chunkArray(compiled, batchSize)
443+
444+
// let a =
445+
// await batches
446+
// ->Array.map(async t => {
447+
// (await t
448+
// ->Array.filter((({id}, _, _)) => !Array.includes(ignoreRuntimeTests, id))
449+
// ->Array.map(async ((example, rescriptCode, jsCode)) => {
450+
// let nodeTest = await runtimeTests(jsCode)
451+
// switch nodeTest {
452+
// | Ok(_) => None
453+
// | Error(error) => Some(example, RuntimeError({rescript: rescriptCode, js: jsCode, error}))
454+
// }
455+
// })
456+
// ->Promise.all)
457+
// ->Array.filterMap(i =>
458+
// switch i {
459+
// | Some(i) => Some(i)
460+
// | None => None
461+
// }
462+
// )
463+
// })
464+
// ->Promise.all
472465

473-
let runtimeErrors = Array.flat(a)
466+
let runtimeErrors = []
467+
// let runtimeErrors = Array.flat(a)
474468

475469
// let runtimeErrors =
476470
// (await compiled

tests/docstrings_examples/DocTest.res.mjs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ async function runtimeTests(code) {
122122
let exitCode = match.code;
123123
let stderr = match.stderr;
124124
let stdout = match.stdout;
125-
console.log({
126-
code: code,
127-
exitCode: exitCode,
128-
stdout: stdout,
129-
stderr: stderr
130-
});
131125
let std;
132126
let exit = 0;
133127
if (exitCode !== null) {
@@ -189,7 +183,7 @@ function extractDocFromFile(file) {
189183
RE_EXN_ID: "Assert_failure",
190184
_1: [
191185
"DocTest.res",
192-
206,
186+
199,
193187
9
194188
],
195189
Error: new Error()
@@ -357,7 +351,7 @@ async function main() {
357351
} else {
358352
return f.endsWith(".resi");
359353
}
360-
}).filter(f => f === "Uint8ClampedArray.res"), [], (acc, cur) => {
354+
}), [], (acc, cur) => {
361355
let isInterface = cur.endsWith(".resi");
362356
let resi = Path.join("runtime", cur + "i");
363357
if (!isInterface && Fs.existsSync(resi)) {
@@ -438,30 +432,8 @@ async function main() {
438432
rhs
439433
];
440434
});
441-
let batches = chunkArray(match[0], batchSize);
442-
let a = await Promise.all(batches.map(async t => $$Array.filterMap(await Promise.all(t.filter(param => !ignoreRuntimeTests.includes(param[0].id)).map(async param => {
443-
let jsCode = param[2];
444-
let nodeTest = await runtimeTests(jsCode);
445-
if (nodeTest.TAG === "Ok") {
446-
return;
447-
} else {
448-
return [
449-
param[0],
450-
{
451-
TAG: "RuntimeError",
452-
rescript: param[1],
453-
js: jsCode,
454-
error: nodeTest._0
455-
}
456-
];
457-
}
458-
})), i => {
459-
if (i !== undefined) {
460-
return i;
461-
}
462-
463-
})));
464-
let runtimeErrors = a.flat();
435+
chunkArray(match[0], batchSize);
436+
let runtimeErrors = [];
465437
let allErrors = runtimeErrors.concat(match[1]);
466438
allErrors.forEach(param => {
467439
let errors = param[1];

0 commit comments

Comments
 (0)