mirror of
https://github.com/denoland/deno
synced 2024-08-24 18:47:06 +00:00
chore: 045_proxy output stdout & stderr on failure (#23810)
Part of https://github.com/denoland/deno/issues/23624
This commit is contained in:
parent
c6189e2070
commit
432792a46c
|
@ -234,12 +234,6 @@ itest!(_044_bad_resource {
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(_045_proxy {
|
|
||||||
args: "run -L debug --allow-net --allow-env --allow-run --allow-read --reload --quiet run/045_proxy_test.ts",
|
|
||||||
output: "run/045_proxy_test.ts.out",
|
|
||||||
http_server: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
itest!(_046_tsx {
|
itest!(_046_tsx {
|
||||||
args: "run --quiet --reload run/046_jsx_test.tsx",
|
args: "run --quiet --reload run/046_jsx_test.tsx",
|
||||||
output: "run/046_jsx_test.tsx.out",
|
output: "run/046_jsx_test.tsx.out",
|
||||||
|
|
4
tests/specs/run/045_proxy/__test__.jsonc
Normal file
4
tests/specs/run/045_proxy/__test__.jsonc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"args": "run -L debug --allow-net --allow-env --allow-run --allow-read --reload --quiet proxy_test.ts",
|
||||||
|
"output": "proxy_test.ts.out"
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import { Server } from "../../../tests/util/std/http/server.ts";
|
import { Server } from "../../../util/std/http/server.ts";
|
||||||
import { assertEquals } from "../../../tests/util/std/assert/mod.ts";
|
|
||||||
|
|
||||||
const addr = Deno.args[1] || "localhost:4555";
|
const addr = Deno.args[1] || "localhost:4555";
|
||||||
|
|
||||||
|
@ -30,25 +29,33 @@ async function handler(req: Request): Promise<Response> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assertSuccessOutput(output: Deno.CommandOutput) {
|
||||||
|
if (output.code !== 0) {
|
||||||
|
console.error("STDOUT", new TextDecoder().decode(output.stdout));
|
||||||
|
console.error("STDERR", new TextDecoder().decode(output.stderr));
|
||||||
|
throw new Error(`Expected exit code 0, was ${output.code}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function testFetch() {
|
async function testFetch() {
|
||||||
const { code } = await new Deno.Command(Deno.execPath(), {
|
const output = await new Deno.Command(Deno.execPath(), {
|
||||||
args: [
|
args: [
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--allow-net",
|
"--allow-net",
|
||||||
"run/045_proxy_client.ts",
|
"proxy_client.ts",
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
HTTP_PROXY: `http://${addr}`,
|
HTTP_PROXY: `http://${addr}`,
|
||||||
},
|
},
|
||||||
}).output();
|
}).output();
|
||||||
|
|
||||||
assertEquals(code, 0);
|
assertSuccessOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testModuleDownload() {
|
async function testModuleDownload() {
|
||||||
const { code } = await new Deno.Command(Deno.execPath(), {
|
const output = await new Deno.Command(Deno.execPath(), {
|
||||||
args: [
|
args: [
|
||||||
"cache",
|
"cache",
|
||||||
"--reload",
|
"--reload",
|
||||||
|
@ -60,17 +67,17 @@ async function testModuleDownload() {
|
||||||
},
|
},
|
||||||
}).output();
|
}).output();
|
||||||
|
|
||||||
assertEquals(code, 0);
|
assertSuccessOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetchNoProxy() {
|
async function testFetchNoProxy() {
|
||||||
const { code } = await new Deno.Command(Deno.execPath(), {
|
const output = await new Deno.Command(Deno.execPath(), {
|
||||||
args: [
|
args: [
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--allow-net",
|
"--allow-net",
|
||||||
"run/045_proxy_client.ts",
|
"proxy_client.ts",
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
HTTP_PROXY: "http://not.exising.proxy.server",
|
HTTP_PROXY: "http://not.exising.proxy.server",
|
||||||
|
@ -78,11 +85,11 @@ async function testFetchNoProxy() {
|
||||||
},
|
},
|
||||||
}).output();
|
}).output();
|
||||||
|
|
||||||
assertEquals(code, 0);
|
assertSuccessOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testModuleDownloadNoProxy() {
|
async function testModuleDownloadNoProxy() {
|
||||||
const { code } = await new Deno.Command(Deno.execPath(), {
|
const output = await new Deno.Command(Deno.execPath(), {
|
||||||
args: [
|
args: [
|
||||||
"cache",
|
"cache",
|
||||||
"--reload",
|
"--reload",
|
||||||
|
@ -95,21 +102,22 @@ async function testModuleDownloadNoProxy() {
|
||||||
},
|
},
|
||||||
}).output();
|
}).output();
|
||||||
|
|
||||||
assertEquals(code, 0);
|
assertSuccessOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testFetchProgrammaticProxy() {
|
async function testFetchProgrammaticProxy() {
|
||||||
const { code } = await new Deno.Command(Deno.execPath(), {
|
const output = await new Deno.Command(Deno.execPath(), {
|
||||||
args: [
|
args: [
|
||||||
"run",
|
"run",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
"--reload",
|
"--reload",
|
||||||
"--allow-net=localhost:4545,localhost:4555",
|
"--allow-net=localhost:4545,localhost:4555",
|
||||||
"--unstable",
|
"--unstable",
|
||||||
"run/045_programmatic_proxy_client.ts",
|
"programmatic_proxy_client.ts",
|
||||||
],
|
],
|
||||||
}).output();
|
}).output();
|
||||||
assertEquals(code, 0);
|
|
||||||
|
assertSuccessOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyServer();
|
proxyServer();
|
|
@ -221,7 +221,7 @@ async function ensureNoNewITests() {
|
||||||
"pm_tests.rs": 0,
|
"pm_tests.rs": 0,
|
||||||
"publish_tests.rs": 0,
|
"publish_tests.rs": 0,
|
||||||
"repl_tests.rs": 0,
|
"repl_tests.rs": 0,
|
||||||
"run_tests.rs": 373,
|
"run_tests.rs": 372,
|
||||||
"shared_library_tests.rs": 0,
|
"shared_library_tests.rs": 0,
|
||||||
"task_tests.rs": 30,
|
"task_tests.rs": 30,
|
||||||
"test_tests.rs": 77,
|
"test_tests.rs": 77,
|
||||||
|
|
Loading…
Reference in a new issue