Wren becomes a test fixture; compose and validate refuse an offered hull with no schematic

Move the starter-box aetheria.wren package from GameData/Mods to tests/fixtures/mods (LFS rule added) so it no longer ships; the Wren tests compose it through TestCatalog.RepoWithFixtures. ShipModCatalog.SchematicFault, built on LoadoutGenerator.IsOffered, excludes an offered hull with no schematic lines at compose and is reported by ship-authoring validate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-17 18:53:45 +01:00
commit ce5d012540
13 changed files with 121 additions and 9 deletions

View file

@ -107,7 +107,7 @@ public class ElementIdUpgradeTests
{
using var directory = new TempDirectory();
var copy = Path.Combine(directory.Path, "ship.cc");
File.Copy(Path.Combine(RunStartTests.FindRepoRoot(), "GameData", "Mods", "aetheria.wren", "ship.cc"), copy);
File.Copy(Path.Combine(RunStartTests.FindRepoRoot(), "tests", "fixtures", "mods", "aetheria.wren", "ship.cc"), copy);
var bytes = File.ReadAllBytes(copy);
var (hull, visual, products) = ShipAuthoringStore.Load(copy);

View file

@ -61,6 +61,7 @@ public sealed class RestoredHullsTests
}
internal static CultCache OpenCatalog() => OpenReadOnlyRealCatalog(TestCatalog.Repo);
internal static CultCache OpenCatalogWithFixtures() => OpenReadOnlyRealCatalog(TestCatalog.RepoWithFixtures);
// 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

View file

@ -49,6 +49,53 @@ public sealed class ShipModCatalogTests : IDisposable
AssertOnlyTheDerivedFile();
}
// A package selling one product through the one product writer, with or without schematic lines and offered or not.
private void PricedPackage(string id, bool lines, bool offered)
{
var factionKey = AddFaction();
WritePackage(id, id, tweak: ship =>
{
ship.Hull.Price = 100;
if (!lines) ship.Visual.SchematicLines = new List<ShipPolyline>();
});
using var cache = ShipAuthoringStore.Open(Path.Combine(Mods, id, "ship.cc"), writable: true);
ShipAuthoringStore.WriteProduct(cache, id, new FactionProductData
{
Name = id + " product",
Design = new CultRecordRef<CraftedItemData>(ShipModCatalog.HullKey(id)),
Manufacturer = new CultRecordRef<Faction>(factionKey),
NotOffered = !offered
});
cache.FlushAsync().Wait();
}
private CultRecordKey AddFaction()
{
using var cache = AetheriaStores.Open(Shipped, catalogWritable: true);
var existing = cache.GetAll<Faction>().FirstOrDefault();
var key = existing != null ? cache.RefOf(existing).Key : cache.Upsert(new Faction { Name = "Acme", ShortName = "ACM" }).Key;
cache.FlushAsync().Wait();
return key;
}
// An offered hull is drawn by its schematic lines (ShipModVisual.BuildLineMesh builds nothing from none), so one without any
// is left out of the catalog with its reason; an offered hull with lines and an unoffered stand-in without them both compose.
[Fact]
public void ComposeExcludesAnOfferedHullWithoutSchematicLinesAndKeepsTheRest()
{
PricedPackage("mod.offeredbare", lines: false, offered: true);
PricedPackage("mod.offeredlined", lines: true, offered: true);
PricedPackage("mod.standin", lines: false, offered: false);
var composition = ShipModCatalog.Compose(Shipped, Derived, Mods);
Assert.Equal(new[] { "mod.offeredlined", "mod.standin" }, composition.Included.OrderBy(id => id, StringComparer.Ordinal));
var excluded = Assert.Single(composition.Excluded);
Assert.Equal("mod.offeredbare", excluded.Package);
Assert.Contains("mod.offeredbare", excluded.Reason);
Assert.Contains("no schematic", excluded.Reason);
}
// A package's station kind is checked per package: a bad one is left out, named with its reason, and the derived catalog
// still opens. The shipped catalog's own check is unchanged.
[Fact]

View file

