summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/run_tests.rs22
-rw-r--r--cli/tests/testdata/run/warn_on_deprecated_api/main.js32
-rw-r--r--cli/tests/testdata/run/warn_on_deprecated_api/main.out72
-rw-r--r--cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_env.out15
-rw-r--r--cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_flag.out14
-rw-r--r--cli/tests/testdata/run/warn_on_deprecated_api/mod.ts11
6 files changed, 166 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 8db06470d..3fd013376 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -4939,3 +4939,25 @@ itest!(unstable_temporal_api_missing_flag {
http_server: false,
exit_code: 1,
});
+
+itest!(warn_on_deprecated_api {
+ args: "run -A run/warn_on_deprecated_api/main.js",
+ output: "run/warn_on_deprecated_api/main.out",
+ http_server: true,
+ exit_code: 0,
+});
+
+itest!(warn_on_deprecated_api_with_flag {
+ args: "run -A --quiet run/warn_on_deprecated_api/main.js",
+ output: "run/warn_on_deprecated_api/main_disabled_flag.out",
+ http_server: true,
+ exit_code: 0,
+});
+
+itest!(warn_on_deprecated_api_with_env_var {
+ args: "run -A run/warn_on_deprecated_api/main.js",
+ envs: vec![("DENO_NO_DEPRECATION_WARNINGS".to_string(), "1".to_string())],
+ output: "run/warn_on_deprecated_api/main_disabled_env.out",
+ http_server: true,
+ exit_code: 0,
+});
diff --git a/cli/tests/testdata/run/warn_on_deprecated_api/main.js b/cli/tests/testdata/run/warn_on_deprecated_api/main.js
new file mode 100644
index 000000000..a464be60a
--- /dev/null
+++ b/cli/tests/testdata/run/warn_on_deprecated_api/main.js
@@ -0,0 +1,32 @@
+import { runEcho as runEcho2 } from "http://localhost:4545/run/warn_on_deprecated_api/mod.ts";
+
+const p = Deno.run({
+ cmd: [
+ Deno.execPath(),
+ "eval",
+ "console.log('hello world')",
+ ],
+});
+await p.status();
+p.close();
+
+async function runEcho() {
+ const p = Deno.run({
+ cmd: [
+ Deno.execPath(),
+ "eval",
+ "console.log('hello world')",
+ ],
+ });
+ await p.status();
+ p.close();
+}
+
+await runEcho();
+await runEcho();
+
+for (let i = 0; i < 10; i++) {
+ await runEcho();
+}
+
+await runEcho2();
diff --git a/cli/tests/testdata/run/warn_on_deprecated_api/main.out b/cli/tests/testdata/run/warn_on_deprecated_api/main.out
new file mode 100644
index 000000000..984dbc291
--- /dev/null
+++ b/cli/tests/testdata/run/warn_on_deprecated_api/main.out
@@ -0,0 +1,72 @@
+Download http://localhost:4545/run/warn_on_deprecated_api/mod.ts
+Warning
+├ Use of deprecated "Deno.run()" API.
+│
+├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
+│
+├ Suggestion: Use "Deno.Command()" API instead.
+│
+└ Stack trace:
+ └─ at [WILDCARD]warn_on_deprecated_api/main.js:3:16
+
+hello world
+Warning
+├ Use of deprecated "Deno.run()" API.
+│
+├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
+│
+├ Suggestion: Use "Deno.Command()" API instead.
+│
+└ Stack trace:
+ ├─ at runEcho ([WILDCARD]warn_on_deprecated_api/main.js:14:18)
+ └─ at [WILDCARD]warn_on_deprecated_api/main.js:25:7
+
+hello world
+Warning
+├ Use of deprecated "Deno.run()" API.
+│
+├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
+│
+├ Suggestion: Use "Deno.Command()" API instead.
+│
+└ Stack trace:
+ ├─ at runEcho ([WILDCARD]warn_on_deprecated_api/main.js:14:18)
+ └─ at [WILDCARD]warn_on_deprecated_api/main.js:26:7
+
+hello world
+Warning
+├ Use of deprecated "Deno.run()" API.
+│
+├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
+│
+├ Suggestion: Use "Deno.Command()" API instead.
+│
+└ Stack trace:
+ ├─ at runEcho ([WILDCARD]warn_on_deprecated_api/main.js:14:18)
+ └─ at [WILDCARD]warn_on_deprecated_api/main.js:29:9
+
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+Warning
+├ Use of deprecated "Deno.run()" API.
+│
+├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
+│
+├ Suggestion: Use "Deno.Command()" API instead.
+│
+├ Suggestion: It appears this API is used by a remote dependency.
+│ Try upgrading to the latest version of that dependency.
+│
+└ Stack trace:
+ ├─ at runEcho (http://localhost:4545/run/warn_on_deprecated_api/mod.ts:2:18)
+ └─ at [WILDCARD]warn_on_deprecated_api/main.js:32:7
+
+hello world
diff --git a/cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_env.out b/cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_env.out
new file mode 100644
index 000000000..ef85a6f99
--- /dev/null
+++ b/cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_env.out
@@ -0,0 +1,15 @@
+Download http://localhost:4545/run/warn_on_deprecated_api/mod.ts
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
diff --git a/cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_flag.out b/cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_flag.out
new file mode 100644
index 000000000..ce3755d16
--- /dev/null
+++ b/cli/tests/testdata/run/warn_on_deprecated_api/main_disabled_flag.out
@@ -0,0 +1,14 @@
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
+hello world
diff --git a/cli/tests/testdata/run/warn_on_deprecated_api/mod.ts b/cli/tests/testdata/run/warn_on_deprecated_api/mod.ts
new file mode 100644
index 000000000..f74632b2c
--- /dev/null
+++ b/cli/tests/testdata/run/warn_on_deprecated_api/mod.ts
@@ -0,0 +1,11 @@
+export async function runEcho() {
+ const p = Deno.run({
+ cmd: [
+ Deno.execPath(),
+ "eval",
+ "console.log('hello world')",
+ ],
+ });
+ await p.status();
+ p.close();
+}