Skip to content

Commit

Permalink
- fix to match file casing of source files when discovered by DBH.exe…
Browse files Browse the repository at this point in the history
…, otherwise test Uris don't exactly match open files in VSCode.

- fix for TAEF test filter arguments not being correct when running a subset of selected tests.
  • Loading branch information
dpar39 committed Jan 4, 2024
1 parent f521c87 commit aa06103
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
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.9.2] - 2024-01-04

### Changed

- fix to match file casing of source files when discovered by DBH.exe, otherwise test Uris don't exactly match open files in VSCode.
- fix for TAEF test filter arguments not being correct when running a subset of selected tests.

## [4.9.0] - 2023-12-30

### Changed
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"icon": "resources/icon.png",
"author": "Mate Pek",
"publisher": "dpar39",
"version": "4.9.1",
"version": "4.9.2",
"license": "MIT",
"homepage": "https://github.com/dpar39/vscode-catch2-test-adapter",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/framework/AbstractExecutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ export abstract class AbstractExecutable<TestT extends AbstractTest = AbstractTe
if (typeof file != 'string') return undefined;

// normalize before apply resolvedSourceFileMap because it is normalize too
// this is for better platfrom independent resolution
// this is for better platform independent resolution
let resolved = pathlib.normalize(file);

for (const m in this.shared.resolvedSourceFileMap) {
Expand Down
33 changes: 8 additions & 25 deletions src/framework/Taef/TaefBinaryExecutable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import * as ansi from 'ansi-colors';
import * as fs from 'fs';

import { AbstractExecutable as AbstractExecutable, HandleProcessResult } from '../AbstractExecutable';
import { TaefBinaryTest } from './TaefBinaryTest';
Expand Down Expand Up @@ -37,6 +38,9 @@ export class TaefBinaryExecutable extends AbstractExecutable<TaefBinaryTest> {
typeParam: string | undefined,
valueParam: string | undefined,
): Promise<TaefBinaryTest> => {
if (file) {
file = fs.realpathSync.native(file!);
}
const resolvedFile = this.findSourceFilePath(file);
const [suiteName, testName] = splitFullTestName(ftn);

Expand Down Expand Up @@ -90,29 +94,6 @@ export class TaefBinaryExecutable extends AbstractExecutable<TaefBinaryTest> {
}
}

private async getFileLine(ftn: string): Promise<[string, string?, string?]> {
const binaryPath = this.shared.path;
const dbhExe = this.shared.shared.dbhExecutablePath!;
if (!dbhExe) {
return [ftn, undefined, undefined];
}
let args = [binaryPath, 'name', ftn];
let proc = await this.shared.spawner.spawn(dbhExe, args, this.shared.options);
let [stdout, _] = await pipeOutputStreams2String(proc.stdout, proc.stderr);
const mAddr = stdout.match(/addr :\s{2,}([a-f0-9]+)/m);
if (mAddr) {
args = [binaryPath, 'laddr', mAddr[1]];
proc = await this.shared.spawner.spawn(dbhExe, args, this.shared.options);
[stdout, _] = await pipeOutputStreams2String(proc.stdout, proc.stderr);
const mFile = stdout.match(/file : (.+)/m);
const mLine = stdout.match(/line : (\d+)/m);
if (mFile && mLine) {
return [ftn, mFile[1], (parseInt(mLine[1]) - 1).toString()];
}
}
return [ftn, undefined, undefined];
}

private async getFileLineMapping(fullTestNames: string[]): Promise<Array<[string, string?, string?]>> {
const binaryPath = this.shared.path;
const dbhExe = this.shared.shared.dbhExecutablePath!;
Expand Down Expand Up @@ -144,6 +125,7 @@ export class TaefBinaryExecutable extends AbstractExecutable<TaefBinaryTest> {

const colouring = this.shared.enableDebugColouring ? 'true' : 'false';
execParams.push(`/coloredConsoleOutput:${colouring}`);
execParams.push('/logOutput:Low');

if (childrenToRun.length == this._numTests()) {
return execParams; // entire binary will be run
Expand All @@ -169,7 +151,8 @@ export class TaefBinaryExecutable extends AbstractExecutable<TaefBinaryTest> {
}
}

execParams.push(`/select:` + testFilterNames.join(' OR '));
execParams.push('/select:');
execParams.push(testFilterNames.join(' OR '));
return execParams;
}

Expand Down Expand Up @@ -202,7 +185,7 @@ export class TaefBinaryExecutable extends AbstractExecutable<TaefBinaryTest> {
let test = executable._getTest(ftn);
if (!test) {
log.info('TestCase not found in children', ftn);
const [_, file, line] = await executable.getFileLine(ftn);
const [[_, file, line]] = await executable.getFileLineMapping([ftn]);
test = await executable._createAndAddTest(ftn, file, line, undefined, undefined);
unexpectedTests.push(test);
} else {
Expand Down

0 comments on commit aa06103

Please sign in to comment.