tests/run-tests.py
changeset 933 eb234d5d695c
parent 932 eb562ea207c3
child 934 cf241f12e977
equal deleted inserted replaced
927:95e99c4d10d3 933:eb234d5d695c
   102 
   102 
   103 defaults = {
   103 defaults = {
   104     'jobs': ('HGTEST_JOBS', 1),
   104     'jobs': ('HGTEST_JOBS', 1),
   105     'timeout': ('HGTEST_TIMEOUT', 180),
   105     'timeout': ('HGTEST_TIMEOUT', 180),
   106     'port': ('HGTEST_PORT', 20059),
   106     'port': ('HGTEST_PORT', 20059),
       
   107     'shell': ('HGTEST_SHELL', '/bin/sh'),
   107 }
   108 }
   108 
   109 
   109 def parseargs():
   110 def parseargs():
   110     parser = optparse.OptionParser("%prog [options] [tests]")
   111     parser = optparse.OptionParser("%prog [options] [tests]")
   111 
   112 
   147         help="restart at last error")
   148         help="restart at last error")
   148     parser.add_option("-r", "--retest", action="store_true",
   149     parser.add_option("-r", "--retest", action="store_true",
   149         help="retest failed tests")
   150         help="retest failed tests")
   150     parser.add_option("-S", "--noskips", action="store_true",
   151     parser.add_option("-S", "--noskips", action="store_true",
   151         help="don't report skip tests verbosely")
   152         help="don't report skip tests verbosely")
       
   153     parser.add_option("--shell", type="string",
       
   154         help="shell to use (default: $%s or %s)" % defaults['shell'])
   152     parser.add_option("-t", "--timeout", type="int",
   155     parser.add_option("-t", "--timeout", type="int",
   153         help="kill errant tests after TIMEOUT seconds"
   156         help="kill errant tests after TIMEOUT seconds"
   154              " (default: $%s or %d)" % defaults['timeout'])
   157              " (default: $%s or %d)" % defaults['timeout'])
   155     parser.add_option("--tmpdir", type="string",
   158     parser.add_option("--tmpdir", type="string",
   156         help="run tests in the given temporary directory"
   159         help="run tests in the given temporary directory"
   166     parser.add_option("-3", "--py3k-warnings", action="store_true",
   169     parser.add_option("-3", "--py3k-warnings", action="store_true",
   167         help="enable Py3k warnings on Python 2.6+")
   170         help="enable Py3k warnings on Python 2.6+")
   168     parser.add_option('--extra-config-opt', action="append",
   171     parser.add_option('--extra-config-opt', action="append",
   169                       help='set the given config opt in the test hgrc')
   172                       help='set the given config opt in the test hgrc')
   170 
   173 
   171     for option, default in defaults.items():
   174     for option, (envvar, default) in defaults.items():
   172         defaults[option] = int(os.environ.get(*default))
   175         defaults[option] = type(default)(os.environ.get(envvar, default))
   173     parser.set_defaults(**defaults)
   176     parser.set_defaults(**defaults)
   174     (options, args) = parser.parse_args()
   177     (options, args) = parser.parse_args()
   175 
   178 
   176     # jython is always pure
   179     # jython is always pure
   177     if 'java' in sys.platform or '__pypy__' in sys.modules:
   180     if 'java' in sys.platform or '__pypy__' in sys.modules:
   178         options.pure = True
   181         options.pure = True
       
   182 
       
   183     if not (os.path.isfile(options.shell) and
       
   184             os.access(options.shell, os.X_OK)):
       
   185         parser.error('--shell must be executable')
   179 
   186 
   180     if options.with_hg:
   187     if options.with_hg:
   181         if not (os.path.isfile(options.with_hg) and
   188         if not (os.path.isfile(options.with_hg) and
   182                 os.access(options.with_hg, os.X_OK)):
   189                 os.access(options.with_hg, os.X_OK)):
   183             parser.error('--with-hg must specify an executable hg script')
   190             parser.error('--with-hg must specify an executable hg script')
   525     try:
   532     try:
   526         for l in script:
   533         for l in script:
   527             os.write(fd, l)
   534             os.write(fd, l)
   528         os.close(fd)
   535         os.close(fd)
   529 
   536 
   530         cmd = '/bin/sh "%s"' % name
   537         cmd = '"%s" "%s"' % (options.shell, name)
   531         vlog("# Running", cmd)
   538         vlog("# Running", cmd)
   532         exitcode, output = run(cmd, wd, options, replacements)
   539         exitcode, output = run(cmd, wd, options, replacements)
   533         # do not merge output if skipped, return hghave message instead
   540         # do not merge output if skipped, return hghave message instead
   534         # similarly, with --debug, output is None
   541         # similarly, with --debug, output is None
   535         if exitcode == SKIPPED_STATUS or output is None:
   542         if exitcode == SKIPPED_STATUS or output is None:
   915     opts = []
   922     opts = []
   916     for opt, value in optcopy.iteritems():
   923     for opt, value in optcopy.iteritems():
   917         name = '--' + opt.replace('_', '-')
   924         name = '--' + opt.replace('_', '-')
   918         if value is True:
   925         if value is True:
   919             opts.append(name)
   926             opts.append(name)
       
   927         elif isinstance(value, list):
       
   928             for v in value:
       
   929                 opts.append(name + '=' + str(v))
   920         elif value is not None:
   930         elif value is not None:
   921             opts.append(name + '=' + str(value))
   931             opts.append(name + '=' + str(value))
   922 
   932 
   923     tests.reverse()
   933     tests.reverse()
   924     jobs = [[] for j in xrange(options.jobs)]
   934     jobs = [[] for j in xrange(options.jobs)]