Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
November 17, 2017 Enumerating unittests | ||||
---|---|---|---|---|
| ||||
Hi all, Is there a way to enumerate all the unittests in a specific module? Thanks, Shachar |
November 17, 2017 Re: Enumerating unittests | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shachar Shemesh | On Friday, 17 November 2017 at 08:12:13 UTC, Shachar Shemesh wrote: > Is there a way to enumerate all the unittests in a specific module? Try this: https://dlang.org/spec/traits.html#getUnitTests Mike |
November 17, 2017 Re: Enumerating unittests | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael V. Franklin | On Friday, 17 November 2017 at 08:32:23 UTC, Michael V. Franklin wrote:
> On Friday, 17 November 2017 at 08:12:13 UTC, Shachar Shemesh wrote:
>
>> Is there a way to enumerate all the unittests in a specific module?
>
> Try this: https://dlang.org/spec/traits.html#getUnitTests
>
> Mike
Note that before dmd 2.077.0 that trait only works when compiling all-at-once.
Atila
|
November 18, 2017 Re: Enumerating unittests | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael V. Franklin | On 17/11/17 10:32, Michael V. Franklin wrote:
> On Friday, 17 November 2017 at 08:12:13 UTC, Shachar Shemesh wrote:
>
>> Is there a way to enumerate all the unittests in a specific module?
>
> Try this: https://dlang.org/spec/traits.html#getUnitTests
>
> Mike
>
This is precisely what I asked for, but not what I need :-\
The problem is that it needs a module name to enumerate. I'm not aware of a way to enumerate all modules at compile time. Essentially, I can enumerate all modules at run time, but to get the list of unittests in them, I need to know them at compile time.
Am I missing something?
Shachar
|
November 18, 2017 Re: Enumerating unittests | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shachar Shemesh | On Saturday, 18 November 2017 at 07:35:11 UTC, Shachar Shemesh wrote:
> On 17/11/17 10:32, Michael V. Franklin wrote:
>> On Friday, 17 November 2017 at 08:12:13 UTC, Shachar Shemesh wrote:
>>
>>> Is there a way to enumerate all the unittests in a specific module?
>>
>> Try this: https://dlang.org/spec/traits.html#getUnitTests
>>
>> Mike
>>
>
> This is precisely what I asked for, but not what I need :-\
>
> The problem is that it needs a module name to enumerate. I'm not aware of a way to enumerate all modules at compile time. Essentially, I can enumerate all modules at run time, but to get the list of unittests in them, I need to know them at compile time.
>
> Am I missing something?
>
> Shachar
No, you're not.
Unfortunately this is how compile-time reflection works in D: at the module level (or lower). If you want to reflect on all modules in a project, then the build system has to generate the file that does the reflection for you. There is currently no way to reflect on a package. This is why unit-threaded has a dub configuration to generate the file that drives the reflection, by looking at the file system and writing out something that looks like this:
import unit_threaded;
int main(string[] args) {
return args.runTests!("module1", "module2", ...);
}
You'd have to do something similar.
Alternatively, just use unit-threaded. ;)
Atila
|
Copyright © 1999-2021 by the D Language Foundation