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
21 changes: 18 additions & 3 deletions .github/workflows/test-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
# all: PR #131 reported zero. That left every runner regression test inert, including the
# one added in #131 to stop the System.Drawing.Common reference being dropped as unused.
#
# Two jobs, deliberately separate.
# Two jobs and two ComplianceRunner test projects, deliberately separate.
#
# dotnet-tests Hermetic. Checkout, SDK, run. No network beyond NuGet, no BHoM.
# SerialiserRunner, VersioningRunner and Compliance.Unit.Tests.
# compliance-tests Resolves the Test_Toolkit dependency graph first, so Compliance.Tests
# can compile and its entry-point tests can run.
#
# Why the ComplianceRunner suite is split across two projects. Compliance.Unit.Tests compiles
# Annotation.cs, ArgParser.cs, FileFilter.cs and SarifBuilder.cs directly instead of
# project-referencing Compliance.Shared, so it pulls in no BHoM assembly and runs in the
# hermetic job with nothing installed. Compliance.Tests holds everything that cannot: the three
# unit files that take a BHoM type as a parameter, and the integration files that invoke the
# built runner executables.
#
# Why Compliance.Tests needs the second job. Compliance.Shared HintPaths five assemblies out
# of C:\ProgramData\BHoM\Assemblies. Measured on a machine carrying the BHoM installer, four
# resolve and only CodeComplianceTest_oM.dll is missing, because it is built by
# BHoM/Test_Toolkit (CodeCompliance_oM/CodeComplianceTest_oM.csproj) rather than shipped in
# the installer payload. AnnotationConvert.cs then fails CS0234 on BH.oM.Test.CodeCompliance
# and takes the whole project down, which is why all nine of its test files were inert.
# and takes the whole project down.
#
# resolve-dependencies in mode: seeds with seed BHoM/Test_Toolkit is exactly what ci-compliance
# already does before prepare-runner publishes ComplianceRunner, and ComplianceRunner.csproj
Expand Down Expand Up @@ -58,17 +66,24 @@ jobs:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

# Two versions: the Serialiser and Versioning suites target net8.0-windows, matching
# their runners; Compliance.Unit.Tests targets net10.0, matching ComplianceRunner.
- name: Set up .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: '8.0'
dotnet-version: |
8.0
10.x

- name: SerialiserRunner tests
run: dotnet test tools/SerialiserRunner/src/SerialiserRunner.Tests --nologo

- name: VersioningRunner tests
run: dotnet test tools/VersioningRunner/src/VersioningRunner.Tests --nologo

- name: ComplianceRunner unit tests (BHoM-free)
run: dotnet test tools/ComplianceRunner/tests/Compliance.Unit.Tests --nologo

# ComplianceRunner's own suite, including the entry-point characterisation tests. Needs
# CodeComplianceTest_oM.dll, so it builds the Test_Toolkit graph first. See the header.
compliance-tests:
Expand Down
1 change: 1 addition & 0 deletions tools/ComplianceRunner/Platform.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<Project Path="src/DatasetComplianceRunner/DatasetComplianceRunner.csproj" Id="073f2c91-6a2b-4af2-91f8-a6b1fffe5c91" />
<Project Path="src/Shared/Compliance.Shared/Compliance.Shared.csproj" Id="a2ff49f5-c2db-4687-b981-e48539def63f" />
<Project Path="tests/Compliance.Tests/Compliance.Tests.csproj" />
<Project Path="tests/Compliance.Unit.Tests/Compliance.Unit.Tests.csproj" />
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,30 @@
<ProjectReference Include="..\..\src\Shared\Compliance.Shared\Compliance.Shared.csproj" />
</ItemGroup>

<!--
This project holds the BHoM-DEPENDENT half of the suite. It runs in test-tools.yml's
compliance-tests job, which resolves the Test_Toolkit dependency graph first so that
CodeComplianceTest_oM.dll exists and this project can compile. The BHoM-free half moved
to ../Compliance.Unit.Tests, which runs in the hermetic dotnet-tests job instead and
needs nothing installed.

