Skip to content

Commit

Permalink
testing: tie test output correctly to runs, rework ui accordingly
Browse files Browse the repository at this point in the history
Previously, test output was handled for an entire TestRunRequest into
a single stream. This didn't match what the public API implied, nor what
the real intentions were.

This makes output be stored correctly on a per-test run (called "tasks"
internally). It changes the order of the Test Results view so that tests
nested under their task, and also improves some of the tree handling
there to update nodes more specifically.

Clicking on the "terminal" button in the test view continues to show
output from the last test run request, but if there were multiple tasks,
the user is asked to choose which they want to view output for.

Finally I removed some old unused code that dealt with storing test
results on disk, which we no longer do, and moved to a simpler interface
instead.

Fixes #180041
  • Loading branch information
connor4312 committed Apr 24, 2023
1 parent e2799e2 commit 9bf9093
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 436 deletions.
5 changes: 4 additions & 1 deletion src/vs/base/common/strings.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 9bf9093

Please sign in to comment.