tests/run-tests.py
changeset 1306 c8f3a433abe6
parent 1305 d8b739c3d37a
child 1307 164ed9bf157c
equal deleted inserted replaced
1302:f103c0693fbb 1306:c8f3a433abe6
   101 if 'java' in sys.platform:
   101 if 'java' in sys.platform:
   102     IMPL_PATH = 'JYTHONPATH'
   102     IMPL_PATH = 'JYTHONPATH'
   103 
   103 
   104 requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip",
   104 requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip",
   105                  "gunzip", "bunzip2", "sed"]
   105                  "gunzip", "bunzip2", "sed"]
       
   106 createdfiles = []
   106 
   107 
   107 defaults = {
   108 defaults = {
   108     'jobs': ('HGTEST_JOBS', 1),
   109     'jobs': ('HGTEST_JOBS', 1),
   109     'timeout': ('HGTEST_TIMEOUT', 180),
   110     'timeout': ('HGTEST_TIMEOUT', 180),
   110     'port': ('HGTEST_PORT', 20059),
   111     'port': ('HGTEST_PORT', 20059),
   418 
   419 
   419 def cleanup(options):
   420 def cleanup(options):
   420     if not options.keep_tmpdir:
   421     if not options.keep_tmpdir:
   421         vlog("# Cleaning up HGTMP", HGTMP)
   422         vlog("# Cleaning up HGTMP", HGTMP)
   422         shutil.rmtree(HGTMP, True)
   423         shutil.rmtree(HGTMP, True)
       
   424         for f in createdfiles:
       
   425             try:
       
   426                 os.remove(f)
       
   427             except OSError:
       
   428                 pass
   423 
   429 
   424 def usecorrectpython():
   430 def usecorrectpython():
   425     # some tests run python interpreter. they must use same
   431     # some tests run python interpreter. they must use same
   426     # interpreter we use or bad things will happen.
   432     # interpreter we use or bad things will happen.
   427     pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
   433     pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
   437             if err.errno != errno.ENOENT:
   443             if err.errno != errno.ENOENT:
   438                 raise
   444                 raise
   439         if findprogram(pyexename) != sys.executable:
   445         if findprogram(pyexename) != sys.executable:
   440             try:
   446             try:
   441                 os.symlink(sys.executable, mypython)
   447                 os.symlink(sys.executable, mypython)
       
   448                 createdfiles.append(mypython)
   442             except OSError, err:
   449             except OSError, err:
   443                 # child processes may race, which is harmless
   450                 # child processes may race, which is harmless
   444                 if err.errno != errno.EEXIST:
   451                 if err.errno != errno.EEXIST:
   445                     raise
   452                     raise
   446     else:
   453     else:
   495         f.close()
   502         f.close()
   496         sys.exit(1)
   503         sys.exit(1)
   497     os.chdir(TESTDIR)
   504     os.chdir(TESTDIR)
   498 
   505 
   499     usecorrectpython()
   506     usecorrectpython()
   500 
       
   501     vlog("# Installing dummy diffstat")
       
   502     f = open(os.path.join(BINDIR, 'diffstat'), 'w')
       
   503     f.write('#!' + sys.executable + '\n'
       
   504             'import sys\n'
       
   505             'files = 0\n'
       
   506             'for line in sys.stdin:\n'
       
   507             '    if line.startswith("diff "):\n'
       
   508             '        files += 1\n'
       
   509             'sys.stdout.write("files patched: %d\\n" % files)\n')
       
   510     f.close()
       
   511     os.chmod(os.path.join(BINDIR, 'diffstat'), 0700)
       
   512 
   507 
   513     if options.py3k_warnings and not options.anycoverage:
   508     if options.py3k_warnings and not options.anycoverage:
   514         vlog("# Updating hg command to enable Py3k Warnings switch")
   509         vlog("# Updating hg command to enable Py3k Warnings switch")
   515         f = open(os.path.join(BINDIR, 'hg'), 'r')
   510         f = open(os.path.join(BINDIR, 'hg'), 'r')
   516         lines = [line.rstrip() for line in f]
   511         lines = [line.rstrip() for line in f]