summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2021-11-28 00:45:38 +0100
committerGitHub <noreply@github.com>2021-11-28 00:45:38 +0100
commit993a1dd41ae5f96bdb24b09757e24c2ac24126d0 (patch)
tree8b6c0d4de8f8101bf8a3c31fe4f163d18c2c298e /cli/tests
parent1d3f734e1815bf1649e0cac445be9eacb4cd296d (diff)
feat(runtime): add op_set_exit_code (#12911)
Set the exit code to use if none is provided to Deno.exit(), or when Deno exits naturally. Needed for process.exitCode Node compat. Paves the way for #12888.
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/run_tests.rs18
-rw-r--r--cli/tests/testdata/empty.out0
-rw-r--r--cli/tests/testdata/set_exit_code_0.ts2
-rw-r--r--cli/tests/testdata/set_exit_code_1.ts2
-rw-r--r--cli/tests/testdata/set_exit_code_2.ts2
5 files changed, 24 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index d6a5a4c25..47041e499 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -859,6 +859,24 @@ itest!(exit_error42 {
output: "exit_error42.ts.out",
});
+itest!(set_exit_code_0 {
+ args: "run --no-check --unstable set_exit_code_0.ts",
+ output: "empty.out",
+ exit_code: 0,
+});
+
+itest!(set_exit_code_1 {
+ args: "run --no-check --unstable set_exit_code_1.ts",
+ output: "empty.out",
+ exit_code: 42,
+});
+
+itest!(set_exit_code_2 {
+ args: "run --no-check --unstable set_exit_code_2.ts",
+ output: "empty.out",
+ exit_code: 42,
+});
+
itest!(heapstats {
args: "run --quiet --unstable --v8-flags=--expose-gc heapstats.js",
output: "heapstats.js.out",
diff --git a/cli/tests/testdata/empty.out b/cli/tests/testdata/empty.out
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/cli/tests/testdata/empty.out
diff --git a/cli/tests/testdata/set_exit_code_0.ts b/cli/tests/testdata/set_exit_code_0.ts
new file mode 100644
index 000000000..7eb14fa3c
--- /dev/null
+++ b/cli/tests/testdata/set_exit_code_0.ts
@@ -0,0 +1,2 @@
+Deno.core.opSync("op_set_exit_code", 42);
+Deno.exit(0); // Takes precedence.
diff --git a/cli/tests/testdata/set_exit_code_1.ts b/cli/tests/testdata/set_exit_code_1.ts
new file mode 100644
index 000000000..96ec9889c
--- /dev/null
+++ b/cli/tests/testdata/set_exit_code_1.ts
@@ -0,0 +1,2 @@
+Deno.core.opSync("op_set_exit_code", 42);
+Deno.exit();
diff --git a/cli/tests/testdata/set_exit_code_2.ts b/cli/tests/testdata/set_exit_code_2.ts
new file mode 100644
index 000000000..a1f2b5d3c
--- /dev/null
+++ b/cli/tests/testdata/set_exit_code_2.ts
@@ -0,0 +1,2 @@
+Deno.core.opSync("op_set_exit_code", 42);
+// Exits naturally.