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

Execute Cram via pytest #549

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vanguard737
Copy link

Description of proposed changes

@huddlej As discussed in PR #543, here's the PR to add just the pytest wrapper for the Cram functional tests, including coverage report.

One noteworthy change: When I submitted this in #543, I got different coverage numbers on my local machine vs. Travis. In this PR, that's no longer the case - I'm now seeing 41% overall coverage both locally and on Travis. Not sure why or how that fixed itself - but, seems to be working now.

This PR does the following:

  • Adds a Pytest wrapper, tests/test_cram.py, to execute all Cram CLI tests located under tests/.
  • Updates .travis.yml to execute this test independently from existing Augur unit tests, and to generate a coverage report showing code coverage just for the Cram tests.
  • Updates pytest.python3.ini to exclude the pytest Cram wrapper when executing unit tests.
  • Updates .gitignore to ignore the coverage datafile .coverage_pytest_cram.

Couple of additional notes:

  • The .travis.yml and .gitignore changes are worth calling out. pytest-cov writes a coverage-data file to the default location, .coverage; Travis then uploads this to codecov.io. I don't want the Cram coverage data to overwrite the unit-test coverage data. So, to keep these separate, I've updated .travis.yml to set COVERAGE_FILE=.coverage_pytest_cram when I call pytest.

On my Travis and Codecov accounts, this seems to work as intended. Codecov correctly shows ~19% unit-test coverage, not the ~40% coverage you'd see if Codecov were picking up the Cram-test coverage data. But, the Codecov bash uploader is a little vague about how it detects coverage files. So, you might want to keep an eye on this. I've added a note for this in the 'Testing' section below.

  • In .travis.yml, I've left in place the call to execute Cram tests in the 'normal' way (cram --shell=/bin/bash tests/functional/*.t tests/builds/*.t). This is redundant to the pytest-Cram call, of course - I kept the original just as a control, to prove that pytest-Cram and normal-Cram are both running and succeeding. Up to you guys, but my instinct would be to keep both calls side-by-side for a while, then delete the normal-cram call when everybody's comfortable with pytest-Cram.

Related issue(s)

Related to #542 #543

Testing

Locally:
COVERAGE_FILE=.coverage_pytest_cram pytest -vv -s tests/test_cram.py --cov-report=term --cov augur

On Travis:
Run a build. Observe that tests/test_cram.py executes tests/builds/zika.t and tests/functional/mask.t, and both tests pass (example). Observe that this writes a coverage report to terminal, currently showing 41% coverage (example).

Check codecov.io to verify that it's still showing coverage for just the augur unit tests. Should be ~19% or so - if it's ~40%, then Codecov may have unexpectedly pulled pytest-Cram's coverage data into the mix.

- Adds a Pytest wrapper, tests/test_cram.py, to execute all Cram CLI tests located under tests/.
- Updates .travis.yml to execute this test independently from existing Augur unit tests, and to generate a coverage report showing code coverage *just* for the Cram CLI tests.  Augur's unit tests generate their own coverage report and upload it to Codecov.  To keep Cram from stepping on that unit-test coverage report, we just write these results to terminal.
- Updates pytest.python3.ini to exclude the pytest Cram wrapper when executing unit tests.  This should keep the Cram tests' pytest coverage report from stepping on the unit-test coverage report.
 - Unit tests write to .coverage, the default.
 - Functional Cram tests write to .coverage_pytest_cram.

 Upon build completion, Travis *should* only upload unit-test coverage (.coverage) to codecov.io.  However, this will depend on how exactly the Codecov bash uploader identifies coverage reports.

 This commit also gitignores .coverage_pytest_cram and its transient friends (.coverage_pytest_cram_$HOSTNAME_$TIMESTAMP).
@codecov
Copy link

codecov bot commented May 16, 2020

Codecov Report

Merging #549 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #549   +/-   ##
=======================================
  Coverage   19.16%   19.16%           
=======================================
  Files          31       31           
  Lines        5072     5072           
  Branches     1289     1289           
=======================================
  Hits          972      972           
  Misses       4077     4077           
  Partials       23       23           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 704f369...ab30fbe. Read the comment docs.

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.

1 participant