On 1/15/19 1:38 AM, Lukáš Doktor wrote:
> Dne 14. 01. 19 v 18:36 Brian J. Murrell napsal(a):
>> Are the tags given to a --filter-by-tags argument available in the test
>> (i.e. setUp(), test_* functions, etc.)?
>>
>> The idea of course is so that a test can know which tags were requested
>> possibly for skipping, etc.
>>
>> Cheers,
>> b.
>>
> 
> Hello Brian,
> 
> they are not intended for dynamic usage. For dynamic purposes we have the 
> test params.
> 

Right.

> Anyway you asked whether they are available and in a way they are. It is not 
> a guaranteed interface, but it should probably work at least until we finish 
> the Job API (which should supersede all of these and is coming for years 
> already). Every test is also given the job instance and job instance contains 
> full parsed test arguments. So you can use something like:
> 
>     self.job.args.filter_by_tags
> 
> in a test and get the list of tags set on the cmdline. Anyway you had been 
> warned that it is not a really good idea. Better would be to create an RFC 
> (or a mini-rfc) with some examples and possible interfaces we could discuss 
> (or at least to join any release meeting and discuss it live) so we can find 
> a generic solution. My first idea would be to populate "self.params" with 
> filters to have a single storage that would allow overrides/extensions from 
> parameter system.
> 

One interface that was recently added was the "self.tags":

https://avocado-framework.readthedocs.io/en/67.0/api/test/avocado.html#avocado.Test.tags

Which let's a test reuses information set on its own tags.  One example
on how it can be used is here:

https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg04317.html

Cheers,
- Cleber.

> Regards,
> Lukáš
> 
> PS: You can also use "sys.argv" but that is even nastier and also might go 
> away with the Job API (at least if we chose the way I envision :D).
> 

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]
[  7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3  ]

Reply via email to