--- a/tests/fsmonitor-run-tests.py Sat Oct 05 10:29:34 2019 -0400
+++ b/tests/fsmonitor-run-tests.py Sun Oct 06 09:45:02 2019 -0400
@@ -28,14 +28,18 @@
if sys.version_info > (3, 5, 0):
PYTHON3 = True
- xrange = range # we use xrange in one place, and we'd rather not use range
+ xrange = range # we use xrange in one place, and we'd rather not use range
+
def _bytespath(p):
return p.encode('utf-8')
+
elif sys.version_info >= (3, 0, 0):
- print('%s is only supported on Python 3.5+ and 2.7, not %s' %
- (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3])))
- sys.exit(70) # EX_SOFTWARE from `man 3 sysexit`
+ print(
+ '%s is only supported on Python 3.5+ and 2.7, not %s'
+ % (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))
+ )
+ sys.exit(70) # EX_SOFTWARE from `man 3 sysexit`
else:
PYTHON3 = False
@@ -46,21 +50,29 @@
def _bytespath(p):
return p
+
def getparser():
"""Obtain the argument parser used by the CLI."""
parser = argparse.ArgumentParser(
description='Run tests with fsmonitor enabled.',
- epilog='Unrecognized options are passed to run-tests.py.')
+ epilog='Unrecognized options are passed to run-tests.py.',
+ )
# - keep these sorted
# - none of these options should conflict with any in run-tests.py
- parser.add_argument('--keep-fsmonitor-tmpdir', action='store_true',
- help='keep temporary directory with fsmonitor state')
- parser.add_argument('--watchman',
+ parser.add_argument(
+ '--keep-fsmonitor-tmpdir',
+ action='store_true',
+ help='keep temporary directory with fsmonitor state',
+ )
+ parser.add_argument(
+ '--watchman',
help='location of watchman binary (default: watchman in PATH)',
- default='watchman')
+ default='watchman',
+ )
return parser
+
@contextlib.contextmanager
def watchman(args):
basedir = tempfile.mkdtemp(prefix='hg-fsmonitor')
@@ -82,19 +94,24 @@
argv = [
args.watchman,
- '--sockname', sockfile,
- '--logfile', logfile,
- '--pidfile', pidfile,
- '--statefile', statefile,
+ '--sockname',
+ sockfile,
+ '--logfile',
+ logfile,
+ '--pidfile',
+ pidfile,
+ '--statefile',
+ statefile,
'--foreground',
- '--log-level=2', # debug logging for watchman
+ '--log-level=2', # debug logging for watchman
]
envb = osenvironb.copy()
envb[b'WATCHMAN_CONFIG_FILE'] = _bytespath(cfgfile)
with open(clilogfile, 'wb') as f:
proc = subprocess.Popen(
- argv, env=envb, stdin=None, stdout=f, stderr=f)
+ argv, env=envb, stdin=None, stdout=f, stderr=f
+ )
try:
yield sockfile
finally:
@@ -106,6 +123,7 @@
else:
shutil.rmtree(basedir, ignore_errors=True)
+
def run():
parser = getparser()
args, runtestsargv = parser.parse_known_args()
@@ -120,20 +138,23 @@
blacklist = os.path.join(runtestdir, 'blacklists', 'fsmonitor')
runtestsargv.insert(0, runtests)
- runtestsargv.extend([
- '--extra-config',
- 'extensions.fsmonitor=',
- # specify fsmonitor.mode=paranoid always in order to force
- # fsmonitor extension execute "paranoid" code path
- #
- # TODO: make fsmonitor-run-tests.py accept specific options
- '--extra-config',
- 'fsmonitor.mode=paranoid',
- '--blacklist',
- blacklist,
- ])
+ runtestsargv.extend(
+ [
+ '--extra-config',
+ 'extensions.fsmonitor=',
+ # specify fsmonitor.mode=paranoid always in order to force
+ # fsmonitor extension execute "paranoid" code path
+ #
+ # TODO: make fsmonitor-run-tests.py accept specific options
+ '--extra-config',
+ 'fsmonitor.mode=paranoid',
+ '--blacklist',
+ blacklist,
+ ]
+ )
return subprocess.call(runtestsargv)
+
if __name__ == '__main__':
sys.exit(run())