utils/get-developers: bail out on parsing errors

Currently 4 types of parsing errors/warnings can be found:
- entry for a file that is not in the tree anymore (warning)
- developer entry with no file entry (error)
- file entry with no developer (error)
- entry that is not a developer, a file or a comment (hard error)

Currently only the last one ends the script with -v with error code.

Make all 3 error types into hard errors and bail out at the first error
found, because the rest of the state machine is not designed to handle
malformed input.
Suggested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Ricardo Martincoski 2022-11-27 11:48:18 -03:00 committed by Thomas Petazzoni
parent ce3d349384
commit 5ee1dd85a3
2 changed files with 5 additions and 5 deletions

View file

@ -70,11 +70,11 @@ class TestGetDevelopers(unittest.TestCase):
b'F:\tutils/get-developers\n'
out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
self.assertIn("Syntax error in DEVELOPERS file, line 1", err)
self.assertEqual(rc, 0)
self.assertEqual(rc, 1)
self.assertEqual(len(out), 0)
self.assertEqual(len(err), 1)
# -v generating error for developer entry with no file entries
# -v generating error for developer entry with no file entries, stopping on first error
developers = b'# comment\n' \
b'# comment\n' \
b'\n' \
@ -84,10 +84,9 @@ class TestGetDevelopers(unittest.TestCase):
b'F:\tutils/get-developers\n'
out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
self.assertIn("Syntax error in DEVELOPERS file, line 1", err)
self.assertIn("Syntax error in DEVELOPERS file, line 2", err)
self.assertEqual(rc, 0)
self.assertEqual(rc, 1)
self.assertEqual(len(out), 0)
self.assertEqual(len(err), 2)
self.assertEqual(len(err), 1)
# -v not generating error for developer entry with empty list of file entries
developers = b'# comment\n' \

View file

@ -243,6 +243,7 @@ def parse_developers(filename=None):
if name is not None or len(files) != 0:
print("Syntax error in DEVELOPERS file, line %d" % linen,
file=sys.stderr)
return None
name = line[2:].strip()
elif line.startswith("F:"):
fname = line[2:].strip()