fix(testing): rename global GRegistry to GTestRegistry to avoid symbol clash

The test framework's `GRegistry: TList<TTestCaseClass>` collided with
`GRegistry: TTargetRegistry` in blaise.codegen.toolkit.  The compiler emits
unit-level globals under their bare name with export (strong) linkage, so both
`GRegistry` symbols resolved to one shared 8-byte slot.  When the test runner
links both units, the test framework and the codegen toolkit alias the same
storage and free/read it as the wrong type at teardown.

Rename the test-framework global to GTestRegistry — a unit-specific name that
collides with nothing else — so the two registries occupy distinct storage.
This commit is contained in:
Graeme Geldenhuys 2026-06-30 01:44:28 +01:00
parent 93596d135c
commit b5f8800817

View file

@ -205,7 +205,7 @@ implementation
----------------------------------------------------------------------- } ----------------------------------------------------------------------- }
var var
GRegistry: TList<TTestCaseClass>; { registered test-case classes } GTestRegistry: TList<TTestCaseClass>; { registered test-case classes }
{ ----------------------------------------------------------------------- { -----------------------------------------------------------------------
TTest TTest
@ -655,22 +655,22 @@ end;
procedure RegisterTest(ATestClass: TTestCaseClass); procedure RegisterTest(ATestClass: TTestCaseClass);
begin begin
if GRegistry = nil then if GTestRegistry = nil then
GRegistry := TList<TTestCaseClass>.Create(); GTestRegistry := TList<TTestCaseClass>.Create();
GRegistry.Add(ATestClass); GTestRegistry.Add(ATestClass);
end; end;
function GetRegisteredTestCount: Integer; function GetRegisteredTestCount: Integer;
begin begin
if GRegistry = nil then if GTestRegistry = nil then
Result := 0 Result := 0
else else
Result := GRegistry.Count; Result := GTestRegistry.Count;
end; end;
function GetRegisteredTest(AIndex: Integer): TTestCaseClass; function GetRegisteredTest(AIndex: Integer): TTestCaseClass;
begin begin
Result := GRegistry.Get(AIndex); Result := GTestRegistry.Get(AIndex);
end; end;
end. end.