diff --git a/cli/tests/node_compat/test.ts b/cli/tests/node_compat/test.ts index 4029596bde..213a279743 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]),