From e6fbfed4c34d307b746f7d358ab51bb5a586a02d Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Thu, 16 May 2024 12:57:40 -0700 Subject: [PATCH] chore(smoke-tests): dont log double stdout/stderr for failing tests --- smoke-tests/test/fixtures/setup.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/smoke-tests/test/fixtures/setup.js b/smoke-tests/test/fixtures/setup.js index e5302104f2503..1147ecdad1dcb 100644 --- a/smoke-tests/test/fixtures/setup.js +++ b/smoke-tests/test/fixtures/setup.js @@ -74,7 +74,8 @@ const getCleanPaths = async () => { } module.exports = async (t, { testdir = {}, debug, mockRegistry = true, useProxy = false } = {}) => { - const debugLog = debug || CI ? (...a) => t.comment(...a) : () => {} + const shouldLog = debug || CI + const debugLog = shouldLog ? (...a) => t.comment(...a) : () => {} debugLog({ SMOKE_PUBLISH_TARBALL, CI }) const cleanPaths = await getCleanPaths() @@ -175,7 +176,17 @@ module.exports = async (t, { testdir = {}, debug, mockRegistry = true, useProxy p.process.stdout.on('data', (c) => log(c.toString().trim())) p.process.stderr.on('data', (c) => log(c.toString().trim())) - const { stdout, stderr } = await p + const { stdout, stderr } = await p.catch(err => { + // If we are already streaming the output from stdout and stderr then + // throwing this error will make a lot more noise since tap will print + // the whole thing. So we only do that if we haven't logged anything. + if (shouldLog) { + delete err.stdout + delete err.stderr + } + throw err + }) + log('='.repeat(40)) return { stderr, stdout }