Skip to content

Commit

Permalink
fixup! Add tests for rosdep checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cottsay committed Sep 18, 2024
1 parent 07c5425 commit 214dcd1
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion test/test_rosdep_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def test_control(rosdep_repo):
repo_dir = Path(rosdep_repo.working_tree_dir)
extension = RosdepAnalyzer()

for file_name, data in VIOLATIONS['*'].items():
rules = _merge_two_rules(EXISTING_RULES, CONTROL_RULES)
for file_name, data in rules.items():
file_path = repo_dir / 'rosdep' / file_name
with file_path.open('w') as f:
yaml.dump(data, f)
Expand All @@ -310,6 +311,46 @@ def test_control(rosdep_repo):
assert all(Recommendation.APPROVE == c.recommendation for c in criteria)


def test_target_ref(rosdep_repo):
repo_dir = Path(rosdep_repo.working_tree_dir)
extension = RosdepAnalyzer()

rules = _merge_two_rules(EXISTING_RULES, CONTROL_RULES)
for file_name, data in rules.items():
file_path = repo_dir / 'rosdep' / file_name
with file_path.open('w') as f:
yaml.dump(data, f)

rosdep_repo.index.add(file_path)

rosdep_repo.index.commit('Add control rules')

# Add some violations to the stage, choose set 'A' as candidate
rules = _merge_two_rules(rules, VIOLATIONS['A'])
for file_name, data in rules.items():
file_path = repo_dir / 'rosdep' / file_name
with file_path.open('w') as f:
yaml.dump(data, f)

criteria, annotations = extension.analyze(repo_dir, head_ref='HEAD')
assert criteria and not annotations
assert all(Recommendation.APPROVE == c.recommendation for c in criteria)

criteria, annotations = extension.analyze(repo_dir)
assert criteria and annotations
assert any(Recommendation.APPROVE != c.recommendation for c in criteria)


def test_removal_only(rosdep_repo):
repo_dir = Path(rosdep_repo.working_tree_dir)
extension = RosdepAnalyzer()

for file_name in EXISTING_RULES.keys():
(repo_dir / 'rosdep' / file_name).write_text('')

assert (None, None) == extension.analyze(repo_dir)


def test_violation(rosdep_repo, violation_rules):
repo_dir = Path(rosdep_repo.working_tree_dir)
extension = RosdepAnalyzer()
Expand Down

0 comments on commit 214dcd1

Please sign in to comment.