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

Fix hanging on circular run depend. #440

Merged
merged 2 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions catkin_tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def get_recursive_depends_in_workspace(
d.name
for d in exclude_function(pkg)
])
# Add the package itself in case we have a circular dependency
checked_pkgs.add(pkg.name)
# Add this package to the list of recursive dependencies for this package
recursive_deps.add(pkg.name)

Expand Down
49 changes: 31 additions & 18 deletions tests/unit/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@
from catkin_tools import common


def test_get_recursive_build_depends_in_workspace_with_test_depend():
pkg1 = mock.Mock()
pkg1.name = 'pkg1'
pkg1.build_depends = []
pkg1.buildtool_depends = []
pkg1.test_depends = []
pkg1.run_depends = []
pkg1.exec_depends = []
pkg1.build_export_depends = []

pkg2 = mock.Mock()
pkg2.name = 'pkg2'
pkg2.build_depends = []
pkg2.buildtool_depends = []
pkg2.test_depends = []
pkg2.run_depends = []
pkg2.exec_depends = []
pkg2.build_export_depends = []
class MockPackage(mock.Mock):
def __init__(self, name):
super(MockPackage, self).__init__()
self.name = name
self.build_depends = []
self.buildtool_depends = []
self.test_depends = []
self.run_depends = []
self.exec_depends = []
self.build_export_depends = []

def test_get_recursive_build_depends_in_workspace_with_test_depend():
pkg1 = MockPackage('pkg1')
pkg2 = MockPackage('pkg2')
pkg1.test_depends.append(pkg2)

ordered_packages = [
Expand All @@ -33,6 +28,24 @@ def test_get_recursive_build_depends_in_workspace_with_test_depend():
assert r == ordered_packages[1:], r


def test_get_recursive_build_depends_in_workspace_circular_run_depend():
pkg1 = MockPackage('pkg1')
pkg2 = MockPackage('pkg2')
pkg1.run_depends.append(pkg2)
pkg2.run_depends.append(pkg1)

ordered_packages = [
('/path/to/pkg1', pkg1),
('/path/to/pkg2', pkg2),
]

r = common.get_recursive_build_depends_in_workspace(pkg1, ordered_packages)
assert r == ordered_packages[:], r

r = common.get_recursive_build_depends_in_workspace(pkg2, ordered_packages)
assert r == ordered_packages[:], r


def test_format_time_delta_short():
inputs = {
1.45: "1.4",
Expand Down