From a04c6414e1a644a63c55499b40e0345bd72df2c6 Mon Sep 17 00:00:00 2001 From: Nibu Date: Thu, 12 Nov 2026 16:10:24 +0000 Subject: [PATCH] Credits test: follow a reviewed font to its SDF asset and fallback tables Prefabs reference the TMP SDF asset made from a font, not the .ttf, so matching the font file guid alone could never fail. The unreferenced-font check now follows the font guid and the guid of every Assets/Fonts file that references a guid already followed (the font's own SDF asset, any SDF asset listing it as a fallback); a file outside Assets/Fonts naming any of them is a use. Co-Authored-By: Claude Sonnet 5.5 --- tests/Aetheria.Shared.Tests/CreditsTests.cs | 27 +++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/CreditsTests.cs b/tests/Aetheria.Shared.Tests/CreditsTests.cs index 8d4a4a6b9..6e9869844 100644 --- a/tests/Aetheria.Shared.Tests/CreditsTests.cs +++ b/tests/Aetheria.Shared.Tests/CreditsTests.cs @@ -207,16 +207,29 @@ namespace Aetheria.Shared.Tests var fonts = FontFiles(); Assert.Equal(Array.Empty(), fonts.Where(font => !accounted.Contains(font)).ToArray()); Assert.Equal(Array.Empty(), accounted.Where(font => !fonts.Contains(font)).ToArray()); - // A reviewed font stays out of the credits only while nothing outside Assets/Fonts uses it. - var guids = ReviewedFonts.Keys.ToDictionary(font => font, font => Regex.Match(Read(font + ".meta"), @"guid: (\w+)").Groups[1].Value); - Assert.All(guids.Values, guid => Assert.Equal(32, guid.Length)); - var users = Directory.EnumerateFiles(Path.Combine(root, "Assets"), "*", SearchOption.AllDirectories) + // A reviewed font stays out of the credits only while nothing outside Assets/Fonts uses it. Prefabs and scenes + // reference the TMP SDF asset made from the font, not the .ttf, so the search follows the font guid, then the + // guid of every file under Assets/Fonts that references a guid already followed: the font's own SDF asset, and + // any other SDF asset carrying it in a fallback table. A use is a file outside Assets/Fonts naming any of them. + var files = Directory.EnumerateFiles(Path.Combine(root, "Assets"), "*", SearchOption.AllDirectories) .Select(path => Path.GetRelativePath(root, path).Replace('\\', '/')) - .Where(path => !path.StartsWith("Assets/Fonts/") && new[] { ".prefab", ".unity", ".mat", ".asset", ".controller" }.Any(ext => path.EndsWith(ext))) + .Where(path => new[] { ".prefab", ".unity", ".mat", ".asset", ".controller" }.Any(ext => path.EndsWith(ext))) .Select(path => (path, text: Read(path))) .ToArray(); - foreach (var (font, guid) in guids) - Assert.Equal(Array.Empty(), users.Where(user => user.text.Contains(guid)).Select(user => user.path).ToArray()); + var inFonts = files.Where(file => file.path.StartsWith("Assets/Fonts/")).ToArray(); + var outside = files.Where(file => !file.path.StartsWith("Assets/Fonts/")).ToArray(); + foreach (var font in ReviewedFonts.Keys) + { + var followed = new System.Collections.Generic.HashSet { Regex.Match(Read(font + ".meta"), @"guid: (\w+)").Groups[1].Value }; + Assert.All(followed, guid => Assert.Equal(32, guid.Length)); + for (var grew = true; grew;) + { + grew = false; + foreach (var file in inFonts.Where(file => followed.Any(guid => file.text.Contains(guid))).ToArray()) + grew |= followed.Add(Regex.Match(Read(file.path + ".meta"), @"guid: (\w+)").Groups[1].Value); + } + Assert.Equal(Array.Empty(), outside.Where(user => followed.Any(guid => user.text.Contains(guid))).Select(user => user.path).ToArray()); + } } [Fact]