tests/run-tests.py
changeset 49244 cd51d4957b28
parent 49217 13dfad0f9f7a
parent 49234 9dad328434c7
child 49285 56f98406831b
equal deleted inserted replaced
49239:a94f28be2e6e 49244:cd51d4957b28
   967     import killdaemons as killmod
   967     import killdaemons as killmod
   968 
   968 
   969     return killmod.killdaemons(pidfile, tryhard=False, remove=True, logfn=vlog)
   969     return killmod.killdaemons(pidfile, tryhard=False, remove=True, logfn=vlog)
   970 
   970 
   971 
   971 
       
   972 # sysconfig is not thread-safe (https://github.com/python/cpython/issues/92452)
       
   973 sysconfiglock = threading.Lock()
       
   974 
       
   975 
   972 class Test(unittest.TestCase):
   976 class Test(unittest.TestCase):
   973     """Encapsulates a single, runnable test.
   977     """Encapsulates a single, runnable test.
   974 
   978 
   975     While this class conforms to the unittest.TestCase API, it differs in that
   979     While this class conforms to the unittest.TestCase API, it differs in that
   976     instances need to be instantiated manually. (Typically, unittest.TestCase
   980     instances need to be instantiated manually. (Typically, unittest.TestCase
  1397         def defineport(i):
  1401         def defineport(i):
  1398             offset = '' if i == 0 else '%s' % i
  1402             offset = '' if i == 0 else '%s' % i
  1399             env["HGPORT%s" % offset] = '%s' % (self._startport + i)
  1403             env["HGPORT%s" % offset] = '%s' % (self._startport + i)
  1400 
  1404 
  1401         env = os.environ.copy()
  1405         env = os.environ.copy()
  1402         env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
  1406         with sysconfiglock:
       
  1407             env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
  1403         env['HGEMITWARNINGS'] = '1'
  1408         env['HGEMITWARNINGS'] = '1'
  1404         env['TESTTMP'] = _bytes2sys(self._testtmp)
  1409         env['TESTTMP'] = _bytes2sys(self._testtmp)
  1405         # the FORWARD_SLASH version is useful when running `sh` on non unix
  1410         # the FORWARD_SLASH version is useful when running `sh` on non unix
  1406         # system (e.g. Windows)
  1411         # system (e.g. Windows)
  1407         env['TESTTMP_FORWARD_SLASH'] = env['TESTTMP'].replace(os.sep, '/')
  1412         env['TESTTMP_FORWARD_SLASH'] = env['TESTTMP'].replace(os.sep, '/')