generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from atsu85/issue-208-java-junit-show-annotat…
…ions-on-pr-changed-files Fix #208 - java-junit: show annotations on PR changed files
- Loading branch information
Showing
6 changed files
with
173 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,3 +100,5 @@ lib/**/* | |
|
||
# Project specific | ||
__tests__/__results__ | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import {parseStackTraceElement} from '../src/parsers/java-junit/java-stack-trace-element-parser' | ||
|
||
describe('parseStackTraceLine tests', () => { | ||
it('empty line is not parsed', async () => { | ||
const line = '' | ||
expect(parseStackTraceElement(line)).toBe(undefined) | ||
}) | ||
|
||
describe('java class', () => { | ||
it('simple', async () => { | ||
const line = | ||
'at org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings(AddMissingPatchVersionTest.java:29)' | ||
expect(parseStackTraceElement(line)).toEqual({ | ||
tracePath: 'org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings', | ||
fileName: 'AddMissingPatchVersionTest.java', | ||
lineStr: '29' | ||
}) | ||
}) | ||
|
||
it('inner class', async () => { | ||
const line = 'at com.foo.Main$Inner.run(Main.java:29)' | ||
expect(parseStackTraceElement(line)).toEqual({ | ||
tracePath: 'com.foo.Main$Inner.run', | ||
fileName: 'Main.java', | ||
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('since Java 9', () => { | ||
it('with classloader and module', async () => { | ||
// Based on Java 9 StackTraceElement.toString() Doc: https://docs.oracle.com/javase/9/docs/api/java/lang/StackTraceElement.html#toString-- | ||
const line = 'at com.foo.loader/[email protected]/com.foo.Main.run(Main.java:101)' | ||
expect(parseStackTraceElement(line)).toEqual({ | ||
classLoader: 'com.foo.loader', | ||
moduleNameAndVersion: '[email protected]', | ||
tracePath: 'com.foo.Main.run', | ||
fileName: 'Main.java', | ||
lineStr: '101' | ||
}) | ||
}) | ||
|
||
it('with classloader', async () => { | ||
const line = 'at com.foo.loader//com.foo.Main.run(Main.java:101)' | ||
expect(parseStackTraceElement(line)).toEqual({ | ||
classLoader: 'com.foo.loader', | ||
moduleNameAndVersion: undefined, | ||
tracePath: 'com.foo.Main.run', | ||
fileName: 'Main.java', | ||
lineStr: '101' | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Kotlin class', () => { | ||
it('method name containing whitespaces', async () => { | ||
const line = 'at com.foo.Main.method with whitespaces(Main.kt:18)' | ||
expect(parseStackTraceElement(line)).toEqual({ | ||
tracePath: 'com.foo.Main.method with whitespaces', | ||
fileName: 'Main.kt', | ||
lineStr: '18' | ||
}) | ||
}) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export interface StackTraceElement { | ||
classLoader: string | undefined | ||
moduleNameAndVersion: string | undefined | ||
tracePath: string | ||
fileName: 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+)\)$/ | ||
|
||
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) | ||
return { | ||
classLoader, | ||
moduleNameAndVersion, | ||
tracePath, | ||
fileName, | ||
lineStr | ||
} | ||
} | ||
return undefined | ||
} | ||
|
||
function parseClassLoaderAndModule(maybeClassLoaderAndModuleNameAndVersion?: string): { | ||
classLoader?: string | ||
moduleNameAndVersion?: string | ||
} { | ||
if (maybeClassLoaderAndModuleNameAndVersion) { | ||
const res = maybeClassLoaderAndModuleNameAndVersion.split('/') | ||
const classLoader = res[0] | ||
let moduleNameAndVersion: string | undefined = res[1] | ||
if (moduleNameAndVersion === '') { | ||
moduleNameAndVersion = undefined | ||
} | ||
return {classLoader, moduleNameAndVersion} | ||
} | ||
return {classLoader: undefined, moduleNameAndVersion: undefined} | ||
} |