Parallel execution of unittests
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 30 13:41:31 PDT 2014
On 4/30/14, 1:19 PM, Jacob Carlborg wrote:
> On 2014-04-30 17:43, Andrei Alexandrescu wrote:
>> Hello,
>>
>>
>> A coworker mentioned the idea that unittests could be run in parallel
>> (using e.g. a thread pool). I've rigged things to run in parallel
>> unittests across modules, and that works well. However, this is too
>> coarse-grained - it would be great if each unittest could be pooled
>> across the thread pool. That's more difficult to implement.
>
> Can't we just collect all unit tests with __traits(getUnitTests) and put
> them through std.parallelism:
>
> foreach (unitTest ; unitTests.parallel)
> unitTest();
I didn't know of that trait; I adapted code from druntime/src/test_runner.d.
> Named unit tests are already possible with the help of UDA's:
>
> @name("foo bar") unittest
> {
> assert(true);
> }
>
> I've tried several times here, in reviews, to get people to add some
> description to the unit tests. But so far no one has agreed.
Yah I think that's possible but I'd like the name to be part of the
function name as well e.g. unittest__%s.
> I'm using something quite similar to RSpec from the Ruby world:
>
> describe! "toMsec" in {
> it! "returns the time in milliseconds" in {
> assert(true);
> }
> }
>
> This uses the old syntax, with UDA's it becomes something like this:
>
> @describe("toMsec")
> {
> @it("returns the time in milliseconds") unittest
> {
> assert(true);
> }
> }
That looks... interesting.
>> Thoughts? Would anyone want to work on such stuff?
>
> Are you thinking of built-in support or an external library?
Built in with possible help from druntime and/or std.
Andrei
More information about the Digitalmars-d
mailing list