Skip to content

Commit c2fad81

Browse files
author
tomaszrup
committed
refactor: update imports to use node: prefix and improve code structure
- Changed imports from 'fs' and 'path' to 'node:fs' and 'node:path' across multiple files. - Refactored BuildToolService to use a BatchCommandOptions interface for better argument handling. - Enhanced error handling and logging in various methods. - Simplified regex handling for XML parsing and control character stripping. - Updated test files to reflect changes in BuildToolService and ConfigurationService. - Adjusted TypeScript configuration to target ES2021. - Updated vitest configuration to use 'node:url' for consistency.
1 parent 303ddb1 commit c2fad81

11 files changed

Lines changed: 752 additions & 519 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "spock-test-runner-vscode-tr",
33
"displayName": "Spock Test Runner & Debugger",
44
"description": "Run, debug, and measure code coverage of Spock Framework (Groovy) tests using Gradle or Maven, with native VS Code Test Explorer integration",
5-
"version": "0.1.5",
5+
"version": "0.1.6",
66
"copyright": "Copyright 2025 Lukas Zaruba, Copyright 2026 Tomasz Rup",
77
"publisher": "TomaszRup",
88
"author": "Tomasz Rup",

src/TestRunCoordinator.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ describe('TestRunCoordinator', () => {
445445
{ test: test2, data: { type: 'test' as const, className: 'Spec', testName: 'test two' } },
446446
];
447447

448-
await coordinator.runBatch('/workspace/project', tests, run as any, false, createCancellationToken());
448+
await coordinator.runBatch('/workspace/project', { uri: vscode.Uri.file('/workspace'), name: 'workspace', index: 0 }, tests, run as any, false, createCancellationToken());
449449

450450
expect(run.started).toHaveBeenCalledWith(test1);
451451
expect(run.started).toHaveBeenCalledWith(test2);
@@ -459,7 +459,7 @@ describe('TestRunCoordinator', () => {
459459
{ test: test1, data: { type: 'test' as const } }, // no className/testName
460460
];
461461

462-
await coordinator.runBatch('/workspace/project', tests, run as any, false, createCancellationToken());
462+
await coordinator.runBatch('/workspace/project', { uri: vscode.Uri.file('/workspace'), name: 'workspace', index: 0 }, tests, run as any, false, createCancellationToken());
463463

464464
expect(run.skipped).toHaveBeenCalledWith(test1);
465465
});
@@ -472,7 +472,7 @@ describe('TestRunCoordinator', () => {
472472
{ test: test1, data: { type: 'test' as const, className: 'Spec', testName: 'data test', isDataDriven: true } },
473473
];
474474

475-
await coordinator.runBatch('/workspace/project', tests, run as any, false, createCancellationToken());
475+
await coordinator.runBatch('/workspace/project', { uri: vscode.Uri.file('/workspace'), name: 'workspace', index: 0 }, tests, run as any, false, createCancellationToken());
476476

477477
expect(resultProcessor.handleDataDrivenTestResults).toHaveBeenCalled();
478478
});
@@ -490,7 +490,15 @@ describe('TestRunCoordinator', () => {
490490
]);
491491
coverageService.parseJacocoReport.mockResolvedValue([{ uri: vscode.Uri.file('/Spec.groovy') }]);
492492

493-
await coordinator.runBatch('/workspace/project', tests, run as any, false, createCancellationToken(), true);
493+
await coordinator.runBatch(
494+
'/workspace/project',
495+
{ uri: vscode.Uri.file('/workspace'), name: 'workspace', index: 0 },
496+
tests,
497+
run as any,
498+
false,
499+
createCancellationToken(),
500+
{ coverage: true },
501+
);
494502

495503
expect(coverageService.findAllJacocoXmlReports).toHaveBeenCalled();
496504
expect(run.addCoverage).toHaveBeenCalled();
@@ -517,7 +525,7 @@ describe('TestRunCoordinator', () => {
517525
return args;
518526
});
519527

520-
await coordinator.runBatch('/workspace/project', tests, run as any, false, createCancellationToken());
528+
await coordinator.runBatch('/workspace/project', { uri: vscode.Uri.file('/workspace'), name: 'workspace', index: 0 }, tests, run as any, false, createCancellationToken());
521529

522530
// Should have called executeBatch (at least once — exact count depends on platform limits)
523531
expect(executionService.executeBatch).toHaveBeenCalled();
@@ -540,7 +548,7 @@ describe('TestRunCoordinator', () => {
540548
{ test: test2, data: { type: 'test' as const, className: 'MySpec', testName: 'test two' } },
541549
];
542550

543-
await coordinator.runBatch('/workspace/project', tests, run as any, false, createCancellationToken());
551+
await coordinator.runBatch('/workspace/project', { uri: vscode.Uri.file('/workspace'), name: 'workspace', index: 0 }, tests, run as any, false, createCancellationToken());
544552

545553
// buildBatchCommandArgs should have been called with classTestCounts as the last arg
546554
const calls = buildToolService.buildBatchCommandArgs.mock.calls;
@@ -914,7 +922,7 @@ describe('TestRunCoordinator', () => {
914922
output: [
915923
'> Task :compileTestGroovy FAILED',
916924
'> Compilation failed; see the compiler error output for details.',
917-
'C:\\work\\src\\test\\groovy\\Spec.groovy: 12: unable to resolve class MissingType',
925+
String.raw`C:\work\src\test\groovy\Spec.groovy: 12: unable to resolve class MissingType`,
918926
'BUILD FAILED',
919927
].join('\n'),
920928
});

0 commit comments

Comments
 (0)