What is left here and why each item cannot move:
Unit/CheckMetadataTests.cs CheckMetadata.GetOutput takes a BH.oM.Test.TestStatus.
Unit/OutputEmitterTests.cs OutputEmitter.Write takes a BH.oM.Test.TestStatus.
Unit/AnnotationConvertTests.cs Constructs BH.oM.Test.CodeCompliance.Error and
exercises the ITestInformation conversion path.
Integration/* Invoke the built runner executables against real engines.

Note the boundary is NOT unit-versus-integration: three of the six original unit test
files are BHoM-dependent. For CheckMetadata and OutputEmitter the whole dependency is a
single enum parameter, which is thin but real, and narrowing it would mean changing
production signatures.
-->

<ItemGroup>
<!--
BHoM assemblies required at compile-time (for TestStatus in CheckMetadataTests)
and by integration tests that invoke the runner executables against real BHoM engines.
Structural unit tests (SarifBuilder, ArgParser, FileFilter) do not need BHoM at runtime.
-->
<Reference Include="BHoM">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/// 2. ComplianceRunner then asks FileFilter.IsRelevantFile of every file it was handed.
///
/// Each half has tests. `.github/scripts/tests/test-changed-file-patterns.sh` asserts the
/// pathspec behaviour against real git, and FileFilterTests asserts the predicate. Neither
/// pathspec behaviour against real git, and FileFilterTests, which lives in the sibling
/// Compliance.Unit.Tests project, asserts the predicate. Neither
/// asserts that the two agree, and they do not: the pathspec token `*AssemblyInfo.cs` selects
/// any file whose name ENDS with that string, while FileFilter.cs:24 requires the name to
/// EQUAL it. A file in between is selected, counted into the skip decision, handed to the
Expand All @@ -20,9 +21,9 @@
/// These tests are written to PASS against today's behaviour. They record the disagreement so
/// it is visible in the suite. Whether the fix narrows the pathspec or widens the filter is
/// open: BHoMBot used EndsWith("AssemblyInfo.cs") (ProjectCompliance.cs:33), so widening the
/// filter restores the older semantics, and FileFilterTests.cs:20 currently asserts the
/// narrower one deliberately. Where an assertion would change under one of those two answers,
/// the comment says what it should become and under which answer.
/// filter restores the older semantics, and line 20 of that same FileFilterTests file asserts
/// the narrower one deliberately. Where an assertion would change under one of those two
/// answers, the comment says what it should become and under which answer.
/// </summary>
[TestFixture]
[Category("Integration")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--
The BHoM-free half of the ComplianceRunner test suite, split out so it can run in CI.

Compliance.Tests cannot compile without a BHoM install AND a built Test_Toolkit: its
ProjectReference to Compliance.Shared drags in AnnotationConvert.cs, which needs
BH.oM.Test.CodeCompliance from CodeComplianceTest_oM.dll. That assembly ships with
Test_Toolkit, not with the installer payload, so even a machine with BHoM installed
cannot build it. Result: every test in that project has been inert since it was written.

This project deliberately has NO ProjectReference to Compliance.Shared. It compiles the
four source files that reference no BHoM type directly into the test assembly, so it
builds and runs on a bare runner with no BHoM install and no Test_Toolkit.

Those four files were verified free of BHoM types by reading them, not by their names:
every "BHoM" occurrence in them is a comment or a string literal (e.g. the "BHoM.<check>"
SARIF ruleId prefix). The three excluded source files have real dependencies:
CheckMetadata and OutputEmitter take a BH.oM.Test.TestStatus parameter, and
AnnotationConvert consumes BH.oM.Test.CodeCompliance.Error and ITestInformation.

NUnit rather than the xUnit used by SerialiserRunner.Tests and VersioningRunner.Tests.
The three test files here were moved verbatim from Compliance.Tests, which is an NUnit
project; rewriting ~350 lines of assertions into xUnit would risk changing what they
assert, and the point of this change is to find out what they do assert. Harmonising the
two frameworks is a separate decision.
-->

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<RootNamespace>Compliance.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>

<!--
Source under test, linked rather than project-referenced. Keep this list in step with
Compliance.Shared: a new file there that references no BHoM type belongs here too, and
one that does must not be added or this project stops building on a bare runner.
-->
<ItemGroup>
<Compile Include="..\..\src\Shared\Compliance.Shared\Annotation.cs" Link="Linked\Annotation.cs" />
<Compile Include="..\..\src\Shared\Compliance.Shared\ArgParser.cs" Link="Linked\ArgParser.cs" />
<Compile Include="..\..\src\Shared\Compliance.Shared\FileFilter.cs" Link="Linked\FileFilter.cs" />
<Compile Include="..\..\src\Shared\Compliance.Shared\SarifBuilder.cs" Link="Linked\SarifBuilder.cs" />
</ItemGroup>

</Project>
Loading