[Lldb-commits] [PATCH] Allow test categories to be skipped.

Stefanus Du Toit stefanus.du.toit at intel.com
Tue Jul 30 10:58:15 PDT 2013


Hi mkopec1,

This adds a new parameter, --skip-category, that can be used to list categories that should be skipped. For example, to run all tests except for Objective-C ones, one can now write:
    
      ./dotest.py --skip-category objc [...]


http://llvm-reviews.chandlerc.com/D1237

Files:
  test/dotest.py

Index: test/dotest.py
===================================================================
--- test/dotest.py
+++ test/dotest.py
@@ -132,6 +132,8 @@
 categoriesList = None
 # set to true if we are going to use categories for cherry-picking test cases
 useCategories = False
+# Categories we want to skip
+skipCategories = []
 # use this to track per-category failures
 failuresPerCategory = {}
 
@@ -347,6 +349,26 @@
 class ArgParseNamespace(object):
     pass
 
+def validate_categories(categories):
+    """For each category in categories, ensure that it's a valid category (or a prefix thereof).
+       If a category is invalid, print a message and quit.
+       If all categories are valid, return the list of categories. Prefixes are expanded in the
+       returned list.
+    """
+    global validCategories
+    result = []
+    for category in categories:
+        origCategory = category
+        if category not in validCategories:
+            category = unique_string_match(category, validCategories)
+        if (category not in validCategories) or category == None:
+            print "fatal error: category '" + origCategory + "' is not a valid category"
+            print "if you have added a new category, please edit dotest.py, adding your new category to validCategories"
+            print "else, please specify one or more of the following: " + str(validCategories.keys())
+            sys.exit(1)
+        result.append(category)
+    return result
+
 def parseOptionsAndInitTestdirs():
     """Initialize the list of directories containing our unittest scripts.
 
@@ -363,6 +385,7 @@
     global categoriesList
     global validCategories
     global useCategories
+    global skipCategories
     global lldbFrameworkPath
     global lldbExecutablePath
     global configFile
@@ -424,6 +447,7 @@
     group.add_argument('-p', metavar='pattern', help='Specify a regexp filename pattern for inclusion in the test suite')
     group.add_argument('-X', metavar='directory', help="Exclude a directory from consideration for test discovery. -X types => if 'types' appear in the pathname components of a potential testfile, it will be ignored")
     group.add_argument('-G', '--category', metavar='category', action='append', dest='categoriesList', help=textwrap.dedent('''Specify categories of test cases of interest. Can be specified more than once.'''))
+    group.add_argument('--skip-category', metavar='category', action='append', dest='skipCategories', help=textwrap.dedent('''Specify categories of test cases to skip. Takes precedence over -G. Can be specified more than once.'''))
 
     # Configuration options
     group = parser.add_argument_group('Configuration options')
@@ -488,22 +512,14 @@
             archs = [platform_machine]
 
     if args.categoriesList:
-        finalCategoriesList = []
-        for category in args.categoriesList:
-            origCategory = category
-            if not(category in validCategories):
-                category = unique_string_match(category,validCategories)
-            if not(category in validCategories) or category == None:
-                print "fatal error: category '" + origCategory + "' is not a valid category"
-                print "if you have added a new category, please edit dotest.py, adding your new category to validCategories"
-                print "else, please specify one or more of the following: " + str(validCategories.keys())
-                sys.exit(1)
-            finalCategoriesList.append(category)
-        categoriesList = set(finalCategoriesList)
+        categoriesList = set(validate_categories(args.categoriesList))
         useCategories = True
     else:
         categoriesList = []
 
+    if args.skipCategories:
+        skipCategories = validate_categories(args.skipCategories)
+
     if args.compilers:
         compilers = args.compilers
     else:
@@ -1465,6 +1481,12 @@
                     test_categories = self.getCategoriesForTest(test)
                     if len(test_categories) == 0 or len(categoriesList & set(test_categories)) == 0:
                         return True
+
+                global skipCategories
+                for category in skipCategories:
+                    if category in self.getCategoriesForTest(test):
+                        return True
+
                 return False
 
             def hardMarkAsSkipped(self,test):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1237.1.patch
Type: text/x-patch
Size: 4387 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130730/d31e07ef/attachment.bin>


More information about the lldb-commits mailing list