From 244926e83c7d3cae3c3ae3fc14e996e3066da43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 15 Apr 2022 14:24:41 +0200 Subject: feat(test): format user code output (#14271) This commit changes "deno test" to better denote user output coming from test cases. This is done by printing "---- output ----" and "---- output end ----" markers if an output is produced. The output from "console" and "Deno.core.print" is captured, as well as direct writes to "Deno.stdout" and "Deno.stderr". To achieve that new APIs were added to "deno_core" crate, that allow to replace an existing resource with a different one (while keeping resource ids intact). Resources for stdout and stderr are replaced by pipes. Co-authored-by: David Sherret --- runtime/js/40_testing.js | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'runtime') diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index c4321c748..fdd044503 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -871,12 +871,6 @@ }); } - function reportTestConsoleOutput(console) { - core.opSync("op_dispatch_test_event", { - output: { console }, - }); - } - function reportTestWait(test) { core.opSync("op_dispatch_test_event", { wait: test, @@ -955,9 +949,6 @@ core.setMacrotaskCallback(handleOpSanitizerDelayMacrotask); const origin = getTestOrigin(); - const originalConsole = globalThis.console; - - globalThis.console = new Console(reportTestConsoleOutput); const only = ArrayPrototypeFilter(tests, (test) => test.only); const filtered = ArrayPrototypeFilter( @@ -1004,8 +995,6 @@ reportTestResult(description, result, elapsed); } - - globalThis.console = originalConsole; } async function runBenchmarks({ -- cgit v1.2.3