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

re-enable HTML reports under Python3 #163

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@latk
Member

latk commented Dec 29, 2016

In commit 1cc987a, the commonpath() function was added, which quite sensibly tries to figure out real path names. Unfortunately, it uses iterools.izip() which is not available under Python3. Instead, that
functionality is now provided by the zip() builtin.

We therefore define an izip() function as an alias for itertools.izip() if that is available, or else use zip().

Since commonpath() is used in HTML reports, it was previously impossible to create HTML reports with GCOVR under Python3. To prevent such problems in the future, the existing HTML tests should
be updated and enabled. (I've already done that in latk@15c10ca, but the tests will not succeed under Python3 until this pull request is merged.)

re-enable HTML reports under Python3
In commit 1cc987a, the `commonpath()` function was added, which quite
sensibly tries to figure out real path names. Unfortunately, it uses
`iterools.izip()` which is not available under Python3. Instead, that
functionality is now provided by the `zip()` builtin.

We therefore define an `izip()` function as an alias for
`itertools.izip()` if that is available, or else use `zip()`.

Since `commonpath()` is used in HTML reports, it was previously
impossible to create HTML reports with GCOVR under Python3.
To prevent such problems in the future, the existing HTML tests should
be updated and enabled.
@mayeut

This comment has been minimized.

Contributor

mayeut commented Aug 15, 2017

@latk, if you already have tests that were showing the error, would be good to have them in the PR as well.

@latk

This comment has been minimized.

Member

latk commented Aug 16, 2017

@mayeut The current HTML tests already trigger the error, but they were commented out of the default test suite. These tests are therefore out of date and would fail under all Python versions.

I don't want to propose changes that cause the build to fail. I will issue the PR for the updated tests once this PR or the equivalent #168 is merged.

@latk

This comment has been minimized.

Member

latk commented Jan 6, 2018

Duplicate of #168

@latk latk marked this as a duplicate of #168 Jan 6, 2018

@latk latk closed this Jan 6, 2018

latk added a commit to latk/gcovr that referenced this pull request Jan 6, 2018

fix HTML tests
The HTML tests are naturally rather fragile, since lots of CSS is copied
into every file. However, they are quite valuable as they exercise
important code paths. For example, this would have found issues gcovr#163
or gcovr#168. By enabling these tests, we can avoid such problems in the
future.

Summary of changes:

**`scripts/gcovr`:**
removed some trailing whitespace in the HTML template.

**`gcovr/tests/test_gcovr.py`:**
normalize HTML files so that they can be compared. In particular, we
remove the exact version string, and the report creation date.

**`gcovr/tests/*/reference/coverage.html`:**
update the HTML files to match the current structure. This is mostly
removing trailing whitespace, and tracking changes to the CSS. If there
was some discrepancy in the content, the TXT and XML references were
assumed to be up to date and fresh values taken from there.

**`gcovr/tests/linked/reference/coverage.html`:**
update as with the other tests. However, this exposed significant
changes to the path name handling. Commit 1cc987a changed
`commonprefix()` to `commonpath()` to figure out better path names. This
function is used only by the HTML test, which therefore reports physical
paths. The HTML reference has been updated to use physical paths. E.g.
since the test case is constructed on the fly from the “nested” test,
the source root dir is `../nested/subdir`. Note that the XML and TXT
reports still use symlinks in paths, but that is another problem.

@latk latk referenced this pull request Jan 6, 2018

Merged

Fix HTML tests #185

latk added a commit to latk/gcovr that referenced this pull request Jan 9, 2018

fix HTML tests
The HTML tests are naturally rather fragile, since lots of CSS is copied
into every file. However, they are quite valuable as they exercise
important code paths. For example, this would have found issues gcovr#163
or gcovr#168. By enabling these tests, we can avoid such problems in the
future.

Summary of changes:

**`scripts/gcovr`:**
removed some trailing whitespace in the HTML template.

**`gcovr/tests/test_gcovr.py`:**
normalize HTML files so that they can be compared. In particular, we
remove the exact version string, and the report creation date.

**`gcovr/tests/*/reference/coverage.html`:**
update the HTML files to match the current structure. This is mostly
removing trailing whitespace, and tracking changes to the CSS. If there
was some discrepancy in the content, the TXT and XML references were
assumed to be up to date and fresh values taken from there.

**`gcovr/tests/linked/reference/coverage.html`:**
update as with the other tests. However, this exposed significant
changes to the path name handling. Commit 1cc987a changed
`commonprefix()` to `commonpath()` to figure out better path names. This
function is used only by the HTML test, which therefore reports physical
paths. The HTML reference has been updated to use physical paths. E.g.
since the test case is constructed on the fly from the “nested” test,
the source root dir is `../nested/subdir`. Note that the XML and TXT
reports still use symlinks in paths, but that is another problem.

@latk latk deleted the latk:fix-html-py3 branch Feb 6, 2018

JamesReynolds pushed a commit to JamesReynolds/gcovr that referenced this pull request Mar 8, 2018

fix HTML tests
The HTML tests are naturally rather fragile, since lots of CSS is copied
into every file. However, they are quite valuable as they exercise
important code paths. For example, this would have found issues gcovr#163
or gcovr#168. By enabling these tests, we can avoid such problems in the
future.

Summary of changes:

**`scripts/gcovr`:**
removed some trailing whitespace in the HTML template.

**`gcovr/tests/test_gcovr.py`:**
normalize HTML files so that they can be compared. In particular, we
remove the exact version string, and the report creation date.

**`gcovr/tests/*/reference/coverage.html`:**
update the HTML files to match the current structure. This is mostly
removing trailing whitespace, and tracking changes to the CSS. If there
was some discrepancy in the content, the TXT and XML references were
assumed to be up to date and fresh values taken from there.

**`gcovr/tests/linked/reference/coverage.html`:**
update as with the other tests. However, this exposed significant
changes to the path name handling. Commit 1cc987a changed
`commonprefix()` to `commonpath()` to figure out better path names. This
function is used only by the HTML test, which therefore reports physical
paths. The HTML reference has been updated to use physical paths. E.g.
since the test case is constructed on the fly from the “nested” test,
the source root dir is `../nested/subdir`. Note that the XML and TXT
reports still use symlinks in paths, but that is another problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment