Fix: Debug.LogError annotation point not parsed correctly (#279)

pull/281/head
Joe Anderson 2024-07-20 20:25:59 +01:00 committed by GitHub
parent 0ff419b913
commit 05a00ef5ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1344 additions and 1334 deletions

2661
dist/index.js generated vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -248,5 +248,13 @@ at Tests.SetupFailedTest.SetUp () [0x00000] in /github/workspace/unity-project/A
expect(result.path).toBe('/github/workspace/unity-project/Assets/Tests/SetupFailedTest.cs');
expect(result.line).toBe(10);
});
test('Debug.LogError annotation point', () => {
const result = ResultsParser.findAnnotationPoint(
`FMODUnity.RuntimeUtils:DebugLogError (string) (at Assets/Plugins/FMOD/src/RuntimeUtils.cs:580)`,
);
expect(result.path).toBe('Assets/Plugins/FMOD/src/RuntimeUtils.cs');
expect(result.line).toBe(580);
});
});
});

View File

@ -127,12 +127,13 @@ const ResultsParser = {
},
findAnnotationPoint(trace) {
const regex = /at(?: .* in)? ((?<path>[^:]+):(?<line>\d+))/;
// Find first entry with non-zero line number in stack trace
const items = trace.match(/at .* in ((?<path>[^:]+):(?<line>\d+))/g);
const items = trace.match(new RegExp(regex, 'g'));
if (Array.isArray(items)) {
const result: { path: any; line: number }[] = [];
for (const item of items) {
const match = item.match(/at .* in ((?<path>[^:]+):(?<line>\d+))/);
const match = item.match(regex);
const point = {
path: match ? match.groups.path : '',
line: match ? Number(match.groups.line) : 0,
@ -146,7 +147,7 @@ const ResultsParser = {
}
}
// If all entries have zero line number match fallback pattern
const match = trace.match(/at .* in ((?<path>[^:]+):(?<line>\d+))/);
const match = trace.match(regex);
return {
path: match ? match.groups.path : '',
line: match ? Number(match.groups.line) : 0,