Quit running foreign unittests >_<

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 27 04:30:10 PDT 2015


On 4/27/15 6:20 AM, Dicebot wrote:
> On Monday, 27 April 2015 at 10:15:20 UTC, Kagamin wrote:
>> On Monday, 27 April 2015 at 09:22:48 UTC, Dicebot wrote:
>>> Compiling tests of dependencies pretty much never causes any notable
>>> slowdown.
>>
>> This thread doesn't support that view, see the first post.
>
> Which part exactly? I only see comparisons for compiling AND running
> tests for dependencies. And it is usually running which causes the
> slowdown.

The problem is as follows:

1. Unit tests for some library are written for that library. They are 
written to run tests during unit tests of that library only (possibly 
with certain requirements of environment, including build lines, or 
expectations of system resource availability).
2. People who import that library's modules are not trying to test the 
library, they are trying to test their code.
3. The library runs its unit tests for templates in this case, not the 
other unit tests in the module (those would be run in that module's unit 
tests, which means you'd have to recompile the library to run unit 
tests). Most often, unit tests in templates are only expected to be 
defined by the library.

I think ketmar had the most reasonable request here -- only compile/run 
unit tests in templates for the module that defines the template.

If you want to create a unit test that runs for your specialized 
template version, there should be a way to do that, but it should be 
opt-in. I envision something like this:

unittest
{
	import somelib.somemod : SomeModTemplate, unittest
	SomeModTemplate!MyLocalType t; // runs templated unit tests
}

If you look in RedBlackTree, I use templated unit tests to great effect 
(found about 4-5 compiler bugs that way). But I have a lot of machinery 
around the unit tests to try and only test unit tests on integral types. 
It would be nice to not have to write all that shit.

And BTW, I didn't even get it right, I forgot about other parameters to 
the RBTree, necessitating a PR later.

-Steve


More information about the Digitalmars-d mailing list