Skip to content

Commit 5721588

Browse files
authored
testing: fix appendOutput not showing up in real time (microsoft#187068)
Fire a test change event when output changes. Previously it only appeared when something else forced decorations to sync. Fixes microsoft#184825
1 parent 75da3d5 commit 5721588

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { flatTestItemDelimiter } from 'vs/workbench/contrib/testing/browser/expl
1212
import { ITestTreeProjection, TestExplorerTreeElement, TestItemTreeElement, TestTreeErrorMessage, getChildrenForParent, testIdentityProvider } from 'vs/workbench/contrib/testing/browser/explorerProjections/index';
1313
import { ISerializedTestTreeCollapseState, isCollapsedInSerializedTestTree } from 'vs/workbench/contrib/testing/browser/explorerProjections/testingViewState';
1414
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
15+
import { TestResultItemChangeReason } from 'vs/workbench/contrib/testing/common/testResult';
1516
import { ITestResultService } from 'vs/workbench/contrib/testing/common/testResultService';
1617
import { ITestService } from 'vs/workbench/contrib/testing/common/testService';
1718
import { ITestItemUpdate, InternalTestItem, TestDiffOpType, TestItemExpandState, TestResultState, TestsDiff, applyTestItemUpdate } from 'vs/workbench/contrib/testing/common/testTypes';
@@ -106,6 +107,10 @@ export class ListProjection extends Disposable implements ITestTreeProjection {
106107

107108
// when test states change, reflect in the tree
108109
this._register(results.onTestChanged(ev => {
110+
if (ev.reason === TestResultItemChangeReason.NewMessage) {
111+
return; // no effect in the tree
112+
}
113+
109114
let result = ev.item;
110115
// if the state is unset, or the latest run is not making the change,
111116
// double check that it's valid. Retire calls might cause previous

src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export class TreeProjection extends Disposable implements ITestTreeProjection {
139139

140140
// when test states change, reflect in the tree
141141
this._register(results.onTestChanged(ev => {
142+
if (ev.reason === TestResultItemChangeReason.NewMessage) {
143+
return; // no effect in the tree
144+
}
145+
142146
let result = ev.item;
143147
// if the state is unset, or the latest run is not making the change,
144148
// double check that it's valid. Retire calls might cause previous

src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,9 @@ class OutputPeekTree extends Disposable {
17021702

17031703
const itemNode = taskNode.itemsCache.get(e.item);
17041704
if (itemNode && this.tree.hasElement(itemNode)) {
1705-
this.tree.setChildren(itemNode, getTestChildren(result, e.item, index), { diffIdentityProvider });
1705+
if (e.reason === TestResultItemChangeReason.NewMessage) {
1706+
this.tree.setChildren(itemNode, getTestChildren(result, e.item, index), { diffIdentityProvider });
1707+
}
17061708
itemNode.changeEmitter.fire();
17071709
return;
17081710
}

src/vs/workbench/contrib/testing/common/testResult.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,13 @@ const itemToNode = (controllerId: string, item: ITestItem, parent: string | null
215215
export const enum TestResultItemChangeReason {
216216
ComputedStateChange,
217217
OwnStateChange,
218+
NewMessage,
218219
}
219220

220221
export type TestResultItemChange = { item: TestResultItem; result: ITestResult } & (
221222
| { reason: TestResultItemChangeReason.ComputedStateChange }
222223
| { reason: TestResultItemChangeReason.OwnStateChange; previousState: TestResultState; previousOwnDuration: number | undefined }
224+
| { reason: TestResultItemChangeReason.NewMessage }
223225
);
224226

225227
/**
@@ -319,8 +321,10 @@ export class LiveTestResult implements ITestResult {
319321
type: TestMessageType.Output,
320322
};
321323

322-
if (testId) {
323-
this.testById.get(testId)?.tasks[index].messages.push(message);
324+
const test = testId && this.testById.get(testId);
325+
if (test) {
326+
test.tasks[index].messages.push(message);
327+
this.changeEmitter.fire({ item: test, result: this, reason: TestResultItemChangeReason.NewMessage });
324328
} else {
325329
task.otherMessages.push(message);
326330
}
@@ -390,13 +394,7 @@ export class LiveTestResult implements ITestResult {
390394
}
391395

392396
entry.tasks[this.mustGetTaskIndex(taskId)].messages.push(message);
393-
this.changeEmitter.fire({
394-
item: entry,
395-
result: this,
396-
reason: TestResultItemChangeReason.OwnStateChange,
397-
previousState: entry.ownComputedState,
398-
previousOwnDuration: entry.ownDuration,
399-
});
397+
this.changeEmitter.fire({ item: entry, result: this, reason: TestResultItemChangeReason.NewMessage });
400398
}
401399

402400
/**

0 commit comments

Comments
 (0)