Skip to content

Commit e998f95

Browse files
committed
Update tests
1 parent 165a42c commit e998f95

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

jscomp/build_tests/cli_help/input.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,41 +80,58 @@ let out = child_process.spawnSync(`../../../rescript`, ["build", "--help"], {
8080
cwd: __dirname,
8181
});
8282
assert.equal(out.stdout, buildHelp);
83+
assert.equal(out.status, 0);
84+
85+
// Shows build help with --help arg
86+
out = child_process.spawnSync(`../../../rescript`, ["build", "-w", "--help"], {
87+
encoding: "utf8",
88+
cwd: __dirname,
89+
});
90+
// FIXME: Shouldn't have "Start compiling" for help
91+
assert.equal(out.stdout, ">>>> Start compiling\n" + buildHelp);
92+
// FIXME: Should be 0
93+
assert.equal(out.status, 1);
8394

8495
// Shows build help with -h arg
8596
out = child_process.spawnSync(`../../../rescript`, ["build", "-h"], {
8697
encoding: "utf8",
8798
cwd: __dirname,
8899
});
89100
assert.equal(out.stdout, buildHelp);
101+
assert.equal(out.status, 0);
90102

91103
// Exits with build help with unknown arg
92104
out = child_process.spawnSync(`../../../rescript`, ["build", "-wtf"], {
93105
encoding: "utf8",
94106
cwd: __dirname,
95107
});
96108
assert.equal(out.stderr, "Error: unknown option: '-wtf'.\n" + buildHelp + "\n");
109+
assert.equal(out.status, 2);
97110

98111
// Shows cli help with --help arg
99112
out = child_process.spawnSync(`../../../rescript`, ["--help"], {
100113
encoding: "utf8",
101114
cwd: __dirname,
102115
});
103116
assert.equal(out.stdout, cliHelp);
117+
// FIXME: Should be 0
118+
assert.equal(out.status, 2);
104119

105120
// Shows cli help with -h arg
106121
out = child_process.spawnSync(`../../../rescript`, ["-h"], {
107122
encoding: "utf8",
108123
cwd: __dirname,
109124
});
110125
assert.equal(out.stdout, cliHelp);
126+
assert.equal(out.status, 0);
111127

112128
// Shows cli help with help command
113129
out = child_process.spawnSync(`../../../rescript`, ["help"], {
114130
encoding: "utf8",
115131
cwd: __dirname,
116132
});
117133
assert.equal(out.stdout, cliHelp);
134+
assert.equal(out.status, 0);
118135

119136
// Shows cli help with unknown command
120137
out = child_process.spawnSync(`../../../rescript`, ["built"], {
@@ -123,6 +140,8 @@ out = child_process.spawnSync(`../../../rescript`, ["built"], {
123140
});
124141
// Should write to stderr instead ???
125142
assert.equal(out.stdout, cliHelp);
143+
// FIXME: Should show a warning that it's an unknown command
144+
assert.equal(out.status, 2);
126145

127146
// Shows cli help with unknown args
128147
out = child_process.spawnSync(`../../../rescript`, ["-w"], {
@@ -131,27 +150,32 @@ out = child_process.spawnSync(`../../../rescript`, ["-w"], {
131150
});
132151
// Should write to stderr instead ???
133152
assert.equal(out.stdout, cliHelp);
153+
// FIXME: Should show a warning that it's an unknown arg
154+
assert.equal(out.status, 2);
134155

135156
// Shows clean help with --help arg
136157
out = child_process.spawnSync(`../../../rescript`, ["clean", "--help"], {
137158
encoding: "utf8",
138159
cwd: __dirname,
139160
});
140161
assert.equal(out.stdout, cleanHelp);
162+
assert.equal(out.status, 0);
141163

142164
// Shows clean help with -h arg
143165
out = child_process.spawnSync(`../../../rescript`, ["clean", "-h"], {
144166
encoding: "utf8",
145167
cwd: __dirname,
146168
});
147169
assert.equal(out.stdout, cleanHelp);
170+
assert.equal(out.status, 0);
148171

149172
// Exits with clean help with unknown arg
150173
out = child_process.spawnSync(`../../../rescript`, ["clean", "-wtf"], {
151174
encoding: "utf8",
152175
cwd: __dirname,
153176
});
154177
assert.equal(out.stderr, "Error: unknown option: '-wtf'.\n" + cleanHelp + "\n");
178+
assert.equal(out.status, 2);
155179

156180
// Shows format help with --help arg
157181
out = child_process.spawnSync(`../../../rescript`, ["format", "--help"], {
@@ -160,6 +184,7 @@ out = child_process.spawnSync(`../../../rescript`, ["format", "--help"], {
160184
});
161185
// Note: it writes to stderr
162186
assert.equal(out.stderr, formatHelp);
187+
assert.equal(out.status, 0);
163188

164189
// Shows format help with -h arg
165190
out = child_process.spawnSync(`../../../rescript`, ["format", "-h"], {
@@ -168,6 +193,7 @@ out = child_process.spawnSync(`../../../rescript`, ["format", "-h"], {
168193
});
169194
// Note: it writes to stderr
170195
assert.equal(out.stderr, formatHelp);
196+
assert.equal(out.status, 0);
171197

172198
// Shows convert help with --help arg
173199
out = child_process.spawnSync(`../../../rescript`, ["convert", "--help"], {
@@ -176,6 +202,7 @@ out = child_process.spawnSync(`../../../rescript`, ["convert", "--help"], {
176202
});
177203
// Note: it writes to stderr
178204
assert.equal(out.stderr, convertHelp);
205+
assert.equal(out.status, 0);
179206

180207
// Shows convert help with -h arg
181208
out = child_process.spawnSync(`../../../rescript`, ["convert", "-h"], {
@@ -184,6 +211,7 @@ out = child_process.spawnSync(`../../../rescript`, ["convert", "-h"], {
184211
});
185212
// Note: it writes to stderr
186213
assert.equal(out.stderr, convertHelp);
214+
assert.equal(out.status, 0);
187215

188216
// Shows dump help with --help arg
189217
out = child_process.spawnSync(`../../../rescript`, ["dump", "--help"], {
@@ -192,6 +220,7 @@ out = child_process.spawnSync(`../../../rescript`, ["dump", "--help"], {
192220
});
193221
// Note: it writes to stderr
194222
assert.equal(out.stderr, dumpHelp);
223+
assert.equal(out.status, 0);
195224

196225
// Shows dump help with -h arg
197226
out = child_process.spawnSync(`../../../rescript`, ["dump", "-h"], {
@@ -200,3 +229,4 @@ out = child_process.spawnSync(`../../../rescript`, ["dump", "-h"], {
200229
});
201230
// Note: it writes to stderr
202231
assert.equal(out.stderr, dumpHelp);
232+
assert.equal(out.status, 0);

0 commit comments

Comments
 (0)