<div dir="ltr">This is the point where I tend to pull out strace to see what the processes are actually doing (a failure to open a file to write coverage data to or an open of a file in an unexpected place perhaps) but I don&#39;t know how easy it would be for you to make D-Bus launch all child processes via strace -f and store its output somewhere useful...  (or you could have your early process start-up code prior to enabling coverage re-exec itself under strace -f)<div>

<br></div><div>-gps</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 5, 2014 at 11:47 AM, Barry Warsaw <span dir="ltr">&lt;<a href="mailto:barry@python.org" target="_blank">barry@python.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a Python 3 project with an extensive test suite for which I want to<br>
gather coverage data.  I use nose2 as the test runner.  While I get accurate<br>
coverage for the parent process tests, covering subprocesses just isn&#39;t<br>
working afaict.<br>
<br>
I suspect the tricky part here is that the subprocesses are D-Bus services<br>
which get activated via a custom system bus run with dbus-daemon.  However,<br>
I&#39;ve verified that environment variables are being seen by these subprocs,<br>
including COVERAGE_PROCESS_START which points to the correct coverage.ini<br>
file.<br>
<br>
That .ini file contains roughly:<br>
<br>
-----snip snip-----<br>
[run]<br>
branch = true<br>
parallel = true<br>
omit =<br>
     setup*<br>
     ...<br>
-----snip snip-----<br>
<br>
but after the full test suite runs I see only one .coverage file such as:<br>
<br>
.coverage.&lt;hostname&gt;.&lt;parent-pid&gt;.&lt;random&gt;<br>
<br>
meaning, that only the parent process is getting covered.  I&#39;d expect to see<br>
about a dozen subproc .coverage files.<br>
<br>
When I debug-print the D-Bus activated subprocs, I can see the environment<br>
variable, and its pid, along with its cwd, which is /.  Thinking that maybe<br>
coverage is trying to write the default .coverage.* files in cwd, I&#39;ve tried<br>
both setting COVERAGE_FILE and chdir&#39;ing to the proper directory.  Neither has<br>
worked.<br>
<br>
My subprocs start coverage like so, early on in their main().<br>
<br>
    ini_file = os.environ.get(&#39;COVERAGE_PROCESS_START&#39;)<br>
    if ini_file is not None:<br>
        try:<br>
            import coverage<br>
        except ImportError:<br>
            pass<br>
        else:<br>
            coverage.process_startup()<br>
<br>
With some debug-printing in the else: clause, I can see that we get through<br>
coverage.process_startup().<br>
<br>
Still, I get no data from the subprocs.  My tests that activate the service<br>
all pass, so I know the subprocs are running.<br>
<br>
My only guess at the moment is that setting [run]parallel=true in the .ini<br>
file isn&#39;t enough to turn on parallel mode.  I can&#39;t really pass<br>
-p/--parallel-mode to the subprocesses so I&#39;m relying on .process_startup() to<br>
get coverage going.<br>
<br>
I&#39;m stuck at the moment, so would appreciate in advance any thoughts on what<br>
to try next or what I might be doing wrong.<br>
<br>
Cheers,<br>
-Barry<br>
<br>_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
<br></blockquote></div><br></div>