Skip to content

Treat rescript as rescript build aka rescript -w support 🚀 #6524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions jscomp/build_tests/cli_help/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ assert.match(
// FIXME: Should be 0
assert.equal(out.status, 1);

// FIXME: Has the same problem with `rescript -w`
out = child_process.spawnSync(`../../../rescript`, ["-w", "--help"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, ">>>> Start compiling\n" + buildHelp);
assert.match(
out.stderr,
new RegExp(
"Uncaught Exception Error: ENOENT: no such file or directory, watch 'bsconfig.json'\n"
)
);

// Shows cli help with --help arg even if there are invalid arguments after it
out = child_process.spawnSync(`../../../rescript`, ["--help", "-w"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, cliHelp);
assert.equal(out.stderr, "");
assert.equal(out.status, 0);

// Shows build help with -h arg
out = child_process.spawnSync(`../../../rescript`, ["build", "-h"], {
encoding: "utf8",
Expand All @@ -108,12 +130,12 @@ assert.equal(out.stderr, "");
assert.equal(out.status, 0);

// Exits with build help with unknown arg
out = child_process.spawnSync(`../../../rescript`, ["build", "-wtf"], {
out = child_process.spawnSync(`../../../rescript`, ["build", "-foo"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, "");
assert.equal(out.stderr, 'Error: Unknown option "-wtf".\n' + buildHelp);
assert.equal(out.stderr, 'Error: Unknown option "-foo".\n' + buildHelp);
assert.equal(out.status, 2);

// Shows cli help with --help arg
Expand Down Expand Up @@ -143,22 +165,22 @@ assert.equal(out.stdout, cliHelp);
assert.equal(out.stderr, "");
assert.equal(out.status, 0);

// Shows cli help with unknown command
// Exits with cli help with unknown command
out = child_process.spawnSync(`../../../rescript`, ["built"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, "");
assert.equal(out.stderr, `Error: Unknown command or flag "built".\n` + cliHelp);
assert.equal(out.stderr, `Error: Unknown command "built".\n` + cliHelp);
assert.equal(out.status, 2);

// Shows cli help with unknown args
out = child_process.spawnSync(`../../../rescript`, ["-w"], {
// Exits with build help with unknown args
out = child_process.spawnSync(`../../../rescript`, ["-foo"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, "");
assert.equal(out.stderr, `Error: Unknown command or flag "-w".\n` + cliHelp);
assert.equal(out.stderr, 'Error: Unknown option "-foo".\n' + buildHelp);
assert.equal(out.status, 2);

// Shows clean help with --help arg
Expand All @@ -180,12 +202,12 @@ assert.equal(out.stderr, "");
assert.equal(out.status, 0);

// Exits with clean help with unknown arg
out = child_process.spawnSync(`../../../rescript`, ["clean", "-wtf"], {
out = child_process.spawnSync(`../../../rescript`, ["clean", "-foo"], {
encoding: "utf8",
cwd: __dirname,
});
assert.equal(out.stdout, "");
assert.equal(out.stderr, 'Error: Unknown option "-wtf".\n' + cleanHelp);
assert.equal(out.stderr, 'Error: Unknown option "-foo".\n' + cleanHelp);
assert.equal(out.status, 2);

// Shows format help with --help arg
Expand Down
Loading