mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
refactor: use spawn API across codebase (#14414)
This commit is contained in:
parent
5ad8919d64
commit
e906fc656a
25 changed files with 266 additions and 327 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -90,7 +90,7 @@ jobs:
|
||||||
if: matrix.job == 'lint'
|
if: matrix.job == 'lint'
|
||||||
uses: denoland/setup-deno@v1
|
uses: denoland/setup-deno@v1
|
||||||
with:
|
with:
|
||||||
deno-version: v1.19.3
|
deno-version: v1.x
|
||||||
|
|
||||||
- name: Install Python
|
- name: Install Python
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v1
|
||||||
|
|
|
@ -182,8 +182,9 @@ itest!(_044_bad_resource {
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
|
||||||
itest!(_045_proxy {
|
itest!(_045_proxy {
|
||||||
args: "run -L debug --allow-net --allow-env --allow-run --allow-read --reload --quiet 045_proxy_test.ts",
|
args: "run -L debug --unstable --allow-net --allow-env --allow-run --allow-read --reload --quiet 045_proxy_test.ts",
|
||||||
output: "045_proxy_test.ts.out",
|
output: "045_proxy_test.ts.out",
|
||||||
http_server: true,
|
http_server: true,
|
||||||
});
|
});
|
||||||
|
@ -509,8 +510,9 @@ itest!(_088_dynamic_import_already_evaluating {
|
||||||
output: "088_dynamic_import_already_evaluating.ts.out",
|
output: "088_dynamic_import_already_evaluating.ts.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
|
||||||
itest!(_089_run_allow_list {
|
itest!(_089_run_allow_list {
|
||||||
args: "run --allow-run=curl 089_run_allow_list.ts",
|
args: "run --unstable --allow-run=curl 089_run_allow_list.ts",
|
||||||
output: "089_run_allow_list.ts.out",
|
output: "089_run_allow_list.ts.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -588,9 +590,10 @@ itest!(lock_write_requires_lock {
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
|
||||||
itest!(lock_write_fetch {
|
itest!(lock_write_fetch {
|
||||||
args:
|
args:
|
||||||
"run --quiet --allow-read --allow-write --allow-env --allow-run lock_write_fetch.ts",
|
"run --quiet --allow-read --allow-write --allow-env --allow-run --unstable lock_write_fetch.ts",
|
||||||
output: "lock_write_fetch.ts.out",
|
output: "lock_write_fetch.ts.out",
|
||||||
http_server: true,
|
http_server: true,
|
||||||
exit_code: 0,
|
exit_code: 0,
|
||||||
|
@ -1861,12 +1864,14 @@ fn dont_cache_on_check_fail() {
|
||||||
mod permissions {
|
mod permissions {
|
||||||
use test_util as util;
|
use test_util as util;
|
||||||
|
|
||||||
|
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
|
||||||
#[test]
|
#[test]
|
||||||
fn with_allow() {
|
fn with_allow() {
|
||||||
for permission in &util::PERMISSION_VARIANTS {
|
for permission in &util::PERMISSION_VARIANTS {
|
||||||
let status = util::deno_cmd()
|
let status = util::deno_cmd()
|
||||||
.current_dir(&util::testdata_path())
|
.current_dir(&util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
|
.arg("--unstable")
|
||||||
.arg(format!("--allow-{0}", permission))
|
.arg(format!("--allow-{0}", permission))
|
||||||
.arg("permission_test.ts")
|
.arg("permission_test.ts")
|
||||||
.arg(format!("{0}Required", permission))
|
.arg(format!("{0}Required", permission))
|
||||||
|
@ -1878,12 +1883,13 @@ mod permissions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bartlomieju): remove --unstable once Deno.spawn is stabilized
|
||||||
#[test]
|
#[test]
|
||||||
fn without_allow() {
|
fn without_allow() {
|
||||||
for permission in &util::PERMISSION_VARIANTS {
|
for permission in &util::PERMISSION_VARIANTS {
|
||||||
let (_, err) = util::run_and_collect_output(
|
let (_, err) = util::run_and_collect_output(
|
||||||
false,
|
false,
|
||||||
&format!("run permission_test.ts {0}Required", permission),
|
&format!("run --unstable permission_test.ts {0}Required", permission),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
44
cli/tests/testdata/045_proxy_test.ts
vendored
44
cli/tests/testdata/045_proxy_test.ts
vendored
|
@ -31,93 +31,76 @@ async function handler(req: Request): Promise<Response> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetch() {
|
async function testFetch() {
|
||||||
const c = Deno.run({
|
const { status } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--allow-net",
|
"--allow-net",
|
||||||
"045_proxy_client.ts",
|
"045_proxy_client.ts",
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
|
||||||
env: {
|
env: {
|
||||||
HTTP_PROXY: `http://${addr}`,
|
HTTP_PROXY: `http://${addr}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const status = await c.status();
|
|
||||||
assertEquals(status.code, 0);
|
assertEquals(status.code, 0);
|
||||||
c.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testModuleDownload() {
|
async function testModuleDownload() {
|
||||||
const http = Deno.run({
|
const { status } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"cache",
|
"cache",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"http://localhost:4545/045_mod.ts",
|
"http://localhost:4545/045_mod.ts",
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
|
||||||
env: {
|
env: {
|
||||||
HTTP_PROXY: `http://${addr}`,
|
HTTP_PROXY: `http://${addr}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const httpStatus = await http.status();
|
assertEquals(status.code, 0);
|
||||||
assertEquals(httpStatus.code, 0);
|
|
||||||
http.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetchNoProxy() {
|
async function testFetchNoProxy() {
|
||||||
const c = Deno.run({
|
const { status } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--allow-net",
|
"--allow-net",
|
||||||
"045_proxy_client.ts",
|
"045_proxy_client.ts",
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
|
||||||
env: {
|
env: {
|
||||||
HTTP_PROXY: "http://not.exising.proxy.server",
|
HTTP_PROXY: "http://not.exising.proxy.server",
|
||||||
NO_PROXY: "localhost",
|
NO_PROXY: "localhost",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const status = await c.status();
|
|
||||||
assertEquals(status.code, 0);
|
assertEquals(status.code, 0);
|
||||||
c.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testModuleDownloadNoProxy() {
|
async function testModuleDownloadNoProxy() {
|
||||||
const http = Deno.run({
|
const { status } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"cache",
|
"cache",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"http://localhost:4545/045_mod.ts",
|
"http://localhost:4545/045_mod.ts",
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
|
||||||
env: {
|
env: {
|
||||||
HTTP_PROXY: "http://not.exising.proxy.server",
|
HTTP_PROXY: "http://not.exising.proxy.server",
|
||||||
NO_PROXY: "localhost",
|
NO_PROXY: "localhost",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const httpStatus = await http.status();
|
assertEquals(status.code, 0);
|
||||||
assertEquals(httpStatus.code, 0);
|
|
||||||
http.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetchProgrammaticProxy() {
|
async function testFetchProgrammaticProxy() {
|
||||||
const c = Deno.run({
|
const { status } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"--reload",
|
"--reload",
|
||||||
|
@ -125,11 +108,8 @@ async function testFetchProgrammaticProxy() {
|
||||||
"--unstable",
|
"--unstable",
|
||||||
"045_programmatic_proxy_client.ts",
|
"045_programmatic_proxy_client.ts",
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
const status = await c.status();
|
|
||||||
assertEquals(status.code, 0);
|
assertEquals(status.code, 0);
|
||||||
c.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyServer();
|
proxyServer();
|
||||||
|
|
11
cli/tests/testdata/089_run_allow_list.ts
vendored
11
cli/tests/testdata/089_run_allow_list.ts
vendored
|
@ -1,13 +1,12 @@
|
||||||
try {
|
try {
|
||||||
Deno.run({
|
await Deno.spawn("ls");
|
||||||
cmd: ["ls"],
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
const proc = Deno.run({
|
const { status } = await Deno.spawn("curl", {
|
||||||
cmd: ["curl", "--help"],
|
args: ["--help"],
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
console.log((await proc.status()).success);
|
console.log(status.success);
|
||||||
|
|
24
cli/tests/testdata/lock_write_fetch.ts
vendored
24
cli/tests/testdata/lock_write_fetch.ts
vendored
|
@ -4,11 +4,10 @@ try {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchProc = Deno.run({
|
const fetchProc = await Deno.spawn(Deno.execPath(), {
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
stderr: "null",
|
stderr: "null",
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"cache",
|
"cache",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--lock=lock_write_fetch.json",
|
"--lock=lock_write_fetch.json",
|
||||||
|
@ -18,14 +17,12 @@ const fetchProc = Deno.run({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchCode = (await fetchProc.status()).code;
|
console.log(`fetch code: ${fetchProc.status.code}`);
|
||||||
console.log(`fetch code: ${fetchCode}`);
|
|
||||||
|
|
||||||
const fetchCheckProc = Deno.run({
|
const fetchCheckProc = await Deno.spawn(Deno.execPath(), {
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
stderr: "null",
|
stderr: "null",
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"cache",
|
"cache",
|
||||||
"--lock=lock_write_fetch.json",
|
"--lock=lock_write_fetch.json",
|
||||||
"--cert=tls/RootCA.pem",
|
"--cert=tls/RootCA.pem",
|
||||||
|
@ -33,16 +30,14 @@ const fetchCheckProc = Deno.run({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchCheckProcCode = (await fetchCheckProc.status()).code;
|
console.log(`fetch check code: ${fetchCheckProc.status.code}`);
|
||||||
console.log(`fetch check code: ${fetchCheckProcCode}`);
|
|
||||||
|
|
||||||
Deno.removeSync("./lock_write_fetch.json");
|
Deno.removeSync("./lock_write_fetch.json");
|
||||||
|
|
||||||
const runProc = Deno.run({
|
const runProc = await Deno.spawn(Deno.execPath(), {
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
stderr: "null",
|
stderr: "null",
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"run",
|
"run",
|
||||||
"--lock=lock_write_fetch.json",
|
"--lock=lock_write_fetch.json",
|
||||||
"--lock-write",
|
"--lock-write",
|
||||||
|
@ -52,7 +47,6 @@ const runProc = Deno.run({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const runCode = (await runProc.status()).code;
|
console.log(`run code: ${runProc.status.code}`);
|
||||||
console.log(`run code: ${runCode}`);
|
|
||||||
|
|
||||||
Deno.removeSync("./lock_write_fetch.json");
|
Deno.removeSync("./lock_write_fetch.json");
|
||||||
|
|
5
cli/tests/testdata/no_prompt.ts
vendored
5
cli/tests/testdata/no_prompt.ts
vendored
|
@ -1,7 +1,10 @@
|
||||||
new Worker("data:,setTimeout(() => Deno.exit(2), 200)", { type: "module" });
|
new Worker("data:,setTimeout(() => Deno.exit(2), 200)", { type: "module" });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Deno.run({ cmd: ["ps"] });
|
await Deno.spawn("ps", {
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
|
});
|
||||||
} catch {
|
} catch {
|
||||||
Deno.exit(0);
|
Deno.exit(0);
|
||||||
}
|
}
|
||||||
|
|
9
cli/tests/testdata/permission_test.ts
vendored
9
cli/tests/testdata/permission_test.ts
vendored
|
@ -15,13 +15,10 @@ const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
|
||||||
netRequired() {
|
netRequired() {
|
||||||
Deno.listen({ transport: "tcp", port: 4541 });
|
Deno.listen({ transport: "tcp", port: 4541 });
|
||||||
},
|
},
|
||||||
runRequired() {
|
async runRequired() {
|
||||||
const p = Deno.run({
|
await Deno.spawn(Deno.build.os === "windows" ? "cmd.exe" : "printf", {
|
||||||
cmd: Deno.build.os === "windows"
|
args: Deno.build.os === "windows" ? ["/c", "echo hello"] : ["hello"],
|
||||||
? ["cmd.exe", "/c", "echo hello"]
|
|
||||||
: ["printf", "hello"],
|
|
||||||
});
|
});
|
||||||
p.close();
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,21 +5,17 @@ import { assertEquals, assertRejects, assertThrows } from "./test_util.ts";
|
||||||
|
|
||||||
async function getUidAndGid(): Promise<{ uid: number; gid: number }> {
|
async function getUidAndGid(): Promise<{ uid: number; gid: number }> {
|
||||||
// get the user ID and group ID of the current process
|
// get the user ID and group ID of the current process
|
||||||
const uidProc = Deno.run({
|
const uidProc = await Deno.spawn("id", {
|
||||||
stdout: "piped",
|
args: ["-u"],
|
||||||
cmd: ["id", "-u"],
|
|
||||||
});
|
});
|
||||||
const gidProc = Deno.run({
|
const gidProc = await Deno.spawn("id", {
|
||||||
stdout: "piped",
|
args: ["-g"],
|
||||||
cmd: ["id", "-g"],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals((await uidProc.status()).code, 0);
|
assertEquals(uidProc.status.code, 0);
|
||||||
assertEquals((await gidProc.status()).code, 0);
|
assertEquals(gidProc.status.code, 0);
|
||||||
const uid = parseInt(new TextDecoder("utf-8").decode(await uidProc.output()));
|
const uid = parseInt(new TextDecoder("utf-8").decode(uidProc.stdout));
|
||||||
uidProc.close();
|
const gid = parseInt(new TextDecoder("utf-8").decode(gidProc.stdout));
|
||||||
const gid = parseInt(new TextDecoder("utf-8").decode(await gidProc.output()));
|
|
||||||
gidProc.close();
|
|
||||||
|
|
||||||
return { uid, gid };
|
return { uid, gid };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals } from "./test_util.ts";
|
import { assertEquals } from "./test_util.ts";
|
||||||
import { readAll } from "../../../test_util/std/io/util.ts";
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, run: true, hrtime: true } },
|
{ permissions: { read: true, run: true, hrtime: true } },
|
||||||
|
@ -103,8 +102,8 @@ async function checkFirstBlocksSecond(opts: {
|
||||||
const secondPsTimes = await secondProcess.getTimes();
|
const secondPsTimes = await secondProcess.getTimes();
|
||||||
return firstPsTimes.exitTime < secondPsTimes.enterTime;
|
return firstPsTimes.exitTime < secondPsTimes.enterTime;
|
||||||
} finally {
|
} finally {
|
||||||
firstProcess.close();
|
await firstProcess.close();
|
||||||
secondProcess.close();
|
await secondProcess.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,14 +148,21 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
|
||||||
console.log(JSON.stringify({ enterTime, exitTime }));
|
console.log(JSON.stringify({ enterTime, exitTime }));
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const process = Deno.run({
|
const process = Deno.spawnChild(Deno.execPath(), {
|
||||||
cmd: [Deno.execPath(), "eval", "--unstable", scriptText],
|
args: ["eval", "--unstable", scriptText],
|
||||||
stdout: "piped",
|
|
||||||
stdin: "piped",
|
stdin: "piped",
|
||||||
});
|
});
|
||||||
|
|
||||||
const waitSignal = () => process.stdout.read(new Uint8Array(1));
|
const waitSignal = async () => {
|
||||||
const signal = () => process.stdin.write(new Uint8Array(1));
|
const reader = process.stdout.getReader({ mode: "byob" });
|
||||||
|
await reader.read(new Uint8Array(1));
|
||||||
|
reader.releaseLock();
|
||||||
|
};
|
||||||
|
const signal = async () => {
|
||||||
|
const writer = process.stdin.getWriter();
|
||||||
|
await writer.write(new Uint8Array(1));
|
||||||
|
writer.releaseLock();
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async waitStartup() {
|
async waitStartup() {
|
||||||
|
@ -174,17 +180,16 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
|
||||||
await waitSignal();
|
await waitSignal();
|
||||||
},
|
},
|
||||||
getTimes: async () => {
|
getTimes: async () => {
|
||||||
const outputBytes = await readAll(process.stdout);
|
const { stdout } = await process.output();
|
||||||
const text = new TextDecoder().decode(outputBytes);
|
const text = new TextDecoder().decode(stdout);
|
||||||
return JSON.parse(text) as {
|
return JSON.parse(text) as {
|
||||||
enterTime: number;
|
enterTime: number;
|
||||||
exitTime: number;
|
exitTime: number;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
close: () => {
|
close: async () => {
|
||||||
process.stdout.close();
|
await process.status;
|
||||||
process.stdin.close();
|
await process.stdin.close();
|
||||||
process.close();
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1165,11 +1165,13 @@ Deno.test(
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = ["curl", "-X", "DELETE", url];
|
const args = ["-X", "DELETE", url];
|
||||||
const proc = Deno.run({ cmd, stdout: "null", stderr: "null" });
|
const { status } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stdout: "null",
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1277,8 +1279,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1287,13 +1288,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(output.includes("content-encoding: gzip\r\n"));
|
assert(output.includes("content-encoding: gzip\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1327,8 +1329,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
"--url",
|
"--url",
|
||||||
|
@ -1336,10 +1337,10 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const proc = Deno.spawnChild("curl", { args, stderr: "null" });
|
||||||
const status = await proc.status();
|
const status = await proc.status;
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const stdout = proc.stdout!.readable
|
const stdout = proc.stdout
|
||||||
.pipeThrough(new DecompressionStream("gzip"))
|
.pipeThrough(new DecompressionStream("gzip"))
|
||||||
.pipeThrough(new TextDecoderStream());
|
.pipeThrough(new TextDecoderStream());
|
||||||
let body = "";
|
let body = "";
|
||||||
|
@ -1347,7 +1348,6 @@ Deno.test({
|
||||||
body += chunk;
|
body += chunk;
|
||||||
}
|
}
|
||||||
assertEquals(JSON.parse(body), data);
|
assertEquals(JSON.parse(body), data);
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1382,8 +1382,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1392,13 +1391,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output()).toLocaleLowerCase();
|
const output = decoder.decode(stdout).toLocaleLowerCase();
|
||||||
assert(output.includes("vary: accept-encoding\r\n"));
|
assert(output.includes("vary: accept-encoding\r\n"));
|
||||||
assert(!output.includes("content-encoding: "));
|
assert(!output.includes("content-encoding: "));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1436,8 +1436,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1446,13 +1445,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip;q=0.8, br;q=1.0, *;q=0.1",
|
"Accept-Encoding: gzip;q=0.8, br;q=1.0, *;q=0.1",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(output.includes("content-encoding: br\r\n"));
|
assert(output.includes("content-encoding: br\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1487,8 +1487,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1497,13 +1496,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding, Accept\r\n"));
|
assert(output.includes("vary: Accept-Encoding, Accept\r\n"));
|
||||||
assert(output.includes("content-encoding: gzip\r\n"));
|
assert(output.includes("content-encoding: gzip\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1541,7 +1541,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
"curl",
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
|
@ -1551,16 +1551,17 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(
|
assert(
|
||||||
output.includes("etag: W/33a64df551425fcc55e4d42a148795d9f25f89d4\r\n"),
|
output.includes("etag: W/33a64df551425fcc55e4d42a148795d9f25f89d4\r\n"),
|
||||||
);
|
);
|
||||||
assert(output.includes("content-encoding: gzip\r\n"));
|
assert(output.includes("content-encoding: gzip\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1598,8 +1599,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1608,16 +1608,17 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(
|
assert(
|
||||||
output.includes("etag: W/33a64df551425fcc55e4d42a148795d9f25f89d4\r\n"),
|
output.includes("etag: W/33a64df551425fcc55e4d42a148795d9f25f89d4\r\n"),
|
||||||
);
|
);
|
||||||
assert(output.includes("content-encoding: gzip\r\n"));
|
assert(output.includes("content-encoding: gzip\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1655,8 +1656,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1665,13 +1665,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(!output.includes("content-encoding: "));
|
assert(!output.includes("content-encoding: "));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1709,8 +1710,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1719,13 +1719,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(!output.includes("content-encoding: "));
|
assert(!output.includes("content-encoding: "));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1768,7 +1769,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
"curl",
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
|
@ -1778,13 +1779,14 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(output.includes("content-encoding: gzip\r\n"));
|
assert(output.includes("content-encoding: gzip\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1827,8 +1829,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
"--url",
|
"--url",
|
||||||
|
@ -1836,10 +1837,10 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const proc = Deno.spawnChild("curl", { args, stderr: "null" });
|
||||||
const status = await proc.status();
|
const status = await proc.status;
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const stdout = proc.stdout.readable
|
const stdout = proc.stdout
|
||||||
.pipeThrough(new DecompressionStream("gzip"))
|
.pipeThrough(new DecompressionStream("gzip"))
|
||||||
.pipeThrough(new TextDecoderStream());
|
.pipeThrough(new TextDecoderStream());
|
||||||
let body = "";
|
let body = "";
|
||||||
|
@ -1847,7 +1848,6 @@ Deno.test({
|
||||||
body += chunk;
|
body += chunk;
|
||||||
}
|
}
|
||||||
assertEquals(JSON.parse(body), data);
|
assertEquals(JSON.parse(body), data);
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
@ -1892,8 +1892,7 @@ Deno.test({
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
const url = `http://${hostname}:${port}/`;
|
const url = `http://${hostname}:${port}/`;
|
||||||
const cmd = [
|
const args = [
|
||||||
"curl",
|
|
||||||
"-i",
|
"-i",
|
||||||
"--request",
|
"--request",
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -1902,16 +1901,17 @@ Deno.test({
|
||||||
"--header",
|
"--header",
|
||||||
"Accept-Encoding: gzip, deflate, br",
|
"Accept-Encoding: gzip, deflate, br",
|
||||||
];
|
];
|
||||||
const proc = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
const status = await proc.status();
|
args,
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
assert(status.success);
|
assert(status.success);
|
||||||
const output = decoder.decode(await proc.output());
|
const output = decoder.decode(stdout);
|
||||||
assert(output.includes("vary: Accept-Encoding\r\n"));
|
assert(output.includes("vary: Accept-Encoding\r\n"));
|
||||||
assert(output.includes("content-encoding: gzip\r\n"));
|
assert(output.includes("content-encoding: gzip\r\n"));
|
||||||
// Ensure the content-length header is updated.
|
// Ensure the content-length header is updated.
|
||||||
assert(!output.includes(`content-length: ${contentLength}\r\n`));
|
assert(!output.includes(`content-length: ${contentLength}\r\n`));
|
||||||
assert(output.includes("content-length: 72\r\n"));
|
assert(output.includes("content-length: 72\r\n"));
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([server(), client()]);
|
await Promise.all([server(), client()]);
|
||||||
|
|
|
@ -74,19 +74,14 @@ Deno.test(
|
||||||
console.log(
|
console.log(
|
||||||
${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env.get(k))
|
${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env.get(k))
|
||||||
)`;
|
)`;
|
||||||
const proc = Deno.run({
|
const { status, stdout } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [Deno.execPath(), "eval", src],
|
args: ["eval", src],
|
||||||
env: { ...inputEnv, NO_COLOR: "1" },
|
env: { ...inputEnv, NO_COLOR: "1" },
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
const status = await proc.status();
|
|
||||||
assertEquals(status.success, true);
|
assertEquals(status.success, true);
|
||||||
const expectedValues = Object.values(expectedEnv);
|
const expectedValues = Object.values(expectedEnv);
|
||||||
const actualValues = JSON.parse(
|
const actualValues = JSON.parse(new TextDecoder().decode(stdout));
|
||||||
new TextDecoder().decode(await proc.output()),
|
|
||||||
);
|
|
||||||
assertEquals(actualValues, expectedValues);
|
assertEquals(actualValues, expectedValues);
|
||||||
proc.close();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
assertEquals(Deno.env.get("path"), Deno.env.get("PATH"));
|
assertEquals(Deno.env.get("path"), Deno.env.get("PATH"));
|
||||||
|
@ -133,16 +128,13 @@ Deno.test(
|
||||||
{ permissions: { run: true, read: true } },
|
{ permissions: { run: true, read: true } },
|
||||||
async function osPpidIsEqualToPidOfParentProcess() {
|
async function osPpidIsEqualToPidOfParentProcess() {
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
const process = Deno.run({
|
const { stdout } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [Deno.execPath(), "eval", "-p", "--unstable", "Deno.ppid"],
|
args: ["eval", "-p", "--unstable", "Deno.ppid"],
|
||||||
stdout: "piped",
|
|
||||||
env: { NO_COLOR: "true" },
|
env: { NO_COLOR: "true" },
|
||||||
});
|
});
|
||||||
const output = await process.output();
|
|
||||||
process.close();
|
|
||||||
|
|
||||||
const expected = Deno.pid;
|
const expected = Deno.pid;
|
||||||
const actual = parseInt(decoder.decode(output));
|
const actual = parseInt(decoder.decode(stdout));
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -262,13 +262,12 @@ if (Deno.build.os === "windows") {
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { run: true, write: true, read: true } },
|
{ permissions: { run: true, write: true, read: true } },
|
||||||
async function removeFileSymlink() {
|
async function removeFileSymlink() {
|
||||||
const symlink = Deno.run({
|
const { status } = await Deno.spawn("cmd", {
|
||||||
cmd: ["cmd", "/c", "mklink", "file_link", "bar"],
|
args: ["/c", "mklink", "file_link", "bar"],
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(await symlink.status());
|
assert(status.success);
|
||||||
symlink.close();
|
|
||||||
await Deno.remove("file_link");
|
await Deno.remove("file_link");
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.lstat("file_link");
|
await Deno.lstat("file_link");
|
||||||
|
@ -279,14 +278,12 @@ if (Deno.build.os === "windows") {
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { run: true, write: true, read: true } },
|
{ permissions: { run: true, write: true, read: true } },
|
||||||
async function removeDirSymlink() {
|
async function removeDirSymlink() {
|
||||||
const symlink = Deno.run({
|
const { status } = await Deno.spawn("cmd", {
|
||||||
cmd: ["cmd", "/c", "mklink", "/d", "dir_link", "bar"],
|
args: ["/c", "mklink", "/d", "dir_link", "bar"],
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(await symlink.status());
|
assert(status.success);
|
||||||
symlink.close();
|
|
||||||
|
|
||||||
await Deno.remove("dir_link");
|
await Deno.remove("dir_link");
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await Deno.lstat("dir_link");
|
await Deno.lstat("dir_link");
|
||||||
|
|
|
@ -173,17 +173,14 @@ Deno.test(
|
||||||
permissions: { run: true, read: true },
|
permissions: { run: true, read: true },
|
||||||
},
|
},
|
||||||
async function canExitWhileListeningToSignal() {
|
async function canExitWhileListeningToSignal() {
|
||||||
const p = Deno.run({
|
const { status } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"eval",
|
"eval",
|
||||||
"--unstable",
|
"--unstable",
|
||||||
"Deno.addSignalListener('SIGIO', () => {})",
|
"Deno.addSignalListener('SIGIO', () => {})",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const res = await p.status();
|
assertEquals(status.code, 0);
|
||||||
assertEquals(res.code, 0);
|
|
||||||
p.close();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -31,17 +31,13 @@ export function pathToAbsoluteFileUrl(path: string): URL {
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
|
|
||||||
export async function execCode(code: string): Promise<[number, string]> {
|
export async function execCode(code: string): Promise<[number, string]> {
|
||||||
const p = Deno.run({
|
const { status, stdout } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [
|
args: [
|
||||||
Deno.execPath(),
|
|
||||||
"eval",
|
"eval",
|
||||||
"--unstable",
|
"--unstable",
|
||||||
"--no-check",
|
"--no-check",
|
||||||
code,
|
code,
|
||||||
],
|
],
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
const [status, output] = await Promise.all([p.status(), p.output()]);
|
return [status.code, decoder.decode(stdout)];
|
||||||
p.close();
|
|
||||||
return [status.code, decoder.decode(output)];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1019,20 +1019,14 @@ function createHttpsListener(port: number): Deno.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function curl(url: string): Promise<string> {
|
async function curl(url: string): Promise<string> {
|
||||||
const curl = Deno.run({
|
const { status, stdout } = await Deno.spawn("curl", {
|
||||||
cmd: ["curl", "--insecure", url],
|
args: ["--insecure", url],
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
if (!status.success) {
|
||||||
const [status, output] = await Promise.all([curl.status(), curl.output()]);
|
throw new Error(`curl ${url} failed: ${status.code}`);
|
||||||
if (!status.success) {
|
|
||||||
throw new Error(`curl ${url} failed: ${status.code}`);
|
|
||||||
}
|
|
||||||
return new TextDecoder().decode(output);
|
|
||||||
} finally {
|
|
||||||
curl.close();
|
|
||||||
}
|
}
|
||||||
|
return new TextDecoder().decode(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
|
|
|
@ -6,12 +6,10 @@ import { assertEquals } from "./test_util.ts";
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { run: true, read: true } },
|
{ permissions: { run: true, read: true } },
|
||||||
async function noColorIfNotTty() {
|
async function noColorIfNotTty() {
|
||||||
const p = Deno.run({
|
const { stdout } = await Deno.spawn(Deno.execPath(), {
|
||||||
cmd: [Deno.execPath(), "eval", "console.log(1)"],
|
args: ["eval", "console.log(1)"],
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
const output = new TextDecoder().decode(await p.output());
|
const output = new TextDecoder().decode(stdout);
|
||||||
assertEquals(output, "1\n");
|
assertEquals(output, "1\n");
|
||||||
p.close();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -141,9 +141,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async output() {
|
async output() {
|
||||||
if (this.#rid === null) {
|
|
||||||
throw new TypeError("Child process has already terminated.");
|
|
||||||
}
|
|
||||||
if (this.#stdout?.locked) {
|
if (this.#stdout?.locked) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
"Can't collect output because stdout is locked",
|
"Can't collect output because stdout is locked",
|
||||||
|
|
|
@ -3,35 +3,34 @@
|
||||||
import { join, ROOT_PATH as ROOT } from "./util.js";
|
import { join, ROOT_PATH as ROOT } from "./util.js";
|
||||||
|
|
||||||
async function bashOut(subcmd) {
|
async function bashOut(subcmd) {
|
||||||
const p = Deno.run({
|
const { status, stdout } = await Deno.spawn("bash", {
|
||||||
cmd: ["bash", "-c", subcmd],
|
args: ["-c", subcmd],
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
stderr: "null",
|
stderr: "null",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check for failure
|
// Check for failure
|
||||||
const { success } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("subcmd failed");
|
throw new Error("subcmd failed");
|
||||||
}
|
}
|
||||||
// Gather output
|
// Gather output
|
||||||
const output = new TextDecoder().decode(await p.output());
|
const output = new TextDecoder().decode(stdout);
|
||||||
// Cleanup
|
|
||||||
p.close();
|
|
||||||
|
|
||||||
return output.trim();
|
return output.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bashThrough(subcmd, opts = {}) {
|
async function bashThrough(subcmd, opts = {}) {
|
||||||
const p = Deno.run({ ...opts, cmd: ["bash", "-c", subcmd] });
|
const { status } = await Deno.spawn("bash", {
|
||||||
|
...opts,
|
||||||
|
args: ["-c", subcmd],
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
|
});
|
||||||
|
|
||||||
// Exit process on failure
|
// Exit process on failure
|
||||||
const { success, code } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
Deno.exit(status.code);
|
||||||
Deno.exit(code);
|
|
||||||
}
|
}
|
||||||
// Cleanup
|
|
||||||
p.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function availableBenches() {
|
async function availableBenches() {
|
||||||
|
|
|
@ -5,14 +5,14 @@ import { getPrebuiltToolPath, join, ROOT_PATH } from "./util.js";
|
||||||
async function dprint() {
|
async function dprint() {
|
||||||
const configFile = join(ROOT_PATH, ".dprint.json");
|
const configFile = join(ROOT_PATH, ".dprint.json");
|
||||||
const execPath = getPrebuiltToolPath("dprint");
|
const execPath = getPrebuiltToolPath("dprint");
|
||||||
const p = Deno.run({
|
const { status } = await Deno.spawn(execPath, {
|
||||||
cmd: [execPath, "fmt", "--config=" + configFile],
|
args: ["fmt", "--config=" + configFile],
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
const { success } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("dprint failed");
|
throw new Error("dprint failed");
|
||||||
}
|
}
|
||||||
p.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
@ -20,17 +20,15 @@ async function main() {
|
||||||
await dprint();
|
await dprint();
|
||||||
|
|
||||||
if (Deno.args.includes("--check")) {
|
if (Deno.args.includes("--check")) {
|
||||||
const git = Deno.run({
|
const { status, stdout } = await Deno.spawn("git", {
|
||||||
cmd: ["git", "status", "-uno", "--porcelain", "--ignore-submodules"],
|
args: ["status", "-uno", "--porcelain", "--ignore-submodules"],
|
||||||
stdout: "piped",
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { success } = await git.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("git status failed");
|
throw new Error("git status failed");
|
||||||
}
|
}
|
||||||
const out = new TextDecoder().decode(await git.output());
|
const out = new TextDecoder().decode(stdout);
|
||||||
git.close();
|
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
console.log("run tools/format.js");
|
console.log("run tools/format.js");
|
||||||
|
|
|
@ -39,14 +39,14 @@ async function dlint() {
|
||||||
|
|
||||||
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
|
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
const p = Deno.run({
|
const { status } = await Deno.spawn(execPath, {
|
||||||
cmd: [execPath, "run", "--config=" + configFile, ...chunk],
|
args: ["run", "--config=" + configFile, ...chunk],
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
const { success } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("dlint failed");
|
throw new Error("dlint failed");
|
||||||
}
|
}
|
||||||
p.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ async function dlintPreferPrimordials() {
|
||||||
|
|
||||||
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
|
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
const p = Deno.run({
|
const { status } = await Deno.spawn(execPath, {
|
||||||
cmd: [execPath, "run", "--rule", "prefer-primordials", ...chunk],
|
args: ["run", "--rule", "prefer-primordials", ...chunk],
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
const { success } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("prefer-primordials failed");
|
throw new Error("prefer-primordials failed");
|
||||||
}
|
}
|
||||||
p.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,14 +101,14 @@ async function clippy() {
|
||||||
console.log("clippy");
|
console.log("clippy");
|
||||||
|
|
||||||
const currentBuildMode = buildMode();
|
const currentBuildMode = buildMode();
|
||||||
const cmd = ["cargo", "clippy", "--all-targets", "--locked"];
|
const cmd = ["clippy", "--all-targets", "--locked"];
|
||||||
|
|
||||||
if (currentBuildMode != "debug") {
|
if (currentBuildMode != "debug") {
|
||||||
cmd.push("--release");
|
cmd.push("--release");
|
||||||
}
|
}
|
||||||
|
|
||||||
const p = Deno.run({
|
const { status } = await Deno.spawn("cargo", {
|
||||||
cmd: [
|
args: [
|
||||||
...cmd,
|
...cmd,
|
||||||
"--",
|
"--",
|
||||||
"-D",
|
"-D",
|
||||||
|
@ -116,12 +116,12 @@ async function clippy() {
|
||||||
"-D",
|
"-D",
|
||||||
"clippy::await_holding_refcell_ref",
|
"clippy::await_holding_refcell_ref",
|
||||||
],
|
],
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
const { success } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("clippy failed");
|
throw new Error("clippy failed");
|
||||||
}
|
}
|
||||||
p.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
|
@ -8,24 +8,21 @@ import {
|
||||||
} from "../test_util/std/path/mod.ts";
|
} from "../test_util/std/path/mod.ts";
|
||||||
export { dirname, fromFileUrl, join, resolve, toFileUrl };
|
export { dirname, fromFileUrl, join, resolve, toFileUrl };
|
||||||
export { existsSync, walk } from "../test_util/std/fs/mod.ts";
|
export { existsSync, walk } from "../test_util/std/fs/mod.ts";
|
||||||
export { readLines } from "../test_util/std/io/mod.ts";
|
export { TextLineStream } from "../test_util/std/streams/delimiter.ts";
|
||||||
export { delay } from "../test_util/std/async/delay.ts";
|
export { delay } from "../test_util/std/async/delay.ts";
|
||||||
|
|
||||||
export const ROOT_PATH = dirname(dirname(fromFileUrl(import.meta.url)));
|
export const ROOT_PATH = dirname(dirname(fromFileUrl(import.meta.url)));
|
||||||
|
|
||||||
async function getFilesFromGit(baseDir, cmd) {
|
async function getFilesFromGit(baseDir, args) {
|
||||||
const p = Deno.run({
|
const { status, stdout } = await Deno.spawn("git", {
|
||||||
cmd,
|
stderr: "inherit",
|
||||||
stdout: "piped",
|
args,
|
||||||
});
|
});
|
||||||
const output = new TextDecoder().decode(await p.output());
|
const output = new TextDecoder().decode(stdout);
|
||||||
const { success } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
|
||||||
throw new Error("gitLsFiles failed");
|
throw new Error("gitLsFiles failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
p.close();
|
|
||||||
|
|
||||||
const files = output.split("\0").filter((line) => line.length > 0).map(
|
const files = output.split("\0").filter((line) => line.length > 0).map(
|
||||||
(filePath) => {
|
(filePath) => {
|
||||||
return Deno.realPathSync(join(baseDir, filePath));
|
return Deno.realPathSync(join(baseDir, filePath));
|
||||||
|
@ -38,7 +35,6 @@ async function getFilesFromGit(baseDir, cmd) {
|
||||||
function gitLsFiles(baseDir, patterns) {
|
function gitLsFiles(baseDir, patterns) {
|
||||||
baseDir = Deno.realPathSync(baseDir);
|
baseDir = Deno.realPathSync(baseDir);
|
||||||
const cmd = [
|
const cmd = [
|
||||||
"git",
|
|
||||||
"-C",
|
"-C",
|
||||||
baseDir,
|
baseDir,
|
||||||
"ls-files",
|
"ls-files",
|
||||||
|
@ -57,7 +53,6 @@ function gitLsFiles(baseDir, patterns) {
|
||||||
function gitStaged(baseDir, patterns) {
|
function gitStaged(baseDir, patterns) {
|
||||||
baseDir = Deno.realPathSync(baseDir);
|
baseDir = Deno.realPathSync(baseDir);
|
||||||
const cmd = [
|
const cmd = [
|
||||||
"git",
|
|
||||||
"-C",
|
"-C",
|
||||||
baseDir,
|
baseDir,
|
||||||
"diff",
|
"diff",
|
||||||
|
|
|
@ -10,15 +10,17 @@ const V_WGPU = "0.12";
|
||||||
const TARGET_DIR = join(ROOT_PATH, "ext", "webgpu");
|
const TARGET_DIR = join(ROOT_PATH, "ext", "webgpu");
|
||||||
|
|
||||||
async function bash(subcmd, opts = {}) {
|
async function bash(subcmd, opts = {}) {
|
||||||
const p = Deno.run({ ...opts, cmd: ["bash", "-c", subcmd] });
|
const { status } = await Deno.spawn("bash", {
|
||||||
|
...opts,
|
||||||
|
args: ["-c", subcmd],
|
||||||
|
stdout: "inherit",
|
||||||
|
sdterr: "inherit",
|
||||||
|
});
|
||||||
|
|
||||||
// Exit process on failure
|
// Exit process on failure
|
||||||
const { success, code } = await p.status();
|
if (!status.success) {
|
||||||
if (!success) {
|
Deno.exit(status.code);
|
||||||
Deno.exit(code);
|
|
||||||
}
|
}
|
||||||
// Cleanup
|
|
||||||
p.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearTargetDir() {
|
async function clearTargetDir() {
|
||||||
|
|
|
@ -90,10 +90,11 @@ async function setup() {
|
||||||
`The WPT require certain entries to be present in your ${hostsPath} file. Should these be configured automatically?`,
|
`The WPT require certain entries to be present in your ${hostsPath} file. Should these be configured automatically?`,
|
||||||
);
|
);
|
||||||
if (autoConfigure) {
|
if (autoConfigure) {
|
||||||
const proc = runPy(["wpt", "make-hosts-file"], { stdout: "piped" });
|
const { status, stdout } = await runPy(["wpt", "make-hosts-file"], {
|
||||||
const status = await proc.status();
|
stdout: "piped",
|
||||||
|
}).output();
|
||||||
assert(status.success, "wpt make-hosts-file should not fail");
|
assert(status.success, "wpt make-hosts-file should not fail");
|
||||||
const entries = new TextDecoder().decode(await proc.output());
|
const entries = new TextDecoder().decode(stdout);
|
||||||
const file = await Deno.open(hostsPath, { append: true }).catch((err) => {
|
const file = await Deno.open(hostsPath, { append: true }).catch((err) => {
|
||||||
if (err instanceof Deno.errors.PermissionDenied) {
|
if (err instanceof Deno.errors.PermissionDenied) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
import { delay, join, readLines, ROOT_PATH, toFileUrl } from "../util.js";
|
import { delay, join, ROOT_PATH, TextLineStream, toFileUrl } from "../util.js";
|
||||||
import { assert, denoBinary, ManifestTestOptions, runPy } from "./utils.ts";
|
import { assert, denoBinary, ManifestTestOptions, runPy } from "./utils.ts";
|
||||||
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.3-alpha2/deno-dom-wasm.ts";
|
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.3-alpha2/deno-dom-wasm.ts";
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@ export async function runWithTestUtil<T>(
|
||||||
const passedTime = performance.now() - start;
|
const passedTime = performance.now() - start;
|
||||||
if (passedTime > 15000) {
|
if (passedTime > 15000) {
|
||||||
proc.kill("SIGINT");
|
proc.kill("SIGINT");
|
||||||
await proc.status();
|
await proc.status;
|
||||||
proc.close();
|
|
||||||
throw new Error("Timed out while trying to start wpt test util.");
|
throw new Error("Timed out while trying to start wpt test util.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +44,7 @@ export async function runWithTestUtil<T>(
|
||||||
} finally {
|
} finally {
|
||||||
if (verbose) console.log("Killing wpt test util.");
|
if (verbose) console.log("Killing wpt test util.");
|
||||||
proc.kill("SIGINT");
|
proc.kill("SIGINT");
|
||||||
await proc.status();
|
await proc.status;
|
||||||
proc.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,21 +87,17 @@ export async function runSingleTest(
|
||||||
|
|
||||||
const startTime = new Date().getTime();
|
const startTime = new Date().getTime();
|
||||||
|
|
||||||
const cmd = [
|
const args = [
|
||||||
denoBinary(),
|
|
||||||
"run",
|
"run",
|
||||||
];
|
|
||||||
|
|
||||||
cmd.push(
|
|
||||||
"-A",
|
"-A",
|
||||||
"--unstable",
|
"--unstable",
|
||||||
);
|
];
|
||||||
|
|
||||||
if (inspectBrk) {
|
if (inspectBrk) {
|
||||||
cmd.push("--inspect-brk");
|
args.push("--inspect-brk");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.push(
|
args.push(
|
||||||
"--enable-testing-features-do-not-use",
|
"--enable-testing-features-do-not-use",
|
||||||
"--location",
|
"--location",
|
||||||
url.toString(),
|
url.toString(),
|
||||||
|
@ -113,8 +107,8 @@ export async function runSingleTest(
|
||||||
"[]",
|
"[]",
|
||||||
);
|
);
|
||||||
|
|
||||||
const proc = Deno.run({
|
const proc = Deno.spawnChild(denoBinary(), {
|
||||||
cmd,
|
args,
|
||||||
env: {
|
env: {
|
||||||
NO_COLOR: "1",
|
NO_COLOR: "1",
|
||||||
},
|
},
|
||||||
|
@ -127,7 +121,9 @@ export async function runSingleTest(
|
||||||
|
|
||||||
let harnessStatus = null;
|
let harnessStatus = null;
|
||||||
|
|
||||||
const lines = readLines(proc.stderr);
|
const lines = proc.stderr.pipeThrough(new TextDecoderStream()).pipeThrough(
|
||||||
|
new TextLineStream(),
|
||||||
|
);
|
||||||
for await (const line of lines) {
|
for await (const line of lines) {
|
||||||
if (line.startsWith("{")) {
|
if (line.startsWith("{")) {
|
||||||
const data = JSON.parse(line);
|
const data = JSON.parse(line);
|
||||||
|
@ -144,7 +140,7 @@ export async function runSingleTest(
|
||||||
|
|
||||||
const duration = new Date().getTime() - startTime;
|
const duration = new Date().getTime() - startTime;
|
||||||
|
|
||||||
const { code } = await proc.status();
|
const { code } = await proc.status;
|
||||||
return {
|
return {
|
||||||
status: code,
|
status: code,
|
||||||
harnessStatus,
|
harnessStatus,
|
||||||
|
|
|
@ -53,7 +53,7 @@ export interface ManifestTestOptions {
|
||||||
const MANIFEST_PATH = join(ROOT_PATH, "./tools/wpt/manifest.json");
|
const MANIFEST_PATH = join(ROOT_PATH, "./tools/wpt/manifest.json");
|
||||||
|
|
||||||
export async function updateManifest() {
|
export async function updateManifest() {
|
||||||
const proc = runPy(
|
const status = await runPy(
|
||||||
[
|
[
|
||||||
"wpt",
|
"wpt",
|
||||||
"manifest",
|
"manifest",
|
||||||
|
@ -64,8 +64,7 @@ export async function updateManifest() {
|
||||||
...(rebuild ? ["--rebuild"] : []),
|
...(rebuild ? ["--rebuild"] : []),
|
||||||
],
|
],
|
||||||
{},
|
{},
|
||||||
);
|
).status;
|
||||||
const status = await proc.status();
|
|
||||||
assert(status.success, "updating wpt manifest should succeed");
|
assert(status.success, "updating wpt manifest should succeed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,23 +118,26 @@ export function assert(condition: unknown, message: string): asserts condition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runPy(
|
export function runPy<T extends Omit<Deno.SpawnOptions, "cwd">>(
|
||||||
args: string[],
|
args: string[],
|
||||||
options: Omit<Omit<Deno.RunOptions, "cmd">, "cwd">,
|
options: T,
|
||||||
): Deno.Process {
|
): Deno.Child<T> {
|
||||||
const cmd = Deno.build.os == "windows" ? "python.exe" : "python3";
|
const cmd = Deno.build.os == "windows" ? "python.exe" : "python3";
|
||||||
return Deno.run({
|
return Deno.spawnChild(cmd, {
|
||||||
cmd: [cmd, ...args],
|
args,
|
||||||
cwd: join(ROOT_PATH, "./test_util/wpt/"),
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
...options,
|
...options,
|
||||||
|
cwd: join(ROOT_PATH, "./test_util/wpt/"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkPy3Available() {
|
export async function checkPy3Available() {
|
||||||
const proc = runPy(["--version"], { stdout: "piped" });
|
const { status, stdout } = await runPy(["--version"], {
|
||||||
const status = await proc.status();
|
stdout: "piped",
|
||||||
|
}).output();
|
||||||
assert(status.success, "failed to run python --version");
|
assert(status.success, "failed to run python --version");
|
||||||
const output = new TextDecoder().decode(await proc.output());
|
const output = new TextDecoder().decode(stdout);
|
||||||
assert(
|
assert(
|
||||||
output.includes("Python 3."),
|
output.includes("Python 3."),
|
||||||
`The ${
|
`The ${
|
||||||
|
@ -146,12 +148,12 @@ export async function checkPy3Available() {
|
||||||
|
|
||||||
export async function cargoBuild() {
|
export async function cargoBuild() {
|
||||||
if (binary) return;
|
if (binary) return;
|
||||||
const proc = Deno.run({
|
const { status } = await Deno.spawn("cargo", {
|
||||||
cmd: ["cargo", "build", ...(release ? ["--release"] : [])],
|
args: ["build", ...(release ? ["--release"] : [])],
|
||||||
cwd: ROOT_PATH,
|
cwd: ROOT_PATH,
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
const status = await proc.status();
|
|
||||||
proc.close();
|
|
||||||
assert(status.success, "cargo build failed");
|
assert(status.success, "cargo build failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,22 +175,17 @@ export async function generateRunInfo(): Promise<unknown> {
|
||||||
"darwin": "mac",
|
"darwin": "mac",
|
||||||
"linux": "linux",
|
"linux": "linux",
|
||||||
};
|
};
|
||||||
const proc = Deno.run({
|
const proc = await Deno.spawn("git", {
|
||||||
cmd: ["git", "rev-parse", "HEAD"],
|
args: ["rev-parse", "HEAD"],
|
||||||
cwd: join(ROOT_PATH, "test_util", "wpt"),
|
cwd: join(ROOT_PATH, "test_util", "wpt"),
|
||||||
stdout: "piped",
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
await proc.status();
|
const revision = (new TextDecoder().decode(proc.stdout)).trim();
|
||||||
const revision = (new TextDecoder().decode(await proc.output())).trim();
|
const proc2 = await Deno.spawn(denoBinary(), {
|
||||||
proc.close();
|
args: ["eval", "console.log(JSON.stringify(Deno.version))"],
|
||||||
const proc2 = Deno.run({
|
|
||||||
cmd: [denoBinary(), "eval", "console.log(JSON.stringify(Deno.version))"],
|
|
||||||
cwd: join(ROOT_PATH, "test_util", "wpt"),
|
cwd: join(ROOT_PATH, "test_util", "wpt"),
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
await proc2.status();
|
const version = JSON.parse(new TextDecoder().decode(proc2.stdout));
|
||||||
const version = JSON.parse(new TextDecoder().decode(await proc2.output()));
|
|
||||||
proc2.close();
|
|
||||||
const runInfo = {
|
const runInfo = {
|
||||||
"os": oses[Deno.build.os],
|
"os": oses[Deno.build.os],
|
||||||
"processor": Deno.build.arch,
|
"processor": Deno.build.arch,
|
||||||
|
|
Loading…
Add table
Reference in a new issue