Skip to content

Commit

Permalink
Trim index prefix from test output
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbonnet committed Jan 26, 2023
1 parent 0250daa commit 0b9fbce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/cmake-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const ROOT_SUITE_ID = '*';
const SUITE_SUFFIX = '*';

/** Regexp for detecting GCC-like error with file and line info */
const DECORATION_RE = /^(?:\d+): ([^<].*?):(\d+):\d*:?\s+(?:fatal\s+)?(?:warning|error):\s+(.*)$/
const DECORATION_RE =
/^([^<].*?):(\d+):\d*:?\s+(?:fatal\s+)?(?:warning|error):\s+(.*)$/;

/**
* CMake test adapter for the Test Explorer UI extension
Expand Down Expand Up @@ -342,7 +343,7 @@ export class CmakeAdapter implements TestAdapter {
if (!outputs[event.index]) outputs[event.index] = [];
outputs[event.index].push(event.line);

const matches = event.line.match(DECORATION_RE)
const matches = event.text?.match(DECORATION_RE);
if (matches) {
const [, file, line, message] = matches;

Expand All @@ -351,7 +352,7 @@ export class CmakeAdapter implements TestAdapter {
file,
line: Number.parseInt(line) - 1,
message,
})
});
}
break;

Expand Down
6 changes: 4 additions & 2 deletions src/cmake-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const CTEST_RE = /^CMAKE_CTEST_COMMAND:INTERNAL=(.*)$/m;
const CTEST_START_RE = /^\s+Start\s+(\d+): (.+)/;

/** Regexp for test output line */
const CTEST_OUTPUT_RE = /^(\d+): .*$/;
const CTEST_OUTPUT_RE = /^(\d+): (.*)$/;

/** Regexp for test passed line */
const CTEST_PASSED_RE = /^\s*\d+\/\d+ Test\s+#(\d+): (.+) \.\.\.+ Passed/;
Expand Down Expand Up @@ -57,6 +57,7 @@ export interface CmakeTestOutputEvent {
type: 'output';
index: number;
line: string;
text?: string;
}

/** Test end event */
Expand Down Expand Up @@ -238,7 +239,8 @@ export function executeCmakeTestProcess(
} else if ((matches = line.match(CTEST_OUTPUT_RE))) {
// Test output
const index = Number.parseInt(matches[1]);
onEvent({ type: 'output', index, line });
const text = matches[2];
onEvent({ type: 'output', index, line, text });
} else if ((matches = line.match(CTEST_PASSED_RE))) {
// Test passed
const index = Number.parseInt(matches[1]);
Expand Down

0 comments on commit 0b9fbce

Please sign in to comment.