Parallel execution of unittests

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 30 22:01:14 PDT 2014


On Wed, 30 Apr 2014 14:35:45 -0700
Andrei Alexandrescu via Digitalmars-d <digitalmars-d at puremagic.com>
wrote:
> Agreed. I think we should look into parallelizing all unittests. --

I'm all for parallelizing all unittest blocks that are pure, as doing
so would be safe, but I think that we're making a big mistake if we try
and insist that all unittest blocks be able to be run in parallel. Any
that aren't pure are not guaranteed to be parallelizable, and any which
access system resources or other global, mutable state stand a good
chance of breaking.

If we make it so that the functions generated from unittest blocks have
their purity inferred, then any unittest block which can safely be
parallelized could then be parallelized by the test runner based on
their purity, and any impure unittest functions could then be safely
run in serial. And if you want to make sure that a unittest block is
parallizable, then you can just explicitly mark it as pure.

With that approach, we don't risk breaking existing unit tests, and it
allows tests that need to not be run in parallel to work properly by
guaranteeing that they're still run serially. And it even make it so
that many tests are automatically parallelizable without the programmer
having to do anything special for it.

- Jonathan M Davis


More information about the Digitalmars-d mailing list