(This is highlighting a what-if, which might make it clear why any special infrastructure is still required at all. It's not intended to actually be merged at this step -- running JUST the iotest linters from e.g. 'make check' is not yet accommodated, so there's no suitable replacement for 297 for block test authors.)
Drop 297. As a consequence, we no longer need to pass an environment variable to the mypy/pylint invocations, so that can be dropped. We also now no longer need to hide output-except-on-error, so that can be dropped as well. The only thing that necessitates any special running logic anymore is the skip list and the python-test-detection code. Without those, we could easily codify the tests as simply: [pylint|mypy] *.py tests/*.py ... and drop this entire file. We're not quite there yet, though. Signed-off-by: John Snow <js...@redhat.com> --- tests/qemu-iotests/297 | 52 ----------------------------------- tests/qemu-iotests/297.out | 2 -- tests/qemu-iotests/linters.py | 20 ++------------ 3 files changed, 2 insertions(+), 72 deletions(-) delete mode 100755 tests/qemu-iotests/297 delete mode 100644 tests/qemu-iotests/297.out diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 deleted file mode 100755 index f79c80216bf..00000000000 --- a/tests/qemu-iotests/297 +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 -# group: meta -# -# Copyright (C) 2020 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -import os -import shutil -import sys - -import iotests -import linters - - -# Looking for the list of files to exclude from linting? See linters.py. - - -def main() -> None: - for linter in ('pylint-3', 'mypy'): - if shutil.which(linter) is None: - iotests.notrun(f'{linter} not found') - - files = linters.get_test_files() - - iotests.logger.debug('Files to be checked:') - iotests.logger.debug(', '.join(sorted(files))) - - env = os.environ.copy() - env['MYPYPATH'] = env['PYTHONPATH'] - - print('=== pylint ===') - sys.stdout.flush() - linters.run_linter('pylint', files, env=env) - - print('=== mypy ===') - sys.stdout.flush() - linters.run_linter('mypy', files, env=env, suppress_output=True) - - -iotests.script_main(main) diff --git a/tests/qemu-iotests/297.out b/tests/qemu-iotests/297.out deleted file mode 100644 index f2e1314d104..00000000000 --- a/tests/qemu-iotests/297.out +++ /dev/null @@ -1,2 +0,0 @@ -=== pylint === -=== mypy === diff --git a/tests/qemu-iotests/linters.py b/tests/qemu-iotests/linters.py index 83fcc5a960c..ca90604d8d9 100644 --- a/tests/qemu-iotests/linters.py +++ b/tests/qemu-iotests/linters.py @@ -17,7 +17,7 @@ import re import subprocess import sys -from typing import List, Mapping, Optional +from typing import List # TODO: Empty this list! @@ -55,31 +55,15 @@ def get_test_files() -> List[str]: return list(filter(is_python_file, check_tests)) -def run_linter( - tool: str, - args: List[str], - env: Optional[Mapping[str, str]] = None, - suppress_output: bool = False, -) -> int: +def run_linter(tool: str, args: List[str]) -> int: """ Run a python-based linting tool. - - If suppress_output is True, capture stdout/stderr of the child - process and only print that information back to stdout if the child - process's return code was non-zero. """ p = subprocess.run( ('python3', '-m', tool, *args), - env=env, check=False, - stdout=subprocess.PIPE if suppress_output else None, - stderr=subprocess.STDOUT if suppress_output else None, - universal_newlines=True, ) - if suppress_output and p.returncode != 0: - print(p.stdout) - return p.returncode -- 2.31.1