From 893b29bbfed41a0baf711df2651ed6d1fe544483 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Wed, 25 Mar 2020 22:55:40 -0700 Subject: [PATCH] Expand file paths only when test fails #1836 --- src/testUtils.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/testUtils.ts b/src/testUtils.ts index 533e4619d..40bb3578e 100644 --- a/src/testUtils.ts +++ b/src/testUtils.ts @@ -328,18 +328,19 @@ export async function goTest(testconfig: TestConfig): Promise { const testResultLines: string[] = []; const processTestResultLine = (line: string) => { - if (!testconfig.includeSubDirectories) { - outputChannel.appendLine(expandFilePathInOutput(line, testconfig.dir)); - return; - } testResultLines.push(line); const result = line.match(packageResultLineRE); if (result && (pkgMap.has(result[2]) || currentGoWorkspace)) { + const hasTestFailed = line.startsWith('FAIL'); const packageNameArr = result[2].split('/'); const baseDir = pkgMap.get(result[2]) || path.join(currentGoWorkspace, ...packageNameArr); - testResultLines.forEach((testResultLine) => - outputChannel.appendLine(expandFilePathInOutput(testResultLine, baseDir)) - ); + testResultLines.forEach((testResultLine) => { + if (hasTestFailed) { + outputChannel.appendLine(expandFilePathInOutput(testResultLine, baseDir)); + } else { + outputChannel.appendLine(testResultLine); + } + }); testResultLines.splice(0); } };