Skip to content

Commit fc87b24

Browse files
committed
better debug
1 parent b14c648 commit fc87b24

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

tests/docstrings_examples/DocTest.res

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ module SpawnAsync = {
9292
stdout: array<Buffer.t>,
9393
stderr: array<Buffer.t>,
9494
code: Null.t<float>,
95+
signal: Null.t<string>,
9596
}
9697
let run = async (~command, ~args, ~options=?) => {
9798
let spawn = ChildProcess.spawn(command, args, ~options?)
@@ -104,11 +105,11 @@ module SpawnAsync = {
104105
Array.push(stderr, data)
105106
})
106107
await Promise.make((resolve, reject) => {
107-
spawn->ChildProcess.once("error", (_, _) => {
108-
reject({stdout, stderr, code: Null.make(1.0)})
108+
spawn->ChildProcess.once("error", (code, signal) => {
109+
reject({stdout, stderr, code, signal})
109110
})
110-
spawn->ChildProcess.once("close", (code, _signal) => {
111-
resolve({stdout, stderr, code})
111+
spawn->ChildProcess.once("close", (code, signal) => {
112+
resolve({stdout, stderr, code, signal})
112113
})
113114
})
114115
}
@@ -124,15 +125,16 @@ type example = {
124125
let createFileInTempDir = id => Path.join2(OS.tmpdir(), id)
125126

126127
let compileTest = async (~id, ~code) => {
127-
Console.log({"id": id, "code": code})
128-
let {stderr, stdout} = await SpawnAsync.run(
128+
let {stderr, stdout, code, signal} = await SpawnAsync.run(
129129
~command=bscBin,
130130
// NOTE: warnings argument (-w) should be before eval (-e) argument
131131
~args=["-w", "-3-109-44", "-e", code],
132132
)
133133

134134
Console.log({
135135
"id": id,
136+
"code": code,
137+
"signal": signal,
136138
"stderr": stderr
137139
->Array.map(e => e->Buffer.toString)
138140
->Array.join(""),

tests/docstrings_examples/DocTest.res.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ async function run(command, args, options) {
7272
stderr.push(data);
7373
});
7474
return await new Promise((resolve, reject) => {
75-
spawn.once("error", (param, param$1) => reject({
75+
spawn.once("error", (code, signal) => reject({
7676
stdout: stdout,
7777
stderr: stderr,
78-
code: 1.0
78+
code: code,
79+
signal: signal
7980
}));
80-
spawn.once("close", (code, _signal) => resolve({
81+
spawn.once("close", (code, signal) => resolve({
8182
stdout: stdout,
8283
stderr: stderr,
83-
code: code
84+
code: code,
85+
signal: signal
8486
}));
8587
});
8688
}
@@ -94,10 +96,6 @@ function createFileInTempDir(id) {
9496
}
9597

9698
async function compileTest(id, code) {
97-
console.log({
98-
id: id,
99-
code: code
100-
});
10199
let match = await run(bscBin, [
102100
"-w",
103101
"-3-109-44",
@@ -108,6 +106,8 @@ async function compileTest(id, code) {
108106
let stdout = match.stdout;
109107
console.log({
110108
id: id,
109+
code: match.code,
110+
signal: match.signal,
111111
stderr: stderr.map(e => e.toString()).join(""),
112112
stdout: stdout.map(e => e.toString()).join("")
113113
});
@@ -202,7 +202,7 @@ function extractDocFromFile(file) {
202202
RE_EXN_ID: "Assert_failure",
203203
_1: [
204204
"DocTest.res",
205-
217,
205+
219,
206206
9
207207
],
208208
Error: new Error()

0 commit comments

Comments
 (0)