1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00
denoland-deno/cli/tests/integration
Bartek Iwańczuk c62615bfe5
feat: Start warning on each use of a deprecated API (#21939)
This commit introduces deprecation warnings for "Deno.*" APIs.

This is gonna be quite noisy, but should tremendously help with user
code updates to ensure
smooth migration to Deno 2.0. The warning is printed at each unique call
site to help quickly
identify where code needs to be adjusted. There's some stack frame
filtering going on to
remove frames that are not useful to the user and would only cause
confusion.

The warning can be silenced using "--quiet" flag or
"DENO_NO_DEPRECATION_WARNINGS" env var.

"Deno.run()" API is now using this warning. Other deprecated APIs will
start warning
in follow up PRs.

Example:

```js
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();

```

```
$ deno run --allow-read foo.js
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 file:///Users/ib/dev/deno/foo.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 (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:13: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 (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:14: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 (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:17: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 file:///Users/ib/dev/deno/foo.js:20:7

hello world

```

Closes #21839
2024-01-18 23:30:49 +00:00
..
bench_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
bundle_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
cache_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
cert_tests.rs chore: bump rustls-tokio-stream and rustls (#21955) 2024-01-16 21:51:54 +01:00
check_tests.rs fix(check): should not panic when all specified files excluded (#21929) 2024-01-13 16:06:18 -05:00
compile_tests.rs fix(compile): preserve granular unstable features (#21827) 2024-01-06 19:31:09 +05:30
coverage_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
doc_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
eval_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
flags_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
fmt_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
info_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
init_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
inspector_tests.rs chore: ignore inspector_port_collision test (#21923) 2024-01-16 13:50:03 -07:00
install_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
js_unit_tests.rs chore: increase unit test timeout to 3m (#21760) 2024-01-02 16:56:52 +01:00
jsr_tests.rs feat(unstable): fast subset type checking of JSR dependencies (#21873) 2024-01-10 22:40:30 +00:00
jupyter_tests.rs feat(jupyter): don't require --unstable flag (#21963) 2024-01-18 23:16:14 +01:00
lint_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
lsp_tests.rs fix(lsp): regression - formatting was broken on windows (#21972) 2024-01-18 15:57:30 -05:00
mod.rs fix(jupyter): error message when install fails due to jupyter command not being on PATH (#21767) 2024-01-03 14:45:10 +00:00
node_compat_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
node_unit_tests.rs feat: "rejectionhandled" Web event and "rejectionHandled" Node event (#21875) 2024-01-12 22:10:42 +00:00
npm_tests.rs fix(unstable/byonm): support using an import map with byonm (#21786) 2024-01-04 09:20:58 +05:30
publish_tests.rs fix(publish): support deno.jsonc file (#21948) 2024-01-15 15:07:57 +00:00
repl_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
run_tests.rs feat: Start warning on each use of a deprecated API (#21939) 2024-01-18 23:30:49 +00:00
shared_library_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
task_tests.rs fix(task): do not eagerly auto-install packages in package.json when "nodeModulesDir": false (#21858) 2024-01-08 19:30:36 -05:00
test_tests.rs fix(config): regression - handle relative patterns with leading dot slash (#21922) 2024-01-13 10:39:22 -05:00
upgrade_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
vendor_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
watcher_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
worker_tests.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00