Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: fix appendOutput not showing up in real time #187068

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { flatTestItemDelimiter } from 'vs/workbench/contrib/testing/browser/expl
import { ITestTreeProjection, TestExplorerTreeElement, TestItemTreeElement, TestTreeErrorMessage, getChildrenForParent, testIdentityProvider } from 'vs/workbench/contrib/testing/browser/explorerProjections/index';
import { ISerializedTestTreeCollapseState, isCollapsedInSerializedTestTree } from 'vs/workbench/contrib/testing/browser/explorerProjections/testingViewState';
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
import { TestResultItemChangeReason } from 'vs/workbench/contrib/testing/common/testResult';
import { ITestResultService } from 'vs/workbench/contrib/testing/common/testResultService';
import { ITestService } from 'vs/workbench/contrib/testing/common/testService';
import { ITestItemUpdate, InternalTestItem, TestDiffOpType, TestItemExpandState, TestResultState, TestsDiff, applyTestItemUpdate } from 'vs/workbench/contrib/testing/common/testTypes';
Expand Down Expand Up @@ -106,6 +107,10 @@ export class ListProjection extends Disposable implements ITestTreeProjection {

// when test states change, reflect in the tree
this._register(results.onTestChanged(ev => {
if (ev.reason === TestResultItemChangeReason.NewMessage) {
return; // no effect in the tree
}

let result = ev.item;
// if the state is unset, or the latest run is not making the change,
// double check that it's valid. Retire calls might cause previous
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export class TreeProjection extends Disposable implements ITestTreeProjection {

// when test states change, reflect in the tree
this._register(results.onTestChanged(ev => {
if (ev.reason === TestResultItemChangeReason.NewMessage) {
return; // no effect in the tree
}

let result = ev.item;
// if the state is unset, or the latest run is not making the change,
// double check that it's valid. Retire calls might cause previous
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,9 @@ class OutputPeekTree extends Disposable {

const itemNode = taskNode.itemsCache.get(e.item);
if (itemNode && this.tree.hasElement(itemNode)) {
this.tree.setChildren(itemNode, getTestChildren(result, e.item, index), { diffIdentityProvider });
if (e.reason === TestResultItemChangeReason.NewMessage) {
this.tree.setChildren(itemNode, getTestChildren(result, e.item, index), { diffIdentityProvider });
}
itemNode.changeEmitter.fire();
return;
}
Expand Down
16 changes: 7 additions & 9 deletions src/vs/workbench/contrib/testing/common/testResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ const itemToNode = (controllerId: string, item: ITestItem, parent: string | null
export const enum TestResultItemChangeReason {
ComputedStateChange,
OwnStateChange,
NewMessage,
}

export type TestResultItemChange = { item: TestResultItem; result: ITestResult } & (
| { reason: TestResultItemChangeReason.ComputedStateChange }
| { reason: TestResultItemChangeReason.OwnStateChange; previousState: TestResultState; previousOwnDuration: number | undefined }
| { reason: TestResultItemChangeReason.NewMessage }
);

/**
Expand Down Expand Up @@ -319,8 +321,10 @@ export class LiveTestResult implements ITestResult {
type: TestMessageType.Output,
};

if (testId) {
this.testById.get(testId)?.tasks[index].messages.push(message);
const test = testId && this.testById.get(testId);
if (test) {
test.tasks[index].messages.push(message);
this.changeEmitter.fire({ item: test, result: this, reason: TestResultItemChangeReason.NewMessage });
} else {
task.otherMessages.push(message);
}
Expand Down Expand Up @@ -390,13 +394,7 @@ export class LiveTestResult implements ITestResult {
}

entry.tasks[this.mustGetTaskIndex(taskId)].messages.push(message);
this.changeEmitter.fire({
item: entry,
result: this,
reason: TestResultItemChangeReason.OwnStateChange,
previousState: entry.ownComputedState,
previousOwnDuration: entry.ownDuration,
});
this.changeEmitter.fire({ item: entry, result: this, reason: TestResultItemChangeReason.NewMessage });
}

/**
Expand Down