Merge lp:~mthaddon/codetree/comments-only into lp:codetree

Proposed by Tom Haddon
Status: Merged
Approved by: Benjamin Allot
Approved revision: 118
Merged at revision: 117
Proposed branch: lp:~mthaddon/codetree/comments-only
Merge into: lp:codetree
Diff against target: 38 lines (+11/-1)
3 files modified
codetree/config.py (+4/-1)
tests/test_config.py (+6/-0)
tests/test_data/comments_only (+1/-0)
To merge this branch: bzr merge lp:~mthaddon/codetree/comments-only
Reviewer Review Type Date Requested Status
Benjamin Allot Approve
Joel Sing (community) +1 Approve
Daniel Manrique (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+385390@code.launchpad.net

Commit message

Make sure we correctly process config files that are empty or comments only

Description of the change

Make sure we correctly process config files that are empty or comments only

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Daniel Manrique (roadmr) wrote :

LGTM, thanks!

review: Approve
lp:~mthaddon/codetree/comments-only updated
118. By Tom Haddon

Clarify comment about workers needing to be at least one

Revision history for this message
Joel Sing (jsing) wrote :

LGTM

review: Approve (+1)
Revision history for this message
Benjamin Allot (ballot) wrote :

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 117

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'codetree/config.py'
2--- codetree/config.py 2020-04-08 09:58:38 +0000
3+++ codetree/config.py 2020-06-09 14:39:18 +0000
4@@ -241,7 +241,10 @@
5 workers = None
6
7 if not workers:
8- workers = len(self.directive_map)
9+ # Make sure there is at least one worker, even if our directive_map
10+ # is empty, which can happen if the file contains comments or
11+ # blank lines only.
12+ workers = len(self.directive_map) or 1
13
14 self.executor = concurrent.futures.ThreadPoolExecutor(
15 max_workers=workers)
16
17=== modified file 'tests/test_config.py'
18--- tests/test_config.py 2020-04-20 06:38:12 +0000
19+++ tests/test_config.py 2020-06-09 14:39:18 +0000
20@@ -260,6 +260,12 @@
21 }
22 self.assertEqual(collect_info["hashes"], expected_hashes)
23
24+ def test_empty_collect_file(self):
25+ # Test that an empty collect file (or a file with comments only)
26+ # is handled correctly and doesn't throw an error due to 0 workers.
27+ collect_config = Config('tests/test_data/comments_only')
28+ self.assertEqual(collect_config.build(), [])
29+
30
31 class TestConfigResults(TestCase):
32 def test_true(self):
33
34=== added file 'tests/test_data/comments_only'
35--- tests/test_data/comments_only 1970-01-01 00:00:00 +0000
36+++ tests/test_data/comments_only 2020-06-09 14:39:18 +0000
37@@ -0,0 +1,1 @@
38+# This file includes comments only

Subscribers

People subscribed via source and target branches