-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
Fix duplicating paths during remapping #1755
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -500,18 +500,6 @@ def get_combined_filenames() -> set[str]: | |
filenames = {relative_filename(f).replace("\\", "/") for f in data.measured_files()} | ||
return filenames | ||
|
||
# Case 1: get the order right. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why you removed this test code. |
||
make_files() | ||
self.make_file(".coveragerc", """\ | ||
[paths] | ||
plugins = | ||
plugins/ | ||
ci/girder/plugins/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is weird; I didn't touch this, and these files remain on my local repository. Go figure, I'll check it out later. |
||
girder = | ||
girder/ | ||
ci/girder/ | ||
""") | ||
assert get_combined_filenames() == {'girder/g1.py', 'plugins/p1.py'} | ||
|
||
# Case 2: get the order "wrong". | ||
make_files() | ||
|
@@ -526,6 +514,51 @@ def get_combined_filenames() -> set[str]: | |
""") | ||
assert get_combined_filenames() == {'girder/g1.py', 'plugins/p1.py'} | ||
|
||
def test_combine_remapping(self) -> None: | ||
self.make_file("foo.py", text="print('Hello from Foo!')") | ||
self.make_file("bar.py", text="print('Hello from Bar!')") | ||
|
||
cov_foo = coverage.Coverage(source=["."], data_suffix="foo_cov.data") | ||
self.start_import_stop(cov_foo, "foo") | ||
cov_foo.save() | ||
|
||
cov_bar = coverage.Coverage(source=["."], data_suffix="bar_cov.data") | ||
self.start_import_stop(cov_bar, "bar") | ||
cov_bar.save() | ||
|
||
# Since the issue seems to be focused around the | ||
# given order of the paths, absolute or otherwise | ||
# So, we'll be testing both ways; absolute and relative, and relative and absolute | ||
# Truthfully, I'm not entirely sure if it makes a difference - but let's see. | ||
|
||
cov1 = coverage.Coverage() | ||
cov1.combine(data_paths=[".coverage.foo_cov.data", ".coverage.bar_cov.data"]) | ||
files1 = cov1.get_data().measured_files() | ||
|
||
|
||
# Since the files are combined, they cease to exist after `cov1.combine()`. | ||
# So the files need to be measured again. | ||
# This is mostly certainly *not* staying like this, but Ill leave it as | ||
# To test if the testing logic is truly correct - which should be, but let's see | ||
# what Ned says. | ||
|
||
cov_foo = coverage.Coverage(source=["."], data_suffix="foo_cov.data") | ||
self.start_import_stop(cov_foo, "foo") | ||
cov_foo.save() | ||
|
||
cov_bar = coverage.Coverage(source=["."], data_suffix="bar_cov.data") | ||
self.start_import_stop(cov_bar, "bar") | ||
cov_bar.save() | ||
|
||
# Combine the data files in the opposite order. | ||
cov2 = coverage.Coverage() | ||
cov2.combine(data_paths=[".coverage.bar_cov.data", ".coverage.foo_cov.data"]) | ||
files2 = cov2.get_data().measured_files() | ||
|
||
# The order of combining should not affect the resulting files. | ||
assert set(files1) == set(files2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In hindsight, this is pretty obvious; so that's a stupid check to take away. |
||
assert set(files2) == set(files1) | ||
|
||
def test_warnings(self) -> None: | ||
self.make_file("hello.py", """\ | ||
import sys, os | ||
|
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.
A key indication of whether the test is doing what it should: comment out "the fix" and see if the test fails. When I comment out these two lines, all the tests still pass.