Skip to content

Commit

Permalink
improve Prebuild parallelizability
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsequitur committed Apr 17, 2024
1 parent ff67074 commit a97c4e0
Show file tree
Hide file tree
Showing 23 changed files with 242 additions and 671 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace Microsoft.DotNet.Interactive.CSharpProject.Tests;

[Collection(nameof(PrebuildFixture))]
[LogToPocketLogger]
public class CSharpProjectKernelTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 Xunit;

namespace Microsoft.DotNet.Interactive.CSharpProject.Tests;

[CollectionDefinition(nameof(PrebuildFixture), DisableParallelization = true)]
public class CollectionDefinitionForPrebuildFixture : ICollectionFixture<PrebuildFixture>
{
// This class has no code, and is never created. Its purpose is simply
// to be the place to apply [CollectionDefinition] and all the
// ICollectionFixture<> interfaces.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.Threading.Tasks;
using Microsoft.DotNet.Interactive.CSharpProject.Build;
using Xunit;

namespace Microsoft.DotNet.Interactive.CSharpProject.Tests;

public class PrebuildFixture : IAsyncLifetime
{
public async Task InitializeAsync()
{
var consolePrebuild = await Prebuild.GetOrCreateConsolePrebuildAsync(true);
await consolePrebuild.EnsureReadyAsync();

consolePrebuild = await Prebuild.GetOrCreateConsolePrebuildAsync(false);
await consolePrebuild.EnsureReadyAsync();
Prebuild = consolePrebuild;
}

public Prebuild Prebuild { get; private set; }

public Task DisposeAsync()
{
return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public async Task A_prebuild_is_not_initialized_more_than_once()

var prebuild = PrebuildUtilities.CreateEmptyBuildablePrebuild(initializer: initializer);

await prebuild.GetOrCreateWorkspaceAsync();
await prebuild.GetOrCreateWorkspaceAsync();
await prebuild.CreateWorkspaceAsync();
await prebuild.CreateWorkspaceAsync();

initializer.InitializeCount.Should().Be(1);
}
Expand All @@ -57,8 +57,8 @@ public async Task Prebuild_after_create_actions_are_not_run_more_than_once()

var prebuild = PrebuildUtilities.CreateEmptyBuildablePrebuild(initializer: initializer);

await prebuild.GetOrCreateWorkspaceAsync();
await prebuild.GetOrCreateWorkspaceAsync();
await prebuild.CreateWorkspaceAsync();
await prebuild.CreateWorkspaceAsync();

afterCreateCallCount.Should().Be(1);
}
Expand All @@ -72,11 +72,11 @@ public async Task A_prebuild_copy_is_not_reinitialized_if_the_source_was_already

var original = PrebuildUtilities.CreateEmptyBuildablePrebuild(initializer: initializer);

await original.GetOrCreateWorkspaceAsync();
await original.CreateWorkspaceAsync();

var copy = await original.CreateBuildableCopy();

await copy.GetOrCreateWorkspaceAsync();
await copy.CreateWorkspaceAsync();

initializer.InitializeCount.Should().Be(1);
}
Expand All @@ -86,7 +86,7 @@ public async Task When_prebuild_contains_simple_console_app_then_entry_point_dll
{
var prebuild = PrebuildUtilities.CreateEmptyBuildablePrebuild(initializer: new PrebuildInitializer("console", "empty"));

await prebuild.GetOrCreateWorkspaceAsync();
await prebuild.CreateWorkspaceAsync();

prebuild.EntryPointAssemblyPath.Exists.Should().BeTrue();

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

namespace Microsoft.DotNet.Interactive.CSharpProject.Tests;

public class RoslynWorkspaceServerTestsConsoleProjectDiagnosticsTests : RoslynWorkspaceServerTestsCore
public class RoslynWorkspaceServerTestsConsoleProjectDiagnosticsTests : WorkspaceServerTestsCore
{


public RoslynWorkspaceServerTestsConsoleProjectDiagnosticsTests(ITestOutputHelper output) : base(output)
public RoslynWorkspaceServerTestsConsoleProjectDiagnosticsTests(PrebuildFixture prebuildFixture, ITestOutputHelper output) : base(prebuildFixture, output)
{
}

Expand Down Expand Up @@ -154,6 +152,4 @@ public static IEnumerable<int> Fibonacci()
result.Diagnostics.Should().NotBeNullOrEmpty();
result.Diagnostics.Should().Contain(diagnostics => diagnostics.Message == "generators/FibonacciGenerator.cs(14,17): error CS0246: The type or namespace name \'adddd\' could not be found (are you missing a using directive or an assembly reference?)");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace Microsoft.DotNet.Interactive.CSharpProject.Tests;

public class RoslynWorkspaceServerTestsConsoleProjectIntellisenseTests : RoslynWorkspaceServerTestsCore
public class RoslynWorkspaceServerTestsConsoleProjectIntellisenseTests : WorkspaceServerTestsCore
{
public RoslynWorkspaceServerTestsConsoleProjectIntellisenseTests(ITestOutputHelper output) : base(output)
public RoslynWorkspaceServerTestsConsoleProjectIntellisenseTests(PrebuildFixture prebuildFixture, ITestOutputHelper output) : base(prebuildFixture, output)
{
}

Expand Down

This file was deleted.

Loading

0 comments on commit a97c4e0

Please sign in to comment.