A program compiled with DMD does not generate the code coverage report file if
the program is not run from the same directory as the source
file(s).
For instance, this works:
~/test$ dmd -cov test.d && ./test
~/test$ ls *.lst
test.lst
This does not output the coverage listing:
~/test/sub$ dmd -cov test.d
~/test/sub$ cd ..
~/test$ ./sub/test.d
~/test$ find . -name '*.lst'
~/test$
This attempt at a workaround works, but produces unhelpful
listing filenames:
~/test/sub2$ dmd -cov ../sub1/test.d -of../sub1/test
~/test/sub2$ ../sub1/test
~/test/sub2$ ls *.lst
zsh: no matches found: *.lst
~/test/sub2$ find . -name '*.lst'
./..-sub1-test.lst
Comment #1 by jrdemail2000-dlang — 2017-04-02T00:09:00Z
It appears that if a relative path is specified on the compiler line, the executable must be run from the directory where the dmd command was issued, preserving the relative path relationship.
Comment #2 by robert.schadek — 2024-12-13T18:12:33Z