Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Jan 1, 2025
1 parent 832c4c9 commit c9ef3ae
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 52 deletions.
19 changes: 9 additions & 10 deletions GitHubActionsTestLogger.Tests/Utils/TestResultBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ namespace GitHubActionsTestLogger.Tests.Utils;

internal class TestResultBuilder
{
private TestResult _testResult =
new(
new TestCase
{
Id = Guid.NewGuid(),
Source = "FakeTests.dll",
FullyQualifiedName = "FakeTests.FakeTest",
DisplayName = "FakeTest",
}
);
private TestResult _testResult = new(
new TestCase
{
Id = Guid.NewGuid(),
Source = "FakeTests.dll",
FullyQualifiedName = "FakeTests.FakeTest",
DisplayName = "FakeTest",
}
);

public TestResultBuilder SetDisplayName(string displayName)
{
Expand Down
83 changes: 41 additions & 42 deletions GitHubActionsTestLogger/Utils/StackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,47 @@ internal partial class StackFrame
private const string Space = @"[\x20\t]";
private const string NotSpace = @"[^\x20\t]";

private static readonly Regex Pattern =
new(
$$"""
^
{{Space}}*
\w+ {{Space}}+
(?<frame>
(?<type> {{NotSpace}}+ ) \.
(?<method> {{NotSpace}}+? ) {{Space}}*
(?<params> \( ( {{Space}}* \)
| (?<pt> .+?) {{Space}}+ (?<pn> .+?)
(, {{Space}}* (?<pt> .+?) {{Space}}+ (?<pn> .+?) )* \) ) )
( {{Space}}+
( # Microsoft .NET stack traces
\w+ {{Space}}+
(?<file> ( [a-z] \: # Windows rooted path starting with a drive letter
| / ) # Unix rooted path starting with a forward-slash
.+? )
\: \w+ {{Space}}+
(?<line> [0-9]+ ) \p{P}?
| # Mono stack traces
\[0x[0-9a-f]+\] {{Space}}+ \w+ {{Space}}+
<(?<file> [^>]+ )>
:(?<line> [0-9]+ )
)
)?
)
\s*
$
""",
RegexOptions.IgnoreCase
| RegexOptions.Multiline
| RegexOptions.ExplicitCapture
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled,
// Cap the evaluation time to make it obvious should the expression
// fall into the "catastrophic backtracking" trap due to over
// generalization.
// https://github.com/atifaziz/StackTraceParser/issues/4
TimeSpan.FromSeconds(5)
);
private static readonly Regex Pattern = new(
$$"""
^
{{Space}}*
\w+ {{Space}}+
(?<frame>
(?<type> {{NotSpace}}+ ) \.
(?<method> {{NotSpace}}+? ) {{Space}}*
(?<params> \( ( {{Space}}* \)
| (?<pt> .+?) {{Space}}+ (?<pn> .+?)
(, {{Space}}* (?<pt> .+?) {{Space}}+ (?<pn> .+?) )* \) ) )
( {{Space}}+
( # Microsoft .NET stack traces
\w+ {{Space}}+
(?<file> ( [a-z] \: # Windows rooted path starting with a drive letter
| / ) # Unix rooted path starting with a forward-slash
.+? )
\: \w+ {{Space}}+
(?<line> [0-9]+ ) \p{P}?
| # Mono stack traces
\[0x[0-9a-f]+\] {{Space}}+ \w+ {{Space}}+
<(?<file> [^>]+ )>
:(?<line> [0-9]+ )
)
)?
)
\s*
$
""",
RegexOptions.IgnoreCase
| RegexOptions.Multiline
| RegexOptions.ExplicitCapture
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled,
// Cap the evaluation time to make it obvious should the expression
// fall into the "catastrophic backtracking" trap due to over
// generalization.
// https://github.com/atifaziz/StackTraceParser/issues/4
TimeSpan.FromSeconds(5)
);

public static IEnumerable<StackFrame> ParseMany(string text) =>
from Match m in Pattern.Matches(text)
Expand Down

0 comments on commit c9ef3ae

Please sign in to comment.