Skip to content

Commit

Permalink
advancedExecutable.exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
matepek committed Mar 5, 2024
1 parent 0df2acb commit 1defb07
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
},
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions documents/configuration/test.advancedExecutables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 1 addition & 0 deletions src/AdvancedExecutableInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type AdvancedExecutableConfigArray = Array<AdvancedExecutableConfig>;

export type AdvancedExecutableConfig = {
pattern: ResolvableString;
exclude: string;
name?: ResolvableString;
description?: ResolvableString;
comment?: string;
Expand Down
27 changes: 19 additions & 8 deletions src/ConfigOfExecGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -118,19 +119,29 @@ export class ConfigOfExecGroup implements vscode.Disposable {

let enabledExcludes: string[] = [];
try {
const fileWatcherExclude =
vscode.workspace.getConfiguration('files').get<Record<string, boolean>>('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<Record<string, boolean>>(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,
);
}

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions src/Configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -457,6 +457,7 @@ export class Configurations {
pattern,
undefined,
undefined,
undefined,
defaultCwd,
this.getTerminalIntegratedEnv(),
undefined,
Expand Down Expand Up @@ -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 : {};
Expand Down Expand Up @@ -602,6 +605,7 @@ export class Configurations {
return new ConfigOfExecGroup(
shared,
pattern,
exclude,
name,
description,
cwd,
Expand Down
6 changes: 4 additions & 2 deletions src/WorkspaceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
13 changes: 11 additions & 2 deletions test/cpp/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 1defb07

Please sign in to comment.