Skip to content

Commit

Permalink
Fix test_build_root.py (fails until pantsbuild#8063)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Aug 11, 2019
1 parent bfbccc0 commit 455abfe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ files(
name = '3rdparty_build',
source = '3rdparty/BUILD',
)

# NB: Be careful when using this in tests! Some tests will use this to determine the buildroot and
# then dynamically try to open other files relative to the buildroot, such as BUILD.tools. This
# should not be used to dynamically import other files—those must be explicitly imported via their
# own BUILD entries.
files(
name = 'pants_script',
source = 'pants',
)
4 changes: 2 additions & 2 deletions src/python/pants/base/build_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def path(self, root_dir):
"""Manually establishes the build root for the current workspace."""
path = os.path.realpath(root_dir)
if not os.path.exists(path):
raise ValueError('Build root does not exist: {}'.format(root_dir))
raise ValueError(f'Build root does not exist: {root_dir}')
self._root_dir = path

def reset(self):
"""Clears the last calculated build root for the current workspace."""
self._root_dir = None

def __str__(self):
return 'BuildRoot({})'.format(self._root_dir)
return f'BuildRoot({self._root_dir})'

@contextmanager
def temporary(self, path):
Expand Down
1 change: 1 addition & 0 deletions tests/python/pants_test/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ python_tests(
name = 'build_root',
sources = ['test_build_root.py'],
dependencies = [
'//:pants_script',
'src/python/pants/base:build_root',
'src/python/pants/util:contextutil',
'src/python/pants/util:dirutil',
Expand Down

0 comments on commit 455abfe

Please sign in to comment.