From f99f81d077af303c027e1f9d061b101d5974c4ab Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Fri, 29 Mar 2024 12:15:20 +0700 Subject: [PATCH] testGrouping by label --- .vscode/launch.json | 17 + CHANGELOG.md | 6 + .../configuration/test.advancedExecutables.md | 1 + package.json | 355 ++++++++++++++++++ src/ConfigOfExecGroup.ts | 11 + src/Configurations.ts | 3 +- src/TestGroupingInterface.ts | 19 +- src/framework/AbstractExecutable.ts | 15 + test/cpp/.vscode/settings.json | 20 +- 9 files changed, 442 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 436861bd..65762dde 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -46,6 +46,23 @@ "preLaunchTask": "preDebug", "postDebugTask": "postDebug" }, + { + "type": "extensionHost", + "request": "launch", + "name": "tmp", + "runtimeExecutable": "${execPath}", + "args": [ + "/Users/matepek/Downloads/testmate", + "--extensionDevelopmentPath=${workspaceFolder}", + "--disable-extensions" + ], + "env": { + "TESTMATE_DEBUG": "true" + }, + "outFiles": ["${workspaceFolder}/out/**/*.js"], + "preLaunchTask": "preDebug", + "postDebugTask": "postDebug" + }, { "type": "extensionHost", "request": "launch", diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cece843..0800e7df 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.12.0] + +### Added + +- `testGrouping.groupByLabel`. ex.: `"testGrouping": { "groupByLabel": { "label": "Release", "groupByExecutable": {}}}` + ## [4.11.0] - 2024-03-09 ### Changed diff --git a/documents/configuration/test.advancedExecutables.md b/documents/configuration/test.advancedExecutables.md index b49851e2..7ffe481e 100644 --- a/documents/configuration/test.advancedExecutables.md +++ b/documents/configuration/test.advancedExecutables.md @@ -315,6 +315,7 @@ It is undocumented. Contact me by opening an issue or read the code a bit. | Property | Description | | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `groupByLabel` | Groups tests by the given label. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping) | | `groupByExecutable` | Groups tests by the executable file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping) | | `groupBySource` | It sorts the tests by the related source file group. (`${sourceRelPath}`, `${sourceAbsPath}`). [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping) | | `groupByTags` | True to group by every exiting combination of the tags. (`{$tag}`) Or it can be an array of tags: `["[tag1]["tag2"]", "tag2", "tag3"]` [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping) | diff --git a/package.json b/package.json index 8ff14e34..87c1bb2d 100644 --- a/package.json +++ b/package.json @@ -447,6 +447,241 @@ ], "default": false }, + "testGrouping": { + "markdownDescription": "Groups the tests inside the executable. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "additionalProperties": false, + "properties": { + "groupByLabel": { + "markdownDescription": "Groups tests by the given label. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "The label of the test executable. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "A less prominent text after the `label`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + } + } + }, + "groupByExecutable": { + "markdownDescription": "Groups tests by the executable file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "The label of the test executable. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "A less prominent text after the `label`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "mergeByLabel": { + "markdownDescription": "By default the executables are distiguished so they have distinct tree-item, unless we set this option to true.", + "type": "boolean" + }, + "groupByLabel": { + "type": "object" + }, + "groupByExecutable": { + "type": "object" + }, + "groupBySource": { + "type": "object" + }, + "groupByTags": { + "type": "object" + }, + "groupByTagRegex": { + "type": "object" + }, + "groupByRegex": { + "type": "object" + } + } + }, + "groupBySource": { + "markdownDescription": "Groups the tests by the source file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "Label of the group. Can be indexed. (`${sourceRelPath}`, `${sourceAbsPath}`). [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "Less prominent text next to label. Can be indexed. (`${sourceRelPath}`, `${sourceAbsPath}`). [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "groupUngroupedTo": { + "markdownDescription": "Ungroupable elements will be grouped under the given value. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string", + "minLength": 1 + }, + "groupByLabel": { + "type": "object" + }, + "groupByExecutable": { + "type": "object" + }, + "groupBySource": { + "type": "object" + }, + "groupByTags": { + "type": "object" + }, + "groupByTagRegex": { + "type": "object" + }, + "groupByRegex": { + "type": "object" + } + } + }, + "groupByTags": { + "markdownDescription": "Group test by tags. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "tags": { + "markdownDescription": "True to group by every exiting combination of the tags. Or it can be an array of tags: `[\"[tag1][tag2]\", \"tag2\", \"tag3\"]` [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + } + }, + "tagFormat": { + "type": "string", + "pattern": "\\$\\{tag\\}" + }, + "groupUngroupedTo": { + "markdownDescription": "Ungroupable elements will be grouped under the given value. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string", + "minLength": 1 + }, + "groupByLabel": { + "type": "object" + }, + "groupByExecutable": { + "type": "object" + }, + "groupBySource": { + "type": "object" + }, + "groupByTags": { + "type": "object" + }, + "groupByTagRegex": { + "type": "object" + }, + "groupByRegex": { + "type": "object" + } + } + }, + "groupByTagRegex": { + "markdownDescription": "Groups tests by the first match group of the first matching regex. (`${match}`, `${match_lowercased}`, `${match_upperfirst}`) Example: `[\"(?:good|bad) (apple|peach)\"]` will create 2 groups and put the matched tests inside it. Hint: Grouping starting with \"?:\" won't count as a match group. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "type": "string" + }, + "description": { + "type": "string" + }, + "regexes": { + "markdownDescription": "Groups by the first match group (enclosed by parentheses like this). of the first matching [regex](https://regex101.com/). Example: `[\"(?:good|bad) (apple|peach)\"]` will create 2 groups and put the matched tests inside it. Hint: Grouping starting with \"?:\" won't count as a match group. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "groupUngroupedTo": { + "markdownDescription": "Ungroupable elements will be grouped under the given value. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string", + "minLength": 1 + }, + "groupByLabel": { + "type": "object" + }, + "groupByExecutable": { + "type": "object" + }, + "groupBySource": { + "type": "object" + }, + "groupByTags": { + "type": "object" + }, + "groupByTagRegex": { + "type": "object" + }, + "groupByRegex": { + "type": "object" + } + }, + "required": [ + "regexes" + ] + }, + "groupByRegex": { + "markdownDescription": "Groups tests by the first match group of the first matching regex. (`${match}`, `${match_lowercased}`, `${match_upperfirst}`) Example: `[\"(?:good|bad) (apple|peach)\"]` will create 2 groups and put the matched tests inside it. Hint: Grouping starting with \"?:\" won't count as a match group. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "type": "string" + }, + "description": { + "type": "string" + }, + "regexes": { + "markdownDescription": "Groups by the first match group (enclosed by parentheses like this). of the first matching [regex](https://regex101.com/). Example: `[\"(?:good|bad) (apple|peach)\"]` will create 2 groups and put the matched tests inside it. Hint: Grouping starting with \"?:\" won't count as a match group. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "groupUngroupedTo": { + "markdownDescription": "Ungroupable elements will be grouped under the given value. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string", + "minLength": 1 + }, + "groupByLabel": { + "type": "object" + }, + "groupByExecutable": { + "type": "object" + }, + "groupBySource": { + "type": "object" + }, + "groupByTags": { + "type": "object" + }, + "groupByTagRegex": { + "type": "object" + }, + "groupByRegex": { + "type": "object" + } + }, + "required": [ + "regexes" + ] + } + } + }, "darwin": { "markdownDescription": "Overrides the parent's properties on the given OS.", "type": "object", @@ -502,6 +737,21 @@ "markdownDescription": "Groups the tests inside the executable. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "additionalProperties": false, "properties": { + "groupByLabel": { + "markdownDescription": "Groups tests by the given label. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "The label of the test executable. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "A less prominent text after the `label`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + } + } + }, "groupByExecutable": { "markdownDescription": "Groups tests by the executable file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "type": "object", @@ -519,6 +769,9 @@ "markdownDescription": "By default the executables are distiguished so they have distinct tree-item, unless we set this option to true.", "type": "boolean" }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -554,6 +807,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -596,6 +852,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -637,6 +896,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -681,6 +943,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -745,6 +1010,21 @@ "markdownDescription": "Groups the tests inside the executable. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "additionalProperties": false, "properties": { + "groupByLabel": { + "markdownDescription": "Groups tests by the given label. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "The label of the test executable. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "A less prominent text after the `label`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + } + } + }, "groupByExecutable": { "markdownDescription": "Groups tests by the executable file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "type": "object", @@ -762,6 +1042,9 @@ "markdownDescription": "By default the executables are distiguished so they have distinct tree-item, unless we set this option to true.", "type": "boolean" }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -797,6 +1080,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -839,6 +1125,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -880,6 +1169,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -924,6 +1216,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -988,6 +1283,21 @@ "markdownDescription": "Groups the tests inside the executable. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "additionalProperties": false, "properties": { + "groupByLabel": { + "markdownDescription": "Groups tests by the given label. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "The label of the test executable. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "A less prominent text after the `label`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + } + } + }, "groupByExecutable": { "markdownDescription": "Groups tests by the executable file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "type": "object", @@ -1005,6 +1315,9 @@ "markdownDescription": "By default the executables are distiguished so they have distinct tree-item, unless we set this option to true.", "type": "boolean" }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1040,6 +1353,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1082,6 +1398,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1123,6 +1442,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1167,6 +1489,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1231,6 +1556,21 @@ "markdownDescription": "Groups the tests inside the executable. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "additionalProperties": false, "properties": { + "groupByLabel": { + "markdownDescription": "Groups tests by the given label. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "object", + "additionalProperties": false, + "properties": { + "label": { + "markdownDescription": "The label of the test executable. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + }, + "description": { + "markdownDescription": "A less prominent text after the `label`. Can contains variables related to `pattern`. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", + "type": "string" + } + } + }, "groupByExecutable": { "markdownDescription": "Groups tests by the executable file. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#testgrouping)", "type": "object", @@ -1248,6 +1588,9 @@ "markdownDescription": "By default the executables are distiguished so they have distinct tree-item, unless we set this option to true.", "type": "boolean" }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1283,6 +1626,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1325,6 +1671,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1366,6 +1715,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, @@ -1410,6 +1762,9 @@ "type": "string", "minLength": 1 }, + "groupByLabel": { + "type": "object" + }, "groupByExecutable": { "type": "object" }, diff --git a/src/ConfigOfExecGroup.ts b/src/ConfigOfExecGroup.ts index 13bcf36e..a7878bab 100644 --- a/src/ConfigOfExecGroup.ts +++ b/src/ConfigOfExecGroup.ts @@ -157,6 +157,17 @@ export class ConfigOfExecGroup implements vscode.Disposable { filePaths = await execWatcher.watched(); + // TODO: we could figure out that it is a symlink and add extra + // filePaths.forEach(f => { + // try { + // if (fs.readlinkSync(f)) { + // console.log(`sym ${f}`); + // } + // } catch (e) { + // console.log(`not sym ${f}`); + // } + // }); + execWatcher.onError((err: Error) => { // eslint-disable-next-line if ((err as any).code == 'ENOENT') this._shared.log.info('watcher error', err); diff --git a/src/Configurations.ts b/src/Configurations.ts index 2b015cc8..2531e766 100644 --- a/src/Configurations.ts +++ b/src/Configurations.ts @@ -652,9 +652,9 @@ export class Configurations { obj?: FrameworkSpecificConfig, ): FrameworkSpecificConfig { const r: FrameworkSpecificConfig = {}; + r.testGrouping = defaultTestGrouping; if (typeof obj === 'object') { if (obj.testGrouping) r.testGrouping = obj.testGrouping; - else r.testGrouping = defaultTestGrouping; if (typeof obj.helpRegex === 'string') r.helpRegex = obj['helpRegex']; @@ -672,7 +672,6 @@ export class Configurations { if (typeof obj.failIfExceedsLimitNs === 'number') r.failIfExceedsLimitNs = obj.failIfExceedsLimitNs; } - return r; } diff --git a/src/TestGroupingInterface.ts b/src/TestGroupingInterface.ts index 9dd0dd65..f79700b4 100644 --- a/src/TestGroupingInterface.ts +++ b/src/TestGroupingInterface.ts @@ -1,3 +1,8 @@ +export interface GroupByLabel extends TestGroupingConfig { + label?: string; + description?: string; +} + export interface GroupByExecutable extends TestGroupingConfig { label?: string; description?: string; @@ -34,6 +39,7 @@ export type GroupByRegex = GroupByTagRegex; /// export type TestGroupingType = + | 'groupByLabel' | 'groupByExecutable' | 'groupBySource' | 'groupByTags' @@ -41,6 +47,8 @@ export type TestGroupingType = | 'groupByRegex'; export interface TestGroupingConfig extends Partial> { + groupByLabel?: GroupByLabel; + groupByExecutable?: GroupByExecutable; groupBySource?: GroupBySource; @@ -58,7 +66,10 @@ export function* testGroupIterator( testGrouping: TestGroupingConfig, ): IterableIterator<[TestGroupingType, TestGroupingConfig]> { while (testGrouping) { - if (testGrouping.groupByExecutable) { + if (testGrouping.groupByLabel) { + testGrouping = testGrouping.groupByLabel; + yield ['groupByLabel', testGrouping]; + } else if (testGrouping.groupByExecutable) { testGrouping = testGrouping.groupByExecutable; yield ['groupByExecutable', testGrouping]; } else if (testGrouping.groupBySource) { @@ -82,6 +93,7 @@ export function* testGroupIterator( export async function testGroupingForEach( testGrouping: TestGroupingConfig, callbacks: { + groupByLabel: (g: GroupByLabel) => Promise; groupByExecutable: (g: GroupByExecutable) => Promise; groupBySource: (g: GroupBySource) => Promise; groupByTags: (g: GroupByTags) => Promise; @@ -90,7 +102,10 @@ export async function testGroupingForEach( }, ): Promise { while (testGrouping) { - if (testGrouping.groupByExecutable) { + if (testGrouping.groupByLabel) { + testGrouping = testGrouping.groupByLabel; + await callbacks.groupByLabel(testGrouping); + } else if (testGrouping.groupByExecutable) { testGrouping = testGrouping.groupByExecutable; await callbacks.groupByExecutable(testGrouping); } else if (testGrouping.groupBySource) { diff --git a/src/framework/AbstractExecutable.ts b/src/framework/AbstractExecutable.ts index ff26473c..cf2c0e7d 100644 --- a/src/framework/AbstractExecutable.ts +++ b/src/framework/AbstractExecutable.ts @@ -23,6 +23,7 @@ import { testGroupingForEach, GroupBySource, GroupByTags, + GroupByLabel, } from '../TestGroupingInterface'; import { isSpawnBusyError } from '../util/FSWrapper'; import { TestResultBuilder } from '../TestResultBuilder'; @@ -286,6 +287,20 @@ export abstract class AbstractExecutable => { + const label = g.label ?? '${filename}'; + const id = label; + const description = g.description ?? '${relDirpath}${osPathSep}'; + itemOfLevel = await this._resolveAndGetOrCreateChildGroup( + itemOfLevel, + id, + label, + description, + varsToResolve, + undefined, + undefined, + ); + }, groupByExecutable: async (g: GroupByExecutable): Promise => { this._updateVarsWithTags(g, tags, tagsResolveRule); diff --git a/test/cpp/.vscode/settings.json b/test/cpp/.vscode/settings.json index 53ba47ac..32550aa2 100644 --- a/test/cpp/.vscode/settings.json +++ b/test/cpp/.vscode/settings.json @@ -2,9 +2,27 @@ "cmake.configureOnOpen": true, "testMate.cpp.test.advancedExecutables": [ { - "pattern":"build/**/*{test,Test,TEST}*", + "pattern":"build/**/*gtest*", "runTask": { // "before": ["build_all"] + }, + "testGrouping": { + "groupByLabel": { + "label": "alma", + "groupByExecutable": {} + }, + } + }, + { + "pattern":"build/**/*suite*", + "runTask": { + // "before": ["build_all"] + }, + "testGrouping": { + "groupByLabel": { + "label": "korte", + "groupByExecutable": {} + }, } } ],