Skip to content

Commit

Permalink
parse line number
Browse files Browse the repository at this point in the history
  • Loading branch information
chylli-deriv committed Jan 16, 2024
1 parent b29084c commit 6f36be1
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/parsers/perl-junit/java-stack-trace-element-parser.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
export interface StackTraceElement {
classLoader: string | undefined
moduleNameAndVersion: string | undefined
tracePath: string
fileName: string
filePath: string
lineStr: string
}

// classloader and module name are optional:
// at <CLASSLOADER>/<MODULE_NAME_AND_VERSION>/<FULLY_QUALIFIED_METHOD_NAME>(<FILE_NAME>:<LINE_NUMBER>)
// https://github.com/eclipse-openj9/openj9/issues/11452#issuecomment-754946992
const re = /^\s*at (\S+\/\S*\/)?(.*)\((.*):(\d+)\)$/
// perl: # at t/test1.t line 23.
const re = /\s+at (.*) line (\d+)\.$/

export function parseStackTraceElement(stackTraceLine: string): StackTraceElement | undefined {
const match = stackTraceLine.match(re)
if (match !== null) {
const [_, maybeClassLoaderAndModuleNameAndVersion, tracePath, fileName, lineStr] = match
const {classLoader, moduleNameAndVersion} = parseClassLoaderAndModule(maybeClassLoaderAndModuleNameAndVersion)
const [_, filePath, lineStr] = match
return {
classLoader,
moduleNameAndVersion,
tracePath,
fileName,
filePath,
lineStr
}
}
Expand Down

0 comments on commit 6f36be1

Please sign in to comment.