Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tests/BenchmarkDotNet.IntegrationTests/PowerRequestsParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,36 @@ private static IEnumerable<Token> 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;
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions tests/BenchmarkDotNet.IntegrationTests/WakeLockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ public async Task BenchmarkRunnerAcquiresWakeLock(Type type, string expected)
async Task WaitForBenchmarkRunningAndGetPowerRequests()
{
await AsTask(ping, testTimeout);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await AsTask(ping, testTimeout) sits outside the new try, so finally { pong.Set(); } doesn't cover it. If the out-of-process build/start exceeds the 1-minute testTimeout (plausible on a cold machine), AsTask faults, pong is never set, and the child blocks another full minute in pong.WaitOne(testTimeout) — the same hang symptom this PR fixes, via the other arm. Fix: wrap the whole method body including the await. pong is an AutoResetEvent, so signalling early is harmless.

pwrRequests = GetPowerRequests("BenchmarkDotNet Running Benchmarks");
pong.Set();
try
{
pwrRequests = GetPowerRequests("BenchmarkDotNet Running Benchmarks");
}
finally
{
pong.Set();
}
}
}

Expand Down