Check that Windows files have Windows line endings
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/tests/scripts/check-files.py b/tests/scripts/check-files.py
index 4ba1d8d..20bd2dd 100755
--- a/tests/scripts/check-files.py
+++ b/tests/scripts/check-files.py
@@ -139,6 +139,18 @@
return b"\r" in line
+class WindowsLineEndingIssueTracker(LineIssueTracker):
+ """Track files with non-Windows line endings (i.e. files without CR)."""
+
+ heading = "Non-Windows line endings:"
+
+ def should_check_file(self, filepath):
+ return is_windows_file(filepath)
+
+ def issue_with_line(self, line, _filepath):
+ return not line.endswith(b"\r\n")
+
+
class TrailingWhitespaceIssueTracker(LineIssueTracker):
"""Track lines with trailing whitespace."""
@@ -221,6 +233,7 @@
EndOfFileNewlineIssueTracker(),
Utf8BomIssueTracker(),
UnixLineEndingIssueTracker(),
+ WindowsLineEndingIssueTracker(),
TrailingWhitespaceIssueTracker(),
TabIssueTracker(),
MergeArtifactIssueTracker(),