Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Commit 1e07da7

Browse files
committed
#7: Correct support for [global] group in RKD_WHITELIST_GROUPS
1 parent 99013b3 commit 1e07da7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/rkd/standardlib/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ def execute(self, context: ExecutionContext) -> bool:
9898
group_name = declaration.get_group_name()
9999

100100
# (optional) whitelists of displayed groups
101-
if whitelisted_groups and (':' + group_name) not in whitelisted_groups:
102-
continue
101+
if whitelisted_groups:
102+
group_to_whitelist_check = (':' + group_name) if group_name else '' # allow empty group ([global])
103+
104+
if group_to_whitelist_check not in whitelisted_groups:
105+
continue
103106

104107
if group_name not in groups:
105108
groups[group_name] = {}

test/test_functional.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ def test_tasks_whitelist_shows_only_selected_groups(self):
165165
self.assertIn(':rkd:create-structure', full_output)
166166
self.assertNotIn(':exec', full_output)
167167

168+
def test_task_whitelist_shows_only_global_group(self):
169+
"""Test that when we set RKD_WHITELIST_GROUPS=,, then we will see only tasks from [global] group"""
170+
171+
try:
172+
os.environ['RKD_WHITELIST_GROUPS'] = ','
173+
full_output, exit_code = self._run_and_capture_output([':tasks'])
174+
finally:
175+
os.environ['RKD_WHITELIST_GROUPS'] = ''
176+
177+
self.assertIn(':tasks', full_output)
178+
self.assertNotIn(':rkd:create-structure', full_output)
179+
168180
def test_task_alias_resolves_task(self):
169181
"""Test that with RKD_ALIAS_GROUPS=":py->:class-war" the :class-war:build would be resolved to :py:build"""
170182

0 commit comments

Comments
 (0)