MCPcopy Index your code
hub / github.com/coderoad/coderoad-vscode / parser

Function parser

src/services/testRunner/parser.ts:51–130  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

49// otherwise code here will eventually get out of hand
50// currently supports: mocha, python tap.py
51const parser = (text: string): ParserOutput => {
52 const lineList = text.split('\n')
53 // start after 1..n output
54 const startingPoint = lineList.findIndex((t) => t.match(r.start))
55 const lines = lineList.slice(startingPoint)
56
57 const result: ParserOutput = {
58 ok: true,
59 passed: [],
60 failed: [],
61 logs: [],
62 summary: {},
63 }
64
65 // temporary holder of error detail strings
66 let currentDetails: string | null = null
67 let logs: string[] = []
68
69 const addCurrentDetails = () => {
70 const failLength: number = result.failed.length
71 if (currentDetails && !!failLength) {
72 result.failed[failLength - 1].details = currentDetails
73 currentDetails = null
74 }
75 }
76
77 for (const line of lines) {
78 if (!line.length || !!r.ignore.exec(line)) {
79 continue
80 }
81 // be optimistic! check for success first
82 const isPass = detect('pass', line)
83 if (!!isPass) {
84 const message = formatMessage(isPass.message)
85 const pass: Pass = { message }
86 if (logs.length) {
87 pass.logs = logs
88 logs = []
89 }
90 result.passed.push(pass)
91 result.summary[message] = true
92 addCurrentDetails()
93 continue
94 }
95
96 // check for failure
97 const isFail = detect('fail', line)
98 if (!!isFail) {
99 result.ok = false
100 addCurrentDetails()
101 const message = formatMessage(isFail.message)
102 const fail: Fail = { message }
103 if (logs.length) {
104 fail.logs = logs
105 logs = []
106 }
107 result.failed.push(fail)
108 result.summary[message] = false

Callers 2

createTestRunnerFunction · 0.85
parser.test.tsFile · 0.85

Calls 3

detectFunction · 0.85
formatMessageFunction · 0.85
addCurrentDetailsFunction · 0.85

Tested by

no test coverage detected