Skip to content

Commit

Permalink
fix sourcing empty workspace built with --merge-install (#179)
Browse files Browse the repository at this point in the history
* fix sourcing empty workspace with merge install

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>

* update test for empty workspaces

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>

* mock -> check

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
  • Loading branch information
mikaelarguedas authored and dirk-thomas committed Apr 3, 2019
1 parent 749204c commit d959c86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions colcon_core/shell/template/prefix_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def get_packages(prefix_path, merged_install):
# must match colcon_core.location.get_relative_package_index_path()
subdirectory = 'share/colcon-core/packages'
if merged_install:
# return if workspace is empty
if not (prefix_path / subdirectory).is_dir():
return packages
# find all files in the subdirectory
for p in (prefix_path / subdirectory).iterdir():
if not p.is_file():
Expand Down
8 changes: 8 additions & 0 deletions test/test_shell_template_prefix_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def test_get_packages():
with TemporaryDirectory(prefix='test_colcon_') as prefix_path:
prefix_path = Path(prefix_path)

# check no packages in not merged install layout
packages = get_packages(prefix_path, False)
assert packages == {}

# mock packages in not merged install layout
subdirectory = get_relative_package_index_path()
for pkg_name in ('pkgA', 'pkgB'):
Expand All @@ -39,6 +43,10 @@ def test_get_packages():
(prefix_path / '.hidden_dir').mkdir()
(prefix_path / 'dummy_file').write_text('')

# check no packages in merged install layout
packages = get_packages(prefix_path, True)
assert packages == {}

# mock packages in merged install layout
(prefix_path / subdirectory).mkdir(parents=True)
(prefix_path / subdirectory / 'pkgB').write_text('')
Expand Down

0 comments on commit d959c86

Please sign in to comment.