Is anyone using DUnitX to run unit tests on Linux?
Is anyone using DUnitX to run unit tests on Linux?
I keep getting an AV (see https://github.com/VSoftTechnologies/DUnitX/issues/201)
DUnit just works.
I keep getting an AV (see https://github.com/VSoftTechnologies/DUnitX/issues/201)
DUnit just works.
I think I can help you on that, from what I remember, you need to decorate a local variable with the Unsafe attribute, and the issue is gone. I will have a lunch and come back with more details :)
ReplyDeletePlease, try this and see if it works:
ReplyDeleteTWeakReference = class(TInterfacedObject, IWeakReference)
private
- FData : TObject;
+ [Unsafe] FData : TObject;
protected
function IsAlive : boolean;
function Data : T;
Horácio Filho And now the question on everyones lips... Why does Linux support need that change?
ReplyDeleteSeems Horácio got himself a twin brother (;
ReplyDeleteGraeme Geldenhuys Because Linux(Like the Mobile compilers) uses ARC (and not manual MM like Windows&Mac)
ReplyDeleteGraeme Geldenhuys Not only for Linux but for ARC platforms at all. Using TObject causes ARC to trigger and cause a strong reference to the object behind a weak references interface.
ReplyDeleteFWIW I also changed the TObject cast in TWeakReferencedObject.BeforeDestruction - otherwise it refcounted below zero.
Vincent does not care for those platforms much unfortunately - which is why I keep using DUnit for all tests I have as it just works.
Thanks for the explanation. That all sounds nasty though... Developers having to jump through hoops to make the compiler happy. Fragmenting the Object Pascal language in the process.
ReplyDeleteGraeme Geldenhuys Developers have to know what they are doing and know about different memory models when doing things like this weakreference implementation for interfaces which is trickery anyway.
ReplyDeleteStefan Glienke which is extremely time-intensive to do when there is no ARC available for Windows.
ReplyDeleteJeroen Wiert Pluimers That is true, however apart from the shitty debugging experience I found Linux quite useful for testing ARC related things. Just deploy some tests to the Ubuntu VM. If developing FMX applications though thats a different story.
ReplyDeleteJeroen Wiert Pluimers I was cloned after having lunch hehehehe :-)
ReplyDeleteIt is possible that the issue reported by Stefan is related to quality.embarcadero.com - Log in - Embarcadero Technologies.
ReplyDeleteHorácio Filho Looks like the one - I submitted a PR that fixes that issue.
ReplyDelete