$ cat test.d void main() { import std.algorithm.sorting : sort; int[] arr1 = [5, 2, 8]; auto s = arr1.sort; } $ dmd -unittest test.d && ./test 1 unittests passed The root cause is most likely a unit test nested inside a template, which gets instantiated from std.algorithm.sorting.sort.
The problem in the example snippet could be solved in phobos by guarding all nested unit tests with `version (StdUnittest)`, but I'm looking for a solution at the dmd/druntime level, as obviously this affects third-party libraries and not just phobos.
DMD (1c609085a8b94b97658d8ca3e07b6ca2e9c3d383) now excludes unittests from non-root modules