Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage #95

Merged
merged 13 commits into from
May 3, 2023
Merged

Conversation

godlygeek
Copy link
Contributor

No description provided.

@godlygeek godlygeek self-assigned this May 3, 2023
sarahmonod and others added 3 commits May 2, 2023 20:49
Signed-off-by: Gus Monod <gmonod1@bloomberg.net>
This is only needed when building with coverage support, not when
running the tests in coverage mode, and the build was performed (with
this environment variable set) by an earlier step.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
The test suite includes several dummy programs whose whole purpose is to
be attached to in order to inspect their state. It's hard to count
coverage for these, because they're run in subprocesses, and because
the interpreter used to run that subprocess might not even be the
interpreter for which `coverage` is installed.

Just exclude those files from coverage reports for now, rather than
trying to find some way to force Coverage to trace them.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +6.65 🎉

Comparison is base (258732e) 82.48% compared to head (c89e680) 89.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
+ Coverage   82.48%   89.13%   +6.65%     
==========================================
  Files          27       46      +19     
  Lines        3260     5432    +2172     
  Branches      226      875     +649     
==========================================
+ Hits         2689     4842    +2153     
- Misses        571      589      +18     
- Partials        0        1       +1     
Flag Coverage Δ
cpp 74.94% <ø> (ø)
python_and_cython 98.27% <100.00%> (+1.62%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tests/integration/test_core_analyzer.py 97.55% <100.00%> (ø)
tests/integration/test_gather_stacks.py 96.32% <100.00%> (ø)
tests/integration/test_gc.py 100.00% <100.00%> (ø)
tests/integration/test_gil.py 100.00% <100.00%> (ø)
tests/integration/test_local_variables.py 100.00% <100.00%> (ø)
tests/integration/test_relocatable_cores.py 100.00% <100.00%> (ø)
tests/integration/test_smoke.py 100.00% <100.00%> (ø)
tests/unit/test_main.py 100.00% <100.00%> (ø)
tests/utils.py 100.00% <100.00%> (ø)

... and 10 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@sarahmonod sarahmonod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all # pragma: no cover of this PR introduced because we are running the tests (with coverage enabled) only with a single python version? Also, is there a way to document why lines are skipped for coverage?

tests/integration/test_smoke.py Show resolved Hide resolved
tests/utils.py Show resolved Hide resolved
Some tests have branches to make different assertions depending on the
version of the interpreter that is being attached to. Because we only
run our coverage tests against one interpreter, rather than every
possible interpreter, ignore these branches for the sake of our branch
coverage metrics.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
For some reason, Coverage thinks there's an uncovered branch when we use
`next(genexpr, None)`. I think this is a Coverage bug, and I've reported
it upstream, but in the meantime we can simplify some of our test
functions to avoid using that construct.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Our test for relocatable self-contained bundles has a hack in it to get
the test passing when used with musl libc, which won't be exercised on
most platforms. Skip test coverage for that hack.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Cheat: improve our branch coverage by removing some branches.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
We can't assume that an interpreter is stripped if the string "stripped"
appears in the output of `file`, because (depending on the version)
`file` can report that a particular executable is "not stripped".

Assume that it has symbols if either "stripped" doesn't appear in the
output, or if "not stripped" does.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
We run some procedural code to decide which interpreters are available
on the system to be tested. Since which branches are taken depends on
the machine's configuration, we should exclude this test configuration
code from our coverage reports.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Some of our tests have two branches, one that's used when the
interpreter is stripped and one that's used when the interpreter has
symbols. Since we want the coverage tests to pass regardless of whether
the interpreter being used has symbols or not, skip branch coverage for
these conditionals.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Previously we were guarding against the possibility that some lines in
`/proc/$pid/maps` wouldn't match our regex, but that conditional isn't
exercised, and shouldn't be possible unless our regex is incorrect.

If it is incorrect, it would be better to fail the test and find out
about the bad regex than to continue running the test despite the
failure.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
For some reason (most likely a bug), Coverage.py reports false positive
uncovered branches on lines that use generator expressions. Sidestep
this by switching some tests to use list comprehensions instead of
generator expressions, since Coverage handles list comprehensions
correctly.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
This test had two branches, one for interpreters using 3.10 or higher,
and one for interpreters using 3.9 or lower.

Split it into two tests, to make the different expectations clearer and
more self-documenting.

Also, exclude the one testing older interpreters from coverage reports,
since we expect those to only be generated using new interpreters.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek godlygeek marked this pull request as ready for review May 3, 2023 19:20
@godlygeek godlygeek merged commit 4a73dad into bloomberg:main May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants