diff --git a/tests/FSharp.Test.Utilities/ILChecker.fs b/tests/FSharp.Test.Utilities/ILChecker.fs index b47ae4409f0..69b5d6c6c6a 100644 --- a/tests/FSharp.Test.Utilities/ILChecker.fs +++ b/tests/FSharp.Test.Utilities/ILChecker.fs @@ -11,7 +11,7 @@ open TestFramework [] module ILChecker = - let config = initializeSuite () + let config = initialConfig let private exec exe args = let arguments = args |> String.concat " " diff --git a/tests/FSharp.Test.Utilities/ILVerifierModule.fs b/tests/FSharp.Test.Utilities/ILVerifierModule.fs index 8610476f217..799af017e6a 100644 --- a/tests/FSharp.Test.Utilities/ILVerifierModule.fs +++ b/tests/FSharp.Test.Utilities/ILVerifierModule.fs @@ -8,7 +8,7 @@ open TestFramework [] module ILVerifierModule = - let config = initializeSuite () + let config = initialConfig let fsharpCoreReference = $"--reference \"{typeof.Assembly.Location}\"" diff --git a/tests/FSharp.Test.Utilities/TestFramework.fs b/tests/FSharp.Test.Utilities/TestFramework.fs index 06b454005c2..768203aa887 100644 --- a/tests/FSharp.Test.Utilities/TestFramework.fs +++ b/tests/FSharp.Test.Utilities/TestFramework.fs @@ -410,7 +410,7 @@ let logConfig (cfg: TestConfig) = log "FSCOREDLLPATH = %s" cfg.FSCOREDLLPATH log "FSI = %s" cfg.FSI #if NETCOREAPP - log "DotNetExe =%s" cfg.DotNetExe + log "DotNetExe = %s" cfg.DotNetExe log "DOTNET_MULTILEVEL_LOOKUP = %s" cfg.DotNetMultiLevelLookup log "DOTNET_ROOT = %s" cfg.DotNetRoot #else @@ -447,7 +447,7 @@ let envVars () = |> Seq.map (fun d -> d.Key :?> string, d.Value :?> string) |> Map.ofSeq -let initializeSuite () = +let initialConfig = #if DEBUG let configurationName = "Debug" @@ -461,15 +461,9 @@ let initializeSuite () = let usedEnvVars = c.EnvironmentVariables |> Map.add "FSC" c.FSC { c with EnvironmentVariables = usedEnvVars } - logConfig cfg - cfg - -let suiteHelpers = lazy (initializeSuite ()) - let testConfig sourceDir (relativePathToTestFixture: string) = - let cfg = suiteHelpers.Value let testFixtureFullPath = Path.GetFullPath(sourceDir ++ relativePathToTestFixture) let tempTestDir = @@ -478,11 +472,10 @@ let testConfig sourceDir (relativePathToTestFixture: string) = .FullName copyDirectory testFixtureFullPath tempTestDir true - { cfg with Directory = tempTestDir } + { initialConfig with Directory = tempTestDir } let createConfigWithEmptyDirectory() = - let cfg = suiteHelpers.Value - { cfg with Directory = createTemporaryDirectory().FullName } + { initialConfig with Directory = createTemporaryDirectory().FullName } type RedirectToType = | Overwrite of FilePath diff --git a/tests/FSharp.Test.Utilities/Utilities.fs b/tests/FSharp.Test.Utilities/Utilities.fs index fec1da0895c..06667fadfaf 100644 --- a/tests/FSharp.Test.Utilities/Utilities.fs +++ b/tests/FSharp.Test.Utilities/Utilities.fs @@ -138,7 +138,7 @@ module Utilities = [] module public TargetFrameworkUtil = - let private config = TestFramework.initializeSuite () + let private config = initialConfig // Do a one time dotnet sdk build to compute the proper set of reference assemblies to pass to the compiler let private projectFile = """ diff --git a/tests/FSharp.Test.Utilities/XunitHelpers.fs b/tests/FSharp.Test.Utilities/XunitHelpers.fs index ce4d47b9635..ac23217c1ed 100644 --- a/tests/FSharp.Test.Utilities/XunitHelpers.fs +++ b/tests/FSharp.Test.Utilities/XunitHelpers.fs @@ -29,7 +29,8 @@ type FSharpXunitFramework(sink: IMessageSink) = // Because xUnit v2 lacks assembly fixture, the next best place to ensure things get called // right at the start of the test run is here in the constructor. // This gets executed once per test assembly. - MessageSink.sinkWriter |> ignore + logConfig initialConfig + log "FSharpXunitFramework installing TestConsole redirection" TestConsole.install() #if !NETCOREAPP AssemblyResolver.addResolver () @@ -144,16 +145,6 @@ type CustomTheoryTestCase = /// `XunitTestFramework` providing parallel console support and conditionally enabling optional xUnit customizations. type FSharpXunitFramework(sink: IMessageSink) = inherit XunitTestFramework(sink) - do - // Because xUnit v2 lacks assembly fixture, the next best place to ensure things get called - // right at the start of the test run is here in the constructor. - // This gets executed once per test assembly. - log "FSharpXunitFramework with XUNIT_EXTRAS installing TestConsole redirection" - TestConsole.install() - -#if !NETCOREAPP - AssemblyResolver.addResolver () -#endif let traceProvider = Sdk.CreateTracerProviderBuilder() @@ -176,6 +167,18 @@ type FSharpXunitFramework(sink: IMessageSink) = { new XunitTestFrameworkExecutor(assemblyName, this.SourceInformationProvider, this.DiagnosticMessageSink) with override _.RunTestCases(testCases, executionMessageSink, executionOptions) = use _ = Activity.start $"{assemblyName.Name} {Runtime.InteropServices.RuntimeInformation.FrameworkDescription}" [] + + // Because xUnit v2 lacks assembly fixture, the next best place to ensure things get called + // right at the start of the test run is here or in the FSharpXunitFramework constructor. + // This gets executed once per test assembly. + printfn $"Running tests in {assemblyName.Name} with XUNIT_EXTRAS" + logConfig initialConfig + log "Installing TestConsole redirection" + TestConsole.install() + +#if !NETCOREAPP + AssemblyResolver.addResolver () +#endif base.RunTestCases(testCases, executionMessageSink, executionOptions) } diff --git a/tests/scripts/scriptlib.fsx b/tests/scripts/scriptlib.fsx index ea1a5a63737..3f93a93b82c 100644 --- a/tests/scripts/scriptlib.fsx +++ b/tests/scripts/scriptlib.fsx @@ -10,14 +10,6 @@ open System.IO open System.Text open System.Diagnostics -module MessageSink = - let sinkWriter = -#if DEBUG - Console.Out -#else - TextWriter.Null -#endif - [] module Scripting = @@ -85,7 +77,7 @@ module Scripting = if Directory.Exists output then Directory.Delete(output, true) - let log format = fprintfn MessageSink.sinkWriter format + let log format = printfn format type FilePath = string