comparison tests/run-tests.py @ 21382:4b8ffe3abdd2

run-tests: move createhgrc into Test
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 10:24:00 -0700
parents 9aa5784992d4
children 772ed56e2519
comparison
equal deleted inserted replaced
21381:9aa5784992d4 21382:4b8ffe3abdd2
310 print m, 310 print m,
311 print 311 print
312 sys.stdout.flush() 312 sys.stdout.flush()
313 iolock.release() 313 iolock.release()
314 314
315 def createhgrc(path, options):
316 # create a fresh hgrc
317 hgrc = open(path, 'w')
318 hgrc.write('[ui]\n')
319 hgrc.write('slash = True\n')
320 hgrc.write('interactive = False\n')
321 hgrc.write('[defaults]\n')
322 hgrc.write('backout = -d "0 0"\n')
323 hgrc.write('commit = -d "0 0"\n')
324 hgrc.write('shelve = --date "0 0"\n')
325 hgrc.write('tag = -d "0 0"\n')
326 if options.extra_config_opt:
327 for opt in options.extra_config_opt:
328 section, key = opt.split('.', 1)
329 assert '=' in key, ('extra config opt %s must '
330 'have an = for assignment' % opt)
331 hgrc.write('[%s]\n%s\n' % (section, key))
332 hgrc.close()
333
334 def terminate(proc): 315 def terminate(proc):
335 """Terminate subprocess (with fallback for Python versions < 2.6)""" 316 """Terminate subprocess (with fallback for Python versions < 2.6)"""
336 vlog('# Terminating process %d' % proc.pid) 317 vlog('# Terminating process %d' % proc.pid)
337 try: 318 try:
338 getattr(proc, 'terminate', lambda : os.kill(proc.pid, signal.SIGTERM))() 319 getattr(proc, 'terminate', lambda : os.kill(proc.pid, signal.SIGTERM))()
420 testtmp = os.path.join(self._threadtmp, os.path.basename(self._path)) 401 testtmp = os.path.join(self._threadtmp, os.path.basename(self._path))
421 os.mkdir(testtmp) 402 os.mkdir(testtmp)
422 replacements, port = self._getreplacements(testtmp) 403 replacements, port = self._getreplacements(testtmp)
423 env = self._getenv(testtmp, port) 404 env = self._getenv(testtmp, port)
424 self._daemonpids.append(env['DAEMON_PIDS']) 405 self._daemonpids.append(env['DAEMON_PIDS'])
425 createhgrc(env['HGRCPATH'], options) 406 self._createhgrc(env['HGRCPATH'])
426 407
427 vlog('# Test', self._test) 408 vlog('# Test', self._test)
428 409
429 starttime = time.time() 410 starttime = time.time()
430 try: 411 try:
565 for k in env.keys(): 546 for k in env.keys():
566 if k.startswith('HG_'): 547 if k.startswith('HG_'):
567 del env[k] 548 del env[k]
568 549
569 return env 550 return env
551
552 def _createhgrc(self, path):
553 # create a fresh hgrc
554 hgrc = open(path, 'w')
555 hgrc.write('[ui]\n')
556 hgrc.write('slash = True\n')
557 hgrc.write('interactive = False\n')
558 hgrc.write('[defaults]\n')
559 hgrc.write('backout = -d "0 0"\n')
560 hgrc.write('commit = -d "0 0"\n')
561 hgrc.write('shelve = --date "0 0"\n')
562 hgrc.write('tag = -d "0 0"\n')
563 if self._options.extra_config_opt:
564 for opt in self._options.extra_config_opt:
565 section, key = opt.split('.', 1)
566 assert '=' in key, ('extra config opt %s must '
567 'have an = for assignment' % opt)
568 hgrc.write('[%s]\n%s\n' % (section, key))
569 hgrc.close()
570 570
571 def success(self): 571 def success(self):
572 return '.', self._test, '' 572 return '.', self._test, ''
573 573
574 def fail(self, msg, ret): 574 def fail(self, msg, ret):