Skip to content

Commit

Permalink
Fixed changed goal for BUILD files in build root
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov authored and stuhood committed Sep 2, 2015
1 parent 3a93428 commit c615fa1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/python/pants/backend/core/wrapped_globs.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, rel_path):
self._rel_path = rel_path

def __call__(self, *args, **kwargs):
root = os.path.join(get_buildroot(), self._rel_path)
root = os.path.normpath(os.path.join(get_buildroot(), self._rel_path))

excludes = kwargs.pop('exclude', [])
if isinstance(excludes, string_types):
Expand All @@ -90,7 +90,7 @@ def files_calculator():
return result

buildroot = get_buildroot()
rel_root = os.path.relpath(root, buildroot)
rel_root = os.path.relpath(root, buildroot) if root != buildroot else ''
filespec = self.to_filespec(args, root=rel_root, excludes=excludes)
return FilesetWithSpec(rel_root, filespec, files_calculator)

Expand Down
16 changes: 15 additions & 1 deletion tests/python/pants_test/tasks/test_what_changed.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pants.backend.core.from_target import FromTarget
from pants.backend.core.targets.resources import Resources
from pants.backend.core.tasks.what_changed import WhatChanged
from pants.backend.core.wrapped_globs import RGlobs
from pants.backend.core.wrapped_globs import RGlobs, Globs
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.targets.jar_library import JarLibrary
from pants.backend.jvm.targets.java_library import JavaLibrary
Expand Down Expand Up @@ -42,6 +42,7 @@ def alias_groups(self):
},
context_aware_object_factories={
'source_root': SourceRoot.factory,
'globs': Globs.factory,
'rglobs': RGlobs.factory,
'from_target': FromTarget,
},
Expand Down Expand Up @@ -201,6 +202,13 @@ def setUp(self):
)
"""))

self.add_to_build_file('BUILD.config', dedent("""
resources(
name='pants-config',
sources = globs('pants.ini*')
)
"""))

def test_spec_excludes(self):
self.assert_console_output(
'root/src/py/a:alpha',
Expand Down Expand Up @@ -361,3 +369,9 @@ def test_deferred_sources(self):
'root/proto:external-source-jars',
workspace=self.workspace(files=['root/proto/BUILD'])
)

def test_root_config(self):
self.assert_console_output(
':pants-config',
workspace=self.workspace(files=['pants.ini'])
)

0 comments on commit c615fa1

Please sign in to comment.