mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
tox: add & document tox usage
This makes it easy to run all the tests against multiple versions of Python. We want to make sure Python 2.7 & 3.6+ work. Change-Id: Ia7b16eb46a2aa7c240f03bb291987fa8cb215267 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/247174 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
5b3a57c3ff
commit
4997d1c838
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,8 @@
|
|||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
*.log
|
||||||
*.pyc
|
*.pyc
|
||||||
__pycache__
|
__pycache__
|
||||||
/dist
|
/dist
|
||||||
.repopickle_*
|
.repopickle_*
|
||||||
/repoc
|
/repoc
|
||||||
|
/.tox
|
||||||
|
@ -69,10 +69,38 @@ suppressed in the included `.flake8` file.
|
|||||||
|
|
||||||
## Running tests
|
## Running tests
|
||||||
|
|
||||||
There is a [`./run_tests`](./run_tests) helper script for quickly invoking all
|
We use [pytest](https://pytest.org/) and [tox](https://tox.readthedocs.io/) for
|
||||||
of our unittests. The coverage isn't great currently, but it should still be
|
running tests. You should make sure to install those first.
|
||||||
run for all commits.
|
|
||||||
|
|
||||||
|
To run the full suite against all supported Python versions, simply execute:
|
||||||
|
```sh
|
||||||
|
$ tox -p auto
|
||||||
|
```
|
||||||
|
|
||||||
|
We have [`./run_tests`](./run_tests) which is a simple wrapper around `pytest`:
|
||||||
|
```sh
|
||||||
|
# Run the full suite against the default Python version.
|
||||||
|
$ ./run_tests
|
||||||
|
# List each test as it runs.
|
||||||
|
$ ./run_tests -v
|
||||||
|
|
||||||
|
# Run a specific unittest module (and all tests in it).
|
||||||
|
$ ./run_tests tests/test_git_command.py
|
||||||
|
|
||||||
|
# Run a specific testsuite in a specific unittest module.
|
||||||
|
$ ./run_tests tests/test_editor.py::EditString
|
||||||
|
|
||||||
|
# Run a single test.
|
||||||
|
$ ./run_tests tests/test_editor.py::EditString::test_cat_editor
|
||||||
|
|
||||||
|
# List all available tests.
|
||||||
|
$ ./run_tests --collect-only
|
||||||
|
|
||||||
|
# Run a single test using substring match.
|
||||||
|
$ ./run_tests -k test_cat_editor
|
||||||
|
```
|
||||||
|
|
||||||
|
The coverage isn't great currently, but it should still be run for all commits.
|
||||||
Adding more unittests for changes you make would be greatly appreciated :).
|
Adding more unittests for changes you make would be greatly appreciated :).
|
||||||
Check out the [tests/](./tests/) subdirectory for more details.
|
Check out the [tests/](./tests/) subdirectory for more details.
|
||||||
|
|
||||||
|
22
tox.ini
Normal file
22
tox.ini
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copyright 2019 The Android Open Source Project
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# https://tox.readthedocs.io/
|
||||||
|
|
||||||
|
[tox]
|
||||||
|
envlist = py27, py36, py37, py38
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
deps = pytest
|
||||||
|
commands = {toxinidir}/run_tests
|
Loading…
Reference in New Issue
Block a user