added bad line ending test

Fri, 18 Sep 2020 20:46:26 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 18 Sep 2020 20:46:26 +0300
changeset 126
16dae12ac0f0
parent 125
43d6ed8515ab
child 127
97de6058109e

added bad line ending test

unittest.py file | annotate | diff | comparison | revisions
unittests/bad-line-endings-dos.test file | annotate | diff | comparison | revisions
unittests/bad-line-endings-unix.test file | annotate | diff | comparison | revisions
--- a/unittest.py	Fri Sep 18 20:41:33 2020 +0300
+++ b/unittest.py	Fri Sep 18 20:46:26 2020 +0300
@@ -25,7 +25,7 @@
     with open(unit_test_path, 'rb') as device:
         import re
         problem_types = set()
-        expecting = set()
+        expecting = None
         while True:
             pos = device.tell()
             line = bytes.decode(device.readline())
@@ -34,14 +34,18 @@
             match = re.match('^0 Testing: (.+)', line)
             if match:
                 set.update(problem_types, match.group(1).split())
+            elif str.strip(line) == '0 Expecting: none':
+                expecting = set()
             else:
                 match = re.match('^0 Expecting: (.+)', line)
                 if match:
+                    if not expecting:
+                        expecting = set()
                     set.update(expecting, map(parse_expectation, match.group(1).split()))
                 else:
                     device.seek(pos)
                     break
-        if not problem_types or not expecting:
+        if not problem_types or expecting is None:
             raise ValueError(str.format(
                 'Unit test {name} does not have a proper manifest',
                 name = name,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unittests/bad-line-endings-dos.test	Fri Sep 18 20:46:26 2020 +0300
@@ -0,0 +1,3 @@
+0 Testing: bad-line-endings
+0 Expecting: none
+1 16 0 0 0 1 0 0 0 1 0 0 0 1 box.dat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unittests/bad-line-endings-unix.test	Fri Sep 18 20:46:26 2020 +0300
@@ -0,0 +1,3 @@
+0 Testing: bad-line-endings
+0 Expecting: bad-line-endings:1
+1 16 0 0 0 1 0 0 0 1 0 0 0 1 box.dat

mercurial