Route every real-catalog test reader through TestCatalog

Deletes the direct GameData/Aetheria.cc opens (FireControlCut124Tests x3, FireControlCut7Tests, MiningCut3Tests x2,
RestoredHullsTests x11) in favour of TestCatalog.Repo, and the eight copies of the shipped-assembly registry in favour of
TestCatalog.Registry() (real-catalog-readers-bypass). Pirates and Roles command tests keep copying the shipped catalog (they
rewrite a copy through AetherDb) and take only the registry.

Builds; not yet run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-10 06:50:26 +02:00
commit d6100b18ca
6 changed files with 26 additions and 44 deletions

View file

@ -475,7 +475,7 @@ public sealed partial class FireControlCut124Tests : IDisposable
public void AGrazingBlastAtAShippedHullsFarthestCornerLands(string hullName)
{
Shape shape;
var cache = OpenReadOnlyRealCatalog(Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc"), out _);
var cache = OpenReadOnlyRealCatalog(TestCatalog.Repo, out _);
try { shape = cache.GetByName<HullData>(hullName).Shape; }
finally { cache.Dispose(); }
@ -2573,9 +2573,7 @@ public sealed partial class FireControlCut124Tests : IDisposable
private static CultCache OpenReadOnlyRealCatalog(string catalogPath, out SingleFileMessagePackBackingStore store)
{
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
var registry = TestCatalog.Registry();
var cache = new CultCache(registry);
store = new SingleFileMessagePackBackingStore(catalogPath, true);
cache.AddBackingStore(store, AetheriaStores.CatalogTypes);
@ -2588,7 +2586,7 @@ public sealed partial class FireControlCut124Tests : IDisposable
[Fact]
public void ShippedCatalogIsNeutralOnBlastRadiusAndFuse()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var cache = OpenReadOnlyRealCatalog(gameData, out var store);
try
{
@ -2621,7 +2619,7 @@ public sealed partial class FireControlCut124Tests : IDisposable
[Fact]
public void WeaponFuseAndBlastRadiusRoundTripThroughAWrittenCatalog()
{
var src = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var src = TestCatalog.Repo;
var fuseValues = new WeaponFuse?[] { null, WeaponFuse.Contact, WeaponFuse.Proximity, WeaponFuse.Delayed };
var radiusValues = new float?[] { null, 0f, 12.5f };
@ -2636,9 +2634,7 @@ public sealed partial class FireControlCut124Tests : IDisposable
var cache = OpenReadOnlyRealCatalog(tmp, out _);
cache.Dispose();
}
var writeCache = new CultCache(CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null)));
var writeCache = new CultCache(TestCatalog.Registry());
writeCache.AddBackingStore(new SingleFileMessagePackBackingStore(tmp, false), AetheriaStores.CatalogTypes);
var w = writeCache.GetAll<WeaponItemData>().OrderBy(x => x.Name).First();
w.Fuse = fuse;

View file

@ -200,7 +200,7 @@ public sealed class FireControlCut7Tests : IDisposable
[Fact]
public void ShippedCatalogOpensAndGeneratesAnArmedHull()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
using var cache = OpenReadOnlyRealCatalog(gameData);
// Force every EquippableItemData -- WeaponItemData included, the type the broken merge could not
@ -255,9 +255,7 @@ public sealed class FireControlCut7Tests : IDisposable
// validation loop -- without the test assembly's own fixture type poisoning it.
private static CultCache OpenReadOnlyRealCatalog(string catalogPath)
{
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
var registry = TestCatalog.Registry();
var cache = new CultCache(registry);
try
{

View file

@ -761,9 +761,7 @@ public sealed partial class MiningCut3Tests : IDisposable
// would otherwise be demanded of a catalog that was never authored with it.
private static CultCache OpenShippedCatalogCopy(string catalogPath, string runPath)
{
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttributes(typeof(CultDocumentAttribute), false).Length > 0));
var registry = TestCatalog.Registry();
var cache = new CultCache(registry);
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(catalogPath, false), AetheriaStores.CatalogTypes);
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(runPath), AetheriaStores.RunTypes);
@ -776,7 +774,7 @@ public sealed partial class MiningCut3Tests : IDisposable
[Fact]
public void GenerationChoosesTheKindByTheSameFunction()
{
var shipped = Path.Combine(RestoredHullsTests.FindRepoRoot(), "GameData", "Aetheria.cc");
var shipped = TestCatalog.Repo;
var belts = 0;
for (uint seed = 1; seed <= 25 && belts < 3; seed++)
{
@ -1043,7 +1041,7 @@ public sealed partial class MiningCut3Tests : IDisposable
var dir = Path.Combine(_root, "shipped");
Directory.CreateDirectory(dir);
var catalog = Path.Combine(dir, "Aetheria.cc");
File.Copy(Path.Combine(RestoredHullsTests.FindRepoRoot(), "GameData", "Aetheria.cc"), catalog);
File.Copy(TestCatalog.Repo, catalog);
using var cache = OpenShippedCatalogCopy(catalog, Path.Combine(dir, "run.cc"));
Assert.Contains(cache.GetAll<FieldKindData>(), kind => kind.GenerationWeight > 0f);
}

View file

@ -25,9 +25,7 @@ public sealed class PiratesFactionCommandTests : IDisposable
// AetherDb.Open composes the process-wide registry, which in this test host also sees this assembly's TestCatalogGlobal
// (see FireControlCut7Tests). So the copy is stripped through a registry scoped to the shipped assembly and then given
// the record that registry's shared sibling demands, as AetheriaStoresTests does.
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
var registry = TestCatalog.Registry();
using (var cache = new CultCache(registry))
{
cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes);

View file

@ -38,9 +38,7 @@ public sealed class RestoredHullsTests
// real catalog's validation the way the shared, AppDomain-scanning CultCache() default would.
private static CultCache OpenReadOnlyRealCatalog(string catalogPath)
{
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
var registry = TestCatalog.Registry();
var cache = new CultCache(registry);
cache.AddBackingStore(new SingleFileMessagePackBackingStore(catalogPath, true), AetheriaStores.CatalogTypes);
return cache;
@ -54,7 +52,7 @@ public sealed class RestoredHullsTests
throw new DirectoryNotFoundException("Run from inside the Aetheria repository.");
}
internal static CultCache OpenCatalog() => OpenReadOnlyRealCatalog(Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc"));
internal static CultCache OpenCatalog() => OpenReadOnlyRealCatalog(TestCatalog.Repo);
// Shared tutorial-galaxy construction settings (Assets/Resources/Settings.asset's own values), factored out
// so every test that needs a real tutorial Galaxy -- not just EntranceZoneAlwaysGetsADockedStationAcrossSeeds
@ -140,7 +138,7 @@ public sealed class RestoredHullsTests
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-nolagrange-scan-{Guid.NewGuid():N}.cc");
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc"), scratchRun);
using var cache = OpenReadOnlyRealCatalogWithScratchRun(TestCatalog.Repo, scratchRun);
return ScanForNoLagrangeCandidateZone(cache);
}
finally
@ -170,9 +168,7 @@ public sealed class RestoredHullsTests
// catalog-only cache has no home for them. A scratch run file, deleted after the seed that used it.
private static CultCache OpenReadOnlyRealCatalogWithScratchRun(string catalogPath, string runPath)
{
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
var registry = TestCatalog.Registry();
var cache = new CultCache(registry);
cache.AddBackingStore(new SingleFileMessagePackBackingStore(catalogPath, true), AetheriaStores.CatalogTypes);
cache.AddBackingStore(new SingleFileMessagePackBackingStore(runPath), AetheriaStores.RunTypes);
@ -357,7 +353,7 @@ public sealed class RestoredHullsTests
var tutorialSettings = TutorialGalaxySettings();
var background = TutorialBackgroundSettings();
var names = TutorialNameSettings();
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var sawGenuineLagrangeOrbit = false;
for (uint seed = 1; seed <= 25; seed++)
{
@ -398,7 +394,7 @@ public sealed class RestoredHullsTests
var tutorialSettings = TutorialGalaxySettings();
var background = TutorialBackgroundSettings();
var names = TutorialNameSettings();
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var sawGenuineCandidate = false;
for (uint seed = 1; seed <= 25; seed++)
{
@ -439,7 +435,7 @@ public sealed class RestoredHullsTests
[Fact]
public void ThrowReachableWithAuthoredSettings()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-throw-{Guid.NewGuid():N}.cc");
try
{
@ -473,7 +469,7 @@ public sealed class RestoredHullsTests
[Fact]
public void MultiRootEntranceStationOrbitsAreAlwaysParentedWithPositiveDistance()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-multiroot-{Guid.NewGuid():N}.cc");
try
{
@ -524,7 +520,7 @@ public sealed class RestoredHullsTests
var tutorialSettings = TutorialGalaxySettings();
var background = TutorialBackgroundSettings();
var names = TutorialNameSettings();
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var checkedAny = false;
for (uint seed = 1; seed <= 25; seed++)
@ -723,7 +719,7 @@ public sealed class RestoredHullsTests
[Fact]
public void TutorialEntranceWithNoLagrangeCandidateStillSeatsAStationWithFiniteNearbyTurrets()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-widened-{Guid.NewGuid():N}.cc");
try
{
@ -772,7 +768,7 @@ public sealed class RestoredHullsTests
[Fact]
public void EntranceOverrideDoesNotLeakToOtherTutorialZonesOrNonTutorialGames()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-leak-{Guid.NewGuid():N}.cc");
try
{
@ -813,7 +809,7 @@ public sealed class RestoredHullsTests
[Fact]
public void ForcedTutorialEntranceStationDoesNotInflateEnemyCount()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-enemycount-{Guid.NewGuid():N}.cc");
try
{
@ -895,7 +891,7 @@ public sealed class RestoredHullsTests
[Fact]
public void WideningDoesNotLeakToANonEntranceNoLagrangeZoneThatRollsAStation()
{
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
var gameData = TestCatalog.Repo;
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-widen-leak-{Guid.NewGuid():N}.cc");
try
{

View file

@ -30,7 +30,7 @@ public sealed class RolesBackfillCommandTests : IDisposable
{
Directory.CreateDirectory(Path.Combine(_root, "GameData"));
File.Copy(Path.Combine(AetherDb.FindRoot(), "GameData", "Aetheria.cc"), CatalogPath);
using var cache = new CultCache(ScopedRegistry());
using var cache = new CultCache(TestCatalog.Registry());
cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes);
var products = cache.GetAll<FactionProductData>().ToArray();
foreach (var design in cache.GetAll<EquippableItemData>().Where(d => Flattened.Contains(d.Name) || Unnamed.Any(u => u.Design == d.Name)))
@ -38,15 +38,11 @@ public sealed class RolesBackfillCommandTests : IDisposable
}
// A registry scoped to the shipped assembly, so this test assembly's own documents never reach the real catalog.
private static CultDocumentRegistry ScopedRegistry() => CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
.Where(t => t is { IsAbstract: false, IsInterface: false })
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
// Puts the named designs back to the state they shipped in before the backfill, through a registry scoped to the shipped
// assembly (as PiratesFactionCommandTests strips its faction).
private void Reset(bool flattened, bool unnamed)
{
using var cache = new CultCache(ScopedRegistry());
using var cache = new CultCache(TestCatalog.Registry());
cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes);
var designs = cache.GetAll<EquippableItemData>().ToArray();
var products = cache.GetAll<FactionProductData>().ToArray();