tests/run-tests.py
changeset 9959 b37b060d84c7
parent 9958 777c1df76ef4
child 10013 b2e87fde6806
equal deleted inserted replaced
9958:777c1df76ef4 9959:b37b060d84c7
    39 # (You could use any subset of the tests: test-s* happens to match
    39 # (You could use any subset of the tests: test-s* happens to match
    40 # enough that it's worth doing parallel runs, few enough that it
    40 # enough that it's worth doing parallel runs, few enough that it
    41 # completes fairly quickly, includes both shell and Python scripts, and
    41 # completes fairly quickly, includes both shell and Python scripts, and
    42 # includes some scripts that run daemon processes.)
    42 # includes some scripts that run daemon processes.)
    43 
    43 
       
    44 from ConfigParser import ConfigParser
    44 import difflib
    45 import difflib
    45 import errno
    46 import errno
    46 import optparse
    47 import optparse
    47 import os
    48 import os
    48 import subprocess
    49 import subprocess
   130         help="use pure Python code instead of C extensions")
   131         help="use pure Python code instead of C extensions")
   131     parser.add_option("-3", "--py3k-warnings", action="store_true",
   132     parser.add_option("-3", "--py3k-warnings", action="store_true",
   132         help="enable Py3k warnings on Python 2.6+")
   133         help="enable Py3k warnings on Python 2.6+")
   133     parser.add_option("--inotify", action="store_true",
   134     parser.add_option("--inotify", action="store_true",
   134         help="enable inotify extension when running tests")
   135         help="enable inotify extension when running tests")
       
   136     parser.add_option("--blacklist", action="append",
       
   137         help="skip tests listed in the specified section of "
       
   138              "the blacklist file")
   135 
   139 
   136     for option, default in defaults.items():
   140     for option, default in defaults.items():
   137         defaults[option] = int(os.environ.get(*default))
   141         defaults[option] = int(os.environ.get(*default))
   138     parser.set_defaults(**defaults)
   142     parser.set_defaults(**defaults)
   139     (options, args) = parser.parse_args()
   143     (options, args) = parser.parse_args()
   195                 'warning: --timeout option ignored with --debug\n')
   199                 'warning: --timeout option ignored with --debug\n')
   196         options.timeout = 0
   200         options.timeout = 0
   197     if options.py3k_warnings:
   201     if options.py3k_warnings:
   198         if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
   202         if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
   199             parser.error('--py3k-warnings can only be used on Python 2.6+')
   203             parser.error('--py3k-warnings can only be used on Python 2.6+')
       
   204     if options.blacklist:
       
   205         configparser = ConfigParser()
       
   206         configparser.read("blacklist")
       
   207         blacklist = dict()
       
   208         for section in options.blacklist:
       
   209             for (item, value) in configparser.items(section):
       
   210                 blacklist["test-" + item] = section
       
   211         options.blacklist = blacklist
   200 
   212 
   201     return (options, args)
   213     return (options, args)
   202 
   214 
   203 def rename(src, dst):
   215 def rename(src, dst):
   204     """Like os.rename(), trade atomicity and opened files friendliness
   216     """Like os.rename(), trade atomicity and opened files friendliness
   728 
   740 
   729         skips = []
   741         skips = []
   730         fails = []
   742         fails = []
   731 
   743 
   732         for test in tests:
   744         for test in tests:
       
   745             if options.blacklist:
       
   746                 section = options.blacklist.get(test)
       
   747                 if section is not None:
       
   748                     skips.append((test, "blacklisted (%s section)" % section))
       
   749                     skipped += 1
       
   750                     continue
       
   751 
   733             if options.retest and not os.path.exists(test + ".err"):
   752             if options.retest and not os.path.exists(test + ".err"):
   734                 skipped += 1
   753                 skipped += 1
   735                 continue
   754                 continue
   736 
   755 
   737             if options.keywords:
   756             if options.keywords: