CI: deviceinfo: allow inline comments (MR 5766)

The current test script disallows these kinds of comments:
  deviceinfo_some_variable="some_value" # an inline comment

Since deviceinfo is essentially a shell script, it does make sense to
allow inline comments. It is relatively simple to implement as well, by
adjusting the regex.
[ci:skip-build]: already built successfully in CI
This commit is contained in:
methanal 2024-11-06 23:26:23 +05:30 committed by Stefan Hansson
parent ea3904055a
commit ecb1c7fa21
No known key found for this signature in database
GPG Key ID: ACD854892B38D898

View File

@ -36,7 +36,7 @@ def test_deviceinfo():
# Iterate over all devices
last_exception = None
count = 0
pattern = re.compile("^deviceinfo_[a-zA-Z0-9_]*=\".*\"$")
pattern = re.compile("^deviceinfo_[a-zA-Z0-9_]*=\".*\"(\\s*# .*)?$")
for folder in pkgrepo_iglob("device/*/device-*"):
device = folder.name.split("-", 1)[1]
@ -63,8 +63,8 @@ def test_deviceinfo():
# Check line against regex (can't use multiple lines etc.)
if not pattern.match(line) or line.endswith("\\\""):
raise RuntimeError("Line looks invalid, maybe missing"
" quotes/multi-line string/comment next"
f" to line instead of above? {line}")
" quotes/multi-line string/malformed"
f" inline comment? {line}")
# Successful deviceinfo parsing / obsolete options
info = pmb.parse.deviceinfo(device)