-
-
Notifications
You must be signed in to change notification settings - Fork 416
Enhanced unittest support #782
Conversation
What's the versioning, |
Yes please. |
@jacob-carlborg you mean what that versioning is for? It's not necessary right now, but it allows changing the exported fields in the future without modifying the moduleinfo flags and we can stay 100% ABI compatible. For example if we want to add a new field later on, e.g. (*) We could define a common set of functionality shared by all versions, |
Ok, I see. |
/** | ||
* Deprecated: | ||
* Please use unitTests instead. | ||
*/ | ||
@property void function() unitTest() nothrow pure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This thing was particularly nasty, a property function returning a function (especially when we have things like -property being in murky waters).
I think an additional versioning scheme is redundant. We can already add bits to the flags, as this does already. |
@@ -1597,6 +1597,7 @@ enum | |||
MIimportedModules = 0x400, | |||
MIlocalClasses = 0x800, | |||
MIname = 0x1000, | |||
MInewUnitTest = 0x2000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use MIunitTest2
instead. Using new
is not workable when the next one is needed, after all, would that be called evenNewer
? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it, but we hopefully never need a MIunitTest3
. MIunitTest2
only enforces representing tests in a module as an 'array of something' where 'something' can be any struct. So MIunitTest2
should be future proof for some time.
Can we please get this in? I've been running the phobos unit tests a lot lately and it's very annoying for all the rest of the tests not to run if a single assert fails somewhere in the middle. |
@property void function() unitTest() nothrow pure | ||
{ | ||
return flags & MIunitTest ? *cast(typeof(return)*)addrOf(MIunitTest) : null; | ||
} | ||
|
||
@property __UnitTest[] unitTests() nothrow | ||
{ | ||
return flags & MIunitTest2 ? *cast(typeof(return)*)addrOf(MIunitTest2) : []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning null
instead of []
saves you a call to _d_arrayliteral.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this had also been fixed in dmd but it seems you're right. (Iain fixed it in gdc some time ago)
The new information is available from the 'unitTests' member of every ModuleInfo. 'unitTests' is an array of __UnitTest structs. The __UnitTest struct provides the unittest function, location etc.
Auto-merge toggled on |
@@ -18,25 +18,35 @@ bool tester() | |||
if(name.length > pkgLen && name[$ - pkgLen .. $] == pkg) | |||
name = name[0 .. $ - pkgLen]; | |||
|
|||
if (auto fp = getModuleInfo(name).unitTest) | |||
bool result = true; | |||
if (auto tests = getModuleInfo(name).unitTests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aww, there is no fallback in the test runner. This actually disabled all tests on our auto-tester.
See #808 for a fixup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. I added the fallback in src/core/runtime.d
but it seems I forgot to add it in the druntime/phobos test runner. Thanks for merging, btw. I'll update the dmd pull later today.
See dlang/dmd#3518 for much more details.
Default druntime tester
Updated to ignore
@disabled
tests and use the new format.The tester now runs all tests in a module, even if a previous test failed.
Example test runner
Simple example: http://dpaste.dzfl.pl/56697348500c
Output: http://dpaste.dzfl.pl/c0c706b0cea4
Parallel runner: http://dpaste.dzfl.pl/cef0a42936d6
Output: http://dpaste.dzfl.pl/d2445d87a9d7
See also
DMD pull request:
dlang/dmd#3518