mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-05 17:38:40 +00:00
Compare commits
3 Commits
WoofWare.N
...
WoofWare.N
Author | SHA1 | Date | |
---|---|---|---|
|
13f636df3d | ||
|
eed076cad5 | ||
|
df64e46079 |
@@ -10,6 +10,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="NoAttribute.fs" />
|
||||
<Compile Include="Inconclusive.fs" />
|
||||
<Compile Include="TestParameterisedFixture.fs" />
|
||||
<Compile Include="TestSetUp.fs" />
|
||||
<Compile Include="TestValues.fs" />
|
||||
<None Include="some-config.json">
|
||||
|
18
Consumer/TestParameterisedFixture.fs
Normal file
18
Consumer/TestParameterisedFixture.fs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace Consumer
|
||||
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
|
||||
[<TestFixture true>]
|
||||
[<TestFixture false>]
|
||||
type TestParameterisedFixture (v : bool) =
|
||||
[<Test>]
|
||||
member _.Thing () = v |> shouldEqual v
|
||||
|
||||
[<TestFixture(3, true)>]
|
||||
[<TestFixture(6, false)>]
|
||||
type TestParameterisedFixtureMultiple (i : int, v : bool) =
|
||||
[<Test>]
|
||||
member _.Thing () =
|
||||
v |> shouldEqual v
|
||||
i |> shouldEqual i
|
@@ -1,5 +1,6 @@
|
||||
namespace WoofWare.NUnitTestRunner
|
||||
|
||||
open System
|
||||
open System.Reflection
|
||||
|
||||
/// A modifier on whether a given test should be run.
|
||||
@@ -62,6 +63,8 @@ type TestFixture =
|
||||
/// Fully-qualified name of this fixture (e.g. MyThing.Test.Foo for `[<TestFixture>] module Foo` in the
|
||||
/// `MyThing.Test` assembly).
|
||||
Name : string
|
||||
/// The type which is this fixture, containing the tests as members.
|
||||
Type : Type
|
||||
/// A method which is run once when this test fixture starts, before any other setup logic and before
|
||||
/// any tests run. If this method fails, no tests will run and no per-test setup/teardown logic will run,
|
||||
/// but OneTimeTearDown will run.
|
||||
@@ -77,19 +80,24 @@ type TestFixture =
|
||||
/// Methods which are run in some arbitrary order after each individual test, even if the test or its setup
|
||||
/// failed. If the first TearDown we run fails, we don't define whether the other TearDowns run.
|
||||
TearDown : MethodInfo list
|
||||
/// You might have defined e.g. `[<TestFixture true>] type Foo (v : bool) = ...`. If so, this gives the
|
||||
/// various possible parameters.
|
||||
Parameters : obj list list
|
||||
/// The individual test methods present within this fixture.
|
||||
Tests : SingleTestMethod list
|
||||
}
|
||||
|
||||
/// A test fixture about which we know nothing. No tests, no setup/teardown.
|
||||
static member Empty (containingAssembly : Assembly) (name : string) =
|
||||
static member Empty (ty : Type) (args : obj list list) =
|
||||
{
|
||||
ContainingAssembly = containingAssembly
|
||||
Name = name
|
||||
ContainingAssembly = ty.Assembly
|
||||
Type = ty
|
||||
Name = ty.Name
|
||||
OneTimeSetUp = None
|
||||
OneTimeTearDown = None
|
||||
SetUp = []
|
||||
TearDown = []
|
||||
Parameters = args
|
||||
Tests = []
|
||||
}
|
||||
|
||||
|
104
WoofWare.NUnitTestRunner.Lib/DotnetRuntime.fs
Normal file
104
WoofWare.NUnitTestRunner.Lib/DotnetRuntime.fs
Normal file
@@ -0,0 +1,104 @@
|
||||
namespace WoofWare.NUnitTestRunner
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open WoofWare.DotnetRuntimeLocator
|
||||
|
||||
/// Functions for locating .NET runtimes.
|
||||
[<RequireQualifiedAccess>]
|
||||
module DotnetRuntime =
|
||||
let private selectRuntime
|
||||
(config : RuntimeOptions)
|
||||
(f : DotnetEnvironmentInfo)
|
||||
: Choice<DotnetEnvironmentFrameworkInfo, DotnetEnvironmentSdkInfo> option
|
||||
=
|
||||
let rollForward =
|
||||
match Environment.GetEnvironmentVariable "DOTNET_ROLL_FORWARD" with
|
||||
| null ->
|
||||
config.RollForward
|
||||
|> Option.map RollForward.Parse
|
||||
|> Option.defaultValue RollForward.Minor
|
||||
| s -> RollForward.Parse s
|
||||
|
||||
let desiredVersions =
|
||||
match config.Framework with
|
||||
| Some f -> [ Version f.Version, f.Name ]
|
||||
| None ->
|
||||
|
||||
match config.Frameworks with
|
||||
| Some f -> f |> List.map (fun f -> Version f.Version, f.Name)
|
||||
| None ->
|
||||
failwith
|
||||
"Could not deduce a framework version due to lack of either Framework or Frameworks in runtimeconfig"
|
||||
|
||||
let compatiblyNamedRuntimes =
|
||||
f.Frameworks
|
||||
|> Seq.collect (fun availableFramework ->
|
||||
desiredVersions
|
||||
|> List.choose (fun (desiredVersion, desiredName) ->
|
||||
if desiredName = availableFramework.Name then
|
||||
Some
|
||||
{|
|
||||
Desired = desiredVersion
|
||||
Name = desiredName
|
||||
Installed = availableFramework
|
||||
InstalledVersion = Version availableFramework.Version
|
||||
|}
|
||||
else
|
||||
None
|
||||
)
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
match rollForward with
|
||||
| RollForward.Minor ->
|
||||
let available =
|
||||
compatiblyNamedRuntimes
|
||||
|> Seq.filter (fun data ->
|
||||
data.InstalledVersion.Major = data.Desired.Major
|
||||
&& data.InstalledVersion.Minor >= data.Desired.Minor
|
||||
)
|
||||
|> Seq.groupBy (fun data -> data.Name)
|
||||
|> Seq.map (fun (name, data) ->
|
||||
let data =
|
||||
data
|
||||
|> Seq.minBy (fun data -> data.InstalledVersion.Minor, data.InstalledVersion.Build)
|
||||
|
||||
name, data.Installed
|
||||
)
|
||||
// TODO: how do we select between many available frameworks?
|
||||
|> Seq.tryHead
|
||||
|
||||
match available with
|
||||
| Some (_, f) -> Some (Choice1Of2 f)
|
||||
| None ->
|
||||
// TODO: maybe we can ask the SDK. But we keep on trucking: maybe we're self-contained,
|
||||
// and we'll actually find all the runtime next to the DLL.
|
||||
None
|
||||
| _ -> failwith "non-minor RollForward not supported yet; please shout if you want it"
|
||||
|
||||
/// Given an executable DLL, locate the .NET runtime that can best run it.
|
||||
let locate (dll : FileInfo) : DirectoryInfo list =
|
||||
let runtimeConfig =
|
||||
let name =
|
||||
if not (dll.Name.EndsWith (".dll", StringComparison.OrdinalIgnoreCase)) then
|
||||
failwith $"Expected DLL %s{dll.FullName} to end in .dll"
|
||||
|
||||
dll.Name.Substring (0, dll.Name.Length - 4)
|
||||
|
||||
Path.Combine (dll.Directory.FullName, $"%s{name}.runtimeconfig.json")
|
||||
|> File.ReadAllText
|
||||
|> System.Text.Json.Nodes.JsonNode.Parse
|
||||
|> RuntimeConfig.jsonParse
|
||||
|> fun f -> f.RuntimeOptions
|
||||
|
||||
let availableRuntimes = DotnetEnvironmentInfo.Get ()
|
||||
|
||||
let runtime = selectRuntime runtimeConfig availableRuntimes
|
||||
|
||||
match runtime with
|
||||
| None ->
|
||||
// Keep on trucking: let's be optimistic and hope that we're self-contained.
|
||||
[ dll.Directory ]
|
||||
| Some (Choice1Of2 runtime) -> [ dll.Directory ; DirectoryInfo $"%s{runtime.Path}/%s{runtime.Version}" ]
|
||||
| Some (Choice2Of2 sdk) -> [ dll.Directory ; DirectoryInfo sdk.Path ]
|
@@ -4,14 +4,14 @@ open System
|
||||
open WoofWare.Myriad.Plugins
|
||||
|
||||
[<JsonParse>]
|
||||
type FrameworkDescription =
|
||||
type internal FrameworkDescription =
|
||||
{
|
||||
Name : string
|
||||
Version : string
|
||||
}
|
||||
|
||||
[<JsonParse>]
|
||||
type RuntimeOptions =
|
||||
type internal RuntimeOptions =
|
||||
{
|
||||
Tfm : string
|
||||
Framework : FrameworkDescription option
|
||||
@@ -20,13 +20,13 @@ type RuntimeOptions =
|
||||
}
|
||||
|
||||
[<JsonParse>]
|
||||
type RuntimeConfig =
|
||||
type internal RuntimeConfig =
|
||||
{
|
||||
RuntimeOptions : RuntimeOptions
|
||||
}
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
type RollForward =
|
||||
type internal RollForward =
|
||||
| Minor
|
||||
| Major
|
||||
| LatestPatch
|
@@ -12,6 +12,8 @@ WoofWare.NUnitTestRunner.Combinatorial.IsCombinatorial [property]: [read-only] b
|
||||
WoofWare.NUnitTestRunner.Combinatorial.IsSequential [property]: [read-only] bool
|
||||
WoofWare.NUnitTestRunner.Combinatorial.Sequential [static property]: [read-only] WoofWare.NUnitTestRunner.Combinatorial
|
||||
WoofWare.NUnitTestRunner.Combinatorial.Tag [property]: [read-only] int
|
||||
WoofWare.NUnitTestRunner.DotnetRuntime inherit obj
|
||||
WoofWare.NUnitTestRunner.DotnetRuntime.locate [static method]: System.IO.FileInfo -> System.IO.DirectoryInfo list
|
||||
WoofWare.NUnitTestRunner.Filter inherit obj, implements WoofWare.NUnitTestRunner.Filter System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.NUnitTestRunner.Filter System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 6 cases
|
||||
WoofWare.NUnitTestRunner.Filter+And inherit WoofWare.NUnitTestRunner.Filter
|
||||
WoofWare.NUnitTestRunner.Filter+And.get_Item1 [method]: unit -> WoofWare.NUnitTestRunner.Filter
|
||||
@@ -185,25 +187,29 @@ WoofWare.NUnitTestRunner.TestFailure.NewTearDownFailed [static method]: WoofWare
|
||||
WoofWare.NUnitTestRunner.TestFailure.NewTestFailed [static method]: WoofWare.NUnitTestRunner.UserMethodFailure -> WoofWare.NUnitTestRunner.TestFailure
|
||||
WoofWare.NUnitTestRunner.TestFailure.Tag [property]: [read-only] int
|
||||
WoofWare.NUnitTestRunner.TestFixture inherit obj, implements WoofWare.NUnitTestRunner.TestFixture System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.NUnitTestRunner.TestFixture..ctor [constructor]: (System.Reflection.Assembly, string, System.Reflection.MethodInfo option, System.Reflection.MethodInfo option, System.Reflection.MethodInfo list, System.Reflection.MethodInfo list, WoofWare.NUnitTestRunner.SingleTestMethod list)
|
||||
WoofWare.NUnitTestRunner.TestFixture..ctor [constructor]: (System.Reflection.Assembly, string, System.Type, System.Reflection.MethodInfo option, System.Reflection.MethodInfo option, System.Reflection.MethodInfo list, System.Reflection.MethodInfo list, obj list list, WoofWare.NUnitTestRunner.SingleTestMethod list)
|
||||
WoofWare.NUnitTestRunner.TestFixture.ContainingAssembly [property]: [read-only] System.Reflection.Assembly
|
||||
WoofWare.NUnitTestRunner.TestFixture.Empty [static method]: System.Reflection.Assembly -> string -> WoofWare.NUnitTestRunner.TestFixture
|
||||
WoofWare.NUnitTestRunner.TestFixture.Empty [static method]: System.Type -> obj list list -> WoofWare.NUnitTestRunner.TestFixture
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_ContainingAssembly [method]: unit -> System.Reflection.Assembly
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_Name [method]: unit -> string
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_OneTimeSetUp [method]: unit -> System.Reflection.MethodInfo option
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_OneTimeTearDown [method]: unit -> System.Reflection.MethodInfo option
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_Parameters [method]: unit -> obj list list
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_SetUp [method]: unit -> System.Reflection.MethodInfo list
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_TearDown [method]: unit -> System.Reflection.MethodInfo list
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_Tests [method]: unit -> WoofWare.NUnitTestRunner.SingleTestMethod list
|
||||
WoofWare.NUnitTestRunner.TestFixture.get_Type [method]: unit -> System.Type
|
||||
WoofWare.NUnitTestRunner.TestFixture.Name [property]: [read-only] string
|
||||
WoofWare.NUnitTestRunner.TestFixture.OneTimeSetUp [property]: [read-only] System.Reflection.MethodInfo option
|
||||
WoofWare.NUnitTestRunner.TestFixture.OneTimeTearDown [property]: [read-only] System.Reflection.MethodInfo option
|
||||
WoofWare.NUnitTestRunner.TestFixture.Parameters [property]: [read-only] obj list list
|
||||
WoofWare.NUnitTestRunner.TestFixture.SetUp [property]: [read-only] System.Reflection.MethodInfo list
|
||||
WoofWare.NUnitTestRunner.TestFixture.TearDown [property]: [read-only] System.Reflection.MethodInfo list
|
||||
WoofWare.NUnitTestRunner.TestFixture.Tests [property]: [read-only] WoofWare.NUnitTestRunner.SingleTestMethod list
|
||||
WoofWare.NUnitTestRunner.TestFixture.Type [property]: [read-only] System.Type
|
||||
WoofWare.NUnitTestRunner.TestFixtureModule inherit obj
|
||||
WoofWare.NUnitTestRunner.TestFixtureModule.parse [static method]: System.Type -> WoofWare.NUnitTestRunner.TestFixture
|
||||
WoofWare.NUnitTestRunner.TestFixtureModule.run [static method]: WoofWare.NUnitTestRunner.ITestProgress -> (WoofWare.NUnitTestRunner.TestFixture -> WoofWare.NUnitTestRunner.SingleTestMethod -> bool) -> WoofWare.NUnitTestRunner.TestFixture -> WoofWare.NUnitTestRunner.FixtureRunResults
|
||||
WoofWare.NUnitTestRunner.TestFixtureModule.run [static method]: WoofWare.NUnitTestRunner.ITestProgress -> (WoofWare.NUnitTestRunner.TestFixture -> WoofWare.NUnitTestRunner.SingleTestMethod -> bool) -> WoofWare.NUnitTestRunner.TestFixture -> WoofWare.NUnitTestRunner.FixtureRunResults list
|
||||
WoofWare.NUnitTestRunner.TestKind inherit obj, implements WoofWare.NUnitTestRunner.TestKind System.IEquatable, System.Collections.IStructuralEquatable - union type with 3 cases
|
||||
WoofWare.NUnitTestRunner.TestKind+Data inherit WoofWare.NUnitTestRunner.TestKind
|
||||
WoofWare.NUnitTestRunner.TestKind+Data.get_Item [method]: unit -> obj list list
|
||||
|
@@ -1,6 +1,7 @@
|
||||
namespace WoofWare.NUnitTestRunner
|
||||
|
||||
open System
|
||||
open System.Collections
|
||||
open System.Diagnostics
|
||||
open System.IO
|
||||
open System.Reflection
|
||||
@@ -415,36 +416,15 @@ module TestFixture =
|
||||
|
||||
/// Run every test (except those which fail the `filter`) in this test fixture, as well as the
|
||||
/// appropriate setup and tear-down logic.
|
||||
let run
|
||||
let private runOneFixture
|
||||
(progress : ITestProgress)
|
||||
(filter : TestFixture -> SingleTestMethod -> bool)
|
||||
(name : string)
|
||||
(containingObject : obj)
|
||||
(tests : TestFixture)
|
||||
: FixtureRunResults
|
||||
=
|
||||
progress.OnTestFixtureStart tests.Name tests.Tests.Length
|
||||
|
||||
let containingObject =
|
||||
let methods =
|
||||
seq {
|
||||
match tests.OneTimeSetUp with
|
||||
| None -> ()
|
||||
| Some t -> yield t
|
||||
|
||||
match tests.OneTimeTearDown with
|
||||
| None -> ()
|
||||
| Some t -> yield t
|
||||
|
||||
yield! tests.Tests |> Seq.map (fun t -> t.Method)
|
||||
}
|
||||
|
||||
methods
|
||||
|> Seq.tryPick (fun mi ->
|
||||
if not mi.IsStatic then
|
||||
Some (Activator.CreateInstance mi.DeclaringType)
|
||||
else
|
||||
None
|
||||
)
|
||||
|> Option.toObj
|
||||
progress.OnTestFixtureStart name tests.Tests.Length
|
||||
|
||||
let oldWorkDir = Environment.CurrentDirectory
|
||||
Environment.CurrentDirectory <- FileInfo(tests.ContainingAssembly.Location).Directory.FullName
|
||||
@@ -470,7 +450,7 @@ module TestFixture =
|
||||
ExecutionId = Guid.NewGuid ()
|
||||
TestId = Guid.NewGuid ()
|
||||
// This one is a bit dubious, because we don't actually have a test name at all
|
||||
TestName = tests.Name
|
||||
TestName = name
|
||||
ClassName = tests.Name
|
||||
StdOut = if String.IsNullOrEmpty stdOut then None else Some stdOut
|
||||
StdErr = if String.IsNullOrEmpty stdErr then None else Some stdErr
|
||||
@@ -540,19 +520,27 @@ module TestFixture =
|
||||
/// Interpret this type as a [<TestFixture>], extracting the test members from it and annotating them with all
|
||||
/// relevant information about how we should run them.
|
||||
let parse (parentType : Type) : TestFixture =
|
||||
if
|
||||
parentType.CustomAttributes
|
||||
|> Seq.exists (fun attr -> attr.AttributeType.FullName = "NUnit.Framework.SetUpFixtureAttribute")
|
||||
then
|
||||
failwith "This test runner does not support SetUpFixture. Please shout if you want this."
|
||||
let categories, args =
|
||||
(([], []), parentType.CustomAttributes)
|
||||
||> Seq.fold (fun (categories, args) attr ->
|
||||
match attr.AttributeType.FullName with
|
||||
| "NUnit.Framework.SetUpFixtureAttribute" ->
|
||||
failwith "This test runner does not support SetUpFixture. Please shout if you want this."
|
||||
| "NUnit.Framework.CategoryAttribute" ->
|
||||
let cat = attr.ConstructorArguments |> Seq.exactlyOne |> _.Value |> unbox<string>
|
||||
cat :: categories, args
|
||||
| "NUnit.Framework.TestFixtureAttribute" ->
|
||||
let newArgs =
|
||||
match attr.ConstructorArguments |> Seq.map _.Value |> Seq.toList with
|
||||
| [ :? ICollection as x ] ->
|
||||
x |> Seq.cast<CustomAttributeTypedArgument> |> Seq.map _.Value |> Seq.toList
|
||||
| xs -> xs
|
||||
|
||||
let categories =
|
||||
parentType.CustomAttributes
|
||||
|> Seq.filter (fun attr -> attr.AttributeType.FullName = "NUnit.Framework.CategoryAttribute")
|
||||
|> Seq.map (fun attr -> attr.ConstructorArguments |> Seq.exactlyOne |> _.Value |> unbox<string>)
|
||||
|> Seq.toList
|
||||
categories, newArgs :: args
|
||||
| _ -> categories, args
|
||||
)
|
||||
|
||||
(TestFixture.Empty parentType.Assembly parentType.Name, parentType.GetRuntimeMethods ())
|
||||
(TestFixture.Empty parentType args, parentType.GetRuntimeMethods ())
|
||||
||> Seq.fold (fun state mi ->
|
||||
((state, []), mi.CustomAttributes)
|
||||
||> Seq.fold (fun (state, unrecognisedAttrs) attr ->
|
||||
@@ -622,3 +610,48 @@ module TestFixture =
|
||||
|
||||
state
|
||||
)
|
||||
|
||||
/// Run every test (except those which fail the `filter`) in this test fixture, as well as the
|
||||
/// appropriate setup and tear-down logic.
|
||||
let run
|
||||
(progress : ITestProgress)
|
||||
(filter : TestFixture -> SingleTestMethod -> bool)
|
||||
(tests : TestFixture)
|
||||
: FixtureRunResults list
|
||||
=
|
||||
match tests.Parameters with
|
||||
| [] -> [ null ]
|
||||
| args -> args |> List.map List.toArray
|
||||
|> List.map (fun args ->
|
||||
let containingObject =
|
||||
let methods =
|
||||
seq {
|
||||
match tests.OneTimeSetUp with
|
||||
| None -> ()
|
||||
| Some t -> yield t
|
||||
|
||||
match tests.OneTimeTearDown with
|
||||
| None -> ()
|
||||
| Some t -> yield t
|
||||
|
||||
yield! tests.Tests |> Seq.map (fun t -> t.Method)
|
||||
}
|
||||
|
||||
methods
|
||||
|> Seq.tryPick (fun mi ->
|
||||
if not mi.IsStatic then
|
||||
Some (Activator.CreateInstance (mi.DeclaringType, args))
|
||||
else
|
||||
None
|
||||
)
|
||||
|> Option.toObj
|
||||
|
||||
let name =
|
||||
if isNull args then
|
||||
tests.Name
|
||||
else
|
||||
let args = args |> Seq.map (fun o -> o.ToString ()) |> String.concat ","
|
||||
$"%s{tests.Name}(%s{args})"
|
||||
|
||||
runOneFixture progress filter name containingObject tests
|
||||
)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<Authors>Patrick Stevens</Authors>
|
||||
<Copyright>Copyright (c) Patrick Stevens 2024</Copyright>
|
||||
@@ -14,10 +14,16 @@
|
||||
<PackageId>WoofWare.NUnitTestRunner.Lib</PackageId>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarnOn>FS3559</WarnOn>
|
||||
<WoofWareMyriadPluginVersion>2.1.44</WoofWareMyriadPluginVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<Compile Include="RuntimeConfig.fs" />
|
||||
<Compile Include="GeneratedRuntimeConfig.fs">
|
||||
<MyriadFile>RuntimeConfig.fs</MyriadFile>
|
||||
</Compile>
|
||||
<Compile Include="DotnetRuntime.fs" />
|
||||
<Compile Include="Array.fs" />
|
||||
<Compile Include="List.fs" />
|
||||
<Compile Include="Result.fs" />
|
||||
@@ -38,6 +44,14 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="WoofWare.PrattParser" Version="0.1.2" />
|
||||
<PackageReference Update="FSharp.Core" Version="6.0.0" />
|
||||
<PackageReference Include="WoofWare.DotnetRuntimeLocator" Version="0.1.4" />
|
||||
<PackageReference Include="WoofWare.Myriad.Plugins.Attributes" Version="3.1.6" />
|
||||
<PackageReference Include="Myriad.SDK" Version="0.8.3" />
|
||||
<PackageReference Include="WoofWare.Myriad.Plugins" Version="$(WoofWareMyriadPluginVersion)" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MyriadSdkGenerator Include="$(NuGetPackageRoot)/woofware.myriad.plugins/$(WoofWareMyriadPluginVersion)/lib/net6.0/WoofWare.Myriad.Plugins.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
0
WoofWare.NUnitTestRunner.Lib/myriad.toml
Normal file
0
WoofWare.NUnitTestRunner.Lib/myriad.toml
Normal file
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.8",
|
||||
"version": "0.10",
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/main$"
|
||||
],
|
||||
@@ -8,4 +8,4 @@
|
||||
":/Directory.Build.props",
|
||||
":/README.md"
|
||||
]
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
namespace WoofWare.NUnitTestRunner
|
||||
|
||||
open System
|
||||
open WoofWare.DotnetRuntimeLocator
|
||||
open System.IO
|
||||
open System.Reflection
|
||||
open System.Runtime.Loader
|
||||
@@ -41,101 +40,6 @@ type Ctx (dll : FileInfo, runtimes : DirectoryInfo list) =
|
||||
|
||||
|
||||
module Program =
|
||||
let selectRuntime
|
||||
(config : RuntimeOptions)
|
||||
(f : DotnetEnvironmentInfo)
|
||||
: Choice<DotnetEnvironmentFrameworkInfo, DotnetEnvironmentSdkInfo> option
|
||||
=
|
||||
let rollForward =
|
||||
match Environment.GetEnvironmentVariable "DOTNET_ROLL_FORWARD" with
|
||||
| null ->
|
||||
config.RollForward
|
||||
|> Option.map RollForward.Parse
|
||||
|> Option.defaultValue RollForward.Minor
|
||||
| s -> RollForward.Parse s
|
||||
|
||||
let desiredVersions =
|
||||
match config.Framework with
|
||||
| Some f -> [ Version f.Version, f.Name ]
|
||||
| None ->
|
||||
|
||||
match config.Frameworks with
|
||||
| Some f -> f |> List.map (fun f -> Version f.Version, f.Name)
|
||||
| None ->
|
||||
failwith
|
||||
"Could not deduce a framework version due to lack of either Framework or Frameworks in runtimeconfig"
|
||||
|
||||
let compatiblyNamedRuntimes =
|
||||
f.Frameworks
|
||||
|> Seq.collect (fun availableFramework ->
|
||||
desiredVersions
|
||||
|> List.choose (fun (desiredVersion, desiredName) ->
|
||||
if desiredName = availableFramework.Name then
|
||||
Some
|
||||
{|
|
||||
Desired = desiredVersion
|
||||
Name = desiredName
|
||||
Installed = availableFramework
|
||||
InstalledVersion = Version availableFramework.Version
|
||||
|}
|
||||
else
|
||||
None
|
||||
)
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
match rollForward with
|
||||
| RollForward.Minor ->
|
||||
let available =
|
||||
compatiblyNamedRuntimes
|
||||
|> Seq.filter (fun data ->
|
||||
data.InstalledVersion.Major = data.Desired.Major
|
||||
&& data.InstalledVersion.Minor >= data.Desired.Minor
|
||||
)
|
||||
|> Seq.groupBy (fun data -> data.Name)
|
||||
|> Seq.map (fun (name, data) ->
|
||||
let data =
|
||||
data
|
||||
|> Seq.minBy (fun data -> data.InstalledVersion.Minor, data.InstalledVersion.Build)
|
||||
|
||||
name, data.Installed
|
||||
)
|
||||
// TODO: how do we select between many available frameworks?
|
||||
|> Seq.tryHead
|
||||
|
||||
match available with
|
||||
| Some (_, f) -> Some (Choice1Of2 f)
|
||||
| None ->
|
||||
// TODO: maybe we can ask the SDK. But we keep on trucking: maybe we're self-contained,
|
||||
// and we'll actually find all the runtime next to the DLL.
|
||||
None
|
||||
| _ -> failwith "non-minor RollForward not supported yet; please shout if you want it"
|
||||
|
||||
let locateRuntimes (dll : FileInfo) : DirectoryInfo list =
|
||||
let runtimeConfig =
|
||||
let name =
|
||||
if not (dll.Name.EndsWith (".dll", StringComparison.OrdinalIgnoreCase)) then
|
||||
failwith $"Expected DLL %s{dll.FullName} to end in .dll"
|
||||
|
||||
dll.Name.Substring (0, dll.Name.Length - 4)
|
||||
|
||||
Path.Combine (dll.Directory.FullName, $"%s{name}.runtimeconfig.json")
|
||||
|> File.ReadAllText
|
||||
|> System.Text.Json.Nodes.JsonNode.Parse
|
||||
|> RuntimeConfig.jsonParse
|
||||
|> fun f -> f.RuntimeOptions
|
||||
|
||||
let availableRuntimes = DotnetEnvironmentInfo.Get ()
|
||||
|
||||
let runtime = selectRuntime runtimeConfig availableRuntimes
|
||||
|
||||
match runtime with
|
||||
| None ->
|
||||
// Keep on trucking: let's be optimistic and hope that we're self-contained.
|
||||
[ dll.Directory ]
|
||||
| Some (Choice1Of2 runtime) -> [ dll.Directory ; DirectoryInfo $"%s{runtime.Path}/%s{runtime.Version}" ]
|
||||
| Some (Choice2Of2 sdk) -> [ dll.Directory ; DirectoryInfo sdk.Path ]
|
||||
|
||||
let main argv =
|
||||
let startTime = DateTimeOffset.Now
|
||||
|
||||
@@ -161,13 +65,13 @@ module Program =
|
||||
|
||||
use _ = new SetBaseDir (testDll)
|
||||
|
||||
let ctx = Ctx (testDll, locateRuntimes testDll)
|
||||
let ctx = Ctx (testDll, DotnetRuntime.locate testDll)
|
||||
let assy = ctx.LoadFromAssemblyPath testDll.FullName
|
||||
|
||||
let testFixtures = assy.ExportedTypes |> Seq.map TestFixture.parse |> Seq.toList
|
||||
|
||||
let creationTime = DateTimeOffset.Now
|
||||
let results = testFixtures |> List.map (TestFixture.run progress filter)
|
||||
let results = testFixtures |> List.collect (TestFixture.run progress filter)
|
||||
|
||||
let finishTime = DateTimeOffset.Now
|
||||
let finishTimeHumanReadable = finishTime.ToString @"yyyy-MM-dd HH:mm:ss"
|
||||
|
@@ -11,6 +11,8 @@ module TestList =
|
||||
[<Test>]
|
||||
let ``combinations has right size`` () =
|
||||
let property (xs : int list list) =
|
||||
let xs = if xs.Length > 6 then xs |> List.take 6 else xs
|
||||
let xs = xs |> List.map (fun xs -> if xs.Length > 6 then xs |> List.take 6 else xs)
|
||||
let combs = List.combinations xs
|
||||
|
||||
combs.Length
|
||||
|
@@ -16,14 +16,9 @@
|
||||
<PackageId>WoofWare.NUnitTestRunner</PackageId>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarnOn>FS3559</WarnOn>
|
||||
<WoofWareMyriadPluginVersion>2.1.42</WoofWareMyriadPluginVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="RuntimeConfig.fs" />
|
||||
<Compile Include="GeneratedRuntimeConfig.fs">
|
||||
<MyriadFile>RuntimeConfig.fs</MyriadFile>
|
||||
</Compile>
|
||||
<Compile Include="Seq.fs" />
|
||||
<Compile Include="Progress.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
@@ -39,14 +34,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Spectre.Console" Version="0.49.1" />
|
||||
<PackageReference Include="WoofWare.DotnetRuntimeLocator" Version="0.1.4" />
|
||||
<PackageReference Include="WoofWare.Myriad.Plugins.Attributes" Version="3.1.6" />
|
||||
<PackageReference Include="Myriad.SDK" Version="0.8.3" />
|
||||
<PackageReference Include="WoofWare.Myriad.Plugins" Version="$(WoofWareMyriadPluginVersion)" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MyriadSdkGenerator Include="$(NuGetPackageRoot)/woofware.myriad.plugins/$(WoofWareMyriadPluginVersion)/lib/net6.0/WoofWare.Myriad.Plugins.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -5,6 +5,7 @@
|
||||
],
|
||||
"pathFilters": [
|
||||
"./",
|
||||
"^./WoofWare.NUnitTestRunner.Test",
|
||||
":/WoofWare.NUnitTestRunner.Lib",
|
||||
":/Directory.Build.props",
|
||||
":/README.md"
|
||||
|
79
nix/deps.nix
79
nix/deps.nix
@@ -36,6 +36,31 @@
|
||||
version = "6.0.0";
|
||||
sha256 = "18q3p0z155znwj1l0qq3vq9nh9wl2i4mlfx4pmrnia4czr0xdkmb";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.AspNetCore.App.Ref";
|
||||
version = "6.0.30";
|
||||
sha256 = "17k3l8xd5bsyk69bm5q4nxbpb4i0izw1kzmzi7j3p8pmm9prgrpy";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64";
|
||||
version = "6.0.30";
|
||||
sha256 = "1n4v5przbrjhzj01b6qijpdc2jbsxr66ijvd0483qxh4s0b4jppr";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.AspNetCore.App.Runtime.linux-x64";
|
||||
version = "6.0.30";
|
||||
sha256 = "18v0l07q74m5xxaf6y6dkmr6and8ivya0nslffnr4djrxcbiygdr";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64";
|
||||
version = "6.0.30";
|
||||
sha256 = "0p53lyqmr5n2ym202pbgmsd9b9aa6jar7ic04dcq86h2g77r5jqk";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.AspNetCore.App.Runtime.osx-x64";
|
||||
version = "6.0.30";
|
||||
sha256 = "009srl8vazkjnd93xr6k1m353spbki9gn1yzp4zgazgbrini6rqc";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.CodeCoverage";
|
||||
version = "17.10.0";
|
||||
@@ -46,6 +71,51 @@
|
||||
version = "17.10.0";
|
||||
sha256 = "13g8fwl09li8fc71nk13dgkb7gahd4qhamyg2xby7am63nlchhdf";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Host.linux-arm64";
|
||||
version = "6.0.30";
|
||||
sha256 = "0l3gjhmnjd5n67w83smqyhmfcwzszafjgcbq8kdwxiwwh2m6nh2i";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Host.linux-x64";
|
||||
version = "6.0.30";
|
||||
sha256 = "0ss3108c2h7afypvliyqixv4dll60sq9iwqy90k1p132znpszrmb";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Host.osx-arm64";
|
||||
version = "6.0.30";
|
||||
sha256 = "08k5v35mvcs712kb0vcfjd1dsas5rgwrmv8rn87mzjb2p6ajl3n3";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Host.osx-x64";
|
||||
version = "6.0.30";
|
||||
sha256 = "02x38c68xan8hlr59mindcl4rcx49bbh4bibh6fw1l4rrijb38lw";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Ref";
|
||||
version = "6.0.30";
|
||||
sha256 = "1wqqjhhlqz4dmijcx3kg3hnwq0s0jzqsddaksskzhq8avr4ziy18";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Runtime.linux-arm64";
|
||||
version = "6.0.30";
|
||||
sha256 = "0xfhcig3gj3986rxp3dhnd8hvnj4nvyhz1fz7kpx342d3g53wb37";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Runtime.linux-x64";
|
||||
version = "6.0.30";
|
||||
sha256 = "1s81sj8lnb8szqawxh3vc8wi815ln12cyhrl3f7hwcpay57xgswx";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Runtime.osx-arm64";
|
||||
version = "6.0.30";
|
||||
sha256 = "0s71k92daakzwish65gmn4nniy6bf2hv34c0sb6m1hv3criqxmp4";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.App.Runtime.osx-x64";
|
||||
version = "6.0.30";
|
||||
sha256 = "0xybqg2wd240r1nm2vrbn2qbfqfnqsmxn1012zzwjn17wa2si9a1";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.NETCore.Platforms";
|
||||
version = "2.0.0";
|
||||
@@ -71,11 +141,6 @@
|
||||
version = "3.6.139";
|
||||
sha256 = "0npcryhq3r0c2zi940jk39h13mzc4hyg7z8gm6jdmxi1aqv1vh8c";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "NETStandard.Library.Ref";
|
||||
version = "2.1.0";
|
||||
sha256 = "12n76gymxq715lkrw841vi5r84kx746cxxssp22pd08as75jzsj6";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Newtonsoft.Json";
|
||||
version = "13.0.1";
|
||||
@@ -188,8 +253,8 @@
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "WoofWare.Myriad.Plugins";
|
||||
version = "2.1.42";
|
||||
sha256 = "0px46m734gsn1xa97111v1nwkyc2j52bw7z4bjdljzkmzzmnqa91";
|
||||
version = "2.1.44";
|
||||
sha256 = "0rp9hpkah60gd9x0ba2izr9ff1g7yhzv5a4pkhi5fbrwf5rpqpwx";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "WoofWare.Myriad.Plugins.Attributes";
|
||||
|
Reference in New Issue
Block a user