diff options
Diffstat (limited to 'meta/lib/patchtest/tests/test_metadata_max_length.py')
-rw-r--r-- | meta/lib/patchtest/tests/test_metadata_max_length.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/meta/lib/patchtest/tests/test_metadata_max_length.py b/meta/lib/patchtest/tests/test_metadata_max_length.py new file mode 100644 index 0000000000..04a5e23469 --- /dev/null +++ b/meta/lib/patchtest/tests/test_metadata_max_length.py | |||
@@ -0,0 +1,26 @@ | |||
1 | # Checks related to patch line lengths | ||
2 | # | ||
3 | # Copyright (C) 2016 Intel Corporation | ||
4 | # | ||
5 | # SPDX-License-Identifier: GPL-2.0 | ||
6 | |||
7 | import base | ||
8 | import re | ||
9 | |||
10 | class MaxLength(base.Base): | ||
11 | add_mark = re.compile('\+ ') | ||
12 | max_length = 200 | ||
13 | |||
14 | def test_max_line_length(self): | ||
15 | for patch in self.patchset: | ||
16 | # for the moment, we are just interested in metadata | ||
17 | if patch.path.endswith('.patch'): | ||
18 | continue | ||
19 | payload = str(patch) | ||
20 | for line in payload.splitlines(): | ||
21 | if self.add_mark.match(line): | ||
22 | current_line_length = len(line[1:]) | ||
23 | if current_line_length > self.max_length: | ||
24 | self.fail('Patch line too long (current length %s)' % current_line_length, | ||
25 | 'Shorten the corresponding patch line (max length supported %s)' % self.max_length, | ||
26 | data=[('Patch', patch.path), ('Line', '%s ...' % line[0:80])]) | ||