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

Make pytest report sources paths relative to the buildroot. #4472

Merged
merged 4 commits into from
Apr 17, 2017

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Apr 16, 2017

Previously the new PytestRun task reported paths relative to
the chroot, which was less readable for end users.

Note that this required writing a root conftest.py into the
chroot. Previously we wrote one (for reporting on sharding)
into its own module in a tmpdir, but now we require the
conftest.py hooks to be run when loading each file from the
chroot, which means it has to be in that chroot.

This makes things a little more complicated if the code
happens to have a root-level conftest.py already. We take
some care to temporarily append to this conftest, and then
restore it to its original state. We also take care to be
resilient to failures that somehow prevent the cleanup from
happening.

Previously the new PytestRun task reported paths relative to
the chroot, which was less readable for end users.

Note that this required writing a root conftest.py into the
chroot. Previously we wrote one (for reporting on sharding)
into its own module in a tmpdir, but now we require the
conftest.py hooks to be run when loading each file from the
chroot, which means it has to be in that chroot.

This makes things a little more complicated if the code
happens to have a root-level conftest.py already.  We take
some care to temporarily append to this conftest, and then
restore it to its original state.  We also take care to be
resilient to failures that somehow prevent the cleanup from
happening.
@benjyw benjyw requested review from kwlzn and stuhood April 16, 2017 23:29
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks Benjy.

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Apr 17, 2017 via email

@stuhood
Copy link
Sponsor Member

stuhood commented Apr 17, 2017

@benjyw : Yea, deleted it.

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Apr 17, 2017 via email

@stuhood
Copy link
Sponsor Member

stuhood commented Apr 17, 2017

Yes, I believe that it is safe... was missing the fact that the shutils.copy will overwrite the destination. Only improvement i can think of would be to put the restoration of the old file in a finally block... but then there is a question of debuggability.

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Apr 17, 2017 via email

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Apr 17, 2017

Retracting "It is, effectively, in a finally block, since this is a contextmanager." The contextmanager still needs a finally block.

Add copious comments to explain why the conftest_orig dance
is valid.
@benjyw benjyw merged commit a22ef1d into pantsbuild:master Apr 17, 2017
@benjyw benjyw deleted the fix_pytest_reporting branch April 17, 2017 21:30
lenucksi pushed a commit to lenucksi/pants that referenced this pull request Apr 25, 2017
…ld#4472)

Previously the new PytestRun task reported paths relative to
the chroot, which was less readable for end users.

Note that this required writing a root conftest.py into the
chroot. Previously we wrote one (for reporting on sharding)
into its own module in a tmpdir, but now we require the
conftest.py hooks to be run when loading each file from the
chroot, which means it has to be in that chroot.

This makes things a little more complicated if the code
happens to have a root-level conftest.py already.  We take
some care to temporarily append to this conftest, and then
restore it to its original state.  We also take care to be
resilient to failures that somehow prevent the cleanup from
happening.
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.

2 participants