October 25, 2013 Re: selectively running unittest functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Friday, 25 October 2013 at 15:55:11 UTC, Gary Willoughby wrote:
> For information how to implement your own unit test handler see the bottom of the report module here:
>
> https://github.com/nomad-software/dunit
>
> From there you can selectively run tests based on some outside criteria. I think the new trait will open up further possibilities too.
After 2.064 is out and good support of attributed test blocks is added I really recommend to consider separating core modules that support it into Phobos proposal. Will need to convince some conservative guys this is actually needed, but I think it is doable :P
|
October 25, 2013 Re: selectively running unittest functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: > This will work starting with 2.064: Ok. I'll keep pressing. Here is an updated version: http://pastebin.com/g6FWsTkr The idea is to be able to just import ut, annotate as you have described and get unit tests run. I want to mixin the equivalent of your "main" in each module that just pulls in a module constructors to evaluate what tests are there. The code in the paste crashes on the call to getUnitests. If I comment out `alias tests = TypeTuple!(__traits(getUnitTests, mod));` then I see similar call to `alias members = TypeTuple!(__traits(allMembers, mod));` work just fine. Is this the right way to use this? Any pointers on the segmentation fault? Thanks Dan |
October 25, 2013 Re: selectively running unittest functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Davidson | On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote: > On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: >> This will work starting with 2.064: > > Ok. I'll keep pressing. Here is an updated version: http://pastebin.com/g6FWsTkr > > The idea is to be able to just import ut, annotate as you have described and get unit tests run. I want to mixin the equivalent of your "main" in each module that just pulls in a module constructors to evaluate what tests are there. The code in the paste crashes on the call to getUnitests. > > If I comment out `alias tests = TypeTuple!(__traits(getUnitTests, mod));` then I see similar call to `alias members = TypeTuple!(__traits(allMembers, mod));` work just fine. > > Is this the right way to use this? Any pointers on the segmentation fault? > > Thanks > Dan Ok, binary reduction has shown the seg fault was due to a debug import. This code causes a crash for me - just because of the getUnittests. If I remove the debug import it works. Since I use debug imports in general, I'm not so sure it is worthwhile to pursue the named unit test approach at this time. import std.typetuple; import std.stdio; debug import std.datetime; unittest { writeln("In Test!!"); } mixin("alias mod = " ~ __MODULE__ ~ ";"); alias tests = TypeTuple!(__traits(getUnitTests, mod)); static this() { writeln("Done"); } Thanks Dan |
October 26, 2013 Re: selectively running unittest functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Davidson | 26-Oct-2013 02:36, Daniel Davidson пишет: > On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote: >> On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: >>> This will work starting with 2.064: >> >> Ok. I'll keep pressing. Here is an updated version: >> http://pastebin.com/g6FWsTkr >> >> The idea is to be able to just import ut, annotate as you have >> described and get unit tests run. I want to mixin the equivalent of >> your "main" in each module that just pulls in a module constructors to >> evaluate what tests are there. The code in the paste crashes on the >> call to getUnitests. >> >> If I comment out `alias tests = TypeTuple!(__traits(getUnitTests, >> mod));` then I see similar call to `alias members = >> TypeTuple!(__traits(allMembers, mod));` work just fine. >> >> Is this the right way to use this? Any pointers on the segmentation >> fault? >> >> Thanks >> Dan > > > Ok, binary reduction has shown the seg fault was due to a debug import. It's a bug so please file it in bugzilla. Don't let them go unnoticed ;) http://d.puremagic.com/issues/ > This code causes a crash for me - just because of the getUnittests. If I > remove the debug import it works. Since I use debug imports in general, > I'm not so sure it is worthwhile to pursue the named unit test approach > at this time. > > import std.typetuple; > import std.stdio; > debug import std.datetime; > unittest { writeln("In Test!!"); } > mixin("alias mod = " ~ __MODULE__ ~ ";"); > alias tests = TypeTuple!(__traits(getUnitTests, mod)); > static this() { > writeln("Done"); > } > > > Thanks > Dan -- Dmitry Olshansky |
October 26, 2013 Re: selectively running unittest functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On Saturday, 26 October 2013 at 08:09:26 UTC, Dmitry Olshansky wrote:
> 26-Oct-2013 02:36, Daniel Davidson пишет:
>> On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote:
>>> On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote:
>>>> This will work starting with 2.064:
>>>
>>> Ok. I'll keep pressing. Here is an updated version:
>>> http://pastebin.com/g6FWsTkr
>>>
>>> The idea is to be able to just import ut, annotate as you have
>>> described and get unit tests run. I want to mixin the equivalent of
>>> your "main" in each module that just pulls in a module constructors to
>>> evaluate what tests are there. The code in the paste crashes on the
>>> call to getUnitests.
>>>
>>> If I comment out `alias tests = TypeTuple!(__traits(getUnitTests,
>>> mod));` then I see similar call to `alias members =
>>> TypeTuple!(__traits(allMembers, mod));` work just fine.
>>>
>>> Is this the right way to use this? Any pointers on the segmentation
>>> fault?
>>>
>>> Thanks
>>> Dan
>>
>>
>> Ok, binary reduction has shown the seg fault was due to a debug import.
>
> It's a bug so please file it in bugzilla. Don't let them go unnoticed ;)
> http://d.puremagic.com/issues/
>
Yes - I have.
|
October 26, 2013 Re: selectively running unittest functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Davidson | Here is a working solution: https://github.com/patefacio/d-help/blob/master/d-help/opmix/ut.d Currently it only pulls in unittests at the module level. I'm sure it will work on unittests scoped to structs/classes, I just need to figure out how to determine if a compile time named object is an aggregate, as __traits(getUnitTests, foo) will complain if foo is not a module or aggregate. With a source a.d and b.d like in: https://github.com/patefacio/d-help/blob/master/d-help/opmix/examples/ut/ it can pull out by module name and uda test name. It has a -s summary option as well. Here is sample output: http://pastebin.com/fYd7k1Kz Thanks Dan |
Copyright © 1999-2021 by the D Language Foundation