Skip to content
Draft
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
258 changes: 141 additions & 117 deletions tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@
<Compile Include="TypeChecks\Graph\Scenarios.fs" />
<Compile Include="TypeChecks\Graph\DependencyResolutionTests.fs" />
<Compile Include="TypeChecks\Graph\CompilationTests.fs" />
<Content Include="testconfig.json" />
<Content Include="TypeChecks\Graph\scrape.fsx" CopyToOutputDirectory="Never" />
<Compile Include="TypeChecks\Graph\CompilationFromCmdlineArgsTests.fs" />
<Compile Include="TypeChecks\Graph\TypedTreeGraph.fs" />
Expand Down Expand Up @@ -484,6 +485,13 @@
</None>
</ItemGroup>

<!-- xUnit3 configuration for this test project (MTP mode) -->
<ItemGroup>
<Content Include="testconfig.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="resources\**" CopyToOutputDirectory="Never" CopyToPublishDirectory="PreserveNewest" />
<EmbeddedResource Remove="Properties\**" />
Expand Down
5 changes: 5 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/testconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"xUnit": {
"maxParallelThreads": "0.5x"
}
}
3 changes: 1 addition & 2 deletions tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<Compile Include="FileInlineDataAttribute.fs" />
<Compile Include="ReflectionHelper.fs" />
<Compile Include="SurfaceArea.fs" />
<Compile Include="XunitHelpers.fs" />
<Compile Include="XunitSetup.fs" />
</ItemGroup>

Expand Down Expand Up @@ -104,7 +103,7 @@
<!-- 44: AssemblyName.CodeBase is deprecated but needed for assembly resolution in VS integration tests -->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" GeneratePathProperty="true" />
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(RoslynForTestingButNotForVSLayer)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(RoslynForTestingButNotForVSLayer)" />
<PackageReference Include="Microsoft.CodeAnalysis.Test.Resources.Proprietary" Version="$(MicrosoftCodeAnalysisTestResourcesProprietaryVersion)" />
Expand Down
260 changes: 0 additions & 260 deletions tests/FSharp.Test.Utilities/XunitHelpers.fs

This file was deleted.

40 changes: 20 additions & 20 deletions tests/FSharp.Test.Utilities/XunitSetup.fs
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
namespace FSharp.Test

open System
open Xunit
open TestFramework

// xUnit3 assembly fixtures: ensure TestConsole is installed once per assembly
// This replaces the OneTimeSetup.EnsureInitialized() call that was done in FSharpXunitFramework
module private XUnitInit =
let private ensureInitialized = lazy (
/// xUnit3 assembly fixture: performs one-time setup for the test assembly.
/// Registered via [<assembly: AssemblyFixture(typeof<FSharpTestAssemblyFixture>)>] below.
/// The constructor is called by xUnit once before any tests in the assembly run.
type FSharpTestAssemblyFixture() =
do
#if !NETCOREAPP
// On .NET Framework, we need the assembly resolver for finding assemblies
// that might be in different locations (e.g., when FSI loads assemblies)
// We need AssemblyResolver already here, because OpenTelemetry loads some assemblies dynamically.
log "Adding AssemblyResolver"
AssemblyResolver.addResolver()
#endif
log $"Server GC enabled: {Runtime.GCSettings.IsServerGC}"
log "Installing TestConsole redirection"
TestConsole.install()
)

/// Call this to ensure TestConsole is installed. Safe to call multiple times.
let initialize() = ensureInitialized.Force()
logConfig initialConfig

/// Exclude from parallelization. Execute test cases in sequence and do not run any other collections at the same time.
/// see https://github.com/xunit/xunit/issues/1999#issuecomment-522635397
[<CollectionDefinition(nameof NotThreadSafeResourceCollection, DisableParallelization = true)>]
type NotThreadSafeResourceCollection() = class end

/// Mark test cases as not safe to run in parallel with other test cases of the same test collection.
/// In case Xunit 3 enables internal parallelization of test collections.
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Method, AllowMultiple = false)>]
type RunTestCasesInSequenceAttribute() = inherit Attribute()

module XUnitSetup =

// NOTE: Custom TestFramework temporarily disabled due to xUnit3 API incompatibilities
// TODO: Reimplement FSharpXunitFramework for xUnit3 if needed
// [<assembly: TestFramework("FSharp.Test.FSharpXunitFramework", "FSharp.Test.Utilities")>]

// NOTE: CaptureTrace is disabled because it conflicts with TestConsole.ExecutionCapture
// which is used by FSI tests to capture console output. xUnit3's trace capture intercepts
// console output before it can reach TestConsole's redirectors.
// [<assembly: CaptureTrace>]

/// Call this to ensure TestConsole is installed. Safe to call multiple times.
let initialize() = XUnitInit.initialize()

// Force initialization when module is loaded
do initialize()

[<assembly: AssemblyFixture(typeof<FSharpTestAssemblyFixture>)>]
do ()
7 changes: 0 additions & 7 deletions tests/fsharp/FSharpSuite.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@
<EmbeddedResource Remove="**" />
</ItemGroup>

<!-- xUnit3 configuration for this test project (MTP mode) -->
<ItemGroup>
<Content Include="testconfig.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Build\FSharp.Build.fsproj" />
<ProjectReference Include="$(FSharpSourcesRoot)\Compiler\FSharp.Compiler.Service.fsproj" />
Expand Down
6 changes: 0 additions & 6 deletions tests/fsharp/testconfig.json

This file was deleted.

Loading