diff --git a/tests/BenchmarkDotNet.IntegrationTests/PowerRequestsParser.cs b/tests/BenchmarkDotNet.IntegrationTests/PowerRequestsParser.cs index 8dac936259..2a55ced74c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/PowerRequestsParser.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/PowerRequestsParser.cs @@ -106,29 +106,36 @@ private static IEnumerable Tokens(string input) // return an empty string when CR is followed by LF. StringReader reader = new StringReader(input); string? line; + TokenType previousTokenType = TokenType.None; while ((line = reader.ReadLine()) != null) { if (line.Length == 0) { yield return new Token(TokenType.EmptyLine, ""); + previousTokenType = TokenType.EmptyLine; } else if (line[line.Length - 1] == ':') { yield return new Token(TokenType.RequestType, line.Substring(0, line.Length - 1).ToString()); - } - else if (string.Equals(line, "None.", StringComparison.InvariantCulture)) - { - yield return new Token(TokenType.None, line); + previousTokenType = TokenType.RequestType; } else if (line[0] == '[') { int pos = line.IndexOf(']'); yield return new Token(TokenType.RequesterType, line.Substring(1, pos - 1)); yield return new Token(TokenType.RequesterName, line.Substring(pos + 2)); + previousTokenType = TokenType.RequesterName; + } + else if (previousTokenType == TokenType.RequestType) + { + // Any single line directly after a request type header is the localized "None." + yield return new Token(TokenType.None, line); + previousTokenType = TokenType.None; } else { yield return new Token(TokenType.Reason, line); + previousTokenType = TokenType.Reason; } } } diff --git a/tests/BenchmarkDotNet.IntegrationTests/WakeLockTests.cs b/tests/BenchmarkDotNet.IntegrationTests/WakeLockTests.cs index f9cc6fef84..39b64e0f4f 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/WakeLockTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/WakeLockTests.cs @@ -99,8 +99,14 @@ public async Task BenchmarkRunnerAcquiresWakeLock(Type type, string expected) async Task WaitForBenchmarkRunningAndGetPowerRequests() { await AsTask(ping, testTimeout); - pwrRequests = GetPowerRequests("BenchmarkDotNet Running Benchmarks"); - pong.Set(); + try + { + pwrRequests = GetPowerRequests("BenchmarkDotNet Running Benchmarks"); + } + finally + { + pong.Set(); + } } }