diff --git a/src/utils/tests_parsers.ts b/src/utils/tests_parsers.ts index e4397dd..46a5a28 100644 --- a/src/utils/tests_parsers.ts +++ b/src/utils/tests_parsers.ts @@ -13,42 +13,61 @@ export interface ParseOutput { tests: Array; } +function splitToTestFileLinesChunk(stdout: string): string[] { + const linesPerTestFileRegex = /(^\w.+ \[(?:.+\.exs)\](?:\s+\*.+\[L#\d+\])+)/gm; + const matches = stdout.match(linesPerTestFileRegex); + return matches || []; +} + +function testFileLinesToFileAndTests(chunk: string): { fileLine: string, testLines: string[] } { + const lines = chunk.trim().split('\n').filter(s => s); + return { + fileLine: lines[0], + testLines: lines.slice(1) + }; +} + +function parseTestFileName(fileLine: string): string { + const fileNamePartPattern = /\[(.+\.exs)\]/; + const matches = fileLine.match(fileNamePartPattern); + return matches![1]; +} + +function parseTestInfo(absolutePath: string, relativePath: string, testLine: string): TestInfo { + // * doctest Phoenix.Naming.camelize/1 (1) (excluded) [L#5] + const testLinePattern = /\*\s+(?\w+)\s+(?