Skip to content
代码片段 群组 项目
未验证 提交 17dcec13 编辑于 作者: Fred Silberberg's avatar Fred Silberberg 提交者: GitHub
浏览文件

Reduce number of iterations for LongInitializers test (#68723)

We were seeing consistent failures in the linux pipeline. Also adds more info when the test does timeout for helping in figuring out how many iterations makes it consistent.
上级 8a200a92
No related branches found
No related tags found
无相关合并请求
......@@ -327,16 +327,17 @@ static void runTest(int n)
public void LongInitializerList()
{
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
int iterations = 0;
try
{
initializerTest(cts.Token);
initializerTest(cts.Token, ref iterations);
}
catch (TaskCanceledException)
catch (Exception e) when (e is OperationCanceledException or TaskCanceledException)
{
Assert.True(false, "Test timed out while getting all semantic info for long initializer list");
Assert.True(false, $"Test timed out while getting all semantic info for long initializer list. Got to {iterations} iterations.");
}
static void initializerTest(CancellationToken ct)
static void initializerTest(CancellationToken ct, ref int iterationReached)
{
var sb = new StringBuilder();
sb.AppendLine("""
......@@ -344,7 +345,7 @@ static void initializerTest(CancellationToken ct)
{
""");
for (int i = 0; i < 75000; i++)
for (int i = 0; i < 50000; i++)
{
sb.AppendLine(""" { "a", "b" },""");
}
......@@ -359,9 +360,11 @@ static void initializerTest(CancellationToken ct)
// If we regress perf here, this test will time out. The original condition here was a O(n^2) algorithm because the syntactic parent of each literal
// was being rebound on every call to GetTypeInfo.
iterationReached = 0;
foreach (var literal in tree.GetRoot().DescendantNodes().OfType<LiteralExpressionSyntax>())
{
ct.ThrowIfCancellationRequested();
iterationReached++;
var type = model.GetTypeInfo(literal).Type;
Assert.Equal(SpecialType.System_String, type.SpecialType);
}
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册