blob: 371ece1f6fd55a7d1fd83edd48983a52b26133eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# Vela Testing
## Sanity checks and tests
The Python codebase is PEP8 compliant with the exception of a 120 character line
length. We run reorder-python-import, black and flake8 against the code base
excluding "ethosu/vela/tflite/" and "ethosu/vela/ethos\_u55\_regs" directories
because they are auto-generated by third party tools. Those tools are run using
[pre-commit framework](https://pre-commit.com/). The configuration file is
.pre-commit-config.yaml
### Install tools
To install pre-commit, run the following:
```bash
pipenv install -e . --dev
```
After the installation, pre-commit is available in the virtual environment.
Besides pre-commit, we install also:
* pytest: testing framework
* pytest-cov: code coverage plugin for pytest
### Install the pre-commit hook
To ease the development, we can run those sanity checks before committing the
code. To install the git hook, run:
```bash
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
```
The checks will be run before the commit: if one of them fails, you need to fix
the code to make the checks pass.
### Run the tests
Tests and test coverage can be run using pre-commit framework.
```bash
$ pre-commit run pytest
...
$ pre-commit run pytest-cov
```
### Run the sanity checks
Those checks can be run manually. This can be achieved running the following
```bash
$ pre-commit run reorder-python-imports --all-files
...
$ pre-commit run flake8 --all-files
...
$ pre-commit run black --all-files
```
If you don't specify anything after run, it will execute all the checks.
```bash
$ pre-commit run --all-files
Reorder python imports...................................................Passed
black....................................................................Passed
flake8...................................................................Passed
pytest...................................................................Passed
...
...
```
|