Skip to content

Commit bf7348e

Browse files
committed
add timeout
1 parent 4753240 commit bf7348e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

scripts/DocTests.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,11 @@ function getCodeBlocks(example) {
323323

324324
async function runtimeTests(code) {
325325
var match = await run("node", [
326-
"-p",
326+
"-e",
327327
code
328328
], {
329-
cwd: compilerDir
329+
cwd: compilerDir,
330+
timeout: 2000
330331
});
331332
var stderr = match.stderr;
332333
if (stderr.length > 0) {

scripts/DocTests.res

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
open RescriptCore
2+
13
module Node = {
24
module Path = {
35
@module("path") external join2: (string, string) => string = "join"
@@ -41,14 +43,13 @@ module Node = {
4143

4244
type readable
4345
type spawnReturns = {stderr: readable, stdout: readable}
44-
type options = {cwd?: string}
46+
type options = {cwd?: string, env?: Dict.t<string>, timeout?: int}
4547
@module("child_process")
4648
external spawn: (string, array<string>, ~options: options=?) => spawnReturns = "spawn"
4749

4850
@send external on: (readable, string, Buffer.t => unit) => unit = "on"
4951
@send
50-
external once: (spawnReturns, string, (Js.Null.t<float>, Js.Null.t<string>) => unit) => unit =
51-
"once"
52+
external once: (spawnReturns, string, (Null.t<float>, Null.t<string>) => unit) => unit = "once"
5253
}
5354

5455
module OS = {
@@ -57,7 +58,6 @@ module Node = {
5758
}
5859
}
5960

60-
open RescriptCore
6161
open Node
6262

6363
module Docgen = RescriptTools.Docgen
@@ -299,8 +299,11 @@ let getCodeBlocks = example => {
299299
let runtimeTests = async code => {
300300
let {stdout, stderr} = await SpawnAsync.run(
301301
~command="node",
302-
~args=["-p", code],
303-
~options={cwd: compilerDir},
302+
~args=["-e", code],
303+
~options={
304+
cwd: compilerDir,
305+
timeout: 2000,
306+
},
304307
)
305308

306309
switch Array.length(stderr) > 0 {

0 commit comments

Comments
 (0)