How to iterate through all modules for use with the new getUnitTests trait?
Daniel Davidson
nospam at spam.com
Wed Nov 6 13:36:50 PST 2013
On Wednesday, 6 November 2013 at 21:26:09 UTC, Dicebot wrote:
> On Wednesday, 6 November 2013 at 21:07:47 UTC, Gary Willoughby
> wrote:
>> Unfortunately this still suffers the same problem in that you
>> need a module symbol name to do anything. I need to get all
>> module symbols at compile time.
>
> You need only symbol name of your root compiled module which
> imports all others. All imported ones will be available in its
> member list, exactly what this snippet shows.
I think what OP wants to do is not as straightforward. I believe
the goal is to have a module somewhere "out there" that looks at
all other modules in the executable. I don't think it works that
way, as how could a compile time test module know about modules
that have pulled it in?
Have a look at
(https://github.com/patefacio/d-help/blob/master/d-help/opmix/ut.d)
where I used dicebot's previous example code to find all
unittests of the *current module*. The trick is to mixin code
that examines the current __MODULE__ for your tests. This may not
be the best way but it is working well for me.
The thread was `selectively running unittest functions`
http://forum.dlang.org/post/xjcgtbyrqzbosajxbgod@forum.dlang.org
More information about the Digitalmars-d-learn
mailing list