Skip to content

Commit 1defb07

Browse files
committed
advancedExecutable.exclude
1 parent 0df2acb commit 1defb07

9 files changed

+72
-16
lines changed

.vscode/launch.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"request": "launch",
3939
"name": "Manual cpp",
4040
"runtimeExecutable": "${execPath}",
41-
"args": ["${workspaceFolder}/out/cpp", "--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"],
41+
"args": ["${workspaceFolder}/test/cpp", "--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"],
4242
"env": {
4343
"TESTMATE_DEBUG": "true"
4444
},
@@ -51,7 +51,7 @@
5151
"request": "launch",
5252
"name": "Manual cpp + extensions",
5353
"runtimeExecutable": "${execPath}",
54-
"args": ["${workspaceFolder}/out/cpp", "--extensionDevelopmentPath=${workspaceFolder}"],
54+
"args": ["${workspaceFolder}/test/cpp", "--extensionDevelopmentPath=${workspaceFolder}"],
5555
"env": {
5656
"TESTMATE_DEBUG": "true"
5757
},

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [Unreleased]
88

9+
## [4.10.0]
10+
11+
### Added/Changed/Removed
12+
13+
- `files.watcherExclude` is not applied by default anymore: reverts `v4.8.0`.
14+
- `testMate.test.advancedExecutables` -> `exclude`: Here one can specify a vscode setting to be applied for exclusion.
15+
916
## [4.9.0] - 2024-02-21
1017

1118
### Added

