-
-
Notifications
You must be signed in to change notification settings - Fork 672
Add unit test runner #9333
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
Add unit test runner #9333
Conversation
|
Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#9333" |
c6dc23d to
0de3370
Compare
f259116 to
4a503ea
Compare
|
I don't understand how this is different from unittests. |
This is unit tests. What we currently have in DMD are end-to-end tests. Also, if this is unclear, this is only internal, to be able to test DMD. It doesn't add any new language features. |
|
I was asked to make this a separate PR: #8528 (comment). |
4a503ea to
6cc806c
Compare
|
Is blocking: #8528. |
6cc806c to
be36f29
Compare
It might be worth clarifying the difference between this and the existing Lines 256 to 266 in 51ecc6f
|
Yup, e.g. Gotchas:
|
wilzbach
left a comment
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.
Still looks very nice 👍
I really hope they will do that. This is indented as an alternative to the kinds of tests in the |
be36f29 to
544ed5c
Compare
BTW one thing that I wanted to ask is whether you know how well the |
I don't know. I haven't experienced any issues with my tool DLP (that uses DMD as a library) [1], but I have 16 GB of memory. |
c413dd0 to
a8c4517
Compare
This will allow to use the compiler as a library to implement more unit test like tests. These tests will be able to inspect the internals of the compiler to perform new kinds of tests that are not possible today. Unit tests live in the `test/unit` directory. They are written using the built-in `unittest` blocks. The unit test framework supports callbacks executed before and after each test. The unit test runner allows to limit the tests executed either by file(s) and/or by UDAs. Example: ```d module self_test; import support : afterEach, beforeEach; @beforeeach initializeFrontend() { import dmd.frontend : initDMD; initDMD(); } @afterEach deinitializeFrontend() { import dmd.frontend : deinitializeDMD; deinitializeDMD(); } @("self test") unittest { import std.algorithm : each; import dmd.frontend; findImportPaths.each!addImport; auto t = parseModule("test.d", q{ int a = 3; }); assert(!t.diagnostics.hasErrors); assert(!t.diagnostics.hasWarnings); } ``` * To run all unit tests, run: `./run.d -u` * To run only the unit tests in a single file, run: `./run.d -u unit/self_test.d` * To run only the unit tests matching a UDA, run: `./run.d -u --filter "self test"`
a8c4517 to
f80c3f3
Compare
|
All tests are passing here. |
|
Thanks. |
|
Looks like these changes only pass intermittently on Win32: https://auto-tester.puremagic.com/platform-history.ghtml?projectid=1&os=Win_32 |
|
@rainers is the error: |
It seems it is. I guess it fails for one build server because they have different versions of optlink installed: power: 8.0.16 works @braddr please update at least win-farm2 |
|
Would removing the |
|
Yes, I think it would. |
|
@jacob-carlborg can you please add documentation for tools/paths.d ? |
This will allow to use the compiler as a library to implement more unit test like tests. These tests will be able to inspect the internals of the compiler to perform new kinds of tests that are not possible today.
Unit tests live in the
test/unitdirectory. They are written using the built-inunittestblocks. The unit test framework supports callbacks executed before and after each test. The unit test runner allows to limit the tests executed either by file(s) and/or by UDAs. Example:./run.d -u./run.d -u unit/self_test.d./run.d -u --filter "self test"