Skip to content

Commit

Permalink
fixed filename format for buddy
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHaxe committed Jan 17, 2025
1 parent cc73b77 commit 0dbaf25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/HaxeTestController.hx
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class HaxeTestController {
if (isAttributableCoverageEnabled()) {
filteredTestItems = [];
for (item in currentTestItems) {
final lcovFilename = makeFileName(workspaceFolder.uri.path, Path.join([Data.FOLDER, item.id + ".lcov"]));
final lcovFilename = makeFileName(workspaceFolder.uri.path, Path.join([Data.FOLDER, fileNameFormTestId(item.id) + ".lcov"]));

if (FileSystem.exists(lcovFilename)) {
filteredTestItems.push(item);
Expand Down Expand Up @@ -536,11 +536,15 @@ class HaxeTestController {

function loadDetailedCoverageForTest(testRun:TestRun, fileCoverage:FileCoverage, fromTestItem:TestItem,
token:CancellationToken):Thenable<Array<FileCoverageDetail>> {
var regEx = ~/[^a-zA-Z0-9_.-]/g;
final lcovFilename = makeFileName(workspaceFolder.uri.path, Path.join([Data.FOLDER, regEx.replace(fromTestItem.id, "_") + ".lcov"]));
final lcovFilename = makeFileName(workspaceFolder.uri.path, Path.join([Data.FOLDER, fileNameFormTestId(fromTestItem.id) + ".lcov"]));
return reportDetailedCoverage(lcovFilename, fileCoverage.uri.fsPath);
}

function fileNameFormTestId(id:String):String {
var regEx = ~/[^a-zA-Z0-9_.-]/g;
return regEx.replace(id, "_");
}

function reportDetailedCoverage(lcovFileName:String, srcFileName:String):Thenable<Array<FileCoverageDetail>> {
var details:Array<FileCoverageDetail> = [];

Expand Down
2 changes: 2 additions & 0 deletions test-adapter/_testadapter/buddy/Injector.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import haxe.macro.Context; import haxe.macro.Expr; using haxe.macro.ExprTools; u
var suiteId:_testadapter.data.Data.SuiteId = SuiteNameAndPos(testSuite.description, pos.fileName, pos.lineNumber);
adapterReporter.addPosition(suiteId, description, pos.fileName, pos.lineNumber - 1);

// create shallow copies of both before+after arrays
// so we don't mess up the data structures outside of our small patch
beforeEachStack = beforeEachStack.copy();
beforeEachStack.unshift([Sync(_ -> instrument.coverage.Coverage.resetAttributableCoverage())]);
afterEachStack = afterEachStack.copy();
Expand Down
2 changes: 1 addition & 1 deletion test-adapter/_testadapter/data/TestFilter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class TestFilter {
}

public static function hasFilters(testFilters:TestFilterList):Bool {
return (testFilters != null) && ((testFilters.include.length + testFilters.exclude.length > 0));
return (testFilters != null) && ((testFilters.include.length + testFilters.exclude.length) > 0);
}

public static function shouldRunTest(testFilters:TestFilterList, className:String, testName:String):Bool {
Expand Down

0 comments on commit 0dbaf25

Please sign in to comment.