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

Refactor --coverage in the test runner #2667

Merged
merged 10 commits into from
Jun 22, 2018
Merged

Conversation

Cadair
Copy link
Member

@Cadair Cadair commented Jun 20, 2018

This moves us away from using astropy to calculate the code coverage and to using pytest-cov. This means that --parallel and --coverage from the test runner work, as well as enabling --cov-report term to work from setup.py

@ghost
Copy link

ghost commented Jun 20, 2018

Thanks for the pull request @Cadair! Everything looks great!

@Cadair Cadair closed this Jun 20, 2018
@Cadair Cadair deleted the travis_race branch June 20, 2018 20:33
@Cadair Cadair reopened this Jun 20, 2018
@Cadair Cadair changed the title Parallelise the online build: TRAVIS RACE Refactor --coverage in the test runner Jun 20, 2018
.travis.yml Outdated

- python: 3.6
stage: Comprehensive tests
env: SETUP_CMD="test --online --coverage --parallel 12"
Copy link
Contributor

Choose a reason for hiding this comment

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

What if there's a bug for odd numbers? ;)

@pep8speaks
Copy link

pep8speaks commented Jun 21, 2018

Hello @Cadair! Thanks for updating the PR.

Line 74:101: E501 line too long (101 > 100 characters)

Line 69:51: E231 missing whitespace after ','
Line 75:101: E501 line too long (110 > 100 characters)
Line 76:101: E501 line too long (111 > 100 characters)

Comment last updated on June 22, 2018 at 11:22 Hours UTC

This enables us to have either term or html reports (html is still the
default) and allows coverage to work with parallel
This changes the path in the .coverage file to be based on the source directory
rather than the test directory. This makes it possible for tools like codecov or
coveralls to read the coverage report relative to the git clone.
@Cadair
Copy link
Member Author

Cadair commented Jun 21, 2018

Well the VSO is all on 🔥 again, so it's messing with codecov, but all seems well.

Copy link
Contributor

@StanczakDominik StanczakDominik left a comment

Choose a reason for hiding this comment

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

Looks good to me! Really looking forward to seeing it upstream :)

cmd_pre += pre
cmd_post += post
# Copy the raw .coverage file back so it can be used for CI reports
cwd = os.path.join(os.path.abspath("."))
Copy link

Choose a reason for hiding this comment

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

Wouldn't just os.path.abspath(".") would suffice here or maybe os.getcwd()?


# Special case html as the default report
if self.cov_report and (isinstance(self.cov_report, bool) or "html" in self.cov_report):
html_cov = os.path.join(os.path.abspath("."), "htmlcov")
Copy link

Choose a reason for hiding this comment

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

This could be os.path.join(cwd, "htmlcov") where cwd comes from above.

Copy link
Contributor

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just a small comment in terms of documentation.



def _patch_coverage(testdir, sourcedir):
import coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to have some kind of docstring or comment that explains in what way the coverage file will be patched.

This also includes a nasty little hack for measuring coverage of the test runner
@nabobalis nabobalis modified the milestones: 0.9.2, 0.9.1 Jun 22, 2018
sunpy/tests/runner.py is correctly measured we force the interpreter to
reload it here while coverage is watching.
"""
imp.reload(sunpy.tests.runner)
Copy link
Member Author

Choose a reason for hiding this comment

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

@nabobalis this isn't python 2 compat. I think in 2.7 this will just need to be the reload() builtin

@Cadair Cadair merged commit 58e5b32 into sunpy:master Jun 22, 2018
@@ -30,7 +30,7 @@ env:
- MAIN_CMD='python setup.py'
- SETUP_CMD='test --coverage'
- CONDA_CHANNELS='sunpy'
- CONDA_DEPENDENCIES='openjpeg Cython jinja2 scipy matplotlib mock requests beautifulsoup4 sqlalchemy scikit-image pytest-mock lxml pyyaml pandas nomkl pytest-astropy suds-jurko glymur'
- CONDA_DEPENDENCIES='openjpeg Cython jinja2 scipy matplotlib mock requests beautifulsoup4 sqlalchemy scikit-image pytest-mock lxml pyyaml pandas nomkl pytest-astropy suds-jurko glymur pytest-xdist'
Copy link
Member

Choose a reason for hiding this comment

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

no need for this, pytest-xdist is installed by ci-helpers when SETUP_CMD has parallel or numprocesses in it.

@dstansby dstansby removed the Needs Review Needs reviews before merge. label Jan 24, 2022
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.

8 participants