documents/configuration/test.advancedExecutables.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ If it is an object it can contains the following properties:
4848
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
4949
| `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) |
5050
| `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) |
51+
| `exclude` | Setting path like `files.watcherExclude` to use for test lookup. |
5152
| `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) |
5253
| `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) |
5354
| `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) |

package.json

+21
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,27 @@
156156
}
157157
]
158158
},
159+
"exclude": {
160+
"markdownDescription": "Setting path like `files.watcherExclude` to use for test lookup.",
161+
"default": null,
162+
"anyOf": [
163+
{
164+
"type": "string",
165+
"enum": [
166+
"files.watcherExclude",
167+
"files.exclude",
168+
"search.exclude"
169+
]
170+
},
171+
{
172+
"type": "string",
173+
"minLength": 1
174+
},
175+
{
176+
"type": "null"
177+
}
178+
]
179+
},
159180
"name": {
160181
"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)",
161182
"anyOf": [

src/AdvancedExecutableInterface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type AdvancedExecutableConfigArray = Array<AdvancedExecutableConfig>;
77

88
export type AdvancedExecutableConfig = {
99
pattern: ResolvableString;
10+
exclude: string;
1011
name?: ResolvableString;
1112
description?: ResolvableString;
1213
comment?: string;

src/ConfigOfExecGroup.ts

+19-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class ConfigOfExecGroup implements vscode.Disposable {
3131
constructor(
3232
private readonly _shared: WorkspaceShared,
3333
private readonly _pattern: string,
34+
private readonly _exclude: string | undefined,
3435
private readonly _name: string | undefined,
3536
private readonly _description: string | undefined,
3637
private readonly _cwd: string,
@@ -118,19 +119,29 @@ export class ConfigOfExecGroup implements vscode.Disposable {
118119

119120
let enabledExcludes: string[] = [];
120121
try {
121-
const fileWatcherExclude =
122-
vscode.workspace.getConfiguration('files').get<Record<string, boolean>>('watcherExclude') ?? {};
123-
enabledExcludes = Object.entries(fileWatcherExclude)
124-
.filter(i => i[1])
125-
.map(i => i[0]);
122+
if (this._exclude === null || this._exclude === undefined) {
123+
// skip
124+
} else if (typeof this._exclude === 'string') {
125+
const excludeObj = vscode.workspace.getConfiguration().get<Record<string, boolean>>(this._exclude);
126+
if (typeof excludeObj === 'object') {
127+
enabledExcludes = Object.entries(excludeObj)
128+
.filter(i => i[1])
129+
.map(i => i[0]);
130+
} else if (excludeObj !== undefined && excludeObj !== null) {
131+
this._shared.log.error('Unknown exclude format, should be {}');
132+
}
133+
} else {
134+
this._shared.log.error('Unknown exclude type');
135+
}
126136
} catch (err) {
127137
this._shared.log.error('Something wrong with exclusion', err);
128138
}
129139

130140
if (enabledExcludes.length > 0) {
131141
this._shared.log.info(
132-
'Test executables might be ignored! Excluding some patterns because they are set in vscode under `files.watcherExclude`.',
142+
'Test executables might be ignored! Excluding some patterns because they are set in vscode',
133143
enabledExcludes,
144+
this._exclude,
134145
);
135146
}
136147

@@ -574,11 +585,11 @@ export class ConfigOfExecGroup implements vscode.Disposable {
574585
}
575586

576587
private _shouldIgnorePath(filePath: string): boolean {
577-
if (!this._pattern.match(/(\/|\\)_deps(\/|\\)/) && filePath.indexOf('/_deps/') !== -1) {
588+
if (!this._pattern.match(/(\/|\\)_deps(\/|\\)/) && filePath.match(/(\/|\\)_deps(\/|\\)/)) {
578589
// cmake fetches the dependencies here. we dont care about it 🤞
579590
this._shared.log.info('skipping because it is under "/_deps/"', filePath);
580591
return true;
581-
} else if (!this._pattern.match(/(\/|\\)CMakeFiles(\/|\\)/) && filePath.indexOf('/CMakeFiles/') !== -1) {
592+
} else if (!this._pattern.match(/(\/|\\)CMakeFiles(\/|\\)/) && filePath.match(/(\/|\\)CMakeFiles(\/|\\)/)) {
582593
// cmake fetches the dependencies here. we dont care about it 🤞
583594
this._shared.log.info('skipping because it is under "/CMakeFiles/"', filePath);
584595
return true;

src/Configurations.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class ConfigurationChangeEvent {
6464
affectsAny(...config: Config[]): boolean {
6565
return config.some(c => this.affects(c));
6666
}
67-
affectsNotTestMate(config: string): boolean {
68-
return this.event.affectsConfiguration(config, this.config._workspaceFolderUri);
67+
affectsNotTestMate(...config: string[]): boolean {
68+
return config.some(c => this.event.affectsConfiguration(c, this.config._workspaceFolderUri));
6969
}
7070
}
7171

@@ -457,6 +457,7 @@ export class Configurations {
457457
pattern,
458458
undefined,
459459
undefined,
460+
undefined,
460461
defaultCwd,
461462
this.getTerminalIntegratedEnv(),
462463
undefined,
@@ -543,6 +544,8 @@ export class Configurations {
543544
}
544545
}
545546

547+
const exclude: string | null | undefined = obj.exclude;
548+
546549
const cwd: string = typeof obj.cwd === 'string' ? obj.cwd : defaultCwd;
547550

548551
const env: { [prop: string]: string } = typeof obj.env === 'object' ? obj.env : {};
@@ -602,6 +605,7 @@ export class Configurations {
602605
return new ConfigOfExecGroup(
603606
shared,
604607
pattern,
608+
exclude,
605609
name,
606610
description,
607611
cwd,

src/WorkspaceManager.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,13 @@ export class WorkspaceManager implements vscode.Disposable {
204204
'test.executables',
205205
'test.parallelExecutionOfExecutableLimit',
206206
'discovery.strictPattern',
207-
) ||
208-
changeEvent.affectsNotTestMate('files.watcherExclude')
207+
)
209208
) {
210209
this.init(true);
211210
}
211+
if (changeEvent.affectsNotTestMate('files.watcherExclude', 'files.exclude', 'search.exclude')) {
212+
this.init(true);
213+
}
212214
} catch (e) {
213215
this._shared.log.exceptionS(e);
214216
}

test/cpp/.vscode/settings.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
"testMate.cpp.test.advancedExecutables": [
44
{
55
"pattern":"build/**/*{test,Test,TEST}*",
6+
"exclude": "files.watcherExcludee",
67
"runTask": {
7-
"before": ["build_all"]
8+
// "before": ["build_all"]
89
}
910
}
10-
]
11+
],
12+
"files.exclude": {
13+
"**/sub/**": false,
14+
"**/excude/**": true
15+
},
16+
"files.watcherExclude": {
17+
"**/sub/**": true,
18+
"**/watcherExclude/**": true
19+
}
1120
}

0 commit comments

Comments
 (0)