Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Share one import per STEP corpus file across the test suite

Yuechen Lib90f0e846465
diff --git a/AGENTS.md b/AGENTS.md
index 403a182f..861008bd 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -41,3 +41,19 @@ If the required .NET SDK/runtime is not installed:
4. then run the full build/test commands.
Do not report .NET tests as “not run due to missing dotnet” unless installation is impossible in the current environment, and if so, explain exactly why.
+
+## Test lanes
+
+Iterate with the fast lane and gate on the full one:
+
+```
+dotnet test Aetheris.Kernel.Core.Tests -c Release --no-build --filter "Category!=SlowCorpus"
+dotnet test Aetheris.slnx -c Release --no-build -m:1 -- RunConfiguration.MaxCpuCount=1
+```
+
+Never report a change as verified on the fast lane alone - it omits the corpus-driven tests,
+which are the ones that catch interchange regressions.
+
+When a test needs a STEP corpus file, take it from `Step242Corpus` (`Body`, `Import` or `Text`)
+rather than reading and importing it again. See CONTRIBUTING.md for when a test genuinely needs
+its own import.
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Queries/BrepSpatialQueriesPointClassificationTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Queries/BrepSpatialQueriesPointClassificationTests.cs
index 07291450..4398ed8c 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Queries/BrepSpatialQueriesPointClassificationTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Queries/BrepSpatialQueriesPointClassificationTests.cs
@@ -1,3 +1,4 @@
+using Aetheris.Kernel.Core.Tests.Step242;
using Aetheris.Kernel.Core.Brep;
using Aetheris.Kernel.Core.Brep.EdgeFinishing;
using Aetheris.Kernel.Core.Brep.Boolean;
@@ -131,8 +132,7 @@ public sealed class BrepSpatialQueriesPointClassificationTests
private static BrepBody ImportFixtureBody(string relativePath)
{
- var fullPath = Path.Combine(RepoRoot, relativePath.Replace('/', Path.DirectorySeparatorChar));
- var import = Step242Importer.ImportBody(File.ReadAllText(fullPath));
+ var import = Step242Corpus.Import(relativePath);
Assert.True(import.IsSuccess, string.Join(Environment.NewLine, import.Diagnostics.Select(d => d.Message)));
return import.Value;
}
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Tessellation/NistDisplayCorpusRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Tessellation/NistDisplayCorpusRegressionTests.cs
index d02f918c..005fe70b 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Tessellation/NistDisplayCorpusRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Tessellation/NistDisplayCorpusRegressionTests.cs
@@ -3,6 +3,7 @@ using Aetheris.Kernel.Core.Diagnostics;
using Aetheris.Kernel.Core.Geometry.Surfaces;
using Aetheris.Kernel.Core.Math;
using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Tests.Step242;
namespace Aetheris.Kernel.Core.Tests.Brep.Tessellation;
@@ -36,7 +37,7 @@ public sealed class NistDisplayCorpusRegressionTests
[Trait("Category", "SlowCorpus")]
public void NistModel_DisplaysEveryFace_WithoutTessellationWarnings(string relativePath)
{
- var import = Step242Importer.ImportBody(File.ReadAllText(Path.Combine(FindRepoRoot(), "testdata", "step242", "nist", relativePath)));
+ var import = Step242Corpus.Import($"testdata/step242/nist/{relativePath}");
Assert.True(import.IsSuccess, string.Join(" | ", import.Diagnostics.Select(d => d.Message)));
var display = DisplayPreparationFallbackBuilder.Build(import.Value, null, null, TimeSpan.FromSeconds(30));
@@ -53,10 +54,11 @@ public sealed class NistDisplayCorpusRegressionTests
/// do not survive import: the stored non-rational surface must follow the geometry the file stated, not the
/// different polynomial surface you get by ignoring them.
/// </summary>
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void RationalBSplineSurface_WeightsAreHonoured_EvenThoughTheyDoNotSurviveImport()
{
- var stepText = File.ReadAllText(Path.Combine(FindRepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_05_asme1_ap242-e1.stp"));
+ var stepText = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp");
BSplineSurfaceWithKnots[] asStated;
using (Step242Importer.PreserveRationalSurfaces())
@@ -90,10 +92,11 @@ public sealed class NistDisplayCorpusRegressionTests
}
/// <summary>The debug path has to stay whole: preserved rationals must export and come back as rationals.</summary>
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void PreservedRationalSurfaces_SurviveAStepRoundTrip()
{
- var stepText = File.ReadAllText(Path.Combine(FindRepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_05_asme1_ap242-e1.stp"));
+ var stepText = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp");
using var scope = Step242Importer.PreserveRationalSurfaces();
var import = Step242Importer.ImportBody(stepText);
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Tessellation/UvTrimMaskExtractorTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Tessellation/UvTrimMaskExtractorTests.cs
index 6da3b0fc..d48dc37a 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Tessellation/UvTrimMaskExtractorTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Tessellation/UvTrimMaskExtractorTests.cs
@@ -11,6 +11,7 @@ namespace Aetheris.Kernel.Core.Tests.Brep.Tessellation;
public sealed class UvTrimMaskExtractorTests
{
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void TryExtract_RealBsplineFace_BuildsDeterministicTrimMaskAndSupportsScaffold()
{
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineEdgeTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineEdgeTests.cs
index 356cad94..4d663744 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineEdgeTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineEdgeTests.cs
@@ -120,6 +120,7 @@ public sealed class Step242BSplineEdgeTests
Assert.DoesNotContain("B_SPLINE_CURVE_WITH_KNOTS self_intersect", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
}
+ [Trait("Category", "SlowCorpus")]
[Theory]
[InlineData("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp")]
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
index f4e6f668..efd736eb 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
@@ -24,8 +24,7 @@ public sealed class Step242BSplineSurfaceWithKnotsTests
[Trait("Category", "SlowCorpus")]
public void Step242_NistCtc02_BSplineSurfaces_ObservedAsNonRationalWithExpectedDegreeFamilies()
{
- var path = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_02_asme1_ap242-e2.stp");
- var import = Step242Importer.ImportBody(File.ReadAllText(path));
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp");
Assert.True(import.IsSuccess);
var splineSurfaces = import.Value.Geometry.Surfaces
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BsplineSurfaceRecoveryTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BsplineSurfaceRecoveryTests.cs
index 359d7bfb..50a1e241 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BsplineSurfaceRecoveryTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BsplineSurfaceRecoveryTests.cs
@@ -92,6 +92,7 @@ public sealed class Step242BsplineSurfaceRecoveryTests
/// CTC-05's rational faces are five-sided vertex blends, not primitives. Import says which primitives it weighed
/// and on what measurement it rejected each, rather than reporting an unexplained "unsupported".
/// </summary>
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void NistCtc05VertexBlends_ReportEveryPrimitiveTheyWereMeasuredAgainst()
{
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
index 14accd33..3a25a513 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
@@ -197,10 +197,7 @@ public sealed class Step242ConicalSurfaceRegressionTests
[Fact]
public void Step242_ConicalSurfaceImport_DegreeContextFromGlobalUnits_NormalizesToRadians()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_01_asme1_ap242-e1.stp");
- var source = File.ReadAllText(fixturePath);
-
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp");
Assert.True(import.IsSuccess);
var cones = import.Value.Geometry.Surfaces
@@ -219,10 +216,7 @@ public sealed class Step242ConicalSurfaceRegressionTests
[Trait("Category", "SlowCorpus")]
public void Step242_ConicalSurfaceImport_RadianContextFromGlobalUnits_RemainsRadians()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "STC", "nist_stc_09_asme1_ap242-e3.stp");
- var source = File.ReadAllText(fixturePath);
-
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("testdata/step242/nist/STC/nist_stc_09_asme1_ap242-e3.stp");
Assert.True(import.IsSuccess);
var cones = import.Value.Geometry.Surfaces
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs
new file mode 100644
index 00000000..5015ac83
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs
@@ -0,0 +1,60 @@
+using System.Collections.Concurrent;
+using System.Text;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Results;
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.Kernel.Core.Tests.Step242;
+
+/// <summary>
+/// Shared, memoized access to the on-disk STEP corpus.
+/// <para>
+/// The corpus holds 48 distinct files but the test project imports from it at roughly two
+/// hundred call sites, and every one of those used to read the file and rebuild the body from
+/// scratch. Importing every corpus file exactly once costs about ten seconds; the suite used to
+/// spend about ninety-eight on it. Parsing is not the expensive part - under a second of that
+/// ten - so caching the parsed document would buy almost nothing. The body is what is expensive
+/// to build, so the body is what is cached.
+/// </para>
+/// <para>
+/// Sharing one <see cref="BrepBody"/> across tests is safe because a body and everything it
+/// exposes is read-only once constructed. Two kinds of test must still import for themselves and
+/// should take only <see cref="Text"/> from here: those that install a
+/// <c>Step242Importer.CaptureLoopRole*Diagnostics</c> scope, which collects during the import and
+/// therefore needs a real one, and those that run under
+/// <c>Step242Importer.PreserveRationalSurfaces()</c>, which changes what the import produces.
+/// </para>
+/// </summary>
+internal static class Step242Corpus
+{
+ private static readonly ConcurrentDictionary<string, Lazy<string>> TextCache = new(StringComparer.Ordinal);
+ private static readonly ConcurrentDictionary<string, Lazy<KernelResult<BrepBody>>> BodyCache = new(StringComparer.Ordinal);
+
+ /// <summary>Absolute path of a corpus file named relative to the repository root.</summary>
+ public static string Path(string relativePath) =>
+ System.IO.Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', System.IO.Path.DirectorySeparatorChar));
+
+ /// <summary>The file's text, read at most once per path per test run.</summary>
+ public static string Text(string relativePath) =>
+ TextCache.GetOrAdd(relativePath, key => new Lazy<string>(
+ () => File.ReadAllText(Path(key), Encoding.UTF8),
+ LazyThreadSafetyMode.ExecutionAndPublication)).Value;
+
+ /// <summary>
+ /// The imported body, built at most once per path per test run. The result is shared, so
+ /// callers must treat it as read-only; anything that needs a private import should call
+ /// <see cref="Step242Importer.ImportBody"/> on <see cref="Text"/> itself.
+ /// </summary>
+ public static KernelResult<BrepBody> Import(string relativePath) =>
+ BodyCache.GetOrAdd(relativePath, key => new Lazy<KernelResult<BrepBody>>(
+ () => Step242Importer.ImportBody(Text(key)),
+ LazyThreadSafetyMode.ExecutionAndPublication)).Value;
+
+ /// <summary>The imported body, asserting that the import succeeded.</summary>
+ public static BrepBody Body(string relativePath)
+ {
+ var import = Import(relativePath);
+ Assert.True(import.IsSuccess, $"{relativePath}: {string.Join(" | ", import.Diagnostics.Select(d => d.Message))}");
+ return import.Value;
+ }
+}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs
index 0699b7d0..d38e23f6 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs
@@ -33,8 +33,7 @@ internal static class Step242CorpusManifestRunner
public static Step242CorpusReportEntry RunOne(Step242CorpusManifestEntry entry, bool includeDisplayAudit = false)
{
- var fullPath = Path.Combine(RepoRoot(), entry.Path.Replace('/', Path.DirectorySeparatorChar));
- var text = File.ReadAllText(fullPath, Encoding.UTF8);
+ var text = Step242Corpus.Text(entry.Path);
var sizeBytes = Encoding.UTF8.GetByteCount(NormalizeLf(text));
try
@@ -63,7 +62,7 @@ internal static class Step242CorpusManifestRunner
}
}
- var import = Step242Importer.ImportBody(text);
+ var import = Step242Corpus.Import(entry.Path);
if (!import.IsSuccess)
{
return BuildAp242Failure(entry, sizeBytes, DetermineImportFailureLayer(import.Diagnostics), import.Diagnostics);
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs
index 5e308656..677ec443 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs
@@ -14,8 +14,7 @@ public sealed class Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTes
[InlineData("testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp")]
public void Step242_Targets_ContainDualSingleCoedgeClosedCircleCylinderFamily(string relativePath)
{
- var fullPath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var import = Step242Importer.ImportBody(File.ReadAllText(fullPath));
+ var import = Step242Corpus.Import(relativePath);
Assert.True(import.IsSuccess);
var body = import.Value;
@@ -56,8 +55,7 @@ public sealed class Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTes
public void Step242_Stc06_AlsoMatchesDualSingleCoedgeClosedCircleCylinderFamily_AndNowAdvances()
{
const string relativePath = "testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp";
- var fullPath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var import = Step242Importer.ImportBody(File.ReadAllText(fullPath));
+ var import = Step242Corpus.Import(relativePath);
Assert.True(import.IsSuccess);
var body = import.Value;
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs
index 33905a83..47ef6084 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs
@@ -243,10 +243,9 @@ END-ISO-10303-21;";
[Fact]
public void ExportBody_Ctc01RoundTrip_ConicalSurfaceSemiAngle_IsCanonicalRadiansConvention()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_01_asme1_ap242-e1.stp");
- var source = File.ReadAllText(fixturePath);
+ var source = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp");
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp");
Assert.True(import.IsSuccess);
var export = Step242Exporter.ExportBody(import.Value);
@@ -268,10 +267,9 @@ END-ISO-10303-21;";
[Trait("Category", "SlowCorpus")]
public void ExportBody_Ctc02RoundTrip_ShallowCones_PreserveApexCoordinates()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_02_asme1_ap242-e2.stp");
- var source = File.ReadAllText(fixturePath);
+ var source = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp");
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp");
Assert.True(import.IsSuccess);
var expectedShallowCones = import.Value.Geometry.Surfaces
@@ -317,10 +315,9 @@ END-ISO-10303-21;";
[Trait("Category", "SlowCorpus")]
public void ExportBody_Ctc02RoundTrip_PreservesPlanarFaceWithCircularBoundaryNearExpectedCenter()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_02_asme1_ap242-e2.stp");
- var source = File.ReadAllText(fixturePath);
+ var source = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp");
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp");
Assert.True(import.IsSuccess);
var sourceFace = FindPlanarFaceWithCircle(import.Value, new Aetheris.Kernel.Core.Math.Point3D(0d, 812d, -140d), 42.5d);
@@ -417,10 +414,9 @@ END-ISO-10303-21;";
[Fact]
public void ExportBody_Ctc03RoundTrip_DoesNotOrphanInnerFaceBounds()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "nist", "CTC", "nist_ctc_03_asme1_ap242-e2.stp");
- var source = File.ReadAllText(fixturePath);
+ var source = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_03_asme1_ap242-e2.stp");
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_03_asme1_ap242-e2.stp");
Assert.True(import.IsSuccess);
var export = Step242Exporter.ExportBody(import.Value);
@@ -530,14 +526,9 @@ END-ISO-10303-21;";
[Fact]
public void ExportBody_OcctSimpleBracket_ExportImportRoundTrip_Succeeds()
{
- var fixturePath = Path.Combine(
- Step242CorpusManifestRunner.RepoRoot(),
- "fixtures", "Compatibility", "Firmasm", "LegacyAssembly", "examples",
- "occt-l-bracket",
- "_part_003_l_bracket.step");
- var source = File.ReadAllText(fixturePath);
+ var source = Step242Corpus.Text("fixtures/Compatibility/Firmasm/LegacyAssembly/examples/occt-l-bracket/_part_003_l_bracket.step");
- var import = Step242Importer.ImportBody(source);
+ var import = Step242Corpus.Import("fixtures/Compatibility/Firmasm/LegacyAssembly/examples/occt-l-bracket/_part_003_l_bracket.step");
Assert.True(import.IsSuccess);
var export = Step242Exporter.ExportBody(import.Value);
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc06SameSenseRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc06SameSenseRegressionTests.cs
index 7575137f..c8a9cd0e 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc06SameSenseRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc06SameSenseRegressionTests.cs
@@ -80,6 +80,7 @@ END-ISO-10303-21;";
Assert.Equal(310, import.Value.Topology.Vertices.Count());
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void Step242Ftc06Export_HasStableTopologySummary()
{
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs
index 5d1be48d..99032224 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs
@@ -10,6 +10,7 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
private static readonly TimeSpan Ftc07WallClockGuard = TimeSpan.FromSeconds(30);
private const string RelativePath = "testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp";
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void Step242Ftc07ViewMaterialization_CompletesOrReportsBoundedDiagnostic()
{
@@ -33,6 +34,7 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
Assert.Contains(tessellation.Diagnostics, diagnostic => string.Equals(diagnostic.Source, "Viewer.Tessellation.Timeout", StringComparison.Ordinal));
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void Step242Ftc07ViewMaterialization_ReportsPhaseAndFaceOnFailure()
{
@@ -56,6 +58,7 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void DisplayPrepare_Ftc07_ReturnsPartialDisplayInsteadOfWholeBodyFailure()
{
@@ -83,8 +86,7 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
private static global::Aetheris.Kernel.Core.Brep.BrepBody ImportFixture()
{
- var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), RelativePath.Replace('/', Path.DirectorySeparatorChar));
- var import = Step242Importer.ImportBody(File.ReadAllText(absolutePath));
+ var import = Step242Corpus.Import(RelativePath);
Assert.True(import.IsSuccess);
return import.Value;
}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
index 2d0a20c3..2c6a0524 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
@@ -51,6 +51,7 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
}
[Theory]
+ [Trait("Category", "SlowCorpus")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_08_asme1_ap242-e2.stp", true, false)]
[InlineData("testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp", true, true)]
[InlineData("testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp", true, true)]
@@ -192,8 +193,9 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
private static IReadOnlyList<Step242Importer.LoopRoleCoedgeGapDiagnostic> CaptureCoedgeGaps(string relativePath)
{
- var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var text = File.ReadAllText(absolutePath);
+ // The capture scope collects while the import runs, so this one cannot share a cached
+ // body - only the file text.
+ var text = Step242Corpus.Text(relativePath);
var diagnostics = new List<Step242Importer.LoopRoleCoedgeGapDiagnostic>();
using var captureScope = Step242Importer.CaptureLoopRoleCoedgeGapDiagnostics(diagnostics);
@@ -202,13 +204,7 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
}
private static global::Aetheris.Kernel.Core.Brep.BrepBody ImportFromCorpus(string relativePath)
- {
- var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var text = File.ReadAllText(absolutePath);
- var import = Step242Importer.ImportBody(text);
- Assert.True(import.IsSuccess);
- return import.Value;
- }
+ => Step242Corpus.Body(relativePath);
private static IReadOnlyList<string> BuildSharedClosedEdgeUseSignature(global::Aetheris.Kernel.Core.Brep.BrepBody body)
{
@@ -242,8 +238,9 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
private static IReadOnlyList<Step242Importer.LoopRoleCircularSamplingDiagnostic> CaptureCircularSampling(string relativePath)
{
- var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var text = File.ReadAllText(absolutePath);
+ // The capture scope collects while the import runs, so this one cannot share a cached
+ // body - only the file text.
+ var text = Step242Corpus.Text(relativePath);
var diagnostics = new List<Step242Importer.LoopRoleCircularSamplingDiagnostic>();
using var captureScope = Step242Importer.CaptureLoopRoleCircularSamplingDiagnostics(diagnostics);
@@ -253,8 +250,9 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
private static IReadOnlyList<Step242Importer.LoopRoleCylinderProjectionDiagnostic> CaptureCylinderProjectionDiagnostics(string relativePath)
{
- var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var text = File.ReadAllText(absolutePath);
+ // The capture scope collects while the import runs, so this one cannot share a cached
+ // body - only the file text.
+ var text = Step242Corpus.Text(relativePath);
var diagnostics = new List<Step242Importer.LoopRoleCylinderProjectionDiagnostic>();
using var captureScope = Step242Importer.CaptureLoopRoleCylinderProjectionDiagnostics(diagnostics);
@@ -264,8 +262,9 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
private static IReadOnlyList<Step242Importer.LoopRoleTorusProjectionDiagnostic> CaptureTorusProjectionDiagnostics(string relativePath)
{
- var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var text = File.ReadAllText(absolutePath);
+ // The capture scope collects while the import runs, so this one cannot share a cached
+ // body - only the file text.
+ var text = Step242Corpus.Text(relativePath);
var diagnostics = new List<Step242Importer.LoopRoleTorusProjectionDiagnostic>();
using var captureScope = Step242Importer.CaptureLoopRoleTorusProjectionDiagnostics(diagnostics);
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242PcurveAndVertexLoopTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242PcurveAndVertexLoopTests.cs
index fd56e88c..df396d78 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242PcurveAndVertexLoopTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242PcurveAndVertexLoopTests.cs
@@ -25,6 +25,7 @@ public sealed class Step242PcurveAndVertexLoopTests
Assert.Contains(imported.Diagnostics, diagnostic => diagnostic.Source == "Importer.Pcurve.UnsupportedCurve");
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void ImportedPlateauPcurves_AreFirstClassAndRoundTrip()
{
@@ -105,6 +106,7 @@ public sealed class Step242PcurveAndVertexLoopTests
Assert.NotNull(binding.Parameter);
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void ConeApexVertexLoops_ArePreservedAndStc06RemainsAmbiguous()
{
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242PeriodicBoundaryOrientationTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242PeriodicBoundaryOrientationTests.cs
index 1f58b7be..cb24f818 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242PeriodicBoundaryOrientationTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242PeriodicBoundaryOrientationTests.cs
@@ -20,7 +20,7 @@ public sealed class Step242PeriodicBoundaryOrientationTests
[Trait("Category", "SlowCorpus")]
public void PeriodicBoundaryOrientation_SurvivesExportImport(string relativePath)
{
- var imported = Step242Importer.ImportBody(ReadNist(relativePath));
+ var imported = Step242Corpus.Import(NistPath(relativePath));
Assert.True(imported.IsSuccess, string.Join(" | ", imported.Diagnostics.Select(diagnostic => diagnostic.Message)));
var exported = Step242Exporter.ExportBody(imported.Value);
@@ -38,7 +38,7 @@ public sealed class Step242PeriodicBoundaryOrientationTests
[Fact]
public void ImportedBoundaryRoles_SelectExplicitJudgmentCandidate()
{
- var imported = Step242Importer.ImportBody(ReadNist("FTC/nist_ftc_11_asme1_ap242-e2.stp"));
+ var imported = Step242Corpus.Import(NistPath("FTC/nist_ftc_11_asme1_ap242-e2.stp"));
Assert.True(imported.IsSuccess);
foreach (var face in imported.Value.Topology.Faces.Where(face => face.LoopIds.Count > 0))
@@ -91,16 +91,11 @@ public sealed class Step242PeriodicBoundaryOrientationTests
[Fact]
public void Stc06_RemainsExplicitlyAmbiguous()
{
- var imported = Step242Importer.ImportBody(ReadNist("STC/nist_stc_06_asme1_ap242-e3.stp"));
+ var imported = Step242Corpus.Import(NistPath("STC/nist_stc_06_asme1_ap242-e3.stp"));
Assert.True(imported.IsSuccess);
Assert.Contains(imported.Value.FaceOrientationReport!.Shells,
shell => shell.Qualification == FaceOrientationQualification.Ambiguous);
}
- private static string ReadNist(string relativePath) => File.ReadAllText(Path.Combine(
- Step242CorpusManifestRunner.RepoRoot(),
- "testdata",
- "step242",
- "nist",
- relativePath.Replace('/', Path.DirectorySeparatorChar)));
+ private static string NistPath(string relativePath) => $"testdata/step242/nist/{relativePath}";
}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RationalSurfaceReductionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RationalSurfaceReductionTests.cs
index de1771cb..3f1b7760 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242RationalSurfaceReductionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RationalSurfaceReductionTests.cs
@@ -30,10 +30,7 @@ public sealed class Step242RationalSurfaceReductionTests
[Trait("Category", "SlowCorpus")]
public void ImportedBody_CarriesNoRationalSurface(string relativePath)
{
- var import = Step242Importer.ImportBody(ReadFixture(relativePath));
-
- Assert.True(import.IsSuccess);
- Assert.Equal(0, CountRationalSurfaces(import.Value));
+ Assert.Equal(0, CountRationalSurfaces(Step242Corpus.Body(relativePath)));
}
[Theory]
@@ -50,10 +47,11 @@ public sealed class Step242RationalSurfaceReductionTests
Assert.DoesNotContain("RATIONAL_B_SPLINE_SURFACE", exported.Value, StringComparison.Ordinal);
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void NistVertexBlends_AreReducedAndSayHowCloselyTheyFollowTheOriginal()
{
- var import = Step242Importer.ImportBody(ReadFixture("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp"));
+ var import = Step242Corpus.Import("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp");
Assert.True(import.IsSuccess);
var reduced = import.Diagnostics
@@ -67,10 +65,11 @@ public sealed class Step242RationalSurfaceReductionTests
/// The debug switch has to give back exactly what the file stated, rationals included, and export has to write
/// them, or it is no use for diagnosing a surface that the reduction mishandled.
/// </summary>
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void PreserveRationalSurfaces_KeepsTheFileAsStated_AndExportsItRational()
{
- var stepText = ReadFixture("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp");
+ var stepText = Step242Corpus.Text("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp");
using (Step242Importer.PreserveRationalSurfaces())
{
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242SphericalTrimSingleCoedgeDiagnosticsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242SphericalTrimSingleCoedgeDiagnosticsTests.cs
index 8d3be1a9..a25b9857 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242SphericalTrimSingleCoedgeDiagnosticsTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242SphericalTrimSingleCoedgeDiagnosticsTests.cs
@@ -7,13 +7,13 @@ namespace Aetheris.Kernel.Core.Tests.Step242;
public sealed class Step242SphericalTrimSingleCoedgeDiagnosticsTests
{
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void Step242_Stc06_Face33_IsSingleCoedgeClosedFullCircleLatitudeLoop_OnSphere()
{
const string relativePath = "testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp";
- var fullPath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
- var import = Step242Importer.ImportBody(File.ReadAllText(fullPath));
+ var import = Step242Corpus.Import(relativePath);
Assert.True(import.IsSuccess);
var body = import.Value;
@@ -36,6 +36,7 @@ public sealed class Step242SphericalTrimSingleCoedgeDiagnosticsTests
Assert.Equal(2d * double.Pi, trim.Value.End, 6);
}
+ [Trait("Category", "SlowCorpus")]
[Fact]
public void Step242_Stc06_AdvancesPastSingleCoedgeSphereTrim_Deterministically()
{
diff --git a/Aetheris.Kernel.Core.Tests/Step242/StepSolidRootExportPlannerTests.cs b/Aetheris.Kernel.Core.Tests/Step242/StepSolidRootExportPlannerTests.cs
index 6ef2da6e..b0f39a05 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/StepSolidRootExportPlannerTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/StepSolidRootExportPlannerTests.cs
@@ -68,8 +68,7 @@ public sealed class StepSolidRootExportPlannerTests
[Fact]
public void Export_ThroughHole_RemainsManifold()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "golden", "firmament-v1", "boolean_box_cylinder_hole.step");
- var import = Step242Importer.ImportBody(File.ReadAllText(fixturePath));
+ var import = Step242Corpus.Import("testdata/step242/golden/firmament-v1/boolean_box_cylinder_hole.step");
Assert.True(import.IsSuccess);
var export = Step242Exporter.ExportBody(import.Value);
@@ -81,8 +80,7 @@ public sealed class StepSolidRootExportPlannerTests
private static BrepBody LoadVoidFixture()
{
- var fixturePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "golden", "firmament-v1", "boolean_box_sphere_cavity_basic.step");
- var import = Step242Importer.ImportBody(File.ReadAllText(fixturePath));
+ var import = Step242Corpus.Import("testdata/step242/golden/firmament-v1/boolean_box_sphere_cavity_basic.step");
Assert.True(import.IsSuccess, string.Join(Environment.NewLine, import.Diagnostics.Select(d => d.Message)));
return import.Value;
}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index bd63e727..81509275 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -16,6 +16,50 @@ dotnet build Aetheris.slnx -c Release -m:1
dotnet test Aetheris.slnx -c Release --no-build -m:1 -- RunConfiguration.MaxCpuCount=1
```
+### Two test lanes
+
+The command above is the **full corpus** lane and is what has to be green before you commit.
+It imports the whole NIST and OCCT corpus, so it is the lane that actually protects the
+interchange behaviour.
+
+For the edit-run-edit inner loop there is a **fast lane** that skips the corpus-driven tests:
+
+```powershell
+dotnet test Aetheris.Kernel.Core.Tests -c Release --no-build --filter "Category!=SlowCorpus"
+```
+
+On a two-core machine that is roughly 9s against 31s for the full lane, over 959 of the 1092
+tests. Use it while iterating; never use it as the gate.
+
+A test belongs in `[Trait("Category", "SlowCorpus")]` when its cost is dominated by importing a
+large corpus file rather than by the behaviour it is checking. Keep at least one cheap test per
+behaviour outside the trait, so the fast lane still fails when something is broken rather than
+merely running fewer tests. `Aetheris.Kernel.Firmament.Tests` has the trait too, but its time is
+spread evenly across real geometry work rather than concentrated in corpus I/O, so the split
+buys much less there.
+
+### Importing corpus files in tests
+
+Do not call `File.ReadAllText` + `Step242Importer.ImportBody` directly in a test. Use the shared
+memoized fixture:
+
+```csharp
+var body = Step242Corpus.Body("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp");
+var import = Step242Corpus.Import(relativePath); // when the diagnostics matter
+var text = Step242Corpus.Text(relativePath); // when the file text itself matters
+```
+
+The corpus has 48 distinct files and the test project reads from it at roughly two hundred call
+sites. Importing every file exactly once costs about ten seconds; doing it per call site cost
+about ninety-eight. Parsing is under a second of that, so caching the parsed document would buy
+almost nothing - the body is what is expensive to build, so the body is what is cached. A
+`BrepBody` is read-only once constructed, which is what makes sharing it safe.
+
+Two cases must still import for themselves and should take only `Step242Corpus.Text`: tests that
+install a `Step242Importer.CaptureLoopRole*Diagnostics` scope, because it collects while the
+import runs, and tests under `Step242Importer.PreserveRationalSurfaces()`, because it changes
+what the import produces.
+
Cadmata and the VS Code extension use TSPack and their checked-in lock files:
```powershell
diff --git a/docs/development/test-suite-performance.md b/docs/development/test-suite-performance.md
index 81256313..18f4d09d 100644
--- a/docs/development/test-suite-performance.md
+++ b/docs/development/test-suite-performance.md
@@ -128,10 +128,40 @@ would bring the inner-loop suite under ~15s without touching coverage, provided
lane still runs before commit. This is the cheapest immediate win and needs no code change
beyond attributes.
-## Suggested order
+## Results
-1. Extend `SlowCorpus` and document the two-lane workflow. Free, today.
-2. Memoized corpus fixture (text + body). Targets ~90% of Kernel.Core CPU.
+Applied: the memoized `Step242Corpus` fixture, conversion of the read-only import call sites to
+it, eleven more `SlowCorpus` traits, and the two-lane workflow written into CONTRIBUTING.md and
+AGENTS.md.
+
+| | before | after |
+|---|---|---|
+| Kernel.Core, full lane (wall) | 61s | 31s |
+| Kernel.Core, full lane (CPU) | 117s | 63s |
+| Kernel.Core, fast lane (wall) | 28s | 10s |
+| Kernel.Core, fast lane (tests) | 981 | 959 |
+| Firmament, full lane (wall) | 37-43s | 33s |
+
+Step242 fell from 98.2s to 51.4s of CPU. All suites green: Kernel.Core 1092/1092,
+Firmament 1624/1624, Server 59/59.
+
+Two things to know when reading per-class numbers after this change. Cost now migrates to
+whichever test touches a corpus file first, so individual classes move up or down between runs
+without anything having changed - only the total is meaningful. And `RunConfiguration.MaxCpuCount=1`
+in the canonical command controls parallelism *across* test assemblies, not xunit's parallelism
+within one, so a single-project run is the same speed with or without it.
+
+The largest remaining item is `Step242LoopRoleNormalizationRegressionTests` at 15s. It cannot
+share a body: each of its tests installs a `CaptureLoopRole*Diagnostics` scope that collects while
+the import runs, so each needs a real import, and several of them import the same file to collect
+different diagnostic families. Unifying capture so one import serves them all is the next step and
+is a real refactor rather than a mechanical one.
+
+## Suggested order## Suggested order
+
+1. ~~Extend `SlowCorpus` and document the two-lane workflow.~~ Done.
+2. ~~Memoized corpus fixture (text + body).~~ Done - Step242 CPU 98.2s to 51.4s.
3. Split the large Step242 classes into separate collections; measure on real hardware.
4. The torus classification-sampling constant, as its own investigation.
-5. Unify diagnostic capture so one import serves several capture-based tests.
+5. Unify diagnostic capture so one import serves several capture-based tests. Now the largest
+ single remaining item at 15s.