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

Allow overriding of data file location #145

Closed
jezdez opened this Issue Jan 12, 2017 · 7 comments

Comments

Projects
None yet
2 participants
@jezdez
Contributor

jezdez commented Jan 12, 2017

For various reasons it'd be useful to be able to specify the location of the data file.

The path to the file was hard-coded in a14e746 which makes sense to fix the issue for sub-processes, but some environments don't allow writing to the CWD (certain Docker setups).

@ionelmc

This comment has been minimized.

Member

ionelmc commented Jan 12, 2017

We could have an --cov-datapath option, or something to that effect.

Just out of curiosity, do you have an example of a project that is using a readonly mount in cwd?

@jezdez

This comment has been minimized.

Contributor

jezdez commented Jan 12, 2017

@ionelmc That sounds what I was looking for.

I don't have an easy to reproduce example at the moment, but the general gist is that we're trying to run tests in a Docker container with a command that is running as a non-privileged user and which has the app code (the host's CWD) mounted as a volume. The restrictions of Docker's volume implementation basically makes any volume owned by root inside the container. I realize that this is an edge case, but since coverage.py allows setting the data file as well and I don't see a reason for this to be hardcoded in pytest-cov, and I hoped this would be an easy fix®.

@ionelmc

This comment has been minimized.

Member

ionelmc commented Mar 15, 2017

@jezdez is putting [run] data_file=/tmpsomething/.coverage in your coverage config not an option? For docker the path doesn't need to be very dynamic (you can mount wherever you want), thus it can sit just fine in a configuration file.

@jezdez

This comment has been minimized.

Contributor

jezdez commented Mar 16, 2017

@ionelmc That's what I tried first but then found the plugin to pass in a value manually which prevented it from working. I can check again, but I think it's safe to say that this is hardcoding .coverage right now.

@ionelmc

This comment has been minimized.

Member

ionelmc commented Mar 16, 2017

Aaah, now I understand the actual problem: we don't take the datafile path from the coverage object - we just guess it with abspath('.coverage').

@jezdez

This comment has been minimized.

Contributor

jezdez commented Mar 16, 2017

@ionelmc Yep, apologies for not stating it more clearly at first.

@ionelmc

This comment has been minimized.

Member

ionelmc commented May 11, 2017

Released 2.5.1.

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue May 17, 2017

wiz
Updated py-test-cov to 2.5.1.
2.5.1 (2017-05-11)
------------------

* Fixed xdist breakage (regression in ``2.5.0``).
  Fixes `#157 <https://github.com/pytest-dev/pytest-cov/issues/157>`_.
* Allow setting custom ``data_file`` name in ``.coveragerc``.
  Fixes `#145 <https://github.com/pytest-dev/pytest-cov/issues/145>`_.
  Contributed by Jannis Leidel & Ionel Cristian Mărieș in
  `#156 <https://github.com/pytest-dev/pytest-cov/pull/156>`_.

2.5.0 (2017-05-09)
------------------

* Always show a summary when ``--cov-fail-under`` is used. Contributed by Francis Niu in `PR#141
  <https://github.com/pytest-dev/pytest-cov/pull/141>`_.
* Added ``--cov-branch`` option. Fixes `#85 <https://github.com/pytest-dev/pytest-cov/issues/85>`_.
* Improve exception handling in subprocess setup. Fixes `#144 <https://github.com/pytest-dev/pytest-cov/issues/144>`_.
* Fixed handling when ``--cov`` is used multiple times. Fixes `#151 <https://github.com/pytest-dev/pytest-cov/issues/151>`_.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment