in action-junit-report/src/testParser.ts [53:92]
export async function resolveFileAndLine(
file: string | null,
line: string | null,
className: string,
output: string
): Promise<Position> {
let fileName = file ? file : className.split('.').slice(-1)[0]
const lineNumber = safeParseInt(line)
try {
if (fileName && lineNumber) {
return {fileName, line: lineNumber}
}
const escapedFileName = fileName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace('::', '/') // Rust test output contains colons between package names - See: https://github.com/mikepenz/action-junit-report/pull/359
const matches = output.match(new RegExp(` [^ ]*${escapedFileName}.*?:\\d+`, 'g'))
if (!matches) return {fileName, line: lineNumber || 1}
const [lastItem] = matches.slice(-1)
const lineTokens = lastItem.split(':')
line = lineTokens.pop() || '0'
// check, if the error message is from a rust file -- this way we have the chance to find
// out the involved test file
// See: https://github.com/mikepenz/action-junit-report/pull/360
{
const lineNumberPrefix = lineTokens.pop() || ''
if (lineNumberPrefix.endsWith('.rs')) {
fileName = lineNumberPrefix.split(' ').pop() || ''
}
}
core.debug(`Resolved file ${fileName} and line ${line}`)
return {fileName, line: safeParseInt(line) || -1}
} catch (error) {
core.warning(`⚠️ Failed to resolve file (${file}) and/or line (${line}) for ${className}`)
return {fileName, line: safeParseInt(line) || -1}
}
}