diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-05-14 12:47:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 16:47:57 +0000 |
commit | 432792a46c71b402408e1bed0affdb1c3a90d8c6 (patch) | |
tree | 22d5f90349acc8388a28351bd95ddc5f9e952c88 | |
parent | c6189e2070ac31006920e210e616c0d9dd159b7c (diff) |
chore: 045_proxy output stdout & stderr on failure (#23810)
Part of https://github.com/denoland/deno/issues/23624
-rw-r--r-- | tests/integration/run_tests.rs | 6 | ||||
-rw-r--r-- | tests/specs/run/045_proxy/__test__.jsonc | 4 | ||||
-rw-r--r-- | tests/specs/run/045_proxy/programmatic_proxy_client.ts (renamed from tests/testdata/run/045_programmatic_proxy_client.ts) | 0 | ||||
-rw-r--r-- | tests/specs/run/045_proxy/proxy_client.ts (renamed from tests/testdata/run/045_proxy_client.ts) | 0 | ||||
-rw-r--r-- | tests/specs/run/045_proxy/proxy_test.ts (renamed from tests/testdata/run/045_proxy_test.ts) | 38 | ||||
-rw-r--r-- | tests/specs/run/045_proxy/proxy_test.ts.out (renamed from tests/testdata/run/045_proxy_test.ts.out) | 0 | ||||
-rwxr-xr-x | tools/lint.js | 2 |
7 files changed, 28 insertions, 22 deletions
diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 8a24603b3..ed07fab96 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -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", diff --git a/tests/specs/run/045_proxy/__test__.jsonc b/tests/specs/run/045_proxy/__test__.jsonc new file mode 100644 index 000000000..d4fb7f60c --- /dev/null +++ b/tests/specs/run/045_proxy/__test__.jsonc @@ -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" +} diff --git a/tests/testdata/run/045_programmatic_proxy_client.ts b/tests/specs/run/045_proxy/programmatic_proxy_client.ts index 73af590c7..73af590c7 100644 --- a/tests/testdata/run/045_programmatic_proxy_client.ts +++ b/tests/specs/run/045_proxy/programmatic_proxy_client.ts diff --git a/tests/testdata/run/045_proxy_client.ts b/tests/specs/run/045_proxy/proxy_client.ts index 41deae2a5..41deae2a5 100644 --- a/tests/testdata/run/045_proxy_client.ts +++ b/tests/specs/run/045_proxy/proxy_client.ts diff --git a/tests/testdata/run/045_proxy_test.ts b/tests/specs/run/045_proxy/proxy_test.ts index fcb898c77..d3386f0d7 100644 --- a/tests/testdata/run/045_proxy_test.ts +++ b/tests/specs/run/045_proxy/proxy_test.ts @@ -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(); diff --git a/tests/testdata/run/045_proxy_test.ts.out b/tests/specs/run/045_proxy/proxy_test.ts.out index a1e567a14..a1e567a14 100644 --- a/tests/testdata/run/045_proxy_test.ts.out +++ b/tests/specs/run/045_proxy/proxy_test.ts.out diff --git a/tools/lint.js b/tools/lint.js index 0fe96b049..aa3b417cc 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -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, |