test framework: add shell-style wildcard matching to filenames 19/15119/4
authorAndrew Yourtchenko <ayourtch@gmail.com>
Wed, 3 Oct 2018 09:38:31 +0000 (11:38 +0200)
committerDamjan Marion <dmarion@me.com>
Wed, 3 Oct 2018 17:39:21 +0000 (17:39 +0000)
Currently, one can either use "*" to denote all filenames,
or to give the specific file name to run the tests in.
This commit adds the possibility to run all tests
matching the shell wildcard, e.g. TEST="test_acl_plugin*"
will execute all ACL plugin testcases.

Change-Id: I9048a601958947c7b757c3dfd57b19cdd8a1e3c0
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
test/run_tests.py

index 0cd057c..6836466 100644 (file)
@@ -3,6 +3,7 @@
 import sys
 import shutil
 import os
+import fnmatch
 import select
 import unittest
 import argparse
@@ -425,8 +426,10 @@ class FilterByTestOption:
         self.filter_func_name = filter_func_name
 
     def __call__(self, file_name, class_name, func_name):
-        if self.filter_file_name and file_name != self.filter_file_name:
-            return False
+        if self.filter_file_name:
+            fn_match = fnmatch.fnmatch(file_name, self.filter_file_name)
+            if not fn_match:
+                return False
         if self.filter_class_name and class_name != self.filter_class_name:
             return False
         if self.filter_func_name and func_name != self.filter_func_name: