Named unittests and __traits(getModules)

Jacob Carlborg doob at me.com
Fri May 24 19:20:43 UTC 2019


On 2019-05-24 20:53, Andre Pany wrote:

> Maybe my understanding is wrong. As far as I understand, your example 
> only works as long as foo.d is compiled first and and main.d last. 

No, please give it a try. It works.

> The order is guaranteed by the import foo statement.
> 
> But if now use __traits(getModules) in main.d and compile with this 
> command:
> dmd -c main.d && dmd main.o -run foo.d
> I assume it won't work anymore.
> 
> The order of compilation will then matter and I do not how you can 
> ensure the file containing the __traits(getModules) is always compiled 
> as last.

The compiler would need to invoke a druntime function every time the 
compiler is invoked. This druntime function will call run 
`__traits(getModules)`. It's basically the same thing as I've done in my 
example.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list