Compare commits

..

2 Commits

Author SHA1 Message Date
Smaug123
71d340d33a Sigh, probably not worth it 2024-06-23 19:16:20 +01:00
Smaug123
c09eb93b5e Add failing test 2024-06-23 18:40:27 +01:00
8 changed files with 65 additions and 20 deletions

View File

@@ -297,7 +297,7 @@ jobs:
name: nuget-package-lib
path: packed
- name: Attest Build Provenance
uses: actions/attest-build-provenance@bdd51370e0416ac948727f861e03c2f05d32d78e # v1.3.2
uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
with:
subject-path: "packed/*.nupkg"
@@ -316,7 +316,7 @@ jobs:
name: nuget-package-tool
path: packed
- name: Attest Build Provenance
uses: actions/attest-build-provenance@bdd51370e0416ac948727f861e03c2f05d32d78e # v1.3.2
uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
with:
subject-path: "packed/*.nupkg"
@@ -358,7 +358,7 @@ jobs:
run: 'bash ./.github/workflows/assert-contents.sh'
- name: Attest Build Provenance
if: steps.publish-success.outputs.result == 'published'
uses: actions/attest-build-provenance@bdd51370e0416ac948727f861e03c2f05d32d78e # v1.3.2
uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
with:
subject-path: "from-nuget.nupkg"
@@ -400,7 +400,7 @@ jobs:
run: 'bash ./.github/workflows/assert-contents.sh'
- name: Attest Build Provenance
if: steps.publish-success.outputs.result == 'published'
uses: actions/attest-build-provenance@bdd51370e0416ac948727f861e03c2f05d32d78e # v1.3.2
uses: actions/attest-build-provenance@897ed5eab6ed058a474202017ada7f40bfa52940 # v1.0.0
with:
subject-path: "from-nuget.nupkg"

View File

@@ -10,6 +10,7 @@
<Compile Include="NoAttribute.fs" />
<Compile Include="Inconclusive.fs" />
<Compile Include="RunSubProcess.fs" />
<Compile Include="TestContext.fs" />
<Compile Include="TestNonParallel.fs" />
<Compile Include="TestParallel.fs" />
<Compile Include="TestStdout.fs" />

27
Consumer/TestContext.fs Normal file
View File

@@ -0,0 +1,27 @@
namespace Consumer
open FsUnitTyped
open NUnit.Framework
[<TestFixture>]
module TestContext =
[<TestCase 3>]
let ``Context has appropriate values`` (i : int) =
// We explicitly cannot support this (https://github.com/dotnet/dotnet-api-docs/pull/3869/files).
// TestContext.Progress.WriteLine "hi!"
TestContext.CurrentContext.Test.MethodName
|> shouldEqual "Context has appropriate values"
TestContext.CurrentContext.Test.Name
|> shouldEqual "Context has appropriate values(3)"
TestContext.CurrentContext.Test.Namespace |> shouldEqual "Consumer"
TestContext.CurrentContext.Test.ClassName |> shouldEqual "Consumer.TestContext"
TestContext.CurrentContext.Test.FullName
|> shouldEqual "Consumer.TestContext.Context has appropriate values(3)"
i |> shouldEqual 3
TestContext.CurrentContext.Test.Arguments |> List.ofArray |> shouldEqual [ 3 ]

View File

@@ -14,3 +14,8 @@ However, we would recommend phrasing some of them differently, for maximum peace
WoofWare.NUnitTestRunner has *limited* support for parallelism.
By default, we run tests serially; we may or may not respect the NUnit parallelism attributes to any given extent (but we will never incorrectly run tests in parallel).
For example, as of this writing, we do not run any tests in parallel (but the internal infrastructure is set up so that we will be able to do this soon).
## `TestContext`
WoofWare.NUnitTestRunner has partial support for NUnit's `TestContext`.
See [the test file](./Consumer/TestContext.fs) for everything we expect to work.

View File

