deleted file mode 100755
@@ -1,82 +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 subprocess
-import sys
-from typing import List
-
-import iotests
-import linters
-
-
-# Looking for something?
-#
-# List of files to exclude from linting: linters.py
-# mypy configuration: mypy.ini
-# pylint configuration: pylintrc
-
-
-def check_linter(linter: str) -> bool:
- try:
- linters.run_linter(linter, ['--version'], suppress_output=True)
- except subprocess.CalledProcessError:
- iotests.case_notrun(f"'{linter}' not found")
- return False
- return True
-
-
-def test_pylint(files: List[str]) -> None:
- print('=== pylint ===')
- sys.stdout.flush()
-
- if not check_linter('pylint'):
- return
-
- linters.run_linter('pylint', files)
-
-
-def test_mypy(files: List[str]) -> None:
- print('=== mypy ===')
- sys.stdout.flush()
-
- if not check_linter('mypy'):
- return
-
- env = os.environ.copy()
- env['MYPYPATH'] = env['PYTHONPATH']
-
- linters.run_linter('mypy', files, env=env, suppress_output=True)
-
-
-def main() -> None:
- files = linters.get_test_files()
-
- iotests.logger.debug('Files to be checked:')
- iotests.logger.debug(', '.join(sorted(files)))
-
- for test in (test_pylint, test_mypy):
- try:
- test(files)
- except subprocess.CalledProcessError as exc:
- # Linter failure will be caught by diffing the IO.
- if exc.output:
- print(exc.output)
-
-
-iotests.script_main(main)
deleted file mode 100644
@@ -1,2 +0,0 @@
-=== pylint ===
-=== mypy ===
@@ -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,25 +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,
-) -> None:
+def run_linter(tool: str, args: List[str]) -> None:
"""
Run a python-based linting tool.
- :param suppress_output: If True, suppress all stdout/stderr output.
:raise CalledProcessError: If the linter process exits with failure.
"""
subprocess.run(
('python3', '-m', tool, *args),
- env=env,
check=True,
- stdout=subprocess.PIPE if suppress_output else None,
- stderr=subprocess.STDOUT if suppress_output else None,
- universal_newlines=True,
)
(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 <jsnow@redhat.com> --- tests/qemu-iotests/297 | 82 ----------------------------------- tests/qemu-iotests/297.out | 2 - tests/qemu-iotests/linters.py | 14 +----- 3 files changed, 2 insertions(+), 96 deletions(-) delete mode 100755 tests/qemu-iotests/297 delete mode 100644 tests/qemu-iotests/297.out