modules in cwd can't be --omitted · Issue #33 · nedbat/coveragepy (original) (raw)
Originally reported by Danek Duvall (Bitbucket: dhduvall, GitHub: dhduvall)
I'm having trouble with --omit. The code that we're testing is off in $PROTO, and the test suite itself is in the current directory, in directories "api" and "cli". So I'm running coverage as
coverage html --omit <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mi>R</mi><mi>O</mi><mi>T</mi><mi>O</mi><mi mathvariant="normal">/</mi><mi>m</mi><mi>o</mi><mi>d</mi><mn>1</mn><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">PROTO/mod1,</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">PROTO</span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal">o</span><span class="mord mathnormal">d</span><span class="mord">1</span><span class="mpunct">,</span></span></span></span>PROTO/mod2,api,cli
but that doesn't actually exclude api and cli from the report. I also tried with PWD/api,PWD/api,PWD/api,PWD/cli, but no dice.
In code_unit_factory(), we match cu.name against "prefix", but that prefix has been turned into an absolute pathname, so the .startswith() call doesn't return true, and we end up putting them into the final list.
If we check against cu.filename instead of cu.name, it appears to work correctly, but I'm not sure if that breaks something else.