Bug 17300 – Enable setting code coverage options on the command line
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2017-04-06T19:24:24Z
Last change time
2017-12-18T22:54:46Z
Assigned to
No Owner
Creator
Jon Degenhardt
Comments
Comment #0 by jrdemail2000-dlang — 2017-04-06T19:24:24Z
The core.runtime functions dmd_coverSetMerge, dmd_coverSourcePath, and dmd_coverDestPath are quite use when generating code coverage reports. This is especially true when generating reports involving multiple runs, multiple executable sharing code, etc.
The main downside is that they are only available from the source code being compiled. It would be much more flexible to have a run-time configurable setting. One use case is with unit tests run directly as result of a compiler build line. Another is building an executable with code coverage turned on, then running the executable multiple times for tests.
One solution might be to use "--DRT-<option>" command line arguments, similar to those used to set GC options on the command line. (See https://dlang.org/spec/garbage.html#gc_config). These are nice because they are processed and removed prior to any other command line argument processing.
Comment #1 by github-bugzilla — 2017-12-11T06:04:33Z
Commit pushed to master at https://github.com/dlang/druntimehttps://github.com/dlang/druntime/commit/269d720186185c51df3560b066bee4cbe9fbeb7e
Fix issue 17300 - Make coverage reports configurable via --DRT-covopt
The coverage module has a couple of options that can be set through some
weirdly looking dmd_coverSetMerge(), dmd_coverSourcePath() and
dmd_coverDestPath() functions (I guess the dmd prefix comes from
pre-druntime times).
These options don't only use non standard names, they also don't use the
standard --DRT-xxx / DRT_XXX runtime options passing mechanism, and they
can only be overridden in code.
This commit plugs the runtime options mechanism and adds support to set
these options via --DRT-covopt (and matching environment variables),
providing the sub-options merge, dstpath and srcpath.
The old functions are kept for backwards compatibility (they are used by
DMD itself for example), but should probably be removed in some distant
future.
Comment #2 by github-bugzilla — 2017-12-18T22:54:46Z