MCPcopy Create free account
hub / github.com/ccxt/ccxt / generateResultFromOutput

Function generateResultFromOutput

run-tests.js:132–186  ·  view source on GitHub ↗
(output, stderr, code)

Source from the content-addressed store, hash-verified

130 let stderr = ''
131
132 const generateResultFromOutput = (output, stderr, code) => {
133 // keep this commented code for a while (just in case), as the below avoids vscode false positive warnings from output: https://github.com/nodejs/node/issues/34799 during debugging
134 // const removeDebuger = (str) => str.replace ('Debugger attached.','').replace('Waiting for the debugger to disconnect...', '').replace(/\(node:\d+\) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time\n\(Use `node --trace-warnings ...` to show where the warning was created\)\n/, '');
135 // stderr = removeDebuger(stderr), output = removeDebuger(output);
136
137 output = ansi.strip (output.trim ())
138
139 // detect error
140 const hasFailed = (
141 // exception caught in "test -> testMethod"
142 output.indexOf('[TEST_FAILURE]') > -1 ||
143 // below checks are retained just for the sake of completeness & possible edge-cases, however it should not be needed anymore, because we always add `[TEST_FAILURE]` to the output in tests
144 // 1) thrown from JS assert module
145 output.indexOf('AssertionError:') > -1 ||
146 // 2) thrown from PYTHON (i.e. [AssertionError], [KeyError], [ValueError], etc)
147 output.match(/\[\w+Error\]/) ||
148 // 3) thrown from PHP assert hook
149 output.indexOf('[ASSERT_ERROR]') > -1 ||
150 // 4) thrown from PHP async library
151 output.indexOf('Fatal error:') > -1
152 );
153
154 // ### Infos ###
155 const infos = []
156 // check output for pattern like `[INFO:TESTING] xyz message`
157 if (output.length) {
158 const infoRegex = /\[INFO(|:([\w_-]+))\].+$(?!\n)*/gm
159 let matchInfo;
160 while ((matchInfo = infoRegex.exec (output))) {
161 infos.push (matchInfo[0])
162 }
163 }
164
165 // ### Warnings ###
166 const warnings = []
167 // check output for pattern like `[TEST_WARNING] whatever`
168 if (output.length) {
169 const warningRegex = /\[TEST_WARNING\].+$(?!\n)*/gmi
170 let matchWarnings;
171 while (matchWarnings = warningRegex.exec (stderr)) {
172 warnings.push (matchWarnings[0])
173 }
174 }
175 // check stderr
176 if (stderr.length > 0) {
177 warnings.push (stderr)
178 }
179
180 return {
181 failed: hasFailed || code !== 0,
182 output,
183 warnings,
184 infos,
185 }
186 }
187
188 return timeout (timeoutSeconds, new Promise (resolver => {
189

Callers 1

execFunction · 0.85

Calls 3

pushMethod · 0.80
stripMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…