summaryrefslogtreecommitdiff
path: root/python/tox.ini
blob: d84714530cad1740b75c796245d2b52af3dccdaf (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
# SPDX-License-Identifier: BSD-2-Clause

[tox]
min_version = 4.1
envlist =
  ruff
  format
  mypy
  unit-tests
isolated_build = True

[defs]
pyfiles_base =
  src/confget \
  unit_tests

pyfiles = {[defs]pyfiles_base} {env:TOX_DEVEL_FILES:}

pyfiles_devel =
  ../t/defs/tools/generate.py

[testenv:ruff]
skip_install = True
tags =
  check
deps =
  -r requirements/ruff.txt
commands =
  ruff check --config {toxinidir}/config/ruff-all/pyproject.toml -- {[defs]pyfiles}

[testenv:mypy]
skip_install = True
tags =
  check
deps =
  mypy >= 1, < 2
  pyparsing >= 3, < 4
  pytest >= 7, < 8
setenv =
  MYPYPATH={toxinidir}/src
commands =
  mypy --strict {[defs]pyfiles}

[testenv:unit-tests]
tags =
  tests
deps =
  pyparsing >= 3, < 4
  pytest >= 7, < 8
commands =
  pytest -s -vv unit_tests

[testenv:generate]
skip_install = True
tags =
  devel
  manual
deps =
  pyparsing >= 3, < 4
whitelist_externals =
  sh
commands =
  sh -c 'cd ../t && env PYTHONPATH={toxinidir}:{toxinidir}/src python defs/tools/generate.py'

[testenv:prove]
tags =
  tests
  devel
deps =
  pyparsing >= 3, < 4
setenv =
  CONFGET=python -m confget
  MANPAGE={toxinidir}/../confget.1
  TESTDIR={toxinidir}/test_data
allowlist_externals =
  prove
commands =
  prove ../t

# The `--config` option passed to `black` is necessary if the defs.pyfiles
# list includes files outside the current directory; then `black` tries to
# look for a configuration file in a higher-level directory and falls
# back to its default settings.
[testenv:format]
skip_install = True
tags =
  check
deps =
  -r requirements/ruff.txt
  black >= 23, < 24
commands =
  ruff check --config {toxinidir}/config/ruff-base/pyproject.toml --select=I --diff -- {[defs]pyfiles}
  black --check {[defs]pyfiles_base}
  black --config {toxinidir}/pyproject.toml --check {env:TOX_DEVEL_FILES:src/confget}

# See the above comment about the `black --config` invocation.
# NB: this one should probably never be placed in the default envlist
[testenv:reformat]
skip_install = True
tags =
  format
  manual
  devel
deps =
  -r requirements/ruff.txt
  black >= 23, < 24
commands =
  ruff check --config {toxinidir}/config/ruff-base/pyproject.toml --select=I --fix -- {[defs]pyfiles} {[defs]pyfiles_devel}
  black {[defs]pyfiles}
  black --config {toxinidir}/pyproject.toml {[defs]pyfiles_devel}

[testenv:reuse]
skip_install = True
tags =
  check
  devel
deps =
  reuse >= 1, < 2
commands =
  reuse lint