AetherDb for ship authors: rooted at a game folder, found in ModTools; ship-ID rule in create
FindRoot keys on GameData/Aetheria.cc. ShipAuthoringStore.RequireShipId is the one ID rule (Validate and create), refusing Windows device names and a trailing dot, naming no value. The add-on's one preference is Game folder; _aetheria_repo, the repo preference and the dotnet-run invocation are deleted. Smokes take SMOKE_GAME_FOLDER. Not yet built or tested at this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7f64e0d733
commit
63d16e81f3
11 changed files with 183 additions and 52 deletions
41
tests/Aetheria.Shared.Tests/AetherDbRootTests.cs
Normal file
41
tests/Aetheria.Shared.Tests/AetherDbRootTests.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
[CollectionDefinition("process working directory", DisableParallelization = true)]
|
||||
public sealed class ProcessWorkingDirectoryCollection { }
|
||||
|
||||
// FindRoot reads the process working directory, so these run alone.
|
||||
[Collection("process working directory")]
|
||||
public sealed class AetherDbRootTests : IDisposable
|
||||
{
|
||||
private readonly TempDirectory _game = new TempDirectory();
|
||||
private readonly string _previous = Environment.CurrentDirectory;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Environment.CurrentDirectory = _previous;
|
||||
_game.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheRootIsTheNearestFolderWhoseGameDataHoldsAetheriaCc()
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(_game.Path, "GameData", "Mods", "probe.a"));
|
||||
File.WriteAllBytes(Path.Combine(_game.Path, "GameData", "Aetheria.cc"), Array.Empty<byte>());
|
||||
Environment.CurrentDirectory = _game.Path;
|
||||
var game = Environment.CurrentDirectory;
|
||||
Environment.CurrentDirectory = Path.Combine(game, "GameData", "Mods", "probe.a");
|
||||
Assert.Equal(game, AetherDb.FindRoot());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AFolderHoldingOnlyTheRepositoryMarkerIsNotARoot()
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(_game.Path, "Aetheria.Shared"));
|
||||
File.WriteAllText(Path.Combine(_game.Path, "Aetheria.Shared", "Aetheria.Shared.csproj"), "");
|
||||
Environment.CurrentDirectory = _game.Path;
|
||||
var error = Assert.Throws<DirectoryNotFoundException>(AetherDb.FindRoot);
|
||||
Assert.Contains("GameData holds Aetheria.cc", error.Message);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue