tests/run-tests.py
branchstable
changeset 1158 2776fd39ac72
parent 1157 06d4b5a1c4e8
child 1159 b2bd669641d3
equal deleted inserted replaced
1157:06d4b5a1c4e8 1158:2776fd39ac72
   752     '''tristate output:
   752     '''tristate output:
   753     None -> skipped
   753     None -> skipped
   754     True -> passed
   754     True -> passed
   755     False -> failed'''
   755     False -> failed'''
   756 
   756 
   757     global results, resultslock, iolock
   757     global results, iolock
   758 
   758 
   759     testpath = os.path.join(TESTDIR, test)
   759     testpath = os.path.join(TESTDIR, test)
   760 
       
   761     def result(l, e):
       
   762         resultslock.acquire()
       
   763         results[l].append(e)
       
   764         resultslock.release()
       
   765 
   760 
   766     def skip(msg):
   761     def skip(msg):
   767         if not options.verbose:
   762         if not options.verbose:
   768             result('s', (test, msg))
   763             results['s'].append((test, msg))
   769         else:
   764         else:
   770             iolock.acquire()
   765             iolock.acquire()
   771             print "\nSkipping %s: %s" % (testpath, msg)
   766             print "\nSkipping %s: %s" % (testpath, msg)
   772             iolock.release()
   767             iolock.release()
   773         return None
   768         return None
   786             if answer.lower() in "y yes".split():
   781             if answer.lower() in "y yes".split():
   787                 if test.endswith(".t"):
   782                 if test.endswith(".t"):
   788                     rename(testpath + ".err", testpath)
   783                     rename(testpath + ".err", testpath)
   789                 else:
   784                 else:
   790                     rename(testpath + ".err", testpath + ".out")
   785                     rename(testpath + ".err", testpath + ".out")
   791                 result('p', test)
   786                 success(test)
   792                 return
   787                 return
   793         result('f', (test, msg))
   788         results['f'].append((test, msg))
   794 
   789 
   795     def success():
   790     def success():
   796         result('p', test)
   791         results['p'].append(test)
   797 
   792 
   798     def ignore(msg):
   793     def ignore(msg):
   799         result('i', (test, msg))
   794         results['i'].append((test, msg))
   800 
   795 
   801     if (os.path.basename(test).startswith("test-") and '~' not in test and
   796     if (os.path.basename(test).startswith("test-") and '~' not in test and
   802         ('.' not in test or test.endswith('.py') or
   797         ('.' not in test or test.endswith('.py') or
   803          test.endswith('.bat') or test.endswith('.t'))):
   798          test.endswith('.bat') or test.endswith('.t'))):
   804         if not os.path.exists(test):
   799         if not os.path.exists(test):
  1097     if options.anycoverage:
  1092     if options.anycoverage:
  1098         outputcoverage(options)
  1093         outputcoverage(options)
  1099     sys.exit(failures != 0)
  1094     sys.exit(failures != 0)
  1100 
  1095 
  1101 results = dict(p=[], f=[], s=[], i=[])
  1096 results = dict(p=[], f=[], s=[], i=[])
  1102 resultslock = threading.Lock()
       
  1103 iolock = threading.Lock()
  1097 iolock = threading.Lock()
  1104 
  1098 
  1105 def runqueue(options, tests, results):
  1099 def runqueue(options, tests, results):
  1106     for test in tests:
  1100     for test in tests:
  1107         ret = runone(options, test)
  1101         ret = runone(options, test)