From b797b4dda4ee8c010935402314a55232c3ecd513 Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Sat, 22 Oct 2022 11:40:35 +0700 Subject: [PATCH] fixed issue regarding of unsetting env in debugConfigTemplate --- CHANGELOG.md | 6 ++++++ documents/support.md | 34 ++++++++++++++++++++++++++++------ src/WorkspaceManager.ts | 7 +++---- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a1ec048..7b120a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/documents/support.md b/documents/support.md index 768f6e89..686fd2e6 100644 --- a/documents/support.md +++ b/documents/support.md @@ -12,18 +12,18 @@ Or one can set the `testMate.cpp.log.logfile: ""`. 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: ``. -### 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. @@ -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", @@ -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 +> } +> } +> ``` diff --git a/src/WorkspaceManager.ts b/src/WorkspaceManager.ts index 01ccac8a..3f85c406 100644 --- a/src/WorkspaceManager.ts +++ b/src/WorkspaceManager.ts @@ -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; }); } @@ -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; } } }