Now let's see how the previous example correlates with compilation taking longer when using -unittest.
Besides the if(compiledWithUnittest) block from the needsCodegen()
which prefers instantiations from root modules,
there's another if(compiledWithUnittest) which enforces the treatment of non-root modules (imports) as root modules.
for reference: https://github.com/dlang/dmd/blob/f5f0b68b8537270fd70cb7fb27c703abd216377d/src/dmd/dtemplate.d#L7139-L7144
This means that if you have the following program:
module test;