Unverified Commit 86034870 authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

[skip changelog] Simplified how integration tests are run (#831)

parent 72c9655f
......@@ -73,7 +73,7 @@ jobs:
- name: Run integration tests
run: |
pip install -r test/requirements.txt
pip install poetry
task test-integration
- name: Send unit tests coverage to Codecov
......
......@@ -84,7 +84,8 @@ tasks:
test-integration:
desc: Run integration tests only
cmds:
- pytest test
- poetry install --no-root
- poetry run pytest test
test-legacy:
desc: Run tests for the `legacy` package
......
......@@ -85,6 +85,7 @@ see following paragraph):
```shell
task test-integration
```
### Running only some tests
By default, all tests from all go packages are run. To run only unit
......@@ -136,43 +137,23 @@ your Operating System.
Some dependencies need to be installed before running the tests and to avoid
polluting your global Python environment with dependencies that might be only
used by the Arduino CLI, you can use a [virtual environment][4]. There are many
ways to manage virtual environments, for example you can use a productivity tool
called [hatch][5]. First you need to install it (you might need to `sudo`
used by the Arduino CLI, to do so we use [Poetry][poetry-website]. First you need to install it (you might need to `sudo`
the following command):
```shell
pip3 install --user hatch
pip3 install --user poetry
```
Then you can create a virtual environment to be used while working on Arduino
CLI:
```shell
hatch env arduino-cli
```
For more installation options read the [official documentation][poetry-docs].
At this point the virtual environment was created and you need to make it active
every time you open a new terminal session with the following command:
```shell
hatch shell arduino-cli
```
From now on, every package installed by Python will be confined to the
`arduino-cli` virtual environment, so you can proceed installing the
dependencies required with:
```shell
pip install -r test/requirements.txt
```
If the last step was successful, you should be able to run the tests with:
After Poetry has been installed you should be able to run the tests with:
```shell
task test-integration
```
This will automatically install the necessary dependencies, if not already installed, and run the integration tests automatically.
## Working on docs
Documentation is provided to final users in form of static HTML content generated
......
This diff is collapsed.
[tool.poetry]
name = "arduino-cli"
version = "0.0.0"
description = "Project used to run integration tests for the Arduino CLI"
authors = []
[tool.poetry.dependencies]
python = "^3.5"
pytest = "5.3.4"
simplejson = "3.17.0"
semver = "2.9.0"
pyserial = "3.4"
pyyaml = "5.3"
prometheus-client = "0.7.1"
requests = "2.22.0"
pytest-timeout = "1.3.4"
invoke = "1.4.1"
[tool.flake8]
max-line-length = 120
[flake8]
exclude = venv
max-line-length = 120
......@@ -7,31 +7,45 @@ and its output from a pure user point of view.
See also [Contributing][0].
To run the integration tests you must install [Poetry][poetry-website].
```shell
cd test
virtualenv --python=python3 venv
source venv/bin/activate
pip install -r requirements.txt
pip3 install --user poetry
```
For more installation options read the [official documentation][poetry-docs].
## Running tests
To run all the tests:
To run all the tests from the project's root folder:
```shell
pytest
task test-integration
```
To run specific modules:
This will create and install all necessary dependencies if not already existing and then run integrations tests.
To run specific modules you must run `pytest` from the virtual environment created by Poetry.
If dependencies have not already been installed first run `poetry install`.
```shell
pytest test_lib.py
poetry run pytest test/test_lib.py
```
To run very specific test functions:
```shell
poetry run pytest test/test_lib.py::test_list
```
You can avoid writing the `poetry run` prefix each time by creating a new shell inside the virtual environment:
```shell
poetry shell
pytest test_lib.py
pytest test_lib.py::test_list
```
[0]: ../docs/CONTRIBUTING.md
[poetry-website]: https://python-poetry.org/
[poetry-docs]: https://python-poetry.org/docs/
pytest==5.3.4
simplejson==3.17.0
semver==2.9.0
pyserial==3.4
pyyaml==5.3
prometheus-client==0.7.1
requests==2.22.0
pytest-timeout==1.3.4
invoke==1.4.1
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile test/requirements.in
#
attrs==19.1.0 # via pytest
certifi==2019.11.28 # via requests
chardet==3.0.4 # via requests
idna==2.8 # via requests
importlib-metadata==1.5.0 # via pluggy, pytest
invoke==1.4.1 # via -r test/requirements.in
more-itertools==7.1.0 # via pytest
packaging==19.0 # via pytest
pluggy==0.13.1 # via pytest
prometheus-client==0.7.1 # via -r test/requirements.in
py==1.8.0 # via pytest
pyparsing==2.4.0 # via packaging
pyserial==3.4 # via -r test/requirements.in
pytest-timeout==1.3.4 # via -r test/requirements.in
pytest==5.3.4 # via -r test/requirements.in, pytest-timeout
pyyaml==5.3 # via -r test/requirements.in
requests==2.22.0 # via -r test/requirements.in
semver==2.9.0 # via -r test/requirements.in
simplejson==3.17.0 # via -r test/requirements.in
six==1.12.0 # via packaging
urllib3==1.25.8 # via requests
wcwidth==0.1.7 # via pytest
zipp==2.1.0 # via importlib-metadata
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment