Mercurial > hg
view tests/test-config-env.py @ 35450:e31773898197
run-tests: use context managers for file descriptors
I've seen the following error a few times recently when running the tests with
`yes | ./run-tests.py --local -j9 -i`:
Errored test-add.t: Traceback (most recent call last):
File "./run-tests.py", line 821, in run
self.runTest()
File "./run-tests.py", line 910, in runTest
if self._result.addOutputMismatch(self, ret, out, self._refout):
File "./run-tests.py", line 1774, in addOutputMismatch
rename(test.errpath, test.path)
File "./run-tests.py", line 571, in rename
os.remove(src)
WindowsError: [Error 32] The process cannot access the file because it is being
used by another process: 'c:\\Users\\Matt\\projects\\hg\\tests\\test-add.t.err'
This change doesn't fix the problem, but it seems like a simple enough
improvement.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 17 Dec 2017 14:06:49 -0500 |
parents | 08fbc97d1364 |
children | a22915edc279 |
line wrap: on
line source
# Test the config layer generated by environment variables from __future__ import absolute_import, print_function import os from mercurial import ( encoding, rcutil, ui as uimod, util, ) testtmp = encoding.environ['TESTTMP'] # prepare hgrc files def join(name): return os.path.join(testtmp, name) with open(join('sysrc'), 'w') as f: f.write('[ui]\neditor=e0\n[pager]\npager=p0\n') with open(join('userrc'), 'w') as f: f.write('[ui]\neditor=e1') # replace rcpath functions so they point to the files above def systemrcpath(): return [join('sysrc')] def userrcpath(): return [join('userrc')] rcutil.systemrcpath = systemrcpath rcutil.userrcpath = userrcpath os.path.isdir = lambda x: False # hack: do not load default.d/*.rc # utility to print configs def printconfigs(env): encoding.environ = env rcutil._rccomponents = None # reset cache ui = uimod.ui.load() for section, name, value in ui.walkconfig(): source = ui.configsource(section, name) print('%s.%s=%s # %s' % (section, name, value, util.pconvert(source))) print('') # environment variable overrides printconfigs({}) printconfigs({'EDITOR': 'e2', 'PAGER': 'p2'})