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: tie test output correctly to runs, rework ui accordingly #180746

Merged
merged 2 commits into from Apr 24, 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
5 changes: 4 additions & 1 deletion src/vs/base/common/strings.ts
Expand Up @@ -730,9 +730,12 @@ export function lcut(text: string, n: number) {
// Escape codes, compiled from https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
const CSI_SEQUENCE = /(:?\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~]/g;

// Plus additional markers for custom `\x1b]...\x07` instructions.
const CSI_CUSTOM_SEQUENCE = /\x1b\].*?\x07/g;

export function removeAnsiEscapeCodes(str: string): string {
if (str) {
str = str.replace(CSI_SEQUENCE, '');
str = str.replace(CSI_SEQUENCE, '').replace(CSI_CUSTOM_SEQUENCE, '');
}

return str;
Expand Down
4 changes: 4 additions & 0 deletions src/vs/base/test/common/strings.test.ts
Expand Up @@ -511,6 +511,10 @@ suite('Strings', () => {
`${CSI}48;5;128m`, // 256 indexed color alt
`${CSI}38:2:0:255:255:255m`, // truecolor
`${CSI}38;2;255;255;255m`, // truecolor alt

// Custom sequences:
'\x1b]633;SetMark;\x07',
'\x1b]633;P;Cwd=/foo\x07',
];

for (const sequence of sequences) {
Expand Down
26 changes: 24 additions & 2 deletions src/vs/workbench/contrib/testing/browser/testExplorerActions.ts
Expand Up @@ -838,9 +838,31 @@ export class ShowMostRecentOutputAction extends Action2 {
});
}

public run(accessor: ServicesAccessor) {
public async run(accessor: ServicesAccessor) {
const quickInputService = accessor.get(IQuickInputService);
const terminalOutputService = accessor.get(ITestingOutputTerminalService);
const result = accessor.get(ITestResultService).results[0];
accessor.get(ITestingOutputTerminalService).open(result);

if (!result.tasks.length) {
return;
}

let index = 0;
if (result.tasks.length > 1) {
const picked = await quickInputService.pick(
result.tasks.map((t, i) => ({ label: t.name || localize('testing.pickTaskUnnamed', "Run #{0}", i), index: i })),
{ placeHolder: localize('testing.pickTask', "Pick a run to show output for") }
);

if (!picked) {
return;
}

index = picked.index;
}


terminalOutputService.open(result, index);
}
}

Expand Down