Skip to content
Merged
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
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/ILChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open TestFramework

[<RequireQualifiedAccess>]
module ILChecker =
let config = initializeSuite ()
let config = initialConfig

let private exec exe args =
let arguments = args |> String.concat " "
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/ILVerifierModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open TestFramework

[<AutoOpen>]
module ILVerifierModule =
let config = initializeSuite ()
let config = initialConfig

let fsharpCoreReference = $"--reference \"{typeof<unit>.Assembly.Location}\""

Expand Down
15 changes: 4 additions & 11 deletions tests/FSharp.Test.Utilities/TestFramework.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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 =
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/Utilities.fs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module Utilities =
[<RequireQualifiedAccess>]
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 = """
Expand Down
25 changes: 14 additions & 11 deletions tests/FSharp.Test.Utilities/XunitHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}

Expand Down
10 changes: 1 addition & 9 deletions tests/scripts/scriptlib.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

[<AutoOpen>]
module Scripting =

Expand Down Expand Up @@ -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

Expand Down