Skip to content

Commit

Permalink
Fixes #3140 - Test log unavailable (#3752)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
hippo91 and gcampbell-msft authored Jun 24, 2024
1 parent b986245 commit 563e3e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions src/ctest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 '';
Expand Down

0 comments on commit 563e3e0

Please sign in to comment.