tests: don't barf when testing for copyrights in files with less than two lines
If you don't get two lines of code after reading the first 2K of the
file, you don't have a copyright in the file. copyright_is_valid() was
failing for some files because it only read one line, so lines[1] raised
IndexError. Catch the exception and make copyright_is_valid() return
properly: the file doesn't have a valid copyright.
diff --git a/tests/test_copyright.py b/tests/test_copyright.py
index b123fd1..0556b65 100644
--- a/tests/test_copyright.py
+++ b/tests/test_copyright.py
@@ -30,12 +30,15 @@
# Either the first or the second line must have a "Copyright:" line
first_line = re.compile(r"(#| \*) Copyright")
- if not first_line.search(lines[0]):
- if first_line.search(lines[1]):
- # Drop the first line to align the copyright to lines[0]
- lines = lines[1:]
- else:
- return False
+ try:
+ if not first_line.search(lines[0]):
+ if first_line.search(lines[1]):
+ # Drop the first line to align the copyright to lines[0]
+ lines = lines[1:]
+ else:
+ return False
+ except IndexError:
+ return False
# The copyright mentions ARM Limited
if "ARM Limited" not in lines[0]: