Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 8b06908

Browse files
committed
Fix a potential deadlock
Avoid using Result to obtain the result of an async call, this can cause a deadlock if the Result is evaluated on the main thread while the main thread is being pumped (which can happen in the tests because there's no actual threading going on, everything is going through the main thread)
1 parent 4ff9775 commit 8b06908

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/tests/IntegrationTests/Git/GitClientTests.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,36 @@ namespace IntegrationTests
1010
class GitClientTests : BaseGitEnvironmentTest
1111
{
1212
[Test]
13-
public void ShouldGetGitVersion()
13+
public async Task ShouldGetGitVersion()
1414
{
1515
Initialize(TestRepoMasterCleanSynchronized);
1616

17-
var version = GitClient.Version();
18-
version.Start().Wait();
17+
var result = await GitClient.Version().StartAwait();
1918

20-
var versionResult = version.Result;
2119
if (Environment.IsWindows)
2220
{
23-
versionResult.Should().Be(new Version(2,11,1));
21+
result.Should().Be(new Version(2,11,1));
2422
}
2523
else
2624
{
27-
versionResult.Should().NotBeNull();
25+
result.Should().NotBeNull();
2826
}
2927
}
3028

3129
[Test]
32-
public void ShouldGetGitLfsVersion()
30+
public async Task ShouldGetGitLfsVersion()
3331
{
3432
Initialize(TestRepoMasterCleanSynchronized);
3533

36-
var version = GitClient.LfsVersion();
37-
version.Start().Wait();
34+
var result = await GitClient.LfsVersion().StartAwait();
3835

39-
var versionResult = version.Result;
4036
if (Environment.IsWindows)
4137
{
42-
versionResult.Should().Be(new Version(2, 3, 4));
38+
result.Should().Be(new Version(2, 3, 4));
4339
}
4440
else
4541
{
46-
versionResult.Should().NotBeNull();
42+
result.Should().NotBeNull();
4743
}
4844
}
4945
}

0 commit comments

Comments
 (0)