avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
336 stars 335 forks source link

Issues converting cache_dirs configuration option as list in _avocado/core/settings.py _as_list(value) method #5906

Open dnegreira opened 2 months ago

dnegreira commented 2 months ago

Describe the bug If I add a custom directory on avocado.conf with the example:

[datadir.paths]
base_dir = /build/avocado/data
logs_dir = /build/avocado/data/job-results
cache_dirs = /build/avocado/data/cache

At a certain point a method is called to convert the cache_dirs to a list, but ast will fail with an error since it contains special (/) characters in it.

Steps to reproduce Can reproduce it in two ways: By setting the above in avocado.conf and running python3.10 test --select=unit

After a bit of debugging I could find the same behavior that _as_list(value) is doing by following the quick example on python CLE.

>>> import ast
>>> bla = '/build/avocado/data/cache'
>>> print(ast.literal_eval(bla))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "/usr/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    /build/avocado/data/cache
    ^

Expected behavior _as_list(value) should return the string as a list.

Current behavior The above errors mentioned.

System information (please complete the following information):

Additional information Currently working on an effort to package avocado-framework into Ubuntu/Debian.

dnegreira commented 2 months ago

And of course I had to use a list as a value, not a string and that worked :)

richtja commented 2 months ago

Hi @dnegreira, thank you for reporting this. I can confirm that I was able to reproduce it.