Skip to content

Commit

Permalink
python: add avocado-framework and tests
Browse files Browse the repository at this point in the history
Try using avocado to manage our various tests; even though right now
they're only invoking shell scripts and not really running any
python-native code.

Create tests/, and add shell scripts which call out to mypy, flake8,
pylint and isort to enforce the standards in this directory.

Add avocado-framework to the setup.cfg development dependencies, and add
avocado.cfg to store some preferences for how we'd like the test output
to look.

Finally, add avocado-framework to the Pipfile environment and lock the
new dependencies. We are using avocado >= 87.0 here to take advantage of
some features that Cleber has helpfully added to make the test output
here *very* friendly and easy to read for developers that might chance
upon the output in Gitlab CI.

[Note: ALL of the dependencies get updated to the most modern versions
that exist at the time of this writing. No way around it that I have
seen. Not ideal, but so it goes.]

Provided you have the right development dependencies (mypy, flake8,
isort, pylint, and now avocado-framework) You should be able to run
"avocado --config avocado.cfg run tests/" from the python folder to run
all of these linters with the correct arguments.

(A forthcoming commit adds the much easier 'make check'.)

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Message-id: 20210527211715.394144-28-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
  • Loading branch information
jnsnow committed Jun 1, 2021
1 parent dbe75f5 commit 31622b2
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions python/README.rst
Expand Up @@ -37,6 +37,8 @@ Files in this directory
-----------------------

- ``qemu/`` Python package source directory.
- ``tests/`` Python package tests directory.
- ``avocado.cfg`` Configuration for the Avocado test-runner.
- ``MANIFEST.in`` is read by python setuptools, it specifies additional files
that should be included by a source distribution.
- ``PACKAGE.rst`` is used as the README file that is visible on PyPI.org.
Expand Down
10 changes: 10 additions & 0 deletions python/avocado.cfg
@@ -0,0 +1,10 @@
[simpletests]
# Don't show stdout/stderr in the test *summary*
status.failure_fields = ['status']

[job]
# Don't show the full debug.log output; only select stdout/stderr.
output.testlogs.logfiles = ['stdout', 'stderr']

# Show full stdout/stderr only on tests that FAIL
output.testlogs.statuses = ['FAIL']
1 change: 1 addition & 0 deletions python/setup.cfg
Expand Up @@ -25,6 +25,7 @@ packages =
[options.extras_require]
# Run `pipenv lock --dev` when changing these requirements.
devel =
avocado-framework >= 87.0
flake8 >= 3.6.0
isort >= 5.1.2
mypy >= 0.770
Expand Down
2 changes: 2 additions & 0 deletions python/tests/flake8.sh
@@ -0,0 +1,2 @@
#!/bin/sh -e
python3 -m flake8
2 changes: 2 additions & 0 deletions python/tests/isort.sh
@@ -0,0 +1,2 @@
#!/bin/sh -e
python3 -m isort -c qemu/
2 changes: 2 additions & 0 deletions python/tests/mypy.sh
@@ -0,0 +1,2 @@
#!/bin/sh -e
python3 -m mypy -p qemu
2 changes: 2 additions & 0 deletions python/tests/pylint.sh
@@ -0,0 +1,2 @@
#!/bin/sh -e
python3 -m pylint qemu/

0 comments on commit 31622b2

Please sign in to comment.