@@ -14,7 +14,7 @@
<PackageId>WoofWare.NUnitTestRunner.Lib</PackageId>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarnOn>FS3559</WarnOn>
<WoofWareMyriadPluginVersion>2.1.51</WoofWareMyriadPluginVersion>
<WoofWareMyriadPluginVersion>2.1.45</WoofWareMyriadPluginVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -71,6 +71,18 @@ public class StartupHookLogic
using var contexts = TestContexts.Empty();
Console.SetOut(contexts.Stdout);
Console.SetError(contexts.Stderr);
var nunitAssembly = Assembly.Load("NUnit.Framework");
if (object.ReferenceEquals(nunitAssembly, null))
{
throw new Exception("Could not load NUnit.Framework");
}
var testContext = nunitAssembly.DefinedTypes.First(t => t.FullName == "NUnit.Framework.TestContext") ?? throw new Exception("Could not find TestContext type");
var currentContextField = testContext.GetField("CurrentContext", BindingFlags.Static | BindingFlags.Public) ?? throw new Exception("Could not find CurrentContext field on TestContext");
var currentContext = currentContextField.GetValue(null) ?? throw new Exception("Could not obtain value of CurrentContext");
currentContextField.SetValue(currentContext, currentContext);
var results =
Task.WhenAll(testFixtures.Select(x =>
TestFixtureModule.run(contexts, par, TestProgress.toWriter(normalErr), filter, x)));

View File

@@ -16,7 +16,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ApiSurface" Version="4.0.42" />
<PackageReference Include="ApiSurface" Version="4.0.41" />
<PackageReference Include="FsCheck" Version="3.0.0-rc3" />
<PackageReference Include="FsUnit" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />

View File

@@ -3,8 +3,8 @@
{fetchNuGet}: [
(fetchNuGet {
pname = "ApiSurface";
version = "4.0.42";
sha256 = "0azjv64bbbhc4rndbjhcmqxxg1bkf1v3ym3x34zmsbz0lr1hy6pv";
version = "4.0.41";
sha256 = "03kfa5ngmgkik9lc58sp8s9rrh9g40hhgjnrv662ks0d0y2i9i89";
})
(fetchNuGet {
pname = "fantomas";
@@ -153,23 +153,23 @@
})
(fetchNuGet {
pname = "NuGet.Common";
version = "6.10.1";
sha256 = "1z69k0j727jcwrxzmvnixdac84lb9706iabqs8mrns8j7kbmw1ns";
version = "6.10.0";
sha256 = "0nizrnilmlcqbm945293h8q3wfqfchb4xi8g50x4kjn0rbpd1kbh";
})
(fetchNuGet {
pname = "NuGet.Configuration";
version = "6.10.1";
sha256 = "0qy2bdi3dz6fdw7qbv77fg956idm9d9733j8b1pcrcj9pfayys26";
version = "6.10.0";
sha256 = "1aqaknaawnqx4mnvx9qw73wvj48jjzv0d78dzwl7m9zjlrl9myhz";
})
(fetchNuGet {
pname = "NuGet.Frameworks";
version = "6.10.1";
sha256 = "1p8d701fhbqv2r8vqmj948af9xvz2fd3273803cdrjy3a2wykmq1";
version = "6.10.0";
sha256 = "0hrd8y31zx9a0wps49czw0qgbrakb49zn3abfgylc9xrq990zkqk";
})
(fetchNuGet {
pname = "NuGet.Packaging";
version = "6.10.1";
sha256 = "0zl8xfzvd1yij2ln6iwy6cz8qfwlbyyqlin872ab5y58ws61a2x2";
version = "6.10.0";
sha256 = "18s53cvrf51lihmaqqdf48p2qi6ky1l48jv0hvbp76cxwdg7rba4";
})
(fetchNuGet {
pname = "NuGet.Protocol";
@@ -178,8 +178,8 @@
})
(fetchNuGet {
pname = "NuGet.Versioning";
version = "6.10.1";
sha256 = "0lji7g6abnpmhzlgvni8wlb7l62n4180v3sphp4494wi0gn7ds4c";
version = "6.10.0";
sha256 = "1x19njx4x0sw9fz8y5fibi15xfsrw5avir0cx0599yd7p3ykik5g";
})
(fetchNuGet {
pname = "NUnit";
@@ -253,8 +253,8 @@
})
(fetchNuGet {
pname = "WoofWare.Myriad.Plugins";
version = "2.1.51";
sha256 = "1pdzdnjvq0a2gnbbz5gy9fzvxkyg6nl6x1k68xkm2a6gdkhkf68z";
version = "2.1.45";
sha256 = "1i9s9aq8dqnxyn01sa10dd24y9i7cgv2d0rshmrkvbvbjkcnz9vs";
})
(fetchNuGet {
pname = "WoofWare.Myriad.Plugins.Attributes";