这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
14 changes: 14 additions & 0 deletions src/Microsoft.TryDotNet.IntegrationTests/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ public static async Task<T> Timeout<T>(
return await source;
}

public static async Task Timeout(
this Task source,
TimeSpan timeout)
{
if (await Task.WhenAny(
source,
Task.Delay(timeout)) != source)
{
throw new TimeoutException();
}

await source;
}

public static Process StartProcess(
string command,
string args,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text.Json;
Expand Down Expand Up @@ -38,6 +39,7 @@ await page.ExposeFunctionAsync("postMessageLogger", async (JsonElement message)
public Task<JsonElement> AwaitForMessage(string messageType)
{
var cs = _completionSources.GetOrAdd(messageType, _ => new TaskCompletionSource<JsonElement>(TaskCreationOptions.RunContinuationsAsynchronously));
return cs.Task;
return cs.Task.Timeout(TimeSpan.FromSeconds(30));
}
}
}

5 changes: 3 additions & 2 deletions src/Microsoft.TryDotNet.IntegrationTests/PageExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -79,7 +80,7 @@ await page.DispatchMessage(new
type = "run"

});
var res = await awaiter;
await awaiter;
return interceptor.Messages;
}

Expand All @@ -106,7 +107,7 @@ await page.DispatchMessage(new

});

await ts.Task;
await ts.Task.Timeout(TimeSpan.FromSeconds(30));

return messages;

Expand Down
Loading