Skip to content

Commit

Permalink
add try catch and attempt to grab specifically the json (#3868)
Browse files Browse the repository at this point in the history
* add try catch and attempt to grab specifically the json

* fix lint errors

---------

Co-authored-by: Fatima Qarni <fatimaqarni@microsoft.com>
  • Loading branch information
gcampbell-msft and qarni authored Jul 10, 2024
1 parent 7117d53 commit 1525857
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# What's New?

## 1.19.0
## 1.19

Bug Fixes:

- Fix issue where `cmake.preferredGenerators` wasn't falling back to the next entry when the first entry didn't exist [#2709](https://github.com/microsoft/vscode-cmake-tools/issues/2709)
- Potential fix for attempting to load a non-variants file as a variants file and throwing a parse exception [#3727](https://github.com/microsoft/vscode-cmake-tools/issues/3727)
- Fix edge case where parsing tests fails when additional output is printed before tests json. [#3750](https://github.com/microsoft/vscode-cmake-tools/issues/3750)
- Fix issue where `Configure with CMake Debugger` fails on restart because the previously used pipe to CMake Debugger is no longer available. [#3582](https://github.com/microsoft/vscode-cmake-tools/issues/3582)

## 1.18.43
Expand Down
8 changes: 7 additions & 1 deletion src/ctest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,13 @@ export class CTestDriver implements vscode.Disposable {
log.error(localize('ctest.error', 'There was an error running ctest to determine available test executables'));
return result.retc || -3;
}
this.tests = JSON.parse(result.stdout) ?? undefined;

try {
this.tests = JSON.parse(result.stdout.slice(result.stdout.indexOf("{"))) ?? undefined;
} catch {
this.tests = undefined;
}

if (this.tests && this.tests.kind === 'ctestInfo') {
this.tests.tests.forEach(test => {
let testDefFile: string | undefined;
Expand Down

0 comments on commit 1525857

Please sign in to comment.