update findAnnotationPoint to use first entry with non-zero line number (#138)
* update findAnnotationPoint to use first entry with non-zero line number * misc: improve comment in findAnnotationPointpull/139/head
parent
c56b66a41b
commit
dfd8e1e91f
File diff suppressed because one or more lines are too long
|
@ -112,6 +112,25 @@ class ResultsParser {
|
|||
}
|
||||
|
||||
static findAnnotationPoint(trace) {
|
||||
// Find first entry with non-zero line number in stack trace
|
||||
const items = trace.match(/at .* in ((?<path>[^:]+):(?<line>\d+))/g);
|
||||
if (Array.isArray(items)) {
|
||||
const result = [];
|
||||
items.forEach(item => {
|
||||
const match = item.match(/at .* in ((?<path>[^:]+):(?<line>\d+))/);
|
||||
const point = {
|
||||
path: match ? match.groups.path : '',
|
||||
line: match ? Number(match.groups.line) : 0,
|
||||
};
|
||||
if (point.line > 0) {
|
||||
result.push(point);
|
||||
}
|
||||
});
|
||||
if (result.length > 0) {
|
||||
return result[0];
|
||||
}
|
||||
}
|
||||
// If all entries have zero line number match fallback pattern
|
||||
const match = trace.match(/at .* in ((?<path>[^:]+):(?<line>\d+))/);
|
||||
return {
|
||||
path: match ? match.groups.path : '',
|
||||
|
|
|
@ -195,6 +195,16 @@ at UnityEngine.TestTools.TestEnumerator+<Execute>d__6.MoveNext () [0x00038] in /
|
|||
expect(result.line).toBe(39);
|
||||
});
|
||||
|
||||
test('first entry with non-zero line number annotation point', () => {
|
||||
const result = ResultsParser.findAnnotationPoint(`at FluentAssertions.Execution.LateBoundTestFramework.Throw (System.String message) [0x00044] in <527a5493e59e45679b35c1e8d65350b3>:0
|
||||
at FluentAssertions.Execution.TestFrameworkProvider.Throw (System.String message) [0x00011] in <527a5493e59e45679b35c1e8d65350b3>:0
|
||||
at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure (System.String message) [0x00005] in <527a5493e59e45679b35c1e8d65350b3>:0
|
||||
at Tests.PlayModeTest+<FailedUnityTest>d__5.MoveNext () [0x0002e] in /github/workspace/unity-project/Assets/Tests/PlayModeTest.cs:39
|
||||
at UnityEngine.TestTools.TestEnumerator+<Execute>d__6.MoveNext () [0x00038] in /github/workspace/unity-project/Library/PackageCache/com.unity.test-framework@1.1.19/UnityEngine.TestRunner/NUnitExtensions/Attributes/TestEnumerator.cs:36`);
|
||||
expect(result.path).toBe('/github/workspace/unity-project/Assets/Tests/PlayModeTest.cs');
|
||||
expect(result.line).toBe(39);
|
||||
});
|
||||
|
||||
test('setup annotation point', () => {
|
||||
const result = ResultsParser.findAnnotationPoint(`SetUp
|
||||
at Tests.SetupFailedTest.SetUp () [0x00000] in /github/workspace/unity-project/Assets/Tests/SetupFailedTest.cs:10`);
|
||||
|
|
Loading…
Reference in New Issue