Skip to content

Commit

Permalink
fixed issue regarding of unsetting env in debugConfigTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
matepek committed Oct 22, 2022
1 parent 991bf7d commit b797b4d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [4.3.2]

### Fixed

- an issue which prevented to unset variables using `null` value in `"testMate.cpp.debug.setEnv"`

## [4.3.1] - 2022-10-15

### Added
Expand Down
34 changes: 28 additions & 6 deletions documents/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ Or one can set the `testMate.cpp.log.logfile: "<full path>"`. In this case a log

## Known issues

### for all:
### for all

- (2018-09-03) On windows the navigate to source button isn't working. It is a framework bug.

### for Catch2:
### for Catch2

- (2018-11-17) Catch2: Long (>80 character) filename, test-name or description can cause test-list parsing failures.
Workaround: `#define CATCH_CONFIG_CONSOLE_WIDTH 300` and it has to be defined before every `#include "catch.hpp"` lines.
- (2020-04-19) Catch2 version < 2.11.4 have a parameter parsing problem issue which makes some test name restrictions. The extension will notify if you are affected.
- (2020-12-05) Catch2 test result parsing can fail if the test outputs unescaped "xml-like" text: `<Pin:10>`.

### for doctest:
### for doctest

- (2019-12-27) doctest 2.3.6 is support file and line informations. Previous version will recognise the tests but navigation will be disabled.
- (2021-10-22) doctest does not provide the skipped information at test listing phase so this extension does not mark the tests skipped.
Expand Down Expand Up @@ -88,7 +88,7 @@ If you want dynamically set enviranment variables generate a file which contains

> You can try this:
>
> ```
> ```json
> "testMate.cpp.test.advancedExecutables": [
> {
> "pattern": "build/**/test*.exe",
Expand Down Expand Up @@ -149,12 +149,34 @@ If you want dynamically set enviranment variables generate a file which contains
> ]
> ```
### Test parsing fails because my executable writes some stuff to the error channel / `std::cerr`.
### Test parsing fails because my executable writes some stuff to the error channel / `std::cerr`
> Check `test.advancedExecutables` -> [ignoreTestEnumerationStdErr](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#ignoreTestEnumerationStdErr)
### The extension doesn't notice if an executable has changed.
### The extension doesn't notice if an executable has changed
> By default the extension watches the workspaceFolder for changes by using the `vscode.workspace.createFileSystemWatcher` API endpoint.
> This is good because we are using the same resources but the `files.watcherExclude` setting affects this.
> So for example one would like to save some resources and adds `**/build/**` to `files.watcherExclude` then vscode won't notify the extension about the changes and this will limit the functionality of the extension.
### I have environment variable with _new line_ character which causes debugging issue
> Add your own `"testMate.cpp.debug.configTemplate"` variable where you can unset the problematic environment variables with `null`. Example:
>
> ```json
> "testMate.cpp.debug.configTemplate": {
> "type": "cppvsdbg",
> "linux": " type: 'cppdbg', MIMode: 'gdb' ",
> "darwin": " type: 'cppdbg', MIMode: 'lldb' ",
> "windows": " type: 'cppvsdbg' ",
> "program": "${exec}",
> "args": "${argsArray}",
> "cwd": "${cwd}",
> "env": "${envObj}",
> "environment": "${envObjArray}",
> "sourceFileMap": "${sourceFileMapObj}",
> "testMate.cpp.debug.setEnv": {
> "ENV_WITH_NEWLINE": null
> }
> }
> ```
7 changes: 3 additions & 4 deletions src/WorkspaceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ export class WorkspaceManager implements vscode.Disposable {

return this._debugInner(test, cancellation, run).catch(e => {
this.log.errorS('error during debug', e);
debugger;
});
}

Expand Down Expand Up @@ -467,14 +466,14 @@ export class WorkspaceManager implements vscode.Disposable {
if (typeof debugConfigData.template[setEnvKey] === 'object') {
for (const envName in debugConfigData.template[setEnvKey]) {
const envValue = debugConfigData.template[setEnvKey][envName];
if (typeof envValue !== 'string')
if (envValue === null) delete envVars[envName];
else if (typeof envValue === 'string') envVars[envName] = envValue;
else
this._shared.log.warn(
'Wrong value. testMate.cpp.debug.setEnv should contains only string values',
envName,
setEnvKey,
);
else if (envValue === null) delete envVars[envName];
else envVars[envName] = envValue;
}
}
}
Expand Down

0 comments on commit b797b4d

Please sign in to comment.