Linaro / squadplugins

GNU Affero General Public License v3.0
1 stars 6 forks source link

ltp: escape regex characters in test name #16

Closed chaws closed 4 years ago

chaws commented 4 years ago

This fixes an error we hit this morning:

Plugin postprocessing error: bad character range o-N at position 79
Traceback (most recent call last):
  File "/srv/qa-reports.linaro.org/lib/python3.5/site-packages/squad/core/tasks/__init__.py", line 259, in __call__
    self.__call_plugin__(plugin, testrun)
  File "/srv/qa-reports.linaro.org/lib/python3.5/site-packages/squad/core/tasks/__init__.py", line 264, in __call_plugin__
    plugin.postprocess_testrun(testrun)
  File "/srv/qa-reports.linaro.org/lib/python3.5/site-packages/ltp/__init__.py", line 15, in postprocess_testrun
    regex = re.compile("^%s.*$" % test.name, re.MULTILINE)
  File "/srv/qa-reports.linaro.org/lib/python3.5/re.py", line 224, in compile
    return _compile(pattern, flags)
  File "/srv/qa-reports.linaro.org/lib/python3.5/re.py", line 293, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/srv/qa-reports.linaro.org/lib/python3.5/sre_compile.py", line 536, in compile
    p = sre_parse.parse(p, flags)
  File "/srv/qa-reports.linaro.org/lib/python3.5/sre_parse.py", line 829, in parse
    p = _parse_sub(source, pattern, 0)
  File "/srv/qa-reports.linaro.org/lib/python3.5/sre_parse.py", line 437, in _parse_sub
    itemsappend(_parse(source, state))
  File "/srv/qa-reports.linaro.org/lib/python3.5/sre_parse.py", line 575, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
sre_constants.error: bad character range o-N at position 79

It happened for tests with regex characters in their name, and that did something not legal, e.g. "[go-Nets]"