tests/run-tests.py
branchstable
changeset 1253 79e201b6826a
parent 1252 e9ad07011f87
child 1254 1642fcc7e2a1
equal deleted inserted replaced
1252:e9ad07011f87 1253:79e201b6826a
   360             assert '=' in key, ('extra config opt %s must '
   360             assert '=' in key, ('extra config opt %s must '
   361                                 'have an = for assignment' % opt)
   361                                 'have an = for assignment' % opt)
   362             hgrc.write('[%s]\n%s\n' % (section, key))
   362             hgrc.write('[%s]\n%s\n' % (section, key))
   363     hgrc.close()
   363     hgrc.close()
   364 
   364 
   365 def createenv(options, testtmp, threadtmp):
   365 def createenv(options, testtmp, threadtmp, port):
   366     env = os.environ.copy()
   366     env = os.environ.copy()
   367     env['TESTTMP'] = testtmp
   367     env['TESTTMP'] = testtmp
   368     env['HOME'] = testtmp
   368     env['HOME'] = testtmp
   369     env["HGPORT"] = str(options.port)
   369     env["HGPORT"] = str(port)
   370     env["HGPORT1"] = str(options.port + 1)
   370     env["HGPORT1"] = str(port + 1)
   371     env["HGPORT2"] = str(options.port + 2)
   371     env["HGPORT2"] = str(port + 2)
   372     env["HGRCPATH"] = os.path.join(threadtmp, '.hgrc')
   372     env["HGRCPATH"] = os.path.join(threadtmp, '.hgrc')
   373     env["DAEMON_PIDS"] = os.path.join(threadtmp, 'daemon.pids')
   373     env["DAEMON_PIDS"] = os.path.join(threadtmp, 'daemon.pids')
   374     env["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
   374     env["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
   375     env["HGMERGE"] = "internal:merge"
   375     env["HGMERGE"] = "internal:merge"
   376     env["HGUSER"]   = "test"
   376     env["HGUSER"]   = "test"
   949     threadtmp = os.path.join(HGTMP, "child%d" % count)
   949     threadtmp = os.path.join(HGTMP, "child%d" % count)
   950     testtmp = os.path.join(threadtmp, os.path.basename(test))
   950     testtmp = os.path.join(threadtmp, os.path.basename(test))
   951     os.mkdir(threadtmp)
   951     os.mkdir(threadtmp)
   952     os.mkdir(testtmp)
   952     os.mkdir(testtmp)
   953 
   953 
       
   954     port = options.port + count * 3
   954     replacements = [
   955     replacements = [
   955         (r':%s\b' % options.port, ':$HGPORT'),
   956         (r':%s\b' % port, ':$HGPORT'),
   956         (r':%s\b' % (options.port + 1), ':$HGPORT1'),
   957         (r':%s\b' % (port + 1), ':$HGPORT1'),
   957         (r':%s\b' % (options.port + 2), ':$HGPORT2'),
   958         (r':%s\b' % (port + 2), ':$HGPORT2'),
   958         ]
   959         ]
   959     if os.name == 'nt':
   960     if os.name == 'nt':
   960         replacements.append(
   961         replacements.append(
   961             (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
   962             (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
   962                      c in '/\\' and r'[/\\]' or
   963                      c in '/\\' and r'[/\\]' or
   964                      '\\' + c
   965                      '\\' + c
   965                      for c in testtmp), '$TESTTMP'))
   966                      for c in testtmp), '$TESTTMP'))
   966     else:
   967     else:
   967         replacements.append((re.escape(testtmp), '$TESTTMP'))
   968         replacements.append((re.escape(testtmp), '$TESTTMP'))
   968 
   969 
   969     env = createenv(options, testtmp, threadtmp)
   970     env = createenv(options, testtmp, threadtmp, port)
   970     createhgrc(env['HGRCPATH'], options)
   971     createhgrc(env['HGRCPATH'], options)
   971 
   972 
   972     if options.time:
   973     if options.time:
   973         starttime = time.time()
   974         starttime = time.time()
   974     ret, out = runner(testpath, testtmp, options, replacements, env)
   975     ret, out = runner(testpath, testtmp, options, replacements, env)