-
-
Notifications
You must be signed in to change notification settings - Fork 379
Add documentation for isOverrideFunction and getUnitTests traits #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
W.r.t. getUnitTests: Could you please add the following code snippet, it will show people how to avoid running the tests automatically:
This will stop the unittests from running, but continue execution into |
Btw, is it possible to make __traits(getUnitTests) work with a ModuleInfo? It would allow this code: void main()
{
foreach (m; ModuleInfo)
{
foreach (test; __traits(getUnitTests, m))
{
// run each test for every module
}
}
} Otherwise we are forced to have a single module which imports all other modules in order to be able to use __traits(getUnitTests). |
One other thing I have w.r.t. this feature, |
Yes, I can do that. |
No, I don't think so. At least not easily. The unit tests are already accessible from the module info. What would this gain? Accessing the individual unit test functions and not only the wrapper? Or accessing UDA's?
Yeah, I know, that's a problem. I have another pull request that is intended to solve this problem. Doing the same as |
Yes, that's how the rest of these traits work.
I thought that was fairly easy solvable using |
Well if it's implementable in a library I suggest we add something like this to Phobos, e.g. a
Both! But yeah |
Added example of overriding the default unit test runner. |
{ | ||
// Override the default unit test runner to do nothing. After that, "main" will | ||
// be called. | ||
Runtime.moduleUnitTester = { return true; }; |
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.
To do this, import core.runtime;
is necessary.
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.
Right. I'll fix it.
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.
Done.
Semicolon, done. |
OK, LGTM. |
Add documentation for isOverrideFunction and getUnitTests traits
Thanks 😃 |
Add documentation for isOverrideFunction and getUnitTests traits
I guess this shouldn't be pulled at least until the pull request for isOverrideFunction is merged.
getUnitTests
is already implemented.