Skip to content

Commit

Permalink
testing: tie test output correctly to runs, rework ui accordingly (#1…
Browse files Browse the repository at this point in the history
…80746)

* testing: don't enqueue tests into tasks that are created

This is an old artifact that caused problems in the issue this fixes #180041

When we get a new 'task' from a test run request, we automatically
marked all tests as being enqueued with it. However, tests are now lazily
added to the test run states, so this would only affect tests that
_already_ had their state set to something (e.g. in another task). And
therefore it was also ineffective for its original purpose of marking
all included tests as being Queued, since extensions have had to do that
themselves anyway.

So just remove this code! Also, adjust priorities such that "skipped"
priorities are shown above unset ones.

* testing: tie test output correctly to runs, rework ui accordingly

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 authored Apr 24, 2023
1 parent 42fbc2f commit 6a283f7
Show file tree
Hide file tree
Showing 13 changed files with 450 additions and 441 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 6a283f7

Please sign in to comment.