Skip to content

Commit

Permalink
support for multi-environment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matepek committed Apr 5, 2023
1 parent 2e269e4 commit 8090cb7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions documents/configuration/test.advancedExecutables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
]
```
20 changes: 18 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/ConfigOfExecGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export class ConfigOfExecGroup implements vscode.Disposable {
progressReporter.setMax(filePaths.length);
const suiteCreationAndLoadingTasks: Promise<void>[] = [];

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;
Expand Down
3 changes: 2 additions & 1 deletion src/framework/AbstractExecutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ export abstract class AbstractExecutable<TestT extends AbstractTest = AbstractTe
groupByExecutable: async (g: GroupByExecutable): Promise<void> => {
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}';

Expand Down
6 changes: 6 additions & 0 deletions src/framework/SharedVarOfExec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,10 +24,13 @@ export class SharedVarOfExec {
readonly resolvedSourceFileMap: Record<string, string>,
) {
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;
}
Expand Down

0 comments on commit 8090cb7

Please sign in to comment.