Skip to content

Commit

Permalink
fix(java-junit): stack trace line can start with whitespaces
Browse files Browse the repository at this point in the history
Fixes #208
  • Loading branch information
Ats Uiboupin committed Nov 19, 2022
1 parent e5edb61 commit 3a48f6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions __tests__/java-stack-trace-element-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ describe('parseStackTraceLine tests', () => {
lineStr: '29'
})
})

it('starts with whitespaces', async () => {
const line = " \tat org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings(AddMissingPatchVersionTest.java:29)"
expect(parseStackTraceElement(line)).toEqual({
tracePath: "org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings",
fileName: "AddMissingPatchVersionTest.java",
lineStr: "29"
})
})
})

describe('Kotlin class', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/java-junit/java-stack-trace-element-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface StackTraceElement {

// simple format:
// at <FULLY_QUALIFIED_METHOD_NAME>(<FILE_NAME>:<LINE_NUMBER>)
const re = /^at (.*)\((.*):(\d+)\)$/
const re = /^\s*at (.*)\((.*):(\d+)\)$/

export function parseStackTraceElement(stackTraceLine: string): StackTraceElement | undefined {
const match = stackTraceLine.match(re)
Expand Down

0 comments on commit 3a48f6e

Please sign in to comment.