tests/misc.py

changeset 94
109fb7cf658f
parent 88
6a0b43a5dec0
child 105
43c367c8895b
--- a/tests/misc.py	Mon Jun 24 17:34:30 2019 +0300
+++ b/tests/misc.py	Mon Jun 24 19:08:24 2019 +0300
@@ -229,6 +229,23 @@
                     command_text = element.text,
                 )
 
+@problem_type('bad-line-endings',
+    severity = 'hold',
+    message = lambda count: str.format(
+        'file contains non-DOS line endings ({count} total)',
+        count = count,
+    ),
+)
+def line_endings_test(model):
+    # Line endings are already checked during parse. This function
+    # only serves to report them.
+    if model.line_ending_errors != None:
+        yield report_problem(
+            'bad-line-endings',
+            bad_object = model.body[model.line_ending_errors['first-at']],
+            count = model.line_ending_errors['count'],
+        )
+
 manifest = {
     'tests': [
         colours_test,
@@ -243,5 +260,6 @@
         moved_to_with_extension_test,
         bfc_invertnext_not_on_subfile_test,
         metacommands_test,
+        line_endings_test,
     ],
 }

mercurial