diff options
| author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-09-05 08:45:55 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-05 08:45:55 +1000 |
| commit | 195b17ae1298f80209e3c2c5ef4d133e6975ff58 (patch) | |
| tree | f9a059722830aa408ecd8f9f7e63180455eb14aa /tests/testdata | |
| parent | c32d692a8f37c50fd700bb320571f76a107a44c2 (diff) | |
BREAKING(types): soft-remove `Deno.run()` (#25403)
Towards #22079
Diffstat (limited to 'tests/testdata')
4 files changed, 15 insertions, 22 deletions
diff --git a/tests/testdata/coverage/complex_test.ts b/tests/testdata/coverage/complex_test.ts index d6e9c2691..6a711a91a 100644 --- a/tests/testdata/coverage/complex_test.ts +++ b/tests/testdata/coverage/complex_test.ts @@ -7,32 +7,29 @@ Deno.test("complex", function () { Deno.test("sub process with stdin", async () => { // ensure launching deno run with stdin doesn't affect coverage const code = "console.log('5')"; - // deno-lint-ignore no-deprecated-deno-api - const p = await Deno.run({ - cmd: [Deno.execPath(), "run", "-"], + const command = new Deno.Command(Deno.execPath(), { + args: ["run", "-"], stdin: "piped", stdout: "piped", }); - const encoder = new TextEncoder(); - await p.stdin.write(encoder.encode(code)); - await p.stdin.close(); - const output = new TextDecoder().decode(await p.output()); - p.close(); + await using child = command.spawn(); + await ReadableStream.from([code]) + .pipeThrough(new TextEncoderStream()) + .pipeTo(child.stdin); + const { stdout } = await child.output(); + const output = new TextDecoder().decode(stdout); if (output.trim() !== "5") { throw new Error("Failed"); } }); -Deno.test("sub process with deno eval", async () => { +Deno.test("sub process with deno eval", () => { // ensure launching deno eval doesn't affect coverage const code = "console.log('5')"; - // deno-lint-ignore no-deprecated-deno-api - const p = await Deno.run({ - cmd: [Deno.execPath(), "eval", code], - stdout: "piped", - }); - const output = new TextDecoder().decode(await p.output()); - p.close(); + const { stdout } = new Deno.Command(Deno.execPath(), { + args: ["eval", code], + }).outputSync(); + const output = new TextDecoder().decode(stdout); if (output.trim() !== "5") { throw new Error("Failed"); } diff --git a/tests/testdata/run/warn_on_deprecated_api/main.js b/tests/testdata/run/warn_on_deprecated_api/main.js index a464be60a..8811df78d 100644 --- a/tests/testdata/run/warn_on_deprecated_api/main.js +++ b/tests/testdata/run/warn_on_deprecated_api/main.js @@ -1,5 +1,6 @@ import { runEcho as runEcho2 } from "http://localhost:4545/run/warn_on_deprecated_api/mod.ts"; +// @ts-ignore `Deno.run()` was soft-removed in Deno 2. const p = Deno.run({ cmd: [ Deno.execPath(), @@ -11,6 +12,7 @@ await p.status(); p.close(); async function runEcho() { + // @ts-ignore `Deno.run()` was soft-removed in Deno 2. const p = Deno.run({ cmd: [ Deno.execPath(), diff --git a/tests/testdata/run/warn_on_deprecated_api/main.out b/tests/testdata/run/warn_on_deprecated_api/main.out index ff44c885f..ef85a6f99 100644 --- a/tests/testdata/run/warn_on_deprecated_api/main.out +++ b/tests/testdata/run/warn_on_deprecated_api/main.out @@ -1,5 +1,4 @@ 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. Run again with DENO_VERBOSE_WARNINGS=1 to get more details. hello world hello world hello world diff --git a/tests/testdata/run/warn_on_deprecated_api/main.verbose.out b/tests/testdata/run/warn_on_deprecated_api/main.verbose.out index 184051de1..e17562eef 100644 --- a/tests/testdata/run/warn_on_deprecated_api/main.verbose.out +++ b/tests/testdata/run/warn_on_deprecated_api/main.verbose.out @@ -1,5 +1,4 @@ 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. See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations @@ -9,7 +8,6 @@ Stack trace: hint: Use "Deno.Command()" API instead. hello world -warning: Use of deprecated "Deno.run()" API. This API will be removed in Deno 2. See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations @@ -20,7 +18,6 @@ Stack trace: hint: Use "Deno.Command()" API instead. hello world -warning: Use of deprecated "Deno.run()" API. This API will be removed in Deno 2. See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations @@ -31,7 +28,6 @@ Stack trace: hint: Use "Deno.Command()" API instead. hello world -warning: Use of deprecated "Deno.run()" API. This API will be removed in Deno 2. See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations @@ -51,7 +47,6 @@ hello world hello world hello world hello world -warning: Use of deprecated "Deno.run()" API. This API will be removed in Deno 2. See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations |
