Run 170's Windows gate went red on 37 tests across four assemblies while the same commit passed 14,370/0 locally. The failures were all one family: Expected: "You have 1 500p" <- built with the machine's culture Actual: "You have 1,500p" <- production, correctly invariant The runner is Swedish; this dev box is not. These tests had been passing on CI only because that machine's registry locale had been pinned by hand — machine state, which came undone (almost certainly the reboot after today's hang). Re-pinning it would be a workaround on one machine for a defect in the repo, so this fixes the repo instead. Two genuinely different bugs were hiding in that one symptom. 1. TESTS that build an expected string with the ambient culture and compare it to invariant production output, and test-side recording sinks whose traces are compared against literal golden strings. Those only ever passed on a machine that happens to format like the invariant culture. Pinned to InvariantCulture: the vendor purse/cost expectations, and the motion-funnel, animation-sequencer, framebuffer-resize, resource-slot, and runtime-attack trace sinks. 2. PRODUCTION that formats player-visible retail text with the ambient culture. This one matters beyond CI: retail is a US client, so it shows "2.50", "1,500p" and "(-20)" to everyone. On a Swedish machine acdream was showing "2,50", "1 500p" and "(-20)" with U+2212 MINUS SIGN — the audience for this alpha is literally Swedish. Converted 76 sites to InvariantCulture across the item/creature appraisal formatters, the character stat panel's buff and vitae parentheticals, the appraisal and link-status controllers, the chat /framerate and /location output, the camera sensitivity toast, the time-override toast, the F3 dump, the sky diagnostics, and the world-frame invariant-failure message. DATES are deliberately left on the current culture (CharacterController's birth/login stamp, RuntimeHouseState's purchase expiry). Retail has no answer for a non-US player's date format, and forcing "08/19/2026 7:00:00 PM" on them is a UX decision, not a retail-fidelity one. Apparatus, so the next occurrence is reproducible instead of mysterious: tests/TestCultureInitializer.cs adds an opt-in ACDREAM_TEST_CULTURE knob to every test assembly, linked in through a new tests/Directory.Build.props. Unset — what CI and everyone runs — it changes nothing. ACDREAM_TEST_CULTURE=sv-SE dotnet test ... reproduced all 37 CI failures on this machine plus 6 more the runner's own locale does not surface (the Unicode-minus family), and drove the fix. Verified both ways on the full solution under the release-gate filter: default culture 14,370 passed / 0 failed, and ACDREAM_TEST_CULTURE=sv-SE 14,370 passed / 0 failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
95 lines
3 KiB
C#
95 lines
3 KiB
C#
using System.Globalization;
|
|
using AcDream.App.Input;
|
|
using AcDream.App.Rendering;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
public sealed class FramebufferResizeControllerTests
|
|
{
|
|
[Fact]
|
|
public void ResizePreservesViewportAspectCameraDevToolsOrder()
|
|
{
|
|
var calls = new List<string>();
|
|
var aspect = new ViewportAspectState();
|
|
var owner = new FramebufferResizeController(aspect);
|
|
owner.BindViewport(new Viewport(calls));
|
|
owner.BindCamera(new Camera(calls));
|
|
owner.BindDevTools(new DevTools(calls));
|
|
|
|
owner.Resize(1600, 900);
|
|
|
|
Assert.Equal(["viewport:1600x900", "camera:1.778", "devtools:1600x900"], calls);
|
|
Assert.Equal(1600f / 900f, aspect.Aspect, 5);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0, 720)]
|
|
[InlineData(1280, 0)]
|
|
[InlineData(-1, 720)]
|
|
[InlineData(1280, -1)]
|
|
public void NonPositiveFramebufferIsRejectedWithoutMutatingTargets(int width, int height)
|
|
{
|
|
var calls = new List<string>();
|
|
var aspect = new ViewportAspectState();
|
|
var owner = new FramebufferResizeController(aspect);
|
|
owner.BindViewport(new Viewport(calls));
|
|
owner.BindCamera(new Camera(calls));
|
|
owner.BindDevTools(new DevTools(calls));
|
|
|
|
owner.Resize(width, height);
|
|
|
|
Assert.Empty(calls);
|
|
Assert.Equal(16f / 9f, aspect.Aspect);
|
|
}
|
|
|
|
[Fact]
|
|
public void LateBindingDoesNotReplayEarlierResize()
|
|
{
|
|
var calls = new List<string>();
|
|
var owner = new FramebufferResizeController(new ViewportAspectState());
|
|
owner.Resize(1024, 768);
|
|
|
|
owner.BindViewport(new Viewport(calls));
|
|
owner.BindCamera(new Camera(calls));
|
|
owner.BindDevTools(new DevTools(calls));
|
|
|
|
Assert.Empty(calls);
|
|
owner.Resize(800, 600);
|
|
Assert.Equal(["viewport:800x600", "camera:1.333", "devtools:800x600"], calls);
|
|
}
|
|
|
|
[Fact]
|
|
public void DevToolsBindingReleasesExpectedTargetWithoutReplayingResize()
|
|
{
|
|
var calls = new List<string>();
|
|
var owner = new FramebufferResizeController(new ViewportAspectState());
|
|
var target = new DevTools(calls);
|
|
using var binding = new FramebufferDevToolsBinding(owner, target);
|
|
|
|
owner.Resize(900, 700);
|
|
binding.Dispose();
|
|
binding.Dispose();
|
|
owner.Resize(1000, 800);
|
|
|
|
Assert.Equal(["devtools:900x700"], calls);
|
|
}
|
|
|
|
private sealed class Viewport(List<string> calls) : IFramebufferViewportTarget
|
|
{
|
|
public void ResizeViewport(int width, int height) =>
|
|
calls.Add($"viewport:{width}x{height}");
|
|
}
|
|
|
|
private sealed class Camera(List<string> calls) : IFramebufferCameraTarget
|
|
{
|
|
public void SetAspect(float aspect) => calls.Add(
|
|
// Invariant: compared against literal golden strings.
|
|
string.Create(CultureInfo.InvariantCulture, $"camera:{aspect:F3}"));
|
|
}
|
|
|
|
private sealed class DevTools(List<string> calls) : IFramebufferDevToolsTarget
|
|
{
|
|
public void ResetLayout(int width, int height) =>
|
|
calls.Add($"devtools:{width}x{height}");
|
|
}
|
|
}
|