Conversation
|
Thanks for your pull request and interest in making D better, @nordlow! 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 run digger -- build "master + dmd#22906" |
|
As always, compiler switches are bugs. Why can't this be the default behavior? |
Indeed.
I've always wanted this to be the default behavior. I'm unsure about the motives for this not being the default. One can always get full unittest triggering via |
Me neither, I would try turning this on and see how the test suite reacts. |
|
So the only change AFAICT here would be for |
Yes, I have been using ./test.sh
2 modules passed unittests
1 modules passed unittestsinside of https://codeberg.org/nordlow/d-snippets/src/branch/main/unittest-roots when using the |
|
Okay. - Well So I don't think we should special-case |
nordlow
left a comment
There was a problem hiding this comment.
All code comments addressed.
Does this mean that you are ok with changing the default behavior of |
|
No, absolutely not. I don't think we should encourage any |
Are you saying we should expect users to solely depend on using reggae (or dub or redub) in their workflow to get these speed gains? I want an effective solution that solely requires the compiler itself regardless of whether we consider this a hack or not. This is the direction that Zig is taking and I believe it's the right one. I'm gonna try enabling this behavior by default and see what CI says. The real issue I want to address here is that there currently is no way of selectively enabling/disabling unittests at the module level other than separate compilation of source files which in turns means redundant (re)parsing (and partially also semantic analysis) of shared imported modules. |
|
I'm not sure you (and Nick, Dennis etc.) knew that unittests in non-root modules are already ignored (not parsed). You are solely tackling the
So I'm sorry, but I really think the proposed feature is bad, because it encourages the terrible combo. And in case DMD ever becomes a daemon, we surely won't use anything like |
Then I suggest working on the default unittest runner implementation (edit: dmd/druntime/src/core/runtime.d Line 561 in 16f3201 dmd/druntime/src/test_runner.d Lines 25 to 48 in 16f3201 |
I mean selectively disable their compilation. Sorry for being imprecise. |
|
Well the point is that other modules shouldn't be compiled at all if they (and their imports) haven't changed, not just skipping (compiling and later running) their unittests. |
Good you bring that up, I didn't know that. I also assumed that modules found by -i are identical to explicitly passed .d files (so also 'root' internally). But this PR strips unittests before -i dependencies are discovered, that's different than what I originally thought this PR was doing.
Agreed
Disagreed, it's my go to for running tests. But if I want to run only a subset of unittests, I agree it's up to the test runner to filter. What I have been considering is |
Yes, and that solely roles on a build tool until the compiler has support for caching which Walter has been reluctant to adding to the compiler itself despite this is what most compilers of modern AOT-compiled languages now support, like Go, Rust, and Zig. |
Oh wow, do you not use dub then for the projects you are testing? I've just run a little comparison, for a dub module itself, simulating working on Manual approach using Using reggae: With So here in this case, an incremental |
At SARC we use dub, Bastiaan set up the build system there. For dmd and Phobos when I have specific unittests to run, I often use a oneliner like That's 86 KLOC for dub compiles/analyzes more LOC (it imports std.exception for one) but that's exactly the problem: by default it puts everything in the source folder on the command line, while |
|
Yeah, the potentially extra needed cmdline flags (at least the Too bad your day-to-day builds are so fast already. :D - Reggae can really make a huge difference for large projects, trust me, we have proven this at Symmetry. :) |
I trust you :) but my own strategy is generally to avoid large projects and only depend on a few important libs from the linux package manager. I should probably try reggae at SARC though, dub build times are often 20-30 seconds for me. |
|
Okay, the 20-30 secs sound more interesting - yeah, please give it a try and let us know then. :) - As shown in the example, the usage is trivial - I recommend simply running |
This speeds up running of unittests locally on my machine typically by a factor of 3x on my projects when incrementally making edits to a single module and wanting it to be self-checked on the fly by editor plugins such as FlyCheck. By its own unittests placed besides its declarations as it always should be. This until we have transitioned dmd into a compiler daemon listening for file system events like Zig now supports.
CLI-wise, alternatively we could instead adopt
-unittest=rootsor someting similar.Works fine locally for me.