@ -99,6 +99,30 @@ public sealed class ShipProductTests : IDisposable
}
}
// validate gives the verdict compose gives: an offered hull with no schematic lines is refused, an unoffered one is not.
[Fact]
public void ValidateRefusesAnOfferedHullWithoutSchematicLinesAsComposeDoes()
{
Environment.CurrentDirectory = _root.Path;
string Bare(string id, bool offered)
{
var directory = ShipFixture.WritePackage(Mods, id, id, tweak: ship => { ship.Hull.Price = 100; ship.Visual.SchematicLines = new List<ShipPolyline>(); });
var path = Path.Combine(directory, "ship.cc");
using var cache = ShipAuthoringStore.Open(path, writable: true);
var product = Product(id + " product", _acme, id);
product.NotOffered = !offered;
ShipAuthoringStore.WriteProduct(cache, id, product);
cache.FlushAsync().Wait();
return path;
}
var (code, _, error) = Run("validate", Bare("mod.offered", offered: true));
Assert.Equal(1, code);
Assert.Contains("no schematic", error);
Assert.Equal(0, Run("validate", Bare("mod.standin", offered: false)).Item1);
Assert.Equal(new[] { "mod.standin" }, ShipModCatalog.Compose(Shipped, Derived, Mods).Included);
}
[Fact]
public void APackageWithAnUnknownMakerIsExcluded()
{

View file

@ -18,6 +18,12 @@ internal static class TestCatalog
// The repo's catalog with its first-party packages composed in, resolved once per test process.
public static string Repo => Shared.Value;
private static readonly Lazy<string> SharedWithFixtures = new Lazy<string>(() => ForRepoWithFixtures(RunStartTests.FindRepoRoot()));
// The repo's catalog with its first-party packages and the test fixture packages (tests/fixtures/mods) composed in. For a
// test whose subject is a fixture package; Repo is the catalog the game ships.
public static string RepoWithFixtures => SharedWithFixtures.Value;
// The shipped assembly's own [CultDocument] types and nothing the test assembly registers (CultDocumentRegistry.ForTypes
// does not re-scan the AppDomain), so this assembly's fixture documents never become catalog globals the real catalog
// must hold. The one registry every test that opens a real catalog, and the composition behind Repo, uses.
@ -34,6 +40,21 @@ internal static class TestCatalog
return Resolve(Path.Combine(repoRoot, "GameData", "Aetheria.cc"), Path.Combine(repoRoot, "GameData", "Mods"), work);
}
// ForRepo over a mods root assembled from GameData/Mods and tests/fixtures/mods, copied into the per-call temp directory.
public static string ForRepoWithFixtures(string repoRoot)
{
var work = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "aetheria-testcatalog-" + Guid.NewGuid().ToString("N"))).FullName;
AppDomain.CurrentDomain.ProcessExit += (_, _) => { try { Directory.Delete(work, true); } catch (IOException) { } };
var mods = Path.Combine(work, "Mods");
foreach (var root in new[] { Path.Combine(repoRoot, "GameData", "Mods"), Path.Combine(repoRoot, "tests", "fixtures", "mods") })
foreach (var package in Directory.GetDirectories(root))
{
var target = Directory.CreateDirectory(Path.Combine(mods, Path.GetFileName(package))).FullName;
foreach (var file in Directory.GetFiles(package)) File.Copy(file, Path.Combine(target, Path.GetFileName(file)));
}
return Resolve(Path.Combine(repoRoot, "GameData", "Aetheria.cc"), mods, work);
}
public static string Resolve(string shippedCatalog, string modsRoot, string workDir)
{
// Every directory under the first-party tree is a package. The game treats a directory without a ship.cc as not a

View file

@ -5,7 +5,7 @@ using Xunit;
using static CultMath.math;
using Random = CultMath.Random;
// GameData/Mods/aetheria.wren: a first-party package written by `ship-authoring starter --like Djinni`, then priced and given
// tests/fixtures/mods/aetheria.wren: a test fixture package, not shipped with the game, written by `ship-authoring starter --like Djinni`, then priced and given
// an unoffered Aeronautics Unlimited product by `ship-authoring price` and `product`; its model is the starter's boxed
// stand-in. It is the pipeline's proof from a hull package on disk to a ship that flies in the headless simulation: the
// package composes into the catalog, its mounts take catalog gear, and the fitted ship moves under thrust. `fly` cannot
@ -19,7 +19,7 @@ public sealed class WrenPackageTests
[Fact]
public void TheStarterPackageIsInTheComposedCatalogWithTheStatsOfItsLike()
{
using var cache = RestoredHullsTests.OpenCatalog();
using var cache = RestoredHullsTests.OpenCatalogWithFixtures();
var hull = Wren(cache);
var like = cache.GetByName<HullData>("Djinni");
Assert.NotNull(hull);
@ -34,7 +34,7 @@ public sealed class WrenPackageTests
[Fact]
public void TheStarterIsMadeButNeverOffered()
{
using var cache = RestoredHullsTests.OpenCatalog();
using var cache = RestoredHullsTests.OpenCatalogWithFixtures();
var hull = Wren(cache);
var product = Assert.Single(cache.GetAll<FactionProductData>(), p => p.Design.Key.Equals(ShipModCatalog.HullKey(Id)));
Assert.Equal("Aeronautics Unlimited", cache.Get(product.Manufacturer).Name);
@ -47,7 +47,7 @@ public sealed class WrenPackageTests
[Fact]
public void EveryMountTakesACatalogDesign()
{
using var cache = RestoredHullsTests.OpenCatalog();
using var cache = RestoredHullsTests.OpenCatalogWithFixtures();
var designs = cache.GetAll<EquippableItemData>().ToArray();
var bare = Wren(cache).Hardpoints.Where(hardpoint => !designs.Any(hardpoint.Takes)).Select(hardpoint => $"{hardpoint.Transform} ({hardpoint.Type})").ToArray();
// No shield design fits a 1x1 yet (hardpoint-fit lists Djinni's 4-cell shield with none either); every other mount does.
@ -57,7 +57,7 @@ public sealed class WrenPackageTests
[Fact]
public void TheStarterFliesUnderThrust()
{
using var cache = RestoredHullsTests.OpenCatalog();
using var cache = RestoredHullsTests.OpenCatalogWithFixtures();
var ship = RestoredHullsTests.BuildThrustedShip(cache, "Wren");
var start = ship.Velocity;
ship.MovementDirection = float2(0, 1);

BIN
tests/fixtures/mods/aetheria.wren/ship.cc (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
tests/fixtures/mods/aetheria.wren/ship.glb (Stored with Git LFS) vendored Normal file

Binary file not shown.