From 92ba46c384806af171f1ad9c0040146a50531e84 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Mon, 27 Feb 2023 19:39:33 +0900 Subject: chore(ext/node): suppress node compat tests stdout by default (#17909) --- cli/tests/node_compat/test.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/tests/node_compat/test.ts b/cli/tests/node_compat/test.ts index 4029596bd..213a27974 100644 --- a/cli/tests/node_compat/test.ts +++ b/cli/tests/node_compat/test.ts @@ -8,6 +8,7 @@ import { config, getPathsFromTestSuites } from "./common.ts"; // deno test -A cli/tests/node_compat/test.ts -- // Use the test-names as filters const filters = Deno.args; +const hasFilters = filters.length > 0; /** * This script will run the test files specified in the configuration file @@ -78,9 +79,10 @@ for await (const path of testPaths) { }); const { code, stdout, stderr } = await command.output(); - if (stdout.length) console.log(decoder.decode(stdout)); - if (code !== 0) { + // If the test case failed, show the stdout, stderr, and instruction + // for repeating the single test case. + if (stdout.length) console.log(decoder.decode(stdout)); console.log(`Error: "${path}" failed`); console.log( "You can repeat only this test with the command:", @@ -89,6 +91,11 @@ for await (const path of testPaths) { ), ); fail(decoder.decode(stderr)); + } else if (hasFilters) { + // Even if the test case is successful, shows the stdout and stderr + // when test case filtering is specified. + if (stdout.length) console.log(decoder.decode(stdout)); + if (stderr.length) console.log(decoder.decode(stderr)); } }, }); @@ -107,7 +114,7 @@ function checkConfigTestFilesOrder(testFileLists: Array) { } } -if (filters.length === 0) { +if (!hasFilters) { Deno.test("checkConfigTestFilesOrder", function () { checkConfigTestFilesOrder([ ...Object.keys(config.ignore).map((suite) => config.ignore[suite]), -- cgit v1.2.3