Skip to content

Commit b1c1f13

Browse files
committed
tmp: only when spawning subprocesses?
1 parent b0c6124 commit b1c1f13

File tree

1 file changed

+22
-44
lines changed

1 file changed

+22
-44
lines changed

jscomp/build_tests/cli_help/input.js

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ const dumpHelp =
7676
let out;
7777

7878
console.group("build --help");
79-
out = child_process.spawnSync(`../../../rescript`, ["build", "--help"], {
79+
out = child_process.execSync(`../../../rescript build --help`, {
8080
encoding: "utf8",
8181
cwd: __dirname,
8282
});
83-
assert.equal(out.stdout, buildHelp);
84-
assert.equal(out.stderr, "");
85-
assert.equal(out.status, 0);
83+
assert.equal(out, buildHelp);
8684
console.groupEnd();
8785

8886
// console.group("build -w --help");
@@ -97,26 +95,22 @@ console.groupEnd();
9795

9896
console.group("-w --help");
9997
console.log("@@ begin ");
100-
out = child_process.spawnSync(`../../../rescript`, ["-w", "--help"], {
98+
out = child_process.execSync(`../../../rescript -w --help`, {
10199
encoding: "utf8",
102100
cwd: __dirname,
103101
});
104-
assert.equal(out.stdout, cliHelp);
105-
assert.equal(out.stderr, "");
106-
assert.equal(out.status, 0);
102+
assert.equal(out, cliHelp);
107103
console.log("@@ done");
108104
console.groupEnd();
109105

110106
// Shows cli help with --help arg even if there are invalid arguments after it
111107
console.group("--help -w");
112108
console.log("@@ begin ");
113-
out = child_process.spawnSync(`../../../rescript`, ["--help", "-w"], {
109+
out = child_process.execSync(`../../../rescript --help -w`, {
114110
encoding: "utf8",
115111
cwd: __dirname,
116112
});
117-
assert.equal(out.stdout, cliHelp);
118-
assert.equal(out.stderr, "");
119-
assert.equal(out.status, 0);
113+
assert.equal(out, cliHelp);
120114
console.log("@@ done");
121115
console.groupEnd();
122116

@@ -203,24 +197,20 @@ console.groupEnd();
203197

204198
// Shows clean help with --help arg
205199
console.group("clean --help");
206-
out = child_process.spawnSync(`../../../rescript`, ["clean", "--help"], {
200+
out = child_process.execSync(`../../../rescript clean --help`, {
207201
encoding: "utf8",
208202
cwd: __dirname,
209203
});
210-
assert.equal(out.stdout, cleanHelp);
211-
assert.equal(out.stderr, "");
212-
assert.equal(out.status, 0);
204+
assert.equal(out, cleanHelp);
213205
console.groupEnd();
214206

215207
// Shows clean help with -h arg
216208
console.group("clean -h");
217-
out = child_process.spawnSync(`../../../rescript`, ["clean", "-h"], {
209+
out = child_process.execSync(`../../../rescript clean -h`, {
218210
encoding: "utf8",
219211
cwd: __dirname,
220212
});
221-
assert.equal(out.stdout, cleanHelp);
222-
assert.equal(out.stderr, "");
223-
assert.equal(out.status, 0);
213+
assert.equal(out, cleanHelp);
224214
console.groupEnd();
225215

226216
// Exits with clean help with unknown arg
@@ -236,66 +226,54 @@ console.groupEnd();
236226

237227
// Shows format help with --help arg
238228
console.group("format --help");
239-
out = child_process.spawnSync(`../../../rescript`, ["format", "--help"], {
229+
out = child_process.execSync(`../../../rescript format --help`, {
240230
encoding: "utf8",
241231
cwd: __dirname,
242232
});
243-
assert.equal(out.stdout, formatHelp);
244-
assert.equal(out.stderr, "");
245-
assert.equal(out.status, 0);
233+
assert.equal(out, formatHelp);
246234
console.groupEnd();
247235

248236
// Shows format help with -h arg
249237
console.group("format -h");
250-
out = child_process.spawnSync(`../../../rescript`, ["format", "-h"], {
238+
out = child_process.execSync(`../../../rescript format -h`, {
251239
encoding: "utf8",
252240
cwd: __dirname,
253241
});
254-
assert.equal(out.stdout, formatHelp);
255-
assert.equal(out.stderr, "");
256-
assert.equal(out.status, 0);
242+
assert.equal(out, formatHelp);
257243
console.groupEnd();
258244

259245
// Shows convert help with --help arg
260246
console.group("convert --help");
261-
out = child_process.spawnSync(`../../../rescript`, ["convert", "--help"], {
247+
out = child_process.execSync(`../../../rescript convert --help`, {
262248
encoding: "utf8",
263249
cwd: __dirname,
264250
});
265-
assert.equal(out.stdout, convertHelp);
266-
assert.equal(out.stderr, "");
267-
assert.equal(out.status, 0);
251+
assert.equal(out, convertHelp);
268252
console.groupEnd();
269253

270254
// Shows convert help with -h arg
271255
console.group("convert -h");
272-
out = child_process.spawnSync(`../../../rescript`, ["convert", "-h"], {
256+
out = child_process.execSync(`../../../rescript convert -h`, {
273257
encoding: "utf8",
274258
cwd: __dirname,
275259
});
276-
assert.equal(out.stdout, convertHelp);
277-
assert.equal(out.stderr, "");
278-
assert.equal(out.status, 0);
260+
assert.equal(out, convertHelp);
279261
console.groupEnd();
280262

281263
// Shows dump help with --help arg
282264
console.group("dump --help");
283-
out = child_process.spawnSync(`../../../rescript`, ["dump", "--help"], {
265+
out = child_process.execSync(`../../../rescript dump --help`, {
284266
encoding: "utf8",
285267
cwd: __dirname,
286268
});
287-
assert.equal(out.stdout, dumpHelp);
288-
assert.equal(out.stderr, "");
289-
assert.equal(out.status, 0);
269+
assert.equal(out, dumpHelp);
290270
console.groupEnd();
291271

292272
// Shows dump help with -h arg
293273
console.group("dump -h");
294-
out = child_process.spawnSync(`../../../rescript`, ["dump", "-h"], {
274+
out = child_process.execSync(`../../../rescript dump -h`, {
295275
encoding: "utf8",
296276
cwd: __dirname,
297277
});
298-
assert.equal(out.stdout, dumpHelp);
299-
assert.equal(out.stderr, "");
300-
assert.equal(out.status, 0);
278+
assert.equal(out, dumpHelp);
301279
console.groupEnd();

0 commit comments

Comments
 (0)