Merge bitcoin/bitcoin#26802: test: Use same Python executable for subprocesses as for all-lint.py

f6eadaa413 Use same Python executable for subprocesses as for all-lint.py (Kristaps Kaupe)

Pull request description:

  Before this all linters were ran by `/usr/bin/env python3`, no matter what was used to run `test/lint/all-lint.py`. This change allows to use non-default Python executable for `test/lint/all-lint.py` and then all subprocesses will also use same Python interpreter (for example, `python3.10 ./test/lint/all-lint.py`). See https://github.com/bitcoin/bitcoin/issues/26792#issuecomment-1369558866 as use case.

ACKs for top commit:
  fanquake:
    ACK f6eadaa413 - did not test

Tree-SHA512: 4da3b5581a0dd8ab9a6387829495019091a93a7ceaf2135d65d40a1983fd11a0b92b20891ef30d2a132abb0a690cd9b2f7eb5fcc38df06a340394ef449d640af
This commit is contained in:
MarcoFalke 2023-01-04 13:53:19 +01:00
commit 4bb840a453
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -10,11 +10,12 @@
from glob import glob
from pathlib import Path
from subprocess import run
from sys import executable
exit_code = 0
mod_path = Path(__file__).parent
for lint in glob(f"{mod_path}/lint-*.py"):
result = run([lint])
result = run([executable, lint])
if result.returncode != 0:
print(f"^---- failure generated from {lint.split('/')[-1]}")
exit_code |= result.returncode