Skip to content

Commit 4b6b856

Browse files
Try to mimimize flakiness due to non-determinism
1 parent c3f6a44 commit 4b6b856

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

Tests/CSharp/ExpressionTests/AccessExpressionTests.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System;
2+
using System.Threading.Tasks;
23
using ICSharpCode.CodeConverter.Tests.TestRunners;
34
using Xunit;
45

@@ -565,15 +566,32 @@ public void compareAccess()
565566

566567
[Fact]
567568
public async Task AliasedImportsWithTypePromotionIssue401Async()
569+
{
570+
for (int i = 0; i < 3; i++) {
571+
try {
572+
// I believe there are two valid simplifications and the simplifier is non-deterministic
573+
// Just retry a few times and see if we get the one we expect before failing
574+
// At the same time as this loop I added "aliasedAgain" in the hope that it'd discourage the simplifier from fully qualifying Strings
575+
await FlakeyAliasedImportsWithTypePromotionIssue401Async();
576+
return;
577+
} catch (Exception e) {
578+
}
579+
}
580+
581+
await FlakeyAliasedImportsWithTypePromotionIssue401Async();
582+
}
583+
584+
private async Task FlakeyAliasedImportsWithTypePromotionIssue401Async()
568585
{
569586
await TestConversionVisualBasicToCSharpAsync(
570587
@"Imports System.IO
571588
Imports SIO = System.IO
572589
Imports Microsoft.VisualBasic
573-
Imports VB = Microsoft.VisualBasic 'TODO: Figure out why this is removed sometimes by the simplifier (making this test flaky)
590+
Imports VB = Microsoft.VisualBasic
574591
575592
Public Class Test
576593
Private aliased As String = VB.Left(""SomeText"", 1)
594+
Private aliasedAgain As String = VB.Left(""SomeText"", 1)
577595
Private aliased2 As System.Delegate = New SIO.ErrorEventHandler(AddressOf OnError)
578596
579597
' Make use of the non-aliased imports, but ensure there's a name clash that requires the aliases in the above case
@@ -590,11 +608,12 @@ End Sub
590608
using System.IO;
591609
using SIO = System.IO;
592610
using Microsoft.VisualBasic; // Install-Package Microsoft.VisualBasic
593-
using VB = Microsoft.VisualBasic; // Install-Package Microsoft.VisualBasic // TODO: Figure out why this is removed sometimes by the simplifier (making this test flaky)
611+
using VB = Microsoft.VisualBasic; // Install-Package Microsoft.VisualBasic
594612
595613
public partial class Test
596614
{
597615
private string aliased = VB.Strings.Left(""SomeText"", 1);
616+
private string aliasedAgain = VB.Strings.Left(""SomeText"", 1);
598617
private Delegate aliased2 = new SIO.ErrorEventHandler(OnError);
599618
600619
// Make use of the non-aliased imports, but ensure there's a name clash that requires the aliases in the above case

0 commit comments

Comments
 (0)