D, Unit_Threaded, and GtkD

Russel Winder russel at winder.org.uk
Sun May 17 10:19:38 UTC 2020


On Sat, 2020-05-16 at 11:37 +0000, Cogitri via Digitalmars-d-learn wrote:
> On Saturday, 16 May 2020 at 10:51:07 UTC, Russel Winder wrote:
> > Has anyone got any D code using the Glib event loop, usually 
> > GtkD code I'd guess, that is well tested using Unit_Threaded?
> 
> I always had a hard time doing unittests for things with as many 
> moving parts as glib based software, so I usually just do 
> integration tests like so: 
> https://gitlab.alpinelinux.org/Cogitri/apk-polkit/-/blob/1dfbe2b3d959e3c083fcb82419a0a0401c485937/tests/apkd_dbus_server/addAndDelete.d
> 
> Maybe I should look into Unit_Threaded for more fine grained 
> tests, but I think the effort for all the mocking stuff that I'd 
> have to implement even for a (relatively) simple GDBus 
> application would be quite substantial.

I am experimenting with using manual control of the Glib event loop using the
pending and iteration methods on the default MainContext within each unit-
threaded test. The alternative of running a GTK application and then putting
the tests in as an asynchronous sequence only works with Rust and Python since
D has no coroutines of any sort.

Of course now there is jin.go which is a synchronous multi-tasking approach
with channels rather than an asynchronous approach available in D. 

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20200517/70055c49/attachment.sig>


More information about the Digitalmars-d-learn mailing list