hghave: handle the case where the `black` executable is not on PATH
For some reason, I can't reproduce this on either of my laptops, even when
`black` isn't on `PATH`. But it was happening on the Windows CI system (where
`black` isn't installed at all), and this was the exception raised.
--- a/tests/hghave.py Tue Dec 17 22:54:36 2024 -0500
+++ b/tests/hghave.py Fri Dec 27 19:58:57 2024 -0500
@@ -1142,12 +1142,16 @@
if 'RUNTESTDIR' in env:
cwd = os.path.realpath(f"{env['RUNTESTDIR']}/..")
- p = subprocess.Popen(
- ['black', '--check', '-'],
- stdin=subprocess.PIPE,
- cwd=cwd,
- env=env,
- )
+ try:
+ p = subprocess.Popen(
+ ['black', '--check', '-'],
+ stdin=subprocess.PIPE,
+ cwd=cwd,
+ env=env,
+ )
+ except FileNotFoundError:
+ return False
+
p.communicate(b'# test\n')
return p.returncode == 0