diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/cat.ts | 10 | ||||
-rw-r--r-- | cli/tests/compiler_api_test.ts | 50 | ||||
-rw-r--r-- | cli/tests/complex_permissions_test.ts | 12 | ||||
-rw-r--r-- | cli/tests/echo_server.ts | 7 | ||||
-rw-r--r-- | cli/tests/permission_test.ts | 16 | ||||
-rw-r--r-- | cli/tests/unbuffered_stderr.ts | 4 | ||||
-rw-r--r-- | cli/tests/unbuffered_stdout.ts | 4 | ||||
-rw-r--r-- | cli/tests/unit/buffer_test.ts | 55 | ||||
-rw-r--r-- | cli/tests/unit/process_test.ts | 67 |
9 files changed, 102 insertions, 123 deletions
diff --git a/cli/tests/cat.ts b/cli/tests/cat.ts index bd6b5af06..a5b38fccd 100644 --- a/cli/tests/cat.ts +++ b/cli/tests/cat.ts @@ -1,10 +1,8 @@ -const { stdout, open, copy, args } = Deno; - async function main(): Promise<void> { - for (let i = 1; i < args.length; i++) { - const filename = args[i]; - const file = await open(filename); - await copy(file, stdout); + for (let i = 1; i < Deno.args.length; i++) { + const filename = Deno.args[i]; + const file = await Deno.open(filename); + await Deno.copy(file, Deno.stdout); } } diff --git a/cli/tests/compiler_api_test.ts b/cli/tests/compiler_api_test.ts index cdc2be6d2..967220cb4 100644 --- a/cli/tests/compiler_api_test.ts +++ b/cli/tests/compiler_api_test.ts @@ -1,10 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - import { assert, assertEquals } from "../../std/testing/asserts.ts"; -const { compile, transpileOnly, bundle, test } = Deno; -test("compilerApiCompileSources", async function () { - const [diagnostics, actual] = await compile("/foo.ts", { +Deno.test("compilerApiCompileSources", async function () { + const [diagnostics, actual] = await Deno.compile("/foo.ts", { "/foo.ts": `import * as bar from "./bar.ts";\n\nconsole.log(bar);\n`, "/bar.ts": `export const bar = "bar";\n`, }); @@ -18,8 +16,8 @@ test("compilerApiCompileSources", async function () { ]); }); -test("compilerApiCompileNoSources", async function () { - const [diagnostics, actual] = await compile("./subdir/mod1.ts"); +Deno.test("compilerApiCompileNoSources", async function () { + const [diagnostics, actual] = await Deno.compile("./subdir/mod1.ts"); assert(diagnostics == null); assert(actual); const keys = Object.keys(actual); @@ -28,8 +26,8 @@ test("compilerApiCompileNoSources", async function () { assert(keys[1].endsWith("print_hello.js")); }); -test("compilerApiCompileOptions", async function () { - const [diagnostics, actual] = await compile( +Deno.test("compilerApiCompileOptions", async function () { + const [diagnostics, actual] = await Deno.compile( "/foo.ts", { "/foo.ts": `export const foo = "foo";`, @@ -45,8 +43,8 @@ test("compilerApiCompileOptions", async function () { assert(actual["/foo.js"].startsWith("define(")); }); -test("compilerApiCompileLib", async function () { - const [diagnostics, actual] = await compile( +Deno.test("compilerApiCompileLib", async function () { + const [diagnostics, actual] = await Deno.compile( "/foo.ts", { "/foo.ts": `console.log(document.getElementById("foo")); @@ -61,8 +59,8 @@ test("compilerApiCompileLib", async function () { assertEquals(Object.keys(actual), ["/foo.js.map", "/foo.js"]); }); -test("compilerApiCompileTypes", async function () { - const [diagnostics, actual] = await compile( +Deno.test("compilerApiCompileTypes", async function () { + const [diagnostics, actual] = await Deno.compile( "/foo.ts", { "/foo.ts": `console.log(Foo.bar);`, @@ -76,8 +74,8 @@ test("compilerApiCompileTypes", async function () { assertEquals(Object.keys(actual), ["/foo.js.map", "/foo.js"]); }); -test("transpileOnlyApi", async function () { - const actual = await transpileOnly({ +Deno.test("transpileOnlyApi", async function () { + const actual = await Deno.transpileOnly({ "foo.ts": `export enum Foo { Foo, Bar, Baz };\n`, }); assert(actual); @@ -86,8 +84,8 @@ test("transpileOnlyApi", async function () { assert(actual["foo.ts"].map); }); -test("transpileOnlyApiConfig", async function () { - const actual = await transpileOnly( +Deno.test("transpileOnlyApiConfig", async function () { + const actual = await Deno.transpileOnly( { "foo.ts": `export enum Foo { Foo, Bar, Baz };\n`, }, @@ -102,8 +100,8 @@ test("transpileOnlyApiConfig", async function () { assert(actual["foo.ts"].map == null); }); -test("bundleApiSources", async function () { - const [diagnostics, actual] = await bundle("/foo.ts", { +Deno.test("bundleApiSources", async function () { + const [diagnostics, actual] = await Deno.bundle("/foo.ts", { "/foo.ts": `export * from "./bar.ts";\n`, "/bar.ts": `export const bar = "bar";\n`, }); @@ -112,15 +110,15 @@ test("bundleApiSources", async function () { assert(actual.includes(`__exp["bar"]`)); }); -test("bundleApiNoSources", async function () { - const [diagnostics, actual] = await bundle("./subdir/mod1.ts"); +Deno.test("bundleApiNoSources", async function () { + const [diagnostics, actual] = await Deno.bundle("./subdir/mod1.ts"); assert(diagnostics == null); assert(actual.includes(`__instantiate("mod1")`)); assert(actual.includes(`__exp["printHello3"]`)); }); -test("bundleApiConfig", async function () { - const [diagnostics, actual] = await bundle( +Deno.test("bundleApiConfig", async function () { + const [diagnostics, actual] = await Deno.bundle( "/foo.ts", { "/foo.ts": `// random comment\nexport * from "./bar.ts";\n`, @@ -134,8 +132,8 @@ test("bundleApiConfig", async function () { assert(!actual.includes(`random`)); }); -test("bundleApiJsModules", async function () { - const [diagnostics, actual] = await bundle("/foo.js", { +Deno.test("bundleApiJsModules", async function () { + const [diagnostics, actual] = await Deno.bundle("/foo.js", { "/foo.js": `export * from "./bar.js";\n`, "/bar.js": `export const bar = "bar";\n`, }); @@ -143,8 +141,8 @@ test("bundleApiJsModules", async function () { assert(actual.includes(`System.register("bar",`)); }); -test("diagnosticsTest", async function () { - const [diagnostics] = await compile("/foo.ts", { +Deno.test("diagnosticsTest", async function () { + const [diagnostics] = await Deno.compile("/foo.ts", { "/foo.ts": `document.getElementById("foo");`, }); assert(Array.isArray(diagnostics)); diff --git a/cli/tests/complex_permissions_test.ts b/cli/tests/complex_permissions_test.ts index 55b4ead35..ad8b5302c 100644 --- a/cli/tests/complex_permissions_test.ts +++ b/cli/tests/complex_permissions_test.ts @@ -1,14 +1,12 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -const { args, readFileSync, writeFileSync, exit } = Deno; - -const name = args[0]; +const name = Deno.args[0]; const test: { [key: string]: Function } = { read(files: string[]): void { - files.forEach((file) => readFileSync(file)); + files.forEach((file) => Deno.readFileSync(file)); }, write(files: string[]): void { files.forEach((file) => - writeFileSync(file, new Uint8Array(0), { append: true }) + Deno.writeFileSync(file, new Uint8Array(0), { append: true }) ); }, netFetch(hosts: string[]): void { @@ -40,7 +38,7 @@ const test: { [key: string]: Function } = { if (!test[name]) { console.log("Unknown test:", name); - exit(1); + Deno.exit(1); } -test[name](args.slice(1)); +test[name](Deno.args.slice(1)); diff --git a/cli/tests/echo_server.ts b/cli/tests/echo_server.ts index 5c6b5954b..48b43aca6 100644 --- a/cli/tests/echo_server.ts +++ b/cli/tests/echo_server.ts @@ -1,11 +1,10 @@ -const { args, listen, copy } = Deno; -const addr = args[1] || "0.0.0.0:4544"; +const addr = Deno.args[1] || "0.0.0.0:4544"; const [hostname, port] = addr.split(":"); -const listener = listen({ hostname, port: Number(port) }); +const listener = Deno.listen({ hostname, port: Number(port) }); console.log("listening on", addr); listener.accept().then( async (conn): Promise<void> => { - await copy(conn, conn); + await Deno.copy(conn, conn); conn.close(); listener.close(); } diff --git a/cli/tests/permission_test.ts b/cli/tests/permission_test.ts index bcfb840bf..399c757d3 100644 --- a/cli/tests/permission_test.ts +++ b/cli/tests/permission_test.ts @@ -1,23 +1,21 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -const { args, listen, env, exit, makeTempDirSync, readFileSync, run } = Deno; - -const name = args[0]; +const name = Deno.args[0]; const test: { [key: string]: Function } = { readRequired(): Promise<void> { - readFileSync("README.md"); + Deno.readFileSync("README.md"); return Promise.resolve(); }, writeRequired(): void { - makeTempDirSync(); + Deno.makeTempDirSync(); }, envRequired(): void { - env.get("home"); + Deno.env.get("home"); }, netRequired(): void { - listen({ transport: "tcp", port: 4541 }); + Deno.listen({ transport: "tcp", port: 4541 }); }, runRequired(): void { - run({ + Deno.run({ cmd: [ "python", "-c", @@ -29,7 +27,7 @@ const test: { [key: string]: Function } = { if (!test[name]) { console.log("Unknown test:", name); - exit(1); + Deno.exit(1); } test[name](); diff --git a/cli/tests/unbuffered_stderr.ts b/cli/tests/unbuffered_stderr.ts index f4bceb1fc..0f1d2a999 100644 --- a/cli/tests/unbuffered_stderr.ts +++ b/cli/tests/unbuffered_stderr.ts @@ -1,3 +1 @@ -const { stderr } = Deno; - -stderr.write(new TextEncoder().encode("x")); +Deno.stderr.write(new TextEncoder().encode("x")); diff --git a/cli/tests/unbuffered_stdout.ts b/cli/tests/unbuffered_stdout.ts index fdb1a0e23..9f1e07a97 100644 --- a/cli/tests/unbuffered_stdout.ts +++ b/cli/tests/unbuffered_stdout.ts @@ -1,3 +1 @@ -const { stdout } = Deno; - -stdout.write(new TextEncoder().encode("a")); +Deno.stdout.write(new TextEncoder().encode("a")); diff --git a/cli/tests/unit/buffer_test.ts b/cli/tests/unit/buffer_test.ts index 23e655a05..c5a63b5c8 100644 --- a/cli/tests/unit/buffer_test.ts +++ b/cli/tests/unit/buffer_test.ts @@ -12,9 +12,6 @@ import { unitTest, } from "./test_util.ts"; -const { Buffer, readAll, readAllSync, writeAll, writeAllSync } = Deno; -type Buffer = Deno.Buffer; - // N controls how many iterations of certain checks are performed. const N = 100; let testBytes: Uint8Array | null; @@ -44,7 +41,7 @@ function check(buf: Deno.Buffer, s: string): void { // The initial contents of buf corresponds to the string s; // the result is the final contents of buf returned as a string. async function fillBytes( - buf: Buffer, + buf: Deno.Buffer, s: string, n: number, fub: Uint8Array @@ -62,7 +59,11 @@ async function fillBytes( // Empty buf through repeated reads into fub. // The initial contents of buf corresponds to the string s. -async function empty(buf: Buffer, s: string, fub: Uint8Array): Promise<void> { +async function empty( + buf: Deno.Buffer, + s: string, + fub: Uint8Array +): Promise<void> { check(buf, s); while (true) { const r = await buf.read(fub); @@ -86,7 +87,7 @@ unitTest(function bufferNewBuffer(): void { init(); assert(testBytes); assert(testString); - const buf = new Buffer(testBytes.buffer as ArrayBuffer); + const buf = new Deno.Buffer(testBytes.buffer as ArrayBuffer); check(buf, testString); }); @@ -94,7 +95,7 @@ unitTest(async function bufferBasicOperations(): Promise<void> { init(); assert(testBytes); assert(testString); - const buf = new Buffer(); + const buf = new Deno.Buffer(); for (let i = 0; i < 5; i++) { check(buf, ""); @@ -133,7 +134,7 @@ unitTest(async function bufferBasicOperations(): Promise<void> { unitTest(async function bufferReadEmptyAtEOF(): Promise<void> { // check that EOF of 'buf' is not reached (even though it's empty) if // results are written to buffer that has 0 length (ie. it can't store any data) - const buf = new Buffer(); + const buf = new Deno.Buffer(); const zeroLengthTmp = new Uint8Array(0); const result = await buf.read(zeroLengthTmp); assertEquals(result, 0); @@ -141,7 +142,7 @@ unitTest(async function bufferReadEmptyAtEOF(): Promise<void> { unitTest(async function bufferLargeByteWrites(): Promise<void> { init(); - const buf = new Buffer(); + const buf = new Deno.Buffer(); const limit = 9; for (let i = 3; i < limit; i += 3) { const s = await fillBytes(buf, "", 5, testBytes!); @@ -155,7 +156,7 @@ unitTest(async function bufferTooLargeByteWrites(): Promise<void> { const tmp = new Uint8Array(72); const growLen = Number.MAX_VALUE; const xBytes = repeat("x", 0); - const buf = new Buffer(xBytes.buffer as ArrayBuffer); + const buf = new Deno.Buffer(xBytes.buffer as ArrayBuffer); await buf.read(tmp); let err; @@ -173,7 +174,7 @@ unitTest(async function bufferLargeByteReads(): Promise<void> { init(); assert(testBytes); assert(testString); - const buf = new Buffer(); + const buf = new Deno.Buffer(); for (let i = 3; i < 30; i += 3) { const n = Math.floor(testBytes.byteLength / i); const s = await fillBytes(buf, "", 5, testBytes.subarray(0, n)); @@ -183,7 +184,7 @@ unitTest(async function bufferLargeByteReads(): Promise<void> { }); unitTest(function bufferCapWithPreallocatedSlice(): void { - const buf = new Buffer(new ArrayBuffer(10)); + const buf = new Deno.Buffer(new ArrayBuffer(10)); assertEquals(buf.capacity, 10); }); @@ -191,7 +192,7 @@ unitTest(async function bufferReadFrom(): Promise<void> { init(); assert(testBytes); assert(testString); - const buf = new Buffer(); + const buf = new Deno.Buffer(); for (let i = 3; i < 30; i += 3) { const s = await fillBytes( buf, @@ -199,13 +200,13 @@ unitTest(async function bufferReadFrom(): Promise<void> { 5, testBytes.subarray(0, Math.floor(testBytes.byteLength / i)) ); - const b = new Buffer(); + const b = new Deno.Buffer(); await b.readFrom(buf); const fub = new Uint8Array(testString.length); await empty(b, s, fub); } assertThrowsAsync(async function () { - await new Buffer().readFrom(null!); + await new Deno.Buffer().readFrom(null!); }); }); @@ -213,7 +214,7 @@ unitTest(async function bufferReadFromSync(): Promise<void> { init(); assert(testBytes); assert(testString); - const buf = new Buffer(); + const buf = new Deno.Buffer(); for (let i = 3; i < 30; i += 3) { const s = await fillBytes( buf, @@ -221,13 +222,13 @@ unitTest(async function bufferReadFromSync(): Promise<void> { 5, testBytes.subarray(0, Math.floor(testBytes.byteLength / i)) ); - const b = new Buffer(); + const b = new Deno.Buffer(); b.readFromSync(buf); const fub = new Uint8Array(testString.length); await empty(b, s, fub); } assertThrows(function () { - new Buffer().readFromSync(null!); + new Deno.Buffer().readFromSync(null!); }); }); @@ -236,7 +237,7 @@ unitTest(async function bufferTestGrow(): Promise<void> { for (const startLen of [0, 100, 1000, 10000, 100000]) { const xBytes = repeat("x", startLen); for (const growLen of [0, 100, 1000, 10000, 100000]) { - const buf = new Buffer(xBytes.buffer as ArrayBuffer); + const buf = new Deno.Buffer(xBytes.buffer as ArrayBuffer); // If we read, this affects buf.off, which is good to test. const nread = (await buf.read(tmp)) ?? 0; buf.grow(growLen); @@ -258,8 +259,8 @@ unitTest(async function bufferTestGrow(): Promise<void> { unitTest(async function testReadAll(): Promise<void> { init(); assert(testBytes); - const reader = new Buffer(testBytes.buffer as ArrayBuffer); - const actualBytes = await readAll(reader); + const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); + const actualBytes = await Deno.readAll(reader); assertEquals(testBytes.byteLength, actualBytes.byteLength); for (let i = 0; i < testBytes.length; ++i) { assertEquals(testBytes[i], actualBytes[i]); @@ -269,8 +270,8 @@ unitTest(async function testReadAll(): Promise<void> { unitTest(function testReadAllSync(): void { init(); assert(testBytes); - const reader = new Buffer(testBytes.buffer as ArrayBuffer); - const actualBytes = readAllSync(reader); + const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); + const actualBytes = Deno.readAllSync(reader); assertEquals(testBytes.byteLength, actualBytes.byteLength); for (let i = 0; i < testBytes.length; ++i) { assertEquals(testBytes[i], actualBytes[i]); @@ -280,8 +281,8 @@ unitTest(function testReadAllSync(): void { unitTest(async function testWriteAll(): Promise<void> { init(); assert(testBytes); - const writer = new Buffer(); - await writeAll(writer, testBytes); + const writer = new Deno.Buffer(); + await Deno.writeAll(writer, testBytes); const actualBytes = writer.bytes(); assertEquals(testBytes.byteLength, actualBytes.byteLength); for (let i = 0; i < testBytes.length; ++i) { @@ -292,8 +293,8 @@ unitTest(async function testWriteAll(): Promise<void> { unitTest(function testWriteAllSync(): void { init(); assert(testBytes); - const writer = new Buffer(); - writeAllSync(writer, testBytes); + const writer = new Deno.Buffer(); + Deno.writeAllSync(writer, testBytes); const actualBytes = writer.bytes(); assertEquals(testBytes.byteLength, actualBytes.byteLength); for (let i = 0; i < testBytes.length; ++i) { diff --git a/cli/tests/unit/process_test.ts b/cli/tests/unit/process_test.ts index c6503b2e0..cf512eea5 100644 --- a/cli/tests/unit/process_test.ts +++ b/cli/tests/unit/process_test.ts @@ -5,20 +5,11 @@ import { assertStringContains, unitTest, } from "./test_util.ts"; -const { - kill, - run, - readFile, - open, - makeTempDir, - writeFile, - writeFileSync, -} = Deno; unitTest(function runPermissions(): void { let caughtError = false; try { - run({ cmd: ["python", "-c", "print('hello world')"] }); + Deno.run({ cmd: ["python", "-c", "print('hello world')"] }); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); @@ -27,7 +18,7 @@ unitTest(function runPermissions(): void { }); unitTest({ perms: { run: true } }, async function runSuccess(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "print('hello world')"], stdout: "piped", stderr: "null", @@ -43,7 +34,7 @@ unitTest({ perms: { run: true } }, async function runSuccess(): Promise<void> { unitTest( { perms: { run: true } }, async function runCommandFailedWithCode(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys;sys.exit(41 + 1)"], }); const status = await p.status(); @@ -61,7 +52,7 @@ unitTest( perms: { run: true }, }, async function runCommandFailedWithSignal(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import os;os.kill(os.getpid(), 9)"], }); const status = await p.status(); @@ -75,7 +66,7 @@ unitTest( unitTest({ perms: { run: true } }, function runNotFound(): void { let error; try { - run({ cmd: ["this file hopefully doesn't exist"] }); + Deno.run({ cmd: ["this file hopefully doesn't exist"] }); } catch (e) { error = e; } @@ -87,7 +78,7 @@ unitTest( { perms: { write: true, run: true } }, async function runWithCwdIsAsync(): Promise<void> { const enc = new TextEncoder(); - const cwd = await makeTempDir({ prefix: "deno_command_test" }); + const cwd = await Deno.makeTempDir({ prefix: "deno_command_test" }); const exitCodeFile = "deno_was_here"; const pyProgramFile = "poll_exit.py"; @@ -107,8 +98,8 @@ while True: pass `; - writeFileSync(`${cwd}/${pyProgramFile}.py`, enc.encode(pyProgram)); - const p = run({ + Deno.writeFileSync(`${cwd}/${pyProgramFile}.py`, enc.encode(pyProgram)); + const p = Deno.run({ cwd, cmd: ["python", `${pyProgramFile}.py`], }); @@ -116,7 +107,7 @@ while True: // Write the expected exit code *after* starting python. // This is how we verify that `run()` is actually asynchronous. const code = 84; - writeFileSync(`${cwd}/${exitCodeFile}`, enc.encode(`${code}`)); + Deno.writeFileSync(`${cwd}/${exitCodeFile}`, enc.encode(`${code}`)); const status = await p.status(); assertEquals(status.success, false); @@ -129,7 +120,7 @@ while True: unitTest({ perms: { run: true } }, async function runStdinPiped(): Promise< void > { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys; assert 'hello' == sys.stdin.read();"], stdin: "piped", }); @@ -153,7 +144,7 @@ unitTest({ perms: { run: true } }, async function runStdinPiped(): Promise< unitTest({ perms: { run: true } }, async function runStdoutPiped(): Promise< void > { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys; sys.stdout.write('hello')"], stdout: "piped", }); @@ -182,7 +173,7 @@ unitTest({ perms: { run: true } }, async function runStdoutPiped(): Promise< unitTest({ perms: { run: true } }, async function runStderrPiped(): Promise< void > { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys; sys.stderr.write('hello')"], stderr: "piped", }); @@ -209,7 +200,7 @@ unitTest({ perms: { run: true } }, async function runStderrPiped(): Promise< }); unitTest({ perms: { run: true } }, async function runOutput(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys; sys.stdout.write('hello')"], stdout: "piped", }); @@ -222,7 +213,7 @@ unitTest({ perms: { run: true } }, async function runOutput(): Promise<void> { unitTest({ perms: { run: true } }, async function runStderrOutput(): Promise< void > { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys; sys.stderr.write('error')"], stderr: "piped", }); @@ -235,14 +226,14 @@ unitTest({ perms: { run: true } }, async function runStderrOutput(): Promise< unitTest( { perms: { run: true, write: true, read: true } }, async function runRedirectStdoutStderr(): Promise<void> { - const tempDir = await makeTempDir(); + const tempDir = await Deno.makeTempDir(); const fileName = tempDir + "/redirected_stdio.txt"; - const file = await open(fileName, { + const file = await Deno.open(fileName, { create: true, write: true, }); - const p = run({ + const p = Deno.run({ cmd: [ "python", "-c", @@ -256,7 +247,7 @@ unitTest( p.close(); file.close(); - const fileContents = await readFile(fileName); + const fileContents = await Deno.readFile(fileName); const decoder = new TextDecoder(); const text = decoder.decode(fileContents); @@ -268,13 +259,13 @@ unitTest( unitTest( { perms: { run: true, write: true, read: true } }, async function runRedirectStdin(): Promise<void> { - const tempDir = await makeTempDir(); + const tempDir = await Deno.makeTempDir(); const fileName = tempDir + "/redirected_stdio.txt"; const encoder = new TextEncoder(); - await writeFile(fileName, encoder.encode("hello")); - const file = await open(fileName); + await Deno.writeFile(fileName, encoder.encode("hello")); + const file = await Deno.open(fileName); - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "import sys; assert 'hello' == sys.stdin.read();"], stdin: file.rid, }); @@ -287,7 +278,7 @@ unitTest( ); unitTest({ perms: { run: true } }, async function runEnv(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: [ "python", "-c", @@ -306,7 +297,7 @@ unitTest({ perms: { run: true } }, async function runEnv(): Promise<void> { }); unitTest({ perms: { run: true } }, async function runClose(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: [ "python", "-c", @@ -340,7 +331,7 @@ unitTest(function killPermissions(): void { // subprocess we can safely kill. Instead we send SIGCONT to the current // process - assuming that Deno does not have a special handler set for it // and will just continue even if a signal is erroneously sent. - kill(Deno.pid, Deno.Signal.SIGCONT); + Deno.kill(Deno.pid, Deno.Signal.SIGCONT); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); @@ -349,12 +340,12 @@ unitTest(function killPermissions(): void { }); unitTest({ perms: { run: true } }, async function killSuccess(): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "from time import sleep; sleep(10000)"], }); assertEquals(Deno.Signal.SIGINT, 2); - kill(p.pid, Deno.Signal.SIGINT); + Deno.kill(p.pid, Deno.Signal.SIGINT); const status = await p.status(); assertEquals(status.success, false); @@ -371,7 +362,7 @@ unitTest({ perms: { run: true } }, async function killSuccess(): Promise<void> { }); unitTest({ perms: { run: true } }, function killFailed(): void { - const p = run({ + const p = Deno.run({ cmd: ["python", "-c", "from time import sleep; sleep(10000)"], }); assert(!p.stdin); @@ -379,7 +370,7 @@ unitTest({ perms: { run: true } }, function killFailed(): void { let err; try { - kill(p.pid, 12345); + Deno.kill(p.pid, 12345); } catch (e) { err = e; } |