diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c894799..c043a523 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.4.1] + +### Added + +- support 'multi-environment' tests [feature](https://github.com/matepek/vscode-catch2-test-adapter/issues/379) + ## [4.4.0] - 2023-03-31 ### Added diff --git a/documents/configuration/test.advancedExecutables.md b/documents/configuration/test.advancedExecutables.md index ed1accb9..17cadc0c 100644 --- a/documents/configuration/test.advancedExecutables.md +++ b/documents/configuration/test.advancedExecutables.md @@ -444,3 +444,20 @@ This is useful if stderr/std::cerr is missing: } ] ``` + +## running the same executable with different env values + +```json +"testMate.cpp.test.advancedExecutables": [ + { + "name": "${filename} [APPLE=1]", + "pattern": "{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*", + "env":{ "APPLE": "1" } + }, + { + "name": "${filename} [APPLE=2]", + "pattern": "{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*", + "env":{ "APPLE": "2" } + } +] +``` diff --git a/package-lock.json b/package-lock.json index 36426950..09d23ee7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-catch2-test-adapter", - "version": "4.3.12", + "version": "4.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-catch2-test-adapter", - "version": "4.3.12", + "version": "4.4.0", "license": "MIT", "dependencies": { "@types/htmlparser2": "^3.10.3", @@ -41,6 +41,7 @@ "glob": "^8.1.0", "mocha": "^10.2.0", "mocha-eslint": "^7.0.0", + "object-hash": "^3.0.0", "prettier": "^2.8.6", "raw-loader": "^4.0.2", "sinon": "^15.0.2", @@ -4810,6 +4811,15 @@ "url": "https://github.com/fb55/nth-check?sponsor=1" } }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/object-inspect": { "version": "1.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", @@ -10575,6 +10585,12 @@ "boolbase": "^1.0.0" } }, + "object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true + }, "object-inspect": { "version": "1.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", diff --git a/package.json b/package.json index 8ac608cc..656349a6 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "glob": "^8.1.0", "mocha": "^10.2.0", "mocha-eslint": "^7.0.0", + "object-hash": "^3.0.0", "prettier": "^2.8.6", "raw-loader": "^4.0.2", "sinon": "^15.0.2", diff --git a/src/ConfigOfExecGroup.ts b/src/ConfigOfExecGroup.ts index fe1e444b..986b860a 100644 --- a/src/ConfigOfExecGroup.ts +++ b/src/ConfigOfExecGroup.ts @@ -102,8 +102,7 @@ export class ConfigOfExecGroup implements vscode.Disposable { progressReporter.setMax(filePaths.length); const suiteCreationAndLoadingTasks: Promise[] = []; - for (let i = 0; i < filePaths.length; i++) { - const file = filePaths[i]; + for (const file of filePaths) { this._shared.log.debug('Checking file for tests:', file); if (this._shouldIgnorePath(file)) continue; diff --git a/src/framework/AbstractExecutable.ts b/src/framework/AbstractExecutable.ts index e40690ac..861216db 100644 --- a/src/framework/AbstractExecutable.ts +++ b/src/framework/AbstractExecutable.ts @@ -277,7 +277,8 @@ export abstract class AbstractExecutable => { this._updateVarsWithTags(g, tags, tagsResolveRule); - const id = g.mergeByLabel === true ? undefined : this.shared.path; + const optionHash = this.shared.optionsHash; + const id = g.mergeByLabel === true ? undefined : this.shared.path + `#${optionHash}`; const label = g.label ?? '${filename}'; const description = g.description ?? '${relDirpath}${osPathSep}'; diff --git a/src/framework/SharedVarOfExec.ts b/src/framework/SharedVarOfExec.ts index 974a9f27..976ead36 100644 --- a/src/framework/SharedVarOfExec.ts +++ b/src/framework/SharedVarOfExec.ts @@ -5,6 +5,9 @@ import { TaskPool } from '../util/TaskPool'; import { Spawner, SpawnOptionsWithoutStdio } from '../Spawner'; import { WorkspaceShared } from '../WorkspaceShared'; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const hash = require('object-hash'); + export class SharedVarOfExec { constructor( readonly shared: WorkspaceShared, @@ -21,10 +24,13 @@ export class SharedVarOfExec { readonly resolvedSourceFileMap: Record, ) { this.parallelizationPool = new TaskPool(_parallelizationLimit); + this.optionsHash = hash.MD5(options).substring(0, 6); } readonly parallelizationPool: TaskPool; + readonly optionsHash: string; + get testGrouping(): TestGroupingConfig | undefined { return this._frameworkSpecific.testGrouping; }