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: testRun.appendOutput formatting is the same as test failure formatting. #200888

Merged
merged 1 commit into from
Dec 14, 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
43 changes: 23 additions & 20 deletions src/vs/workbench/contrib/testing/browser/testingDecorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,26 +366,29 @@ export class TestingDecorationService extends Disposable implements ITestingDeco
for (const test of lastResult.tests) {
for (let taskId = 0; taskId < test.tasks.length; taskId++) {
const state = test.tasks[taskId];
for (let i = 0; i < state.messages.length; i++) {
const m = state.messages[i];
if (this.invalidatedMessages.has(m) || m.location?.uri.toString() !== uriStr) {
continue;
}

// Only add one message per line number. Overlapping messages
// don't appear well, and the peek will show all of them (#134129)
const line = m.location.range.startLineNumber;
if (!messageLines.has(line)) {
const decoration = lastDecorations.getMessage(m) || this.instantiationService.createInstance(TestMessageDecoration, m, buildTestUri({
type: TestUriType.ResultActualOutput,
messageIndex: i,
taskIndex: taskId,
resultId: lastResult.id,
testExtId: test.item.extId,
}), model);

newDecorations.addMessage(decoration);
messageLines.add(line);
// push error decorations first so they take precedence over normal output
for (const kind of [TestMessageType.Error, TestMessageType.Output]) {
for (let i = 0; i < state.messages.length; i++) {
const m = state.messages[i];
if (m.type !== kind || this.invalidatedMessages.has(m) || m.location?.uri.toString() !== uriStr) {
continue;
}

// Only add one message per line number. Overlapping messages
// don't appear well, and the peek will show all of them (#134129)
const line = m.location.range.startLineNumber;
if (!messageLines.has(line)) {
const decoration = lastDecorations.getMessage(m) || this.instantiationService.createInstance(TestMessageDecoration, m, buildTestUri({
type: TestUriType.ResultActualOutput,
messageIndex: i,
taskIndex: taskId,
resultId: lastResult.id,
testExtId: test.item.extId,
}), model);

newDecorations.addMessage(decoration);
messageLines.add(line);
}
}
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilitie
import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings';
import { editorBackground } from 'vs/platform/theme/common/colorRegistry';
import { widgetClose } from 'vs/platform/theme/common/iconRegistry';
import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IViewPaneOptions, ViewPane } from 'vs/workbench/browser/parts/views/viewPane';
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
Expand All @@ -85,7 +85,7 @@ import { getXtermScaledDimensions } from 'vs/workbench/contrib/terminal/browser/
import { TERMINAL_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { getTestItemContextOverlay } from 'vs/workbench/contrib/testing/browser/explorerProjections/testItemContextOverlay';
import * as icons from 'vs/workbench/contrib/testing/browser/icons';
import { testingPeekBorder, testingPeekHeaderBackground } from 'vs/workbench/contrib/testing/browser/theme';
import { testingMessagePeekBorder, testingPeekBorder, testingPeekHeaderBackground, testingPeekMessageHeaderBackground } from 'vs/workbench/contrib/testing/browser/theme';
import { AutoOpenPeekViewWhen, TestingConfigKeys, getTestingConfiguration } from 'vs/workbench/contrib/testing/common/configuration';
import { Testing } from 'vs/workbench/contrib/testing/common/constants';
import { IObservableValue, MutableObservableValue, staticObservableValue } from 'vs/workbench/contrib/testing/common/observableValue';
Expand Down Expand Up @@ -941,7 +941,7 @@ class TestResultsPeek extends PeekViewWidget {

constructor(
editor: ICodeEditor,
@IThemeService themeService: IThemeService,
@IThemeService private readonly themeService: IThemeService,
@IPeekViewService peekViewService: IPeekViewService,
@ITestingPeekOpener private readonly testingPeek: ITestingPeekOpener,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
Expand All @@ -953,13 +953,14 @@ class TestResultsPeek extends PeekViewWidget {

this._disposables.add(themeService.onDidColorThemeChange(this.applyTheme, this));
this._disposables.add(this.onDidClose(() => this.visibilityChange.fire(false)));
this.applyTheme(themeService.getColorTheme());
peekViewService.addExclusiveWidget(editor, this);
}

private applyTheme(theme: IColorTheme) {
const borderColor = theme.getColor(testingPeekBorder) || Color.transparent;
const headerBg = theme.getColor(testingPeekHeaderBackground) || Color.transparent;
private applyTheme() {
const theme = this.themeService.getColorTheme();
const isError = this.current instanceof MessageSubject && this.current.message.type === TestMessageType.Error;
const borderColor = (isError ? theme.getColor(testingPeekBorder) : theme.getColor(testingMessagePeekBorder)) || Color.transparent;
const headerBg = (isError ? theme.getColor(testingPeekHeaderBackground) : theme.getColor(testingPeekMessageHeaderBackground)) || Color.transparent;
const editorBg = theme.getColor(editorBackground);
this.style({
arrowColor: borderColor,
Expand Down Expand Up @@ -1038,6 +1039,7 @@ class TestResultsPeek extends PeekViewWidget {
} else {
this.setTitle(localize('testOutputTitle', 'Test Output'));
}
this.applyTheme();
await this.content.reveal({ subject: subject, preserveFocus: false });
}

Expand Down
16 changes: 15 additions & 1 deletion src/vs/workbench/contrib/testing/browser/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Color, RGBA } from 'vs/base/common/color';
import { localize } from 'vs/nls';
import { contrastBorder, editorErrorForeground, editorForeground, registerColor, transparent } from 'vs/platform/theme/common/colorRegistry';
import { contrastBorder, editorErrorForeground, editorForeground, editorInfoForeground, registerColor, transparent } from 'vs/platform/theme/common/colorRegistry';
import { TestMessageType, TestResultState } from 'vs/workbench/contrib/testing/common/testTypes';

export const testingColorIconFailed = registerColor('testing.iconFailed', {
Expand Down Expand Up @@ -64,13 +64,27 @@ export const testingPeekBorder = registerColor('testing.peekBorder', {
hcLight: contrastBorder
}, localize('testing.peekBorder', 'Color of the peek view borders and arrow.'));

export const testingMessagePeekBorder = registerColor('testing.messagePeekBorder', {
dark: editorInfoForeground,
light: editorInfoForeground,
hcDark: contrastBorder,
hcLight: contrastBorder
}, localize('testing.messagePeekBorder', 'Color of the peek view borders and arrow when peeking a logged message.'));

export const testingPeekHeaderBackground = registerColor('testing.peekHeaderBackground', {
dark: transparent(editorErrorForeground, 0.1),
light: transparent(editorErrorForeground, 0.1),
hcDark: null,
hcLight: null
}, localize('testing.peekBorder', 'Color of the peek view borders and arrow.'));

export const testingPeekMessageHeaderBackground = registerColor('testing.messagePeekHeaderBackground', {
dark: transparent(editorInfoForeground, 0.1),
light: transparent(editorInfoForeground, 0.1),
hcDark: null,
hcLight: null
}, localize('testing.messagePeekHeaderBackground', 'Color of the peek view borders and arrow when peeking a logged message.'));

export const testMessageSeverityColors: {
[K in TestMessageType]: {
decorationForeground: string;
Expand Down