chore: 045_proxy output stdout & stderr on failure (#23810)

Part of https://github.com/denoland/deno/issues/23624
This commit is contained in:
David Sherret 2024-05-14 12:47:57 -04:00 committed by GitHub
parent c6189e2070
commit 432792a46c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 28 additions and 22 deletions

View file

@ -234,12 +234,6 @@ itest!(_044_bad_resource {
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 {
args: "run --quiet --reload run/046_jsx_test.tsx",
output: "run/046_jsx_test.tsx.out",

View 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"
}

View file

@ -1,6 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { Server } from "../../../tests/util/std/http/server.ts";
import { assertEquals } from "../../../tests/util/std/assert/mod.ts";
import { Server } from "../../../util/std/http/server.ts";
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() {
const { code } = await new Deno.Command(Deno.execPath(), {
const output = await new Deno.Command(Deno.execPath(), {
args: [
"run",
"--quiet",
"--reload",
"--allow-net",
"run/045_proxy_client.ts",
"proxy_client.ts",
],
env: {
HTTP_PROXY: `http://${addr}`,
},
}).output();
assertEquals(code, 0);
assertSuccessOutput(output);
}
async function testModuleDownload() {
const { code } = await new Deno.Command(Deno.execPath(), {
const output = await new Deno.Command(Deno.execPath(), {
args: [
"cache",
"--reload",
@ -60,17 +67,17 @@ async function testModuleDownload() {
},
}).output();
assertEquals(code, 0);
assertSuccessOutput(output);
}
async function testFetchNoProxy() {
const { code } = await new Deno.Command(Deno.execPath(), {
const output = await new Deno.Command(Deno.execPath(), {
args: [
"run",
"--quiet",
"--reload",
"--allow-net",
"run/045_proxy_client.ts",
"proxy_client.ts",
],
env: {
HTTP_PROXY: "http://not.exising.proxy.server",
@ -78,11 +85,11 @@ async function testFetchNoProxy() {
},
}).output();
assertEquals(code, 0);
assertSuccessOutput(output);
}
async function testModuleDownloadNoProxy() {
const { code } = await new Deno.Command(Deno.execPath(), {
const output = await new Deno.Command(Deno.execPath(), {
args: [
"cache",
"--reload",
@ -95,21 +102,22 @@ async function testModuleDownloadNoProxy() {
},
}).output();
assertEquals(code, 0);
assertSuccessOutput(output);
}
async function testFetchProgrammaticProxy() {
const { code } = await new Deno.Command(Deno.execPath(), {
const output = await new Deno.Command(Deno.execPath(), {
args: [
"run",
"--quiet",
"--reload",
"--allow-net=localhost:4545,localhost:4555",
"--unstable",
"run/045_programmatic_proxy_client.ts",
"programmatic_proxy_client.ts",
],
}).output();
assertEquals(code, 0);
assertSuccessOutput(output);
}
proxyServer();

View file

@ -221,7 +221,7 @@ async function ensureNoNewITests() {
"pm_tests.rs": 0,
"publish_tests.rs": 0,
"repl_tests.rs": 0,
"run_tests.rs": 373,
"run_tests.rs": 372,
"shared_library_tests.rs": 0,
"task_tests.rs": 30,
"test_tests.rs": 77,