Skip to content

Commit

Permalink
Dispatch test-single failed events
Browse files Browse the repository at this point in the history
  • Loading branch information
petrovic-d committed Dec 5, 2024
1 parent bb12df4 commit 7b1f6b1
Showing 1 changed file with 46 additions and 14 deletions.
60 changes: 46 additions & 14 deletions java/java.lsp.server/vscode/src/testAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,56 +97,88 @@ export class NbTestAdapter {
}
// TBD - message
else {
this.itemsToRun.forEach(item => this.set(item, 'failed', new TestMessage('Build failure')));
this.itemsToRun.forEach(item => this.set(item, 'failed', new TestMessage('Build failure'), false, true));
}
this.itemsToRun = undefined;
this.currentRun.end();
this.currentRun = undefined;
}
}

set(item: TestItem, state: SuiteState, message?: TestMessage | readonly TestMessage[], noPassDown? : boolean): void {
set(item: TestItem, state: SuiteState, message?: TestMessage | readonly TestMessage[], noPassDown? : boolean, dispatchBuildFailEvent?: boolean): void {
if (this.currentRun) {
switch (state) {
case 'enqueued':
this.dispatchTestSuiteEvent(state, item);
this.dispatchTestEvent(state, item);
this.itemsToRun?.add(item);
this.currentRun.enqueued(item);
break;
case 'skipped':
this.dispatchTestSuiteEvent(state, item);
this.dispatchTestEvent(state, item);
case 'started':
case 'passed':
this.itemsToRun?.delete(item);
this.currentRun[state](item);
break;
case 'failed':
case 'errored':
if (dispatchBuildFailEvent) {
this.dispatchTestEvent(state, item);
}
this.itemsToRun?.delete(item);
this.currentRun[state](item, message || new TestMessage(""));
break;
}
this.suiteStates.set(item, state);
if (!noPassDown) {
item.children.forEach(child => this.set(child, state, message, noPassDown));
item.children.forEach(child => this.set(child, state, message, noPassDown, dispatchBuildFailEvent));
}
}
}

dispatchTestSuiteEvent(state: SuiteState, testItem: TestItem): void {
dispatchTestEvent(state: SuiteState, testItem: TestItem): void {
if (testItem.parent && testItem.children.size > 0) {
const testProgressListeners = listeners.get(TEST_PROGRESS_EVENT);
testProgressListeners?.forEach(listener => {
commands.executeCommand(listener, {
name: testItem.id,
moduleName: testItem.parent?.id,
modulePath: testItem.parent?.uri?.path,
this.dispatchEvent({
name: testItem.id,
moduleName: testItem.parent?.id,
modulePath: testItem.parent?.uri?.path,
state,
});
} else if (testItem.children.size === 0) {
const testSuite = testItem.parent;
if (testSuite) {
const testSuiteEvent: any = {
name: testSuite.id,
moduleName: testSuite.parent?.id,
modulePath: testSuite.parent?.uri?.path,
state,
});
})
tests: []
}
testSuite?.children.forEach(suite => {
if (suite.id === testItem.id) {
const idx = suite.id.indexOf(':');
if (idx >= 0) {
const name = suite.id.slice(idx + 1);
testSuiteEvent.tests?.push({
id: suite.id,
name,
state
})
}
}
})
this.dispatchEvent(testSuiteEvent);
}
}
}

dispatchEvent(event: any): void {
const testProgressListeners = listeners.get(TEST_PROGRESS_EVENT);
testProgressListeners?.forEach(listener => {
commands.executeCommand(listener, event);
})
}

cancel(): void {
debug.stopDebugging();
}
Expand Down

0 comments on commit 7b1f6b1

Please sign in to comment.