-
Notifications
You must be signed in to change notification settings - Fork 212
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
Combine in finish (extension of #142) #143
Conversation
…(where now we reinitialize the cov object for forced combine) that are caused by sloppy cwd changes (crazy stuff ppl put in tests).
…sing data_file attr).
Man, this seems super hacky. What if we made another instance during start, and then just used it for combine at the end, rather than making a new instance at the end? I'll give that a try. |
How would that simplify things? Those paths being made absolute is not that bad, in fact there are many places already doing absolutization in pytest-cov ... |
Is that just internally, or is that for reporting? My concern is that codecov won't understand it, and also that test runs on different machines will be needlessly different because of the path.I haven't tried it, so it's possible I just don't understand what's be absolutized. |
I did try, before, commit 1b12416, and it gave me this error, which is likely because I'm using
|
Interesting, can you paste full traceback? |
|
Ah, a slight bug. Fixed now. |
@@ -18,7 +18,7 @@ def __init__(self, cov_source, cov_report, cov_config, cov_append, config=None, | |||
"""Get some common config used by multiple derived classes.""" | |||
self.cov_source = cov_source | |||
self.cov_report = cov_report | |||
self.cov_config = os.path.abspath(cov_config) | |||
self.cov_config = os.path.abspath(cov_config) if os.path.exists(cov_config) else cov_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now don't we still have that change in working directory bug if you're not setting the config file manually, and it's not the default .coveragerc
(which is used to also mean autodetect)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not specifying --cov-config
then cov_config
will be None
(and coverage will try to find it itself).
If you do specify it and it doesn't exist then coverage should complain, I suspect it doesn't and we should do our own check.
You're quite correct here, if coverage is using a autofound config file with a different name this will make the coverage reinit malfunction (since config won't exist in cwd).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually .... hmmm ... aren't you using --cov-config=tox.ini
? That would make the path absolute at the right time ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm relying on the autodiscover. I know that pytest-cov is using .coveragerc
as the default value from argparse, so this won't ever be None
, AFAIK, but it will be .coveragerc
, which coverage.py interprets the sameway for backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating the combiner instance early along with the other one would also make this issue go away. It does make me wonder if this just really isn't a use-case that combine was intended for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm sure it was intended for this, at least in part. I just wonder if this is more of a design bug in coverage. It's also something we want to address here, as usage in tox is very common. Still, it does seem cumbersome.
Well if this doesn't work I give up. Today at least. |
Nope, not quite. Now it's giving duplicate results, and it's leaving the parallel file, but not leaving the
|
self.cov.combine() | ||
self.cov.save() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue that's causing the duplicates is that you're not setting self.cov = self.combining_cov
before doing the load()
.
@@ -221,6 +227,9 @@ def finish(self): | |||
|
|||
# Combine all the suffix files into the data file. | |||
self.cov.stop() | |||
self.cov.save() | |||
self.cov = self.combining_cov | |||
self.cov.load() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is needed in a distributed mode, unless you're having each worker report itself (which I think is a feature you have). It probably would cause problems in the normal case, though, since I think the parallel version of the coverage file gets deleted normally when it's being combined.
@@ -289,3 +298,12 @@ def summary(self, stream): | |||
"""Only the master reports so do nothing.""" | |||
|
|||
pass | |||
|
|||
|
|||
def laxabspath(path_or_something, *replacemet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it supposed to be *replacement
?
Closes #142. Maybe.