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

Add a test for the "buildroot is below the gitroot" case #6339

Closed

Conversation

stuhood
Copy link
Member

@stuhood stuhood commented Aug 12, 2018

Problem

#6301 was fixed in #6331, but adding a test to cover it was non-trivial, and so was not added there.

Solution

Add a test to cover #6331.

Result

Fixes #6301. Thanks to @yaup, et al. for the report and original fix!

with temporary_dir(root_dir=get_buildroot()) as worktree:
with safe_open(os.path.join(worktree, 'README'), 'w') as fp:
fp.write('Just a test tree.')
rel_buildroot = fast_relpath(worktree, get_buildroot())
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT you're not usingrel_buildroot anywhere?

from pants_test.pants_run_integration_test import PantsRunIntegrationTest
from pants_test.testutils.git_util import initialize_repo


class ChangedTargetGoalsIntegrationTest(PantsRunIntegrationTest):
@contextmanager
def known_commits(self):
"""Creates an anonymous git repository under the buildroot."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it important for it to be under the real buildroot? I'm getting quite confused by the nesting of real buildroot, test gitroot and test buildroot.

if os.path.exists(gitdir):
raise Exception('`known_commits_in` should not be used with an existing git repository.')

buildroot = os.path.join(worktree, prefix[0]) if prefix else get_buildroot()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing to me. I think "worktree" is the same thing as "gitroot" in the change description? If so it would be good to standardize on a single term.

More confusingly, if I'm grokking correctly, if prefix is specified then the test buildroot is under worktree (which is under the real buildroot), otherwise the test buildroot is the real buildroot, which means it contains worktree?

I feel like I must be reading this wrong.

def test_list_changed_with_buildroot_ne_gitroot(self):
# Create a temporary directory, create a mock buildroot in a subdirectory, and then
# initialize a git repository _above_ the buildroot in the original temp directory.
with temporary_dir(root_dir=get_buildroot()) as worktree, \
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, why does this need to be under the real buildroot?

@stuhood
Copy link
Member Author

stuhood commented Jan 24, 2019

The test is still useful, but going to hold onto the branch and close this until I have an abundance of time.

@stuhood stuhood closed this Jan 24, 2019
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.

Changed getting AscendantAddress with directory ".." when git root not the same as build root
2 participants