tests/run-tests.py
branchstable
changeset 681 d0a410e49776
parent 680 f10a5301d082
child 682 1c7056415039
equal deleted inserted replaced
680:f10a5301d082 681:d0a410e49776
    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
       
    45 import difflib
    44 import difflib
    46 import errno
    45 import errno
    47 import optparse
    46 import optparse
    48 import os
    47 import os
    49 import subprocess
    48 import subprocess
   132     parser.add_option("-3", "--py3k-warnings", action="store_true",
   131     parser.add_option("-3", "--py3k-warnings", action="store_true",
   133         help="enable Py3k warnings on Python 2.6+")
   132         help="enable Py3k warnings on Python 2.6+")
   134     parser.add_option("--inotify", action="store_true",
   133     parser.add_option("--inotify", action="store_true",
   135         help="enable inotify extension when running tests")
   134         help="enable inotify extension when running tests")
   136     parser.add_option("--blacklist", action="append",
   135     parser.add_option("--blacklist", action="append",
   137         help="skip tests listed in the specified section of "
   136         help="skip tests listed in the specified blacklist file")
   138              "the blacklist file")
       
   139 
   137 
   140     for option, default in defaults.items():
   138     for option, default in defaults.items():
   141         defaults[option] = int(os.environ.get(*default))
   139         defaults[option] = int(os.environ.get(*default))
   142     parser.set_defaults(**defaults)
   140     parser.set_defaults(**defaults)
   143     (options, args) = parser.parse_args()
   141     (options, args) = parser.parse_args()
   200         options.timeout = 0
   198         options.timeout = 0
   201     if options.py3k_warnings:
   199     if options.py3k_warnings:
   202         if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
   200         if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
   203             parser.error('--py3k-warnings can only be used on Python 2.6+')
   201             parser.error('--py3k-warnings can only be used on Python 2.6+')
   204     if options.blacklist:
   202     if options.blacklist:
   205         configparser = ConfigParser()
       
   206         configparser.read("blacklist")
       
   207         blacklist = dict()
   203         blacklist = dict()
   208         for section in options.blacklist:
   204         for filename in options.blacklist:
   209             for (item, value) in configparser.items(section):
   205             try:
   210                 blacklist["test-" + item] = section
   206                 path = os.path.expanduser(os.path.expandvars(filename))
       
   207                 f = open(path, "r")
       
   208             except IOError, err:
       
   209                 if err.errno != errno.ENOENT:
       
   210                     raise
       
   211                 print "warning: no such blacklist file: %s" % filename
       
   212                 continue
       
   213 
       
   214             for line in f.readlines():
       
   215                 line = line.strip()
       
   216                 if line and not line.startswith('#'):
       
   217                     blacklist[line] = filename
       
   218 
   211         options.blacklist = blacklist
   219         options.blacklist = blacklist
   212 
   220 
   213     return (options, args)
   221     return (options, args)
   214 
   222 
   215 def rename(src, dst):
   223 def rename(src, dst):
   742         skips = []
   750         skips = []
   743         fails = []
   751         fails = []
   744 
   752 
   745         for test in tests:
   753         for test in tests:
   746             if options.blacklist:
   754             if options.blacklist:
   747                 section = options.blacklist.get(test)
   755                 filename = options.blacklist.get(test)
   748                 if section is not None:
   756                 if filename is not None:
   749                     skips.append((test, "blacklisted (%s section)" % section))
   757                     skips.append((test, "blacklisted (%s)" % filename))
   750                     skipped += 1
   758                     skipped += 1
   751                     continue
   759                     continue
   752 
   760 
   753             if options.retest and not os.path.exists(test + ".err"):
   761             if options.retest and not os.path.exists(test + ".err"):
   754                 skipped += 1
   762                 skipped += 1