tests/run-tests.py
changeset 1167 ca46d3dccb19
parent 1166 d38c648869bb
child 1168 96a0960a7909
equal deleted inserted replaced
1162:0928d50a0abe 1167:ca46d3dccb19
   161     parser.add_option("-n", "--nodiff", action="store_true",
   161     parser.add_option("-n", "--nodiff", action="store_true",
   162         help="skip showing test changes")
   162         help="skip showing test changes")
   163     parser.add_option("-p", "--port", type="int",
   163     parser.add_option("-p", "--port", type="int",
   164         help="port on which servers should listen"
   164         help="port on which servers should listen"
   165              " (default: $%s or %d)" % defaults['port'])
   165              " (default: $%s or %d)" % defaults['port'])
       
   166     parser.add_option("--compiler", type="string",
       
   167         help="compiler to build with")
   166     parser.add_option("--pure", action="store_true",
   168     parser.add_option("--pure", action="store_true",
   167         help="use pure Python code instead of C extensions")
   169         help="use pure Python code instead of C extensions")
   168     parser.add_option("-R", "--restart", action="store_true",
   170     parser.add_option("-R", "--restart", action="store_true",
   169         help="restart at last error")
   171         help="restart at last error")
   170     parser.add_option("-r", "--retest", action="store_true",
   172     parser.add_option("-r", "--retest", action="store_true",
   369         shutil.copymode(sys.executable, mypython)
   371         shutil.copymode(sys.executable, mypython)
   370 
   372 
   371 def installhg(options):
   373 def installhg(options):
   372     vlog("# Performing temporary installation of HG")
   374     vlog("# Performing temporary installation of HG")
   373     installerrs = os.path.join("tests", "install.err")
   375     installerrs = os.path.join("tests", "install.err")
       
   376     compiler = ''
       
   377     if options.compiler:
       
   378         compiler = '--compiler ' + options.compiler
   374     pure = options.pure and "--pure" or ""
   379     pure = options.pure and "--pure" or ""
   375 
   380 
   376     # Run installer in hg root
   381     # Run installer in hg root
   377     script = os.path.realpath(sys.argv[0])
   382     script = os.path.realpath(sys.argv[0])
   378     hgroot = os.path.dirname(os.path.dirname(script))
   383     hgroot = os.path.dirname(os.path.dirname(script))
   382         # The --home="" trick works only on OS where os.sep == '/'
   387         # The --home="" trick works only on OS where os.sep == '/'
   383         # because of a distutils convert_path() fast-path. Avoid it at
   388         # because of a distutils convert_path() fast-path. Avoid it at
   384         # least on Windows for now, deal with .pydistutils.cfg bugs
   389         # least on Windows for now, deal with .pydistutils.cfg bugs
   385         # when they happen.
   390         # when they happen.
   386         nohome = ''
   391         nohome = ''
   387     cmd = ('%s setup.py %s clean --all'
   392     cmd = ('%(exe)s setup.py %(pure)s clean --all'
   388            ' build --build-base="%s"'
   393            ' build %(compiler)s --build-base="%(base)s"'
   389            ' install --force --prefix="%s" --install-lib="%s"'
   394            ' install --force --prefix="%(prefix)s" --install-lib="%(libdir)s"'
   390            ' --install-scripts="%s" %s >%s 2>&1'
   395            ' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1'
   391            % (sys.executable, pure, os.path.join(HGTMP, "build"),
   396            % dict(exe=sys.executable, pure=pure, compiler=compiler,
   392               INST, PYTHONDIR, BINDIR, nohome, installerrs))
   397                   base=os.path.join(HGTMP, "build"),
       
   398                   prefix=INST, libdir=PYTHONDIR, bindir=BINDIR,
       
   399                   nohome=nohome, logfile=installerrs))
   393     vlog("# Running", cmd)
   400     vlog("# Running", cmd)
   394     if os.system(cmd) == 0:
   401     if os.system(cmd) == 0:
   395         if not options.verbose:
   402         if not options.verbose:
   396             os.remove(installerrs)
   403             os.remove(installerrs)
   397     else:
   404     else:
   766     '''tristate output:
   773     '''tristate output:
   767     None -> skipped
   774     None -> skipped
   768     True -> passed
   775     True -> passed
   769     False -> failed'''
   776     False -> failed'''
   770 
   777 
   771     global results, iolock
   778     global results, resultslock, iolock
   772 
   779 
   773     testpath = os.path.join(TESTDIR, test)
   780     testpath = os.path.join(TESTDIR, test)
       
   781 
       
   782     def result(l, e):
       
   783         resultslock.acquire()
       
   784         results[l].append(e)
       
   785         resultslock.release()
   774 
   786 
   775     def skip(msg):
   787     def skip(msg):
   776         if not options.verbose:
   788         if not options.verbose:
   777             results['s'].append((test, msg))
   789             result('s', (test, msg))
   778         else:
   790         else:
   779             iolock.acquire()
   791             iolock.acquire()
   780             print "\nSkipping %s: %s" % (testpath, msg)
   792             print "\nSkipping %s: %s" % (testpath, msg)
   781             iolock.release()
   793             iolock.release()
   782         return None
   794         return None
   795             if answer.lower() in "y yes".split():
   807             if answer.lower() in "y yes".split():
   796                 if test.endswith(".t"):
   808                 if test.endswith(".t"):
   797                     rename(testpath + ".err", testpath)
   809                     rename(testpath + ".err", testpath)
   798                 else:
   810                 else:
   799                     rename(testpath + ".err", testpath + ".out")
   811                     rename(testpath + ".err", testpath + ".out")
   800                 success(test)
   812                 result('p', test)
   801                 return
   813                 return
   802         results['f'].append((test, msg))
   814         result('f', (test, msg))
   803 
   815 
   804     def success():
   816     def success():
   805         results['p'].append(test)
   817         result('p', test)
   806 
   818 
   807     def ignore(msg):
   819     def ignore(msg):
   808         results['i'].append((test, msg))
   820         result('i', (test, msg))
   809 
   821 
   810     if (os.path.basename(test).startswith("test-") and '~' not in test and
   822     if (os.path.basename(test).startswith("test-") and '~' not in test and
   811         ('.' not in test or test.endswith('.py') or
   823         ('.' not in test or test.endswith('.py') or
   812          test.endswith('.bat') or test.endswith('.t'))):
   824          test.endswith('.bat') or test.endswith('.t'))):
   813         if not os.path.exists(test):
   825         if not os.path.exists(test):
  1116     if options.anycoverage:
  1128     if options.anycoverage:
  1117         outputcoverage(options)
  1129         outputcoverage(options)
  1118     sys.exit(failures != 0)
  1130     sys.exit(failures != 0)
  1119 
  1131 
  1120 results = dict(p=[], f=[], s=[], i=[])
  1132 results = dict(p=[], f=[], s=[], i=[])
       
  1133 resultslock = threading.Lock()
  1121 times = []
  1134 times = []
  1122 iolock = threading.Lock()
  1135 iolock = threading.Lock()
  1123 
  1136 
  1124 def runqueue(options, tests):
  1137 def runqueue(options, tests):
  1125     for test in tests:
  1138     for test in tests: