You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[PR #10104/6008e6e1 backport][stable-9] Allow running sanity and unit tests with antsibull-nox; impove testing documentation (#10152)
Allow running sanity and unit tests with antsibull-nox; impove testing documentation (#10104)
* Whitespace fixes.
* Allow to run unit and sanity tests with antsibull-nox.
* Document installation of needed collections for tests.
* Also mention other sanity tests.
(cherry picked from commit 6008e6e)
Co-authored-by: Felix Fontein <[email protected]>
# Run all other sanity tests for all files in the collection:
64
+
nox -R
65
+
```
66
+
67
+
If you replace `-Re` with `-e`, respectively. leave `-R` away, then the virtual environments will be re-created. The `-R` re-uses them (if they already exist).
68
+
69
+
### Unit tests
70
+
71
+
The following commands show how to run unit tests:
72
+
73
+
```.bash
74
+
# Run all unit tests:
75
+
nox -Re ansible-test-units-devel
76
+
77
+
# Run all unit tests for one Python version (a lot faster):
78
+
nox -Re ansible-test-units-devel -- --python 3.13
79
+
80
+
# Run a specific unit test (for the nmcli module) for one Python version:
If you replace `-Re` with `-e`, then the virtual environments will be re-created. The `-R` re-uses them (if they already exist).
85
+
86
+
## Run basic sanity, unit or integration tests locally (with ansible-test)
87
+
88
+
Instead of using antsibull-nox, you can also run sanity and unit tests with ansible-test directly.
89
+
This also allows you to run integration tests.
48
90
49
91
You have to check out the repository into a specific path structure to be able to run `ansible-test`. The path to the git checkout must end with `.../ansible_collections/community/general`. Please see [our testing guide](https://github.com/ansible/community-docs/blob/main/test_pr_locally_guide.rst) for instructions on how to check out the repository into a correct path structure. The short version of these instructions is:
50
92
@@ -56,20 +98,27 @@ cd ~/dev/ansible_collections/community/general
56
98
57
99
Then you can run `ansible-test` (which is a part of [ansible-core](https://pypi.org/project/ansible-core/)) inside the checkout. The following example commands expect that you have installed Docker or Podman. Note that Podman has only been supported by more recent ansible-core releases. If you are using Docker, the following will work with Ansible 2.9+.
58
100
59
-
### Sanity tests
101
+
### Basic sanity tests
60
102
61
-
The following commands show how to run sanity tests:
103
+
The following commands show how to run basic sanity tests:
62
104
63
105
```.bash
64
-
# Run sanity tests for all files in the collection:
106
+
# Run basic sanity tests for all files in the collection:
65
107
ansible-test sanity --docker -v
66
108
67
-
# Run sanity tests for the given files and directories:
109
+
# Run basic sanity tests for the given files and directories:
Note that for running integration tests, you need to install required collections in the same folder structure that `community.general` is checked out in.
138
+
Right now, depending on the test, you need to install [`ansible.posix`](https://github.com/ansible-collections/ansible.posix), [`community.crypto`](https://github.com/ansible-collections/community.crypto), and [`community.docker`](https://github.com/ansible-collections/community.docker):
139
+
If you want to use the latest versions from GitHub, you can run:
0 commit comments