From 563e3e0fa9eeedac34bd2959261ed907e0dab328 Mon Sep 17 00:00:00 2001 From: hippo91 Date: Mon, 24 Jun 2024 17:26:26 +0200 Subject: [PATCH] Fixes #3140 - Test log unavailable (#3752) * Using \r\n as line ending Seems like \r\n is the line ending characters in the Test Output even on systems different from win32 * Specify the test item in the call to appendOutput Doing so allows to have the output of the test to be printed out in the left part of the "TEST RESULTS" pane when clicking on the desired test in the right part of the same pane. Before this change we get "The test case did not report any output" * Adds location information in the call to appendOutput. The test object may have uri and ranges that can help localization * Adds entry in the CHANGELOG --------- Co-authored-by: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> --- CHANGELOG.md | 1 + src/ctest.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2189f0951..5850769ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Features: Bug Fixes: +- Fix issue "Logs are unavailable when running tests from the Test Explorer" and display properly the test output. [#3140](https://github.com/microsoft/vscode-cmake-tools/issues/3140) - Fix issue with "Test Results Not Found" when `cmake.ctest.allowParallelJobs` is disabled. [#3798](https://github.com/microsoft/vscode-cmake-tools/issues/3798) - Update localized strings for Project Status UI and quick pick dropdowns. [#3803](https://github.com/microsoft/vscode-cmake-tools/issues/3803), [#3802](https://github.com/microsoft/vscode-cmake-tools/issues/3802) - Fix issue where new presets couldn't inherit from presets in CmakeUserPresets.json. These presets are now added to CmakeUserPresets.json instead of CmakePresets.json. [#3725](https://github.com/microsoft/vscode-cmake-tools/issues/3725) diff --git a/src/ctest.ts b/src/ctest.ts index 0d92e013c..109c17ad1 100644 --- a/src/ctest.ts +++ b/src/ctest.ts @@ -532,10 +532,13 @@ export class CTestDriver implements vscode.Disposable { } let output = testResult.output; - if (process.platform === 'win32') { - output = output.replace(/\r?\n/g, '\r\n'); + // https://code.visualstudio.com/api/extension-guides/testing#test-output + output = output.replace(/\r?\n/g, '\r\n'); + if (test.uri && test.range) { + run.appendOutput(output, new vscode.Location(test.uri, test.range.end), test); + } else { + run.appendOutput(output, undefined, test); } - run.appendOutput(output); if (testResult.status !== 'passed' && !havefailures) { const failureDurationStr = testResult.measurements.get("Execution Time")?.value; @@ -997,7 +1000,7 @@ export class CTestDriver implements vscode.Disposable { .find(test => test.name === testName)?.properties .find(prop => prop.name === 'WORKING_DIRECTORY'); - if (typeof(property?.value) === 'string') { + if (typeof (property?.value) === 'string') { return property.value; } return '';