summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2022-05-18 22:00:11 +0200
committerGitHub <noreply@github.com>2022-05-18 22:00:11 +0200
commit4e1ca1d1787f25ab9f0a72ccf9d8028f70b3a7ed (patch)
tree2d0062ec1dd864c7ed98301119ac5f1c133f844a /cli/tests/testdata
parent5ad8919d642b646caa3328930dd1a3f290bc587e (diff)
refactor: use spawn API across codebase (#14414)
Diffstat (limited to 'cli/tests/testdata')
-rw-r--r--cli/tests/testdata/045_proxy_test.ts44
-rw-r--r--cli/tests/testdata/089_run_allow_list.ts11
-rw-r--r--cli/tests/testdata/lock_write_fetch.ts24
-rw-r--r--cli/tests/testdata/no_prompt.ts5
-rw-r--r--cli/tests/testdata/permission_test.ts9
5 files changed, 33 insertions, 60 deletions
diff --git a/cli/tests/testdata/045_proxy_test.ts b/cli/tests/testdata/045_proxy_test.ts
index d6edf2be9..620e23e14 100644
--- a/cli/tests/testdata/045_proxy_test.ts
+++ b/cli/tests/testdata/045_proxy_test.ts
@@ -31,93 +31,76 @@ async function handler(req: Request): Promise<Response> {
}
async function testFetch() {
- const c = Deno.run({
- cmd: [
- Deno.execPath(),
+ const { status } = await Deno.spawn(Deno.execPath(), {
+ args: [
"run",
"--quiet",
"--reload",
"--allow-net",
"045_proxy_client.ts",
],
- stdout: "piped",
env: {
HTTP_PROXY: `http://${addr}`,
},
});
- const status = await c.status();
assertEquals(status.code, 0);
- c.close();
}
async function testModuleDownload() {
- const http = Deno.run({
- cmd: [
- Deno.execPath(),
+ const { status } = await Deno.spawn(Deno.execPath(), {
+ args: [
"cache",
"--reload",
"--quiet",
"http://localhost:4545/045_mod.ts",
],
- stdout: "piped",
env: {
HTTP_PROXY: `http://${addr}`,
},
});
- const httpStatus = await http.status();
- assertEquals(httpStatus.code, 0);
- http.close();
+ assertEquals(status.code, 0);
}
async function testFetchNoProxy() {
- const c = Deno.run({
- cmd: [
- Deno.execPath(),
+ const { status } = await Deno.spawn(Deno.execPath(), {
+ args: [
"run",
"--quiet",
"--reload",
"--allow-net",
"045_proxy_client.ts",
],
- stdout: "piped",
env: {
HTTP_PROXY: "http://not.exising.proxy.server",
NO_PROXY: "localhost",
},
});
- const status = await c.status();
assertEquals(status.code, 0);
- c.close();
}
async function testModuleDownloadNoProxy() {
- const http = Deno.run({
- cmd: [
- Deno.execPath(),
+ const { status } = await Deno.spawn(Deno.execPath(), {
+ args: [
"cache",
"--reload",
"--quiet",
"http://localhost:4545/045_mod.ts",
],
- stdout: "piped",
env: {
HTTP_PROXY: "http://not.exising.proxy.server",
NO_PROXY: "localhost",
},
});
- const httpStatus = await http.status();
- assertEquals(httpStatus.code, 0);
- http.close();
+ assertEquals(status.code, 0);
}
async function testFetchProgrammaticProxy() {
- const c = Deno.run({
- cmd: [
- Deno.execPath(),
+ const { status } = await Deno.spawn(Deno.execPath(), {
+ args: [
"run",
"--quiet",
"--reload",
@@ -125,11 +108,8 @@ async function testFetchProgrammaticProxy() {
"--unstable",
"045_programmatic_proxy_client.ts",
],
- stdout: "piped",
});
- const status = await c.status();
assertEquals(status.code, 0);
- c.close();
}
proxyServer();
diff --git a/cli/tests/testdata/089_run_allow_list.ts b/cli/tests/testdata/089_run_allow_list.ts
index defb3196f..0eb79dcc2 100644
--- a/cli/tests/testdata/089_run_allow_list.ts
+++ b/cli/tests/testdata/089_run_allow_list.ts
@@ -1,13 +1,12 @@
try {
- Deno.run({
- cmd: ["ls"],
- });
+ await Deno.spawn("ls");
} catch (e) {
console.log(e);
}
-const proc = Deno.run({
- cmd: ["curl", "--help"],
+const { status } = await Deno.spawn("curl", {
+ args: ["--help"],
stdout: "null",
+ stderr: "inherit",
});
-console.log((await proc.status()).success);
+console.log(status.success);
diff --git a/cli/tests/testdata/lock_write_fetch.ts b/cli/tests/testdata/lock_write_fetch.ts
index b6ecf4747..7be6af84a 100644
--- a/cli/tests/testdata/lock_write_fetch.ts
+++ b/cli/tests/testdata/lock_write_fetch.ts
@@ -4,11 +4,10 @@ try {
// pass
}
-const fetchProc = Deno.run({
+const fetchProc = await Deno.spawn(Deno.execPath(), {
stdout: "null",
stderr: "null",
- cmd: [
- Deno.execPath(),
+ args: [
"cache",
"--reload",
"--lock=lock_write_fetch.json",
@@ -18,14 +17,12 @@ const fetchProc = Deno.run({
],
});
-const fetchCode = (await fetchProc.status()).code;
-console.log(`fetch code: ${fetchCode}`);
+console.log(`fetch code: ${fetchProc.status.code}`);
-const fetchCheckProc = Deno.run({
+const fetchCheckProc = await Deno.spawn(Deno.execPath(), {
stdout: "null",
stderr: "null",
- cmd: [
- Deno.execPath(),
+ args: [
"cache",
"--lock=lock_write_fetch.json",
"--cert=tls/RootCA.pem",
@@ -33,16 +30,14 @@ const fetchCheckProc = Deno.run({
],
});
-const fetchCheckProcCode = (await fetchCheckProc.status()).code;
-console.log(`fetch check code: ${fetchCheckProcCode}`);
+console.log(`fetch check code: ${fetchCheckProc.status.code}`);
Deno.removeSync("./lock_write_fetch.json");
-const runProc = Deno.run({
+const runProc = await Deno.spawn(Deno.execPath(), {
stdout: "null",
stderr: "null",
- cmd: [
- Deno.execPath(),
+ args: [
"run",
"--lock=lock_write_fetch.json",
"--lock-write",
@@ -52,7 +47,6 @@ const runProc = Deno.run({
],
});
-const runCode = (await runProc.status()).code;
-console.log(`run code: ${runCode}`);
+console.log(`run code: ${runProc.status.code}`);
Deno.removeSync("./lock_write_fetch.json");
diff --git a/cli/tests/testdata/no_prompt.ts b/cli/tests/testdata/no_prompt.ts
index f3d503f63..7f9750995 100644
--- a/cli/tests/testdata/no_prompt.ts
+++ b/cli/tests/testdata/no_prompt.ts
@@ -1,7 +1,10 @@
new Worker("data:,setTimeout(() => Deno.exit(2), 200)", { type: "module" });
try {
- await Deno.run({ cmd: ["ps"] });
+ await Deno.spawn("ps", {
+ stdout: "inherit",
+ stderr: "inherit",
+ });
} catch {
Deno.exit(0);
}
diff --git a/cli/tests/testdata/permission_test.ts b/cli/tests/testdata/permission_test.ts
index a3a38f2a0..4b186a0a2 100644
--- a/cli/tests/testdata/permission_test.ts
+++ b/cli/tests/testdata/permission_test.ts
@@ -15,13 +15,10 @@ const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
netRequired() {
Deno.listen({ transport: "tcp", port: 4541 });
},
- runRequired() {
- const p = Deno.run({
- cmd: Deno.build.os === "windows"
- ? ["cmd.exe", "/c", "echo hello"]
- : ["printf", "hello"],
+ async runRequired() {
+ await Deno.spawn(Deno.build.os === "windows" ? "cmd.exe" : "printf", {
+ args: Deno.build.os === "windows" ? ["/c", "echo hello"] : ["hello"],
});
- p.close();
},
};