From 1defb073fed5961d32149d935f04b30876653db5 Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Tue, 5 Mar 2024 19:14:35 +0700 Subject: [PATCH] advancedExecutable.exclude --- .vscode/launch.json | 4 +-- CHANGELOG.md | 7 +++++ .../configuration/test.advancedExecutables.md | 1 + package.json | 21 +++++++++++++++ src/AdvancedExecutableInterface.ts | 1 + src/ConfigOfExecGroup.ts | 27 +++++++++++++------ src/Configurations.ts | 8 ++++-- src/WorkspaceManager.ts | 6 +++-- test/cpp/.vscode/settings.json | 13 +++++++-- 9 files changed, 72 insertions(+), 16 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7defe9bf..436861bd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -38,7 +38,7 @@ "request": "launch", "name": "Manual cpp", "runtimeExecutable": "${execPath}", - "args": ["${workspaceFolder}/out/cpp", "--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"], + "args": ["${workspaceFolder}/test/cpp", "--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"], "env": { "TESTMATE_DEBUG": "true" }, @@ -51,7 +51,7 @@ "request": "launch", "name": "Manual cpp + extensions", "runtimeExecutable": "${execPath}", - "args": ["${workspaceFolder}/out/cpp", "--extensionDevelopmentPath=${workspaceFolder}"], + "args": ["${workspaceFolder}/test/cpp", "--extensionDevelopmentPath=${workspaceFolder}"], "env": { "TESTMATE_DEBUG": "true" }, diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c4e602a..bca5b159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +## [4.10.0] + +### Added/Changed/Removed + +- `files.watcherExclude` is not applied by default anymore: reverts `v4.8.0`. +- `testMate.test.advancedExecutables` -> `exclude`: Here one can specify a vscode setting to be applied for exclusion. + ## [4.9.0] - 2024-02-21 ### Added diff --git a/documents/configuration/test.advancedExecutables.md b/documents/configuration/test.advancedExecutables.md index 82f29ed3..b49851e2 100644 --- a/documents/configuration/test.advancedExecutables.md +++ b/documents/configuration/test.advancedExecutables.md @@ -48,6 +48,7 @@ If it is an object it can contains the following properties: | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `name` | The name of the test suite (file). Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md) | | `pattern` | A relative (to workspace directory) or an absolute path or [_glob pattern_](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options). ⚠️**Avoid backslash!**: NO `\\`; (required) [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md) | +| `exclude` | Setting path like `files.watcherExclude` to use for test lookup. | | `description` | A less prominent text after the `name`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md) | | `cwd` | The current working directory for the test executable. If it isn't provided and `test.workingDirectory` does then that will be used. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md) | | `env` | Environment variables for the test executable. Can contains variables related to `pattern` and variables related to the process's environment variables (Ex.: `${os_env:PATH}`). [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md) | diff --git a/package.json b/package.json index 437e89e3..3f464df3 100644 --- a/package.json +++ b/package.json @@ -156,6 +156,27 @@ } ] }, + "exclude": { + "markdownDescription": "Setting path like `files.watcherExclude` to use for test lookup.", + "default": null, + "anyOf": [ + { + "type": "string", + "enum": [ + "files.watcherExclude", + "files.exclude", + "search.exclude" + ] + }, + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, "name": { "markdownDescription": "The name of the test suite (file). Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md)", "anyOf": [ diff --git a/src/AdvancedExecutableInterface.ts b/src/AdvancedExecutableInterface.ts index c54f1060..bdf27f3a 100644 --- a/src/AdvancedExecutableInterface.ts +++ b/src/AdvancedExecutableInterface.ts @@ -7,6 +7,7 @@ export type AdvancedExecutableConfigArray = Array; export type AdvancedExecutableConfig = { pattern: ResolvableString; + exclude: string; name?: ResolvableString; description?: ResolvableString; comment?: string; diff --git a/src/ConfigOfExecGroup.ts b/src/ConfigOfExecGroup.ts index 169d11a5..13bcf36e 100644 --- a/src/ConfigOfExecGroup.ts +++ b/src/ConfigOfExecGroup.ts @@ -31,6 +31,7 @@ export class ConfigOfExecGroup implements vscode.Disposable { constructor( private readonly _shared: WorkspaceShared, private readonly _pattern: string, + private readonly _exclude: string | undefined, private readonly _name: string | undefined, private readonly _description: string | undefined, private readonly _cwd: string, @@ -118,19 +119,29 @@ export class ConfigOfExecGroup implements vscode.Disposable { let enabledExcludes: string[] = []; try { - const fileWatcherExclude = - vscode.workspace.getConfiguration('files').get>('watcherExclude') ?? {}; - enabledExcludes = Object.entries(fileWatcherExclude) - .filter(i => i[1]) - .map(i => i[0]); + if (this._exclude === null || this._exclude === undefined) { + // skip + } else if (typeof this._exclude === 'string') { + const excludeObj = vscode.workspace.getConfiguration().get>(this._exclude); + if (typeof excludeObj === 'object') { + enabledExcludes = Object.entries(excludeObj) + .filter(i => i[1]) + .map(i => i[0]); + } else if (excludeObj !== undefined && excludeObj !== null) { + this._shared.log.error('Unknown exclude format, should be {}'); + } + } else { + this._shared.log.error('Unknown exclude type'); + } } catch (err) { this._shared.log.error('Something wrong with exclusion', err); } if (enabledExcludes.length > 0) { this._shared.log.info( - 'Test executables might be ignored! Excluding some patterns because they are set in vscode under `files.watcherExclude`.', + 'Test executables might be ignored! Excluding some patterns because they are set in vscode', enabledExcludes, + this._exclude, ); } @@ -574,11 +585,11 @@ export class ConfigOfExecGroup implements vscode.Disposable { } private _shouldIgnorePath(filePath: string): boolean { - if (!this._pattern.match(/(\/|\\)_deps(\/|\\)/) && filePath.indexOf('/_deps/') !== -1) { + if (!this._pattern.match(/(\/|\\)_deps(\/|\\)/) && filePath.match(/(\/|\\)_deps(\/|\\)/)) { // cmake fetches the dependencies here. we dont care about it 🤞 this._shared.log.info('skipping because it is under "/_deps/"', filePath); return true; - } else if (!this._pattern.match(/(\/|\\)CMakeFiles(\/|\\)/) && filePath.indexOf('/CMakeFiles/') !== -1) { + } else if (!this._pattern.match(/(\/|\\)CMakeFiles(\/|\\)/) && filePath.match(/(\/|\\)CMakeFiles(\/|\\)/)) { // cmake fetches the dependencies here. we dont care about it 🤞 this._shared.log.info('skipping because it is under "/CMakeFiles/"', filePath); return true; diff --git a/src/Configurations.ts b/src/Configurations.ts index 0d70496e..2b015cc8 100644 --- a/src/Configurations.ts +++ b/src/Configurations.ts @@ -64,8 +64,8 @@ class ConfigurationChangeEvent { affectsAny(...config: Config[]): boolean { return config.some(c => this.affects(c)); } - affectsNotTestMate(config: string): boolean { - return this.event.affectsConfiguration(config, this.config._workspaceFolderUri); + affectsNotTestMate(...config: string[]): boolean { + return config.some(c => this.event.affectsConfiguration(c, this.config._workspaceFolderUri)); } } @@ -457,6 +457,7 @@ export class Configurations { pattern, undefined, undefined, + undefined, defaultCwd, this.getTerminalIntegratedEnv(), undefined, @@ -543,6 +544,8 @@ export class Configurations { } } + const exclude: string | null | undefined = obj.exclude; + const cwd: string = typeof obj.cwd === 'string' ? obj.cwd : defaultCwd; const env: { [prop: string]: string } = typeof obj.env === 'object' ? obj.env : {}; @@ -602,6 +605,7 @@ export class Configurations { return new ConfigOfExecGroup( shared, pattern, + exclude, name, description, cwd, diff --git a/src/WorkspaceManager.ts b/src/WorkspaceManager.ts index b483773c..534b6f39 100644 --- a/src/WorkspaceManager.ts +++ b/src/WorkspaceManager.ts @@ -204,11 +204,13 @@ export class WorkspaceManager implements vscode.Disposable { 'test.executables', 'test.parallelExecutionOfExecutableLimit', 'discovery.strictPattern', - ) || - changeEvent.affectsNotTestMate('files.watcherExclude') + ) ) { this.init(true); } + if (changeEvent.affectsNotTestMate('files.watcherExclude', 'files.exclude', 'search.exclude')) { + this.init(true); + } } catch (e) { this._shared.log.exceptionS(e); } diff --git a/test/cpp/.vscode/settings.json b/test/cpp/.vscode/settings.json index 714f744f..1b73bdd8 100644 --- a/test/cpp/.vscode/settings.json +++ b/test/cpp/.vscode/settings.json @@ -3,9 +3,18 @@ "testMate.cpp.test.advancedExecutables": [ { "pattern":"build/**/*{test,Test,TEST}*", + "exclude": "files.watcherExcludee", "runTask": { - "before": ["build_all"] + // "before": ["build_all"] } } - ] + ], + "files.exclude": { + "**/sub/**": false, + "**/excude/**": true + }, + "files.watcherExclude": { + "**/sub/**": true, + "**/watcherExclude/**": true + } } \ No newline at end of file