summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/testdata/run/045_proxy_test.ts20
-rw-r--r--cli/tests/testdata/run/089_run_allow_list.ts6
-rw-r--r--cli/tests/testdata/run/lock_write_fetch/main.ts12
-rw-r--r--cli/tests/testdata/run/no_prompt.ts4
-rw-r--r--cli/tests/testdata/run/permission_test.ts4
-rw-r--r--cli/tests/testdata/run/spawn_stdout_inherit.ts8
-rw-r--r--cli/tests/testdata/test/captured_output.ts12
-rw-r--r--cli/tests/unit/chown_test.ts8
-rw-r--r--cli/tests/unit/flash_test.ts4
-rw-r--r--cli/tests/unit/flock_test.ts4
-rw-r--r--cli/tests/unit/http_test.ts50
-rw-r--r--cli/tests/unit/os_test.ts12
-rw-r--r--cli/tests/unit/remove_test.ts8
-rw-r--r--cli/tests/unit/signal_test.ts4
-rw-r--r--cli/tests/unit/test_util.ts4
-rw-r--r--cli/tests/unit/tls_test.ts4
-rw-r--r--cli/tests/unit/tty_color_test.ts4
17 files changed, 84 insertions, 84 deletions
diff --git a/cli/tests/testdata/run/045_proxy_test.ts b/cli/tests/testdata/run/045_proxy_test.ts
index 0ff7184b1..f90c37649 100644
--- a/cli/tests/testdata/run/045_proxy_test.ts
+++ b/cli/tests/testdata/run/045_proxy_test.ts
@@ -31,7 +31,7 @@ async function handler(req: Request): Promise<Response> {
}
async function testFetch() {
- const { code } = await Deno.spawn(Deno.execPath(), {
+ const { code } = await new Deno.Command(Deno.execPath(), {
args: [
"run",
"--quiet",
@@ -42,13 +42,13 @@ async function testFetch() {
env: {
HTTP_PROXY: `http://${addr}`,
},
- });
+ }).output();
assertEquals(code, 0);
}
async function testModuleDownload() {
- const { code } = await Deno.spawn(Deno.execPath(), {
+ const { code } = await new Deno.Command(Deno.execPath(), {
args: [
"cache",
"--reload",
@@ -58,13 +58,13 @@ async function testModuleDownload() {
env: {
HTTP_PROXY: `http://${addr}`,
},
- });
+ }).output();
assertEquals(code, 0);
}
async function testFetchNoProxy() {
- const { code } = await Deno.spawn(Deno.execPath(), {
+ const { code } = await new Deno.Command(Deno.execPath(), {
args: [
"run",
"--quiet",
@@ -76,13 +76,13 @@ async function testFetchNoProxy() {
HTTP_PROXY: "http://not.exising.proxy.server",
NO_PROXY: "localhost",
},
- });
+ }).output();
assertEquals(code, 0);
}
async function testModuleDownloadNoProxy() {
- const { code } = await Deno.spawn(Deno.execPath(), {
+ const { code } = await new Deno.Command(Deno.execPath(), {
args: [
"cache",
"--reload",
@@ -93,13 +93,13 @@ async function testModuleDownloadNoProxy() {
HTTP_PROXY: "http://not.exising.proxy.server",
NO_PROXY: "localhost",
},
- });
+ }).output();
assertEquals(code, 0);
}
async function testFetchProgrammaticProxy() {
- const { code } = await Deno.spawn(Deno.execPath(), {
+ const { code } = await new Deno.Command(Deno.execPath(), {
args: [
"run",
"--quiet",
@@ -108,7 +108,7 @@ async function testFetchProgrammaticProxy() {
"--unstable",
"run/045_programmatic_proxy_client.ts",
],
- });
+ }).output();
assertEquals(code, 0);
}
diff --git a/cli/tests/testdata/run/089_run_allow_list.ts b/cli/tests/testdata/run/089_run_allow_list.ts
index d7bc8e195..d9cabba84 100644
--- a/cli/tests/testdata/run/089_run_allow_list.ts
+++ b/cli/tests/testdata/run/089_run_allow_list.ts
@@ -1,12 +1,12 @@
try {
- await Deno.spawn("ls");
+ await new Deno.Command("ls").output();
} catch (e) {
console.log(e);
}
-const { success } = await Deno.spawn("curl", {
+const { success } = await new Deno.Command("curl", {
args: ["--help"],
stdout: "null",
stderr: "inherit",
-});
+}).output();
console.log(success);
diff --git a/cli/tests/testdata/run/lock_write_fetch/main.ts b/cli/tests/testdata/run/lock_write_fetch/main.ts
index 3e6892cf0..57bc54d02 100644
--- a/cli/tests/testdata/run/lock_write_fetch/main.ts
+++ b/cli/tests/testdata/run/lock_write_fetch/main.ts
@@ -4,7 +4,7 @@ try {
// pass
}
-const fetchProc = await Deno.spawn(Deno.execPath(), {
+const fetchProc = await new Deno.Command(Deno.execPath(), {
stdout: "null",
stderr: "null",
args: [
@@ -15,11 +15,11 @@ const fetchProc = await Deno.spawn(Deno.execPath(), {
"--cert=tls/RootCA.pem",
"run/https_import.ts",
],
-});
+}).output();
console.log(`fetch code: ${fetchProc.code}`);
-const fetchCheckProc = await Deno.spawn(Deno.execPath(), {
+const fetchCheckProc = await new Deno.Command(Deno.execPath(), {
stdout: "null",
stderr: "null",
args: [
@@ -28,13 +28,13 @@ const fetchCheckProc = await Deno.spawn(Deno.execPath(), {
"--cert=tls/RootCA.pem",
"run/https_import.ts",
],
-});
+}).output();
console.log(`fetch check code: ${fetchCheckProc.code}`);
Deno.removeSync("./lock_write_fetch.json");
-const runProc = await Deno.spawn(Deno.execPath(), {
+const runProc = await new Deno.Command(Deno.execPath(), {
stdout: "null",
stderr: "null",
args: [
@@ -45,7 +45,7 @@ const runProc = await Deno.spawn(Deno.execPath(), {
"run/lock_write_fetch/file_exists.ts",
"lock_write_fetch.json",
],
-});
+}).output();
console.log(`run code: ${runProc.code}`);
diff --git a/cli/tests/testdata/run/no_prompt.ts b/cli/tests/testdata/run/no_prompt.ts
index 7f9750995..17d54b92c 100644
--- a/cli/tests/testdata/run/no_prompt.ts
+++ b/cli/tests/testdata/run/no_prompt.ts
@@ -1,10 +1,10 @@
new Worker("data:,setTimeout(() => Deno.exit(2), 200)", { type: "module" });
try {
- await Deno.spawn("ps", {
+ await new Deno.Command("ps", {
stdout: "inherit",
stderr: "inherit",
- });
+ }).output();
} catch {
Deno.exit(0);
}
diff --git a/cli/tests/testdata/run/permission_test.ts b/cli/tests/testdata/run/permission_test.ts
index 9b5409b4f..a2312e3ac 100644
--- a/cli/tests/testdata/run/permission_test.ts
+++ b/cli/tests/testdata/run/permission_test.ts
@@ -16,9 +16,9 @@ const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
Deno.listen({ transport: "tcp", port: 4541 });
},
async runRequired() {
- await Deno.spawn(Deno.build.os === "windows" ? "cmd.exe" : "printf", {
+ await new Deno.Command(Deno.build.os === "windows" ? "cmd.exe" : "printf", {
args: Deno.build.os === "windows" ? ["/c", "echo hello"] : ["hello"],
- });
+ }).output();
},
};
diff --git a/cli/tests/testdata/run/spawn_stdout_inherit.ts b/cli/tests/testdata/run/spawn_stdout_inherit.ts
index be5f9b7ef..04f635cea 100644
--- a/cli/tests/testdata/run/spawn_stdout_inherit.ts
+++ b/cli/tests/testdata/run/spawn_stdout_inherit.ts
@@ -1,8 +1,8 @@
-await Deno.spawn(Deno.execPath(), {
+await new Deno.Command(Deno.execPath(), {
args: ["eval", "--quiet", "console.log('Hello, world! 1')"],
stdout: "inherit",
-});
-Deno.spawnSync(Deno.execPath(), {
+}).output();
+new Deno.Command(Deno.execPath(), {
args: ["eval", "--quiet", "console.log('Hello, world! 2')"],
stdout: "inherit",
-});
+}).outputSync();
diff --git a/cli/tests/testdata/test/captured_output.ts b/cli/tests/testdata/test/captured_output.ts
index 2e6aec948..43295f027 100644
--- a/cli/tests/testdata/test/captured_output.ts
+++ b/cli/tests/testdata/test/captured_output.ts
@@ -4,21 +4,21 @@ Deno.test("output", async () => {
});
await p.status();
await p.close();
- Deno.spawnSync(Deno.execPath(), {
+ new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(2); console.error(3);"],
stdout: "inherit",
stderr: "inherit",
- });
- await Deno.spawn(Deno.execPath(), {
+ }).outputSync();
+ await new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(4); console.error(5);"],
stdout: "inherit",
stderr: "inherit",
- });
- const c = await Deno.spawnChild(Deno.execPath(), {
+ }).output();
+ const c = new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(6); console.error(7);"],
stdout: "inherit",
stderr: "inherit",
- });
+ }).spawn();
await c.status;
const worker = new Worker(
import.meta.resolve("./captured_output.worker.js"),
diff --git a/cli/tests/unit/chown_test.ts b/cli/tests/unit/chown_test.ts
index 2fa203e18..dd23627ae 100644
--- a/cli/tests/unit/chown_test.ts
+++ b/cli/tests/unit/chown_test.ts
@@ -5,12 +5,12 @@ import { assertEquals, assertRejects, assertThrows } from "./test_util.ts";
async function getUidAndGid(): Promise<{ uid: number; gid: number }> {
// get the user ID and group ID of the current process
- const uidProc = await Deno.spawn("id", {
+ const uidProc = await new Deno.Command("id", {
args: ["-u"],
- });
- const gidProc = await Deno.spawn("id", {
+ }).output();
+ const gidProc = await new Deno.Command("id", {
args: ["-g"],
- });
+ }).output();
assertEquals(uidProc.code, 0);
assertEquals(gidProc.code, 0);
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts
index 024069455..836c9b603 100644
--- a/cli/tests/unit/flash_test.ts
+++ b/cli/tests/unit/flash_test.ts
@@ -1033,11 +1033,11 @@ Deno.test(
await listeningPromise;
const url = `http://${hostname}:${port}/`;
const args = ["-X", "DELETE", url];
- const { success } = await Deno.spawn("curl", {
+ const { success } = await new Deno.Command("curl", {
args,
stdout: "null",
stderr: "null",
- });
+ }).output();
assert(success);
await promise;
ac.abort();
diff --git a/cli/tests/unit/flock_test.ts b/cli/tests/unit/flock_test.ts
index 7ece1695c..be463bf12 100644
--- a/cli/tests/unit/flock_test.ts
+++ b/cli/tests/unit/flock_test.ts
@@ -148,10 +148,10 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
console.log(JSON.stringify({ enterTime, exitTime }));
`;
- const process = Deno.spawnChild(Deno.execPath(), {
+ const process = new Deno.Command(Deno.execPath(), {
args: ["eval", "--unstable", scriptText],
stdin: "piped",
- });
+ }).spawn();
const waitSignal = async () => {
const reader = process.stdout.getReader({ mode: "byob" });
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index 1d2addb2d..0c17c7277 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -1249,11 +1249,11 @@ Deno.test(
async function client() {
const url = `http://${hostname}:${port}/`;
const args = ["-X", "DELETE", url];
- const { success } = await Deno.spawn("curl", {
+ const { success } = await new Deno.Command("curl", {
args,
stdout: "null",
stderr: "null",
- });
+ }).output();
assert(success);
}
@@ -1380,10 +1380,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1430,7 +1430,7 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.spawnChild("curl", { args, stderr: "null" });
+ const proc = new Deno.Command("curl", { args, stderr: "null" }).spawn();
const status = await proc.status;
assert(status.success);
const stdout = proc.stdout
@@ -1485,10 +1485,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout).toLocaleLowerCase();
assert(output.includes("vary: accept-encoding\r\n"));
@@ -1540,10 +1540,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip;q=0.8, br;q=1.0, *;q=0.1",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1592,10 +1592,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding, Accept\r\n"));
@@ -1648,10 +1648,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1706,10 +1706,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1764,10 +1764,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1819,10 +1819,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1880,10 +1880,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -1939,7 +1939,7 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const proc = Deno.spawnChild("curl", { args, stderr: "null" });
+ const proc = new Deno.Command("curl", { args, stderr: "null" }).spawn();
const status = await proc.status;
assert(status.success);
const stdout = proc.stdout
@@ -2004,10 +2004,10 @@ Deno.test({
"--header",
"Accept-Encoding: gzip, deflate, br",
];
- const { success, stdout } = await Deno.spawn("curl", {
+ const { success, stdout } = await new Deno.Command("curl", {
args,
stderr: "null",
- });
+ }).output();
assert(success);
const output = decoder.decode(stdout);
assert(output.includes("vary: Accept-Encoding\r\n"));
@@ -2569,7 +2569,7 @@ Deno.test({
"Accept-Encoding: gzip, deflate, br",
"--no-buffer",
];
- const proc = Deno.spawnChild("curl", { args, stderr: "null" });
+ const proc = new Deno.Command("curl", { args, stderr: "null" }).spawn();
const stdout = proc.stdout
.pipeThrough(new DecompressionStream("gzip"))
.pipeThrough(new TextDecoderStream());
diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts
index 04ddf8ae0..72e0b57ba 100644
--- a/cli/tests/unit/os_test.ts
+++ b/cli/tests/unit/os_test.ts
@@ -74,10 +74,10 @@ Deno.test(
console.log(
${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env.get(k))
)`;
- const { success, stdout } = await Deno.spawn(Deno.execPath(), {
+ const { success, stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", src],
env: { ...inputEnv, NO_COLOR: "1" },
- });
+ }).output();
assertEquals(success, true);
const expectedValues = Object.values(expectedEnv);
const actualValues = JSON.parse(new TextDecoder().decode(stdout));
@@ -162,10 +162,10 @@ Deno.test(
{ permissions: { run: true, read: true } },
async function osPpidIsEqualToPidOfParentProcess() {
const decoder = new TextDecoder();
- const { stdout } = await Deno.spawn(Deno.execPath(), {
+ const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "-p", "--unstable", "Deno.ppid"],
env: { NO_COLOR: "true" },
- });
+ }).output();
const expected = Deno.pid;
const actual = parseInt(decoder.decode(stdout));
@@ -212,9 +212,9 @@ Deno.test(
{ permissions: { run: [Deno.execPath()], read: true } },
// See https://github.com/denoland/deno/issues/16527
async function hostnameWithoutOtherNetworkUsages() {
- const { stdout } = await Deno.spawn(Deno.execPath(), {
+ const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "-p", "Deno.hostname()"],
- });
+ }).output();
const hostname = new TextDecoder().decode(stdout).trim();
assert(hostname.length > 0);
},
diff --git a/cli/tests/unit/remove_test.ts b/cli/tests/unit/remove_test.ts
index ae439e305..0032459eb 100644
--- a/cli/tests/unit/remove_test.ts
+++ b/cli/tests/unit/remove_test.ts
@@ -260,10 +260,10 @@ if (Deno.build.os === "windows") {
Deno.test(
{ permissions: { run: true, write: true, read: true } },
async function removeFileSymlink() {
- const { success } = await Deno.spawn("cmd", {
+ const { success } = await new Deno.Command("cmd", {
args: ["/c", "mklink", "file_link", "bar"],
stdout: "null",
- });
+ }).output();
assert(success);
await Deno.remove("file_link");
@@ -276,10 +276,10 @@ if (Deno.build.os === "windows") {
Deno.test(
{ permissions: { run: true, write: true, read: true } },
async function removeDirSymlink() {
- const { success } = await Deno.spawn("cmd", {
+ const { success } = await new Deno.Command("cmd", {
args: ["/c", "mklink", "/d", "dir_link", "bar"],
stdout: "null",
- });
+ }).output();
assert(success);
await Deno.remove("dir_link");
diff --git a/cli/tests/unit/signal_test.ts b/cli/tests/unit/signal_test.ts
index 86092a298..25143da1f 100644
--- a/cli/tests/unit/signal_test.ts
+++ b/cli/tests/unit/signal_test.ts
@@ -185,13 +185,13 @@ Deno.test(
permissions: { run: true, read: true },
},
async function canExitWhileListeningToSignal() {
- const { code } = await Deno.spawn(Deno.execPath(), {
+ const { code } = await new Deno.Command(Deno.execPath(), {
args: [
"eval",
"--unstable",
"Deno.addSignalListener('SIGINT', () => {})",
],
- });
+ }).output();
assertEquals(code, 0);
},
);
diff --git a/cli/tests/unit/test_util.ts b/cli/tests/unit/test_util.ts
index c33da5338..9a1b13038 100644
--- a/cli/tests/unit/test_util.ts
+++ b/cli/tests/unit/test_util.ts
@@ -32,13 +32,13 @@ export function pathToAbsoluteFileUrl(path: string): URL {
const decoder = new TextDecoder();
export async function execCode(code: string): Promise<[number, string]> {
- const output = await Deno.spawn(Deno.execPath(), {
+ const output = await new Deno.Command(Deno.execPath(), {
args: [
"eval",
"--unstable",
"--no-check",
code,
],
- });
+ }).output();
return [output.code, decoder.decode(output.stdout)];
}
diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts
index d3ef4d0bf..e5ad6e66c 100644
--- a/cli/tests/unit/tls_test.ts
+++ b/cli/tests/unit/tls_test.ts
@@ -1046,9 +1046,9 @@ function createHttpsListener(port: number): Deno.Listener {
}
async function curl(url: string): Promise<string> {
- const { success, code, stdout } = await Deno.spawn("curl", {
+ const { success, code, stdout } = await new Deno.Command("curl", {
args: ["--insecure", url],
- });
+ }).output();
if (!success) {
throw new Error(`curl ${url} failed: ${code}`);
diff --git a/cli/tests/unit/tty_color_test.ts b/cli/tests/unit/tty_color_test.ts
index 7662d039b..f819a1a63 100644
--- a/cli/tests/unit/tty_color_test.ts
+++ b/cli/tests/unit/tty_color_test.ts
@@ -6,9 +6,9 @@ import { assertEquals } from "./test_util.ts";
Deno.test(
{ permissions: { run: true, read: true } },
async function noColorIfNotTty() {
- const { stdout } = await Deno.spawn(Deno.execPath(), {
+ const { stdout } = await new Deno.Command(Deno.execPath(), {
args: ["eval", "console.log(1)"],
- });
+ }).output();
const output = new TextDecoder().decode(stdout);
assertEquals(output, "1\n");
},