summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-12-02 14:43:17 +0100
committerGitHub <noreply@github.com>2022-12-02 14:43:17 +0100
commit4d07ed0efa8f0e2cab1a33f1b7b6a3627bfce69f (patch)
tree898aadf1ae739190ed98ec463824f7e9ca8f48eb /cli/tests/testdata
parent6982c74e11ec8294ed5bd53d2a9d316d7e20e7d2 (diff)
chore: rewrite tests and utils to use Deno.Command API (#16895)
Since "Deno.spawn()", "Deno.spawnSync()" and "Deno.spawnChild" are getting deprecated, this commits rewrites all tests and utilities to use "Deno.Command" API instead.
Diffstat (limited to 'cli/tests/testdata')
-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
7 files changed, 33 insertions, 33 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"),