Skip to content

Commit f54ee80

Browse files
committed
add ignore-runtime-tests
1 parent 4f13047 commit f54ee80

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "rescript",
77
"watch": "rescript build -w",
88
"test": "node test/TestSuite.mjs && node test/TempTests.mjs",
9-
"test-doc-examples": "node scripts/DocTests.mjs"
9+
"test-doc-examples": "node scripts/DocTests.mjs --ignore-runtime-tests 'RescriptCore.Array.toReversed, RescriptCore.Promise.withResolvers'"
1010
},
1111
"keywords": [
1212
"rescript"

scripts/DocTests.mjs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as Os from "os";
55
import * as Url from "url";
66
import * as Path from "path";
77
import * as Belt_List from "rescript/lib/es6/belt_List.js";
8+
import * as Nodeutil from "node:util";
89
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
910
import * as Core__List from "../src/Core__List.mjs";
1011
import * as Caml_option from "rescript/lib/es6/caml_option.js";
@@ -28,14 +29,17 @@ var ChildProcess = {};
2829

2930
var OS = {};
3031

32+
var Util = {};
33+
3134
var $$Node = {
3235
Path: Path$1,
3336
$$URL: $$URL,
3437
Process: Process,
3538
Fs: Fs$1,
3639
$$Buffer: $$Buffer,
3740
ChildProcess: ChildProcess,
38-
OS: OS
41+
OS: OS,
42+
Util: Util
3943
};
4044

4145
var dirname = Path.dirname(Url.fileURLToPath(import.meta.url));
@@ -73,7 +77,7 @@ function prepareCompiler() {
7377
RE_EXN_ID: "Assert_failure",
7478
_1: [
7579
"DocTests.res",
76-
129,
80+
145,
7781
9
7882
],
7983
Error: new Error()
@@ -86,7 +90,7 @@ function prepareCompiler() {
8690
RE_EXN_ID: "Assert_failure",
8791
_1: [
8892
"DocTests.res",
89-
127,
93+
143,
9094
11
9195
],
9296
Error: new Error()
@@ -99,7 +103,7 @@ function prepareCompiler() {
99103
RE_EXN_ID: "Assert_failure",
100104
_1: [
101105
"DocTests.res",
102-
127,
106+
143,
103107
11
104108
],
105109
Error: new Error()
@@ -110,7 +114,7 @@ function prepareCompiler() {
110114
RE_EXN_ID: "Assert_failure",
111115
_1: [
112116
"DocTests.res",
113-
129,
117+
145,
114118
9
115119
],
116120
Error: new Error()
@@ -130,6 +134,24 @@ function prepareCompiler() {
130134
});
131135
}
132136

137+
var options = Object.fromEntries([[
138+
"ignore-runtime-tests",
139+
{
140+
type: "string"
141+
}
142+
]]);
143+
144+
var match = Nodeutil.parseArgs({
145+
args: process.argv.slice(2),
146+
options: options
147+
});
148+
149+
var values = match.values;
150+
151+
var v = values["ignore-runtime-tests"];
152+
153+
var ignoreRuntimeTests = v !== undefined ? v.split(",") : [];
154+
133155
prepareCompiler();
134156

135157
async function run(command, args, options) {
@@ -437,7 +459,9 @@ async function compilerResults() {
437459
]
438460
];
439461
});
440-
var exampleErrors = await Promise.all(examples.map(async function (param) {
462+
var exampleErrors = await Promise.all(examples.filter(function (param) {
463+
return !ignoreRuntimeTests.includes(param[0].id);
464+
}).map(async function (param) {
441465
var match = param[1];
442466
var nodeTests = await Promise.all(match[0].map(async function (param) {
443467
var js = param[1];
@@ -513,6 +537,9 @@ export {
513537
makePackageJson ,
514538
rescriptJson ,
515539
prepareCompiler ,
540+
options ,
541+
values ,
542+
ignoreRuntimeTests ,
516543
SpawnAsync ,
517544
createFileInTempDir ,
518545
compileTest ,

scripts/DocTests.res

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ module Node = {
1515
@scope("process") external exit: int => unit = "exit"
1616
@scope(("process", "stderr"))
1717
external stderrWrite: string => unit = "write"
18+
19+
@val @scope("process")
20+
external argv: array<string> = "argv"
1821
}
1922

2023
module Fs = {
@@ -56,6 +59,19 @@ module Node = {
5659
@module("os")
5760
external tmpdir: unit => string = "tmpdir"
5861
}
62+
63+
module Util = {
64+
type arg = {@as("type") type_: string}
65+
type config = {
66+
args: array<string>,
67+
options: Dict.t<arg>,
68+
}
69+
type parsed = {
70+
values: Dict.t<string>,
71+
positionals: array<string>,
72+
}
73+
@module("node:util") external parseArgs: config => parsed = "parseArgs"
74+
}
5975
}
6076

6177
open Node
@@ -143,6 +159,18 @@ let prepareCompiler = () => {
143159
ChildProcess.execFileSync(rescriptBin, ["build"], {cwd: compilerDir})->ignore
144160
}
145161

162+
let options = Dict.fromArray([("ignore-runtime-tests", {Util.type_: "string"})])
163+
164+
let {Util.values: values} = Util.parseArgs({
165+
args: Process.argv->Array.sliceToEnd(~start=2),
166+
options,
167+
})
168+
169+
let ignoreRuntimeTests = switch values->Dict.get("ignore-runtime-tests") {
170+
| Some(v) => v->String.split(",")
171+
| None => []
172+
}
173+
146174
prepareCompiler()
147175

148176
type example = {
@@ -373,6 +401,7 @@ let compilerResults = async () => {
373401

374402
let exampleErrors =
375403
await examples
404+
->Array.filter((({id}, _)) => !Array.includes(ignoreRuntimeTests, id))
376405
->Array.map(async ((example, (compiled, errors))) => {
377406
let nodeTests =
378407
await compiled

0 commit comments

Comments
 (0)