Skip to content

Commit c87dce7

Browse files
Use ITestOutputHelper
1 parent ef0993a commit c87dce7

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/Sentry/PlatformAbstractions/RuntimeInfo.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,20 @@ internal static SentryRuntime WithAdditionalProperties(this SentryRuntime runtim
3838

3939
internal static SentryRuntime? Parse(string? rawRuntimeDescription, string? name = null)
4040
{
41-
Console.WriteLine($"{nameof(rawRuntimeDescription)}: {rawRuntimeDescription}, {nameof(name)}: {name}");
4241
if (rawRuntimeDescription == null)
4342
{
44-
Console.WriteLine("rawRuntimeDescription is null");
4543
return name == null ? null : new SentryRuntime(name);
4644
}
4745

4846
var match = RuntimeParseRegex.Match(rawRuntimeDescription);
4947
if (match.Success)
5048
{
51-
Console.WriteLine("Regex matched: " + match.Value);
5249
return new SentryRuntime(
5350
name ?? (match.Groups["name"].Value == string.Empty ? null : match.Groups["name"].Value.Trim()),
5451
match.Groups["version"].Value == string.Empty ? null : match.Groups["version"].Value.Trim(),
5552
raw: rawRuntimeDescription);
5653
}
5754

58-
Console.WriteLine("No regex match");
5955
return new SentryRuntime(name, raw: rawRuntimeDescription);
6056
}
6157

test/Sentry.Tests/PlatformAbstractions/RuntimeInfoTests.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,37 @@
22

33
namespace Sentry.Tests.PlatformAbstractions;
44

5-
public class RuntimeInfoTests
5+
public class RuntimeInfoTests(ITestOutputHelper output)
66
{
77
[Fact]
88
public void GetRuntime_AllProperties()
99
{
10+
void Parse(string rawRuntimeDescription, string name = null)
11+
{
12+
Regex runtimeParseRegex = new(
13+
@"^(?<name>(?:[A-Za-z.]\S*\s?)*)(?:\s|^|$)(?<version>\d\S*)?",
14+
RegexOptions.Compiled | RegexOptions.CultureInvariant);
15+
16+
output.WriteLine($"{nameof(rawRuntimeDescription)}: {rawRuntimeDescription}, {nameof(name)}: {name}");
17+
if (rawRuntimeDescription == null)
18+
{
19+
output.WriteLine("rawRuntimeDescription is null");
20+
return;
21+
}
22+
23+
var match = runtimeParseRegex.Match(rawRuntimeDescription);
24+
if (match.Success)
25+
{
26+
output.WriteLine("Regex matched: " + match.Value);
27+
return;
28+
}
29+
30+
output.WriteLine("No regex match");
31+
}
32+
33+
var frameworkDescription = RuntimeInformation.FrameworkDescription;
34+
Parse(frameworkDescription);
35+
1036
var actual = RuntimeInfo.GetRuntime();
1137
Assert.NotNull(actual);
1238
Assert.NotNull(actual.Name);

0 commit comments

Comments
